How to use the @polkadot/util.formatBalance function in @polkadot/util

To help you get started, we’ve selected a few @polkadot/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / apps / packages / react-components / src / AddressInfo.tsx View on Github external
text={stakingInfo.unlocking.map(({ remainingBlocks, value }, index): React.ReactNode => (
          <div>
            {t('{{value}}, {{remaining}} blocks left', {
              replace: {
                remaining: formatNumber(remainingBlocks),
                value: formatBalance(value, { forceUnit: '-' })
              }
            })}
          </div>
        ))}
        trigger='unlocking-trigger'
github polkadot-js / apps / packages / react-signer / src / Checks / Proposal.tsx View on Github external
{isBelowMinimum &amp;&amp; (
        <div>
          
          {t('The deposit is below the {{minimum}} minimum required for the proposal to be evaluated', {
            replace: {
              minimum: formatBalance(minDeposit, { forceUnit: '-' })
            }
          })}
        </div>
      )}
      {!extraAmount.isZero() &amp;&amp; (
        <div>
          
          {t('The deposit of {{deposit}} will be reserved until the proposal is completed', {
            replace: {
              deposit: formatBalance(extraAmount, { forceUnit: '-' })
            }
          })}
        </div>
      )}
    
  );
}
github polkadot-js / apps / packages / app-democracy / src / Overview / Referendum.tsx View on Github external
private renderResults (): React.ReactNode {
    const { voteCount, voteCountAye, voteCountNay, votedAye, votedNay, votedTotal } = this.state;

    if (voteCount === 0 || votedTotal.eqn(0)) {
      return null;
    }

    return (
      <div>
        
      </div>
    );
  }
}
github polkadot-js / apps / packages / ui-signer / src / Checks / Proposal.tsx View on Github external
public render (): React.ReactNode {
    const { democracy_minimumDeposit = new BN(0), t } = this.props;
    const { extraAmount, isBelowMinimum } = this.state;

    return (
      &lt;&gt;
        {
          isBelowMinimum
            ? <div>{t('The deposit is below the {{minimum}} minimum required for the proposal to be evaluated', {
              replace: {
                minimum: formatBalance(democracy_minimumDeposit)
              }
            })}</div>
            : undefined
        }
        {
          extraAmount.isZero()
            ? undefined
            : <div>{t('The deposit of {{deposit}} will be reserved until the proposal is completed', {
              replace: {
                deposit: formatBalance(extraAmount)
              }
            })}</div>
        }
      
    );
  }
github polkadot-js / apps / packages / react-query / src / TotalIssuance.tsx View on Github external
export default function TotalIssuance ({ children, className, label, style }: Props): React.ReactElement {
  const { api } = useApi();
  const totalIssuance = useCall(api.query.balances.totalIssuance, [], {
    transform: (totalIssuance: Balance): string =&gt;
      totalIssuance?.toString()
  });

  return (
    <div style="{style}">
      {label || ''}{
        totalIssuance
          ? `${formatBalance(totalIssuance, false)}${formatBalance.calcSi(totalIssuance).value}`
          : '-'
      }{children}
    </div>
  );
}
github polkadot-js / apps / packages / ui-signer / src / Checks / Transfer.tsx View on Github external
public render (): React.ReactNode {
    const { fees, t } = this.props;
    const { isCreation, isNoEffect } = this.state;

    return (
      &lt;&gt;
        {
          isNoEffect
            ? (
              <div>
                
                {t('The final recipient balance is less or equal to {{existentialDeposit}} (the existential amount) and will not be reflected',
                  {
                    replace: {
                      existentialDeposit: formatBalance(fees.existentialDeposit)
                    }
                  }
                )}
              </div>
            )
            : undefined
        }
        {
          isCreation
            ? <div>{t('A fee of {{creationFee}} will be deducted from the sender since the destination account does not exist', {
              replace: {
                creationFee: formatBalance(fees.creationFee)
              }
            })}</div>
            : undefined
        }
github polkadot-js / apps / packages / app-staking / src / Targets / Summary.tsx View on Github external
useEffect((): void => {
    if (totalInsurance && totalStaked?.gtn(0)) {
      setStakeInfo({
        percentage: `${(totalStaked.muln(10000).div(totalInsurance).toNumber() / 100).toFixed(2)}%`,
        staked: `${formatBalance(totalStaked, false)}${formatBalance.calcSi(totalStaked.toString()).value}`
      });
    }
  }, [totalInsurance, totalStaked]);
github polkadot-js / apps / packages / react-components / src / AddressInfo.tsx View on Github external
}

  const [ownBonded, otherBonded] = calcBonded(staking_info, balanceDisplay.bonded);

  return (
    &lt;&gt;
      {balanceDisplay.total &amp;&amp; (
        &lt;&gt;
          <label label="{t('total')}">
          <div>{formatBalance(balances_all.votingBalance)}</div>
        
      )}
      {balanceDisplay.available &amp;&amp; (
        &lt;&gt;
          <label label="{t('available')}">
          <div>{formatBalance(balances_all.availableBalance)}</div>
        
      )}
      {balanceDisplay.bonded &amp;&amp; (ownBonded.gtn(0) || otherBonded.length !== 0) &amp;&amp; (
        &lt;&gt;
          <label label="{t('bonded')}">
          <div>{formatBalance(ownBonded)}{otherBonded.length !== 0 &amp;&amp; (
            ` (+${otherBonded.map((bonded): string =&gt; formatBalance(bonded)).join(', ')})`
          )}</div>
        
      )}
      {balanceDisplay.redeemable &amp;&amp; staking_info &amp;&amp; staking_info.redeemable &amp;&amp; staking_info.redeemable.gtn(0) &amp;&amp; (
        &lt;&gt;
          <label label="{t('redeemable')}">
          <div>
            {formatBalance(staking_info.redeemable)}
            {staking_info.controllerId &amp;&amp; (</div></label></label></label></label>
github paritytech / substrate-light-ui / packages / ui-components / src / BalanceDisplay.tsx View on Github external
const renderDetailedBalances = (): React.ReactElement =&gt; {
    const { availableBalance, lockedBalance, reservedBalance } = allBalances!;

    return (
      
        <span><b>Available:</b> {formatBalance(availableBalance)}</span>
        <span>
          {
            allStaking &amp;&amp; allStaking.redeemable &amp;&amp;
            
              <b>Redeemable:</b>
              {formatBalance(allStaking.redeemable)}
              {allStaking.redeemable.gtn(0) &amp;&amp; renderRedeemButton()}
            
          }
        </span>
        <span><b>Reserved:</b>{reservedBalance &amp;&amp; {formatBalance(reservedBalance)}}</span>
        <span><b>Locked:</b>{lockedBalance &amp;&amp; {formatBalance(lockedBalance)}}</span>
        {renderUnlocking()}
      
    );
  };
github polkadot-js / apps / packages / react-components / src / AddressInfo.tsx View on Github external
return (
    &lt;&gt;
      <div>
      {validatorPrefsDisplay.unstakeThreshold &amp;&amp; (staking_info.validatorPrefs as ValidatorPrefs0to145).unstakeThreshold &amp;&amp; (
        &lt;&gt;
          <label label="{t('unstake">
          <div>
            {(staking_info.validatorPrefs as ValidatorPrefs0to145).unstakeThreshold.toString()}
          </div>
        
      )}
      {validatorPrefsDisplay.validatorPayment &amp;&amp; staking_info.validatorPrefs.validatorPayment &amp;&amp; (
        &lt;&gt;
          <label label="{t('commission')}">
          <div>{
            formatBalance(staking_info.validatorPrefs.validatorPayment)
          }</div>
        
      )}
    
  );
}
</label></label></div>