How to use the iotex-antenna/lib/account/utils.fromRau function in iotex-antenna

To help you get started, we’ve selected a few iotex-antenna 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 iotexproject / iotex-explorer / src / shared / action / action-receipt.tsx View on Github external
const receipt =
            get(data || {}, "getReceiptByAction.receiptInfo.receipt") || {};

          // @ts-ignore
          if (receipt.__typename) {
            // @ts-ignore
            delete receipt.__typename;
          }

          const gasPrice = Number(get(action, "core.gasPrice"));
          const gasConsumed = Number(get(receipt, "gasConsumed"));

          const dataSource = buildKeyValueArray({
            ...receipt,
            actionFee: `${fromRau(`${gasConsumed * gasPrice}`, "IOTX")} IOTX`
          });

          return (
            
              
                {t("title.receipt")}
github iotexproject / iotex-explorer / src / shared / block / block-detail.tsx View on Github external
export function renderValue(text: string, record: any): JSX.Element | string {
  switch (record.key) {
    case "transferAmount":
      return `${fromRau(text || "0", "IOTX")} IOTX`;
    case "type":
      return <span>{t(`render.value.rewardType.${text}`)}</span>;
    case "amount":
      return `${fromRau(text, "IOTX")} IOTX`;

    case "balance": {
      return record.value.split(",").map((v: string, i: number) =&gt; (
        <span>
          {i === 0 ? (
            `${fromRau(String(v || 0), "IOTX")} IOTX`
          ) : (
            &lt;&gt;
              <br>
              {v}
            
          )}</span>
github iotexproject / iotex-explorer / src / shared / address-details / address-details.tsx View on Github external
public renderAddressInfo = (addressInfo: AccountMeta): JSX.Element =&gt; (
    &lt;&gt;
      <div>
        <div>
          
        </div>
        <div>{t("address.balance")}</div>
        <div>{`${(+utils.fromRau(
          String((addressInfo &amp;&amp; addressInfo.balance) || 0),
          "IOTX"
        )).toFixed(4)} IOTX`}</div>
        {this.renderOtherTokenBalance()}
      </div>
      <div>
        <div>
          
        </div>
        <div>{t("address.nonce")}</div>
        <div>{(addressInfo &amp;&amp; addressInfo.nonce) || 0}</div>
      </div>
      <div>
        <div>
          
        </div></div>
github iotexproject / iotex-explorer / src / shared / renderer / action-fee-renderer.tsx View on Github external
{({ data, error, loading }: GetActionDetailsResponse) =&gt; {
        if (error) {
          notification.error({
            message: `failed to query action details by hash in ActionFeeRenderer: ${error}`
          });
        }
        if (!data || loading) {
          return null;
        }
        const { gasPrice = "0" } =
          get(data, "action.actionInfo.0.action.core") || {};
        const { gasConsumed = 0 } =
          get(data, "receipt.receiptInfo.receipt") || {};
        return `${fromRau(`${gasConsumed * Number(gasPrice)}`, "Iotx")}`;
      }}
github iotexproject / iotex-explorer / src / shared / pages / action-detail-page.tsx View on Github external
const from = (senderPubKey && publicKeyToAddress(senderPubKey)) || undefined;

  return {
    status,
    blkHeight,
    timestamp,
    from,
    ...(execution ? { to: { execution, contractAddress } } : {}),
    ...(transfer ? { to: { transfer } } : {}),
    ...(grantReward ? { actionType: t("render.value.grantReward") } : {}),
    ...(execution ? { evmTransfer: actHash, value: execution.amount } : {}),
    ...(transfer ? { value: transfer.amount } : {}),
    fee: `${fromRau(`${gasConsumed * Number(gasPrice)}`, "Iotx")} IOTX`,
    gasLimit: Number(gasLimit).toLocaleString(),
    gasPrice: `${Number(gasPrice).toLocaleString()} (${fromRau(
      gasPrice,
      "Qev"
    )} Qev)`,
    nonce,
    ...(execution ? { data: execution.data.toString() } : {}),
    logs: removeTypeName(logs)
  };
};
github iotexproject / iotex-explorer / src / shared / pages / account-list-page.tsx View on Github external
render: (_: string, record: TopHolderInfo): JSX.Element | string => {
      const percentage: string = (
        (parseFloat(fromRau(record.balance, "iotx")) * 100) /
        10000000000
      ).toFixed(8);
      return `${percentage}%`;
    }
  },
github iotexproject / iotex-explorer / src / shared / pages / action-detail-page.tsx View on Github external
const { senderPubKey }: Dict = get(data, "action.actionInfo.0.action") || {};

  const from = (senderPubKey && publicKeyToAddress(senderPubKey)) || undefined;

  return {
    status,
    blkHeight,
    timestamp,
    from,
    ...(execution ? { to: { execution, contractAddress } } : {}),
    ...(transfer ? { to: { transfer } } : {}),
    ...(grantReward ? { actionType: t("render.value.grantReward") } : {}),
    ...(execution ? { evmTransfer: actHash, value: execution.amount } : {}),
    ...(transfer ? { value: transfer.amount } : {}),
    fee: `${fromRau(`${gasConsumed * Number(gasPrice)}`, "Iotx")} IOTX`,
    gasLimit: Number(gasLimit).toLocaleString(),
    gasPrice: `${Number(gasPrice).toLocaleString()} (${fromRau(
      gasPrice,
      "Qev"
    )} Qev)`,
    nonce,
    ...(execution ? { data: execution.data.toString() } : {}),
    logs: removeTypeName(logs)
  };
};
github iotexproject / iotex-explorer / src / shared / renderer / token-transfer-renderer.tsx View on Github external
style={{ color: colors.black80 }}
                &gt;
                  
                    
                  
                  {t("render.key.from")}
                  
                    {from}
                  
                  {t("render.key.to")}
                  
                    {to}
                  
                  
                    {t("transfer.for", {
                      value: `${fromRau(quantity, "iotx")} (IOTX)`
                    })}
                  
                
              );
            })}
github iotexproject / iotex-explorer / src / shared / wallet / account-section.tsx View on Github external
public renderBalance(): JSX.Element | null {
    const { tokenInfos, accountMeta, isLoading } = this.state;
    const { network } = this.props;
    const dataSource = Object.keys(tokenInfos)
      .map(addr =&gt; tokenInfos[addr])
      .filter(tokenInfo =&gt; tokenInfo &amp;&amp; tokenInfo.symbol);
    const columns = this.getColumns();
    if (accountMeta) {
      dataSource.unshift({
        symbol: "IOTX",
        balanceString: new BigNumber(fromRau(accountMeta.balance, "")).toString(
          10
        ),
        tokenAddress: "",
        balance: new BigNumber(accountMeta.balance),
        decimals: new BigNumber(0),
        name: "IOTX"
      });
    }
    const spinning = isLoading || !network;
    return (