How to use the iotex-antenna/lib/account/utils.toRau 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 / wallet / contract / interact.tsx View on Github external
abi,
          contractAddress,
          method: selectedFunction,
          gasPrice,
          gasLimit
        })},`,
        ...args,
        ")"
      );

      try {
        // TODO(tian): what if multiple values returned?
        const result = await antenna.iotx.readContractByMethod(
          {
            from: fromAddress,
            amount: toRau(amount, "Iotx"),
            abi,
            contractAddress,
            method: selectedFunction,
            gasPrice,
            gasLimit
          },
          ...args
        );
        window.console.log(
          `readContractByMethod result=${JSON.stringify(result)}`
        );
        this.setState({ outputValues: [].concat(result) });
      } catch (e) {
        notification.error({
          message: e.message
        });
github iotexproject / iotex-explorer / src / shared / wallet / transfer / transfer.tsx View on Github external
const {
      recipient,
      amount,
      gasLimit,
      gasPrice,
      symbol,
      dataInHex
    } = form.getFieldsValue();
    const tokenSymbol = symbol === "iotx" ? "IOTX" : tokens[symbol].symbol;
    const dataSource: { [index: string]: string } = {
      address: address,
      toAddress: recipient,
      amount: `${new BigNumber(amount).toString()} ${tokenSymbol}`,
      limit: gasLimit,
      price: `${toRau(gasPrice, "Qev")} (${gasPrice} Qev)`
    };

    if (tokenSymbol.match(/iotx/i)) {
      dataSource.dataInHex = `${dataInHex || " "}`; // Fix undefined and always display Data field in modal if it is needed.
    }

    return (
      
    );
  };
github iotexproject / iotex-explorer / src / shared / wallet / transfer / transfer.tsx View on Github external
return this.setState({
          showConfirmTransfer: false
        });
      }
      const {
        recipient,
        amount,
        gasLimit,
        gasPrice,
        dataInHex,
        symbol
      } = value;

      const customToken = symbol.match(/iotx/) ? null : Token.getToken(symbol);

      const price = gasPrice ? toRau(gasPrice, "Qev") : undefined;

      this.setState({ sending: true, showConfirmTransfer: false });
      let txHash = "";
      if (!customToken) {
        window.console.log(
          `antenna.iotx.sendTransfer(${JSON.stringify({
            from: address,
            to: recipient,
            value: toRau(amount, "Iotx"),
            payload: dataInHex,
            gasLimit: gasLimit || undefined,
            gasPrice: price
          })})`
        );
        try {
          txHash = await antenna.iotx.sendTransfer({
github iotexproject / iotex-explorer / src / shared / wallet / contract / interact.tsx View on Github external
this.props.form.validateFields(async (err, values) => {
      if (err) {
        return;
      }

      const {
        contractAddress,
        amount,
        gasPrice,
        gasLimit,
        abi,
        selectedFunction,
        args
      } = values;

      const price = gasPrice ? toRau(gasPrice, "Qev") : undefined;

      window.console.log(
        `antenna.iotx.executeContract(${JSON.stringify({
          from: fromAddress,
          amount,
          abi,
          contractAddress,
          method: selectedFunction,
          gasPrice: price,
          gasLimit
        })},`,
        ...(args || []),
        ")"
      );

      try {
github iotexproject / iotex-explorer / src / shared / wallet / transfer / transfer.tsx View on Github external
if (!customToken) {
        window.console.log(
          `antenna.iotx.sendTransfer(${JSON.stringify({
            from: address,
            to: recipient,
            value: toRau(amount, "Iotx"),
            payload: dataInHex,
            gasLimit: gasLimit || undefined,
            gasPrice: price
          })})`
        );
        try {
          txHash = await antenna.iotx.sendTransfer({
            from: address,
            to: recipient,
            value: toRau(amount, "Iotx"),
            payload: dataInHex,
            gasLimit: gasLimit || undefined,
            gasPrice: price
          });
        } catch (error) {
          notification.error({
            message: `${error.message}`,
            duration: 3
          });
        }
      } else {
        const tokenInfo = tokens[symbol];
        const tokenAmount = new BigNumber(amount).multipliedBy(
          new BigNumber(`1e${tokenInfo.decimals.toNumber()}`)
        );
        const gasPriceRau = toRau(gasPrice, "Qev");
github iotexproject / iotex-explorer / src / shared / wallet / transfer / transfer.tsx View on Github external
public updateGasCostLimit = (form: WrappedFormUtils) => {
    const { gasLimit, gasPrice } = form.getFieldsValue();
    const gasCostLimit = fromRau(
      `${Number(toRau(gasPrice, "Qev")) * gasLimit}`,
      "IoTx"
    );
    this.setState({ gasCostLimit });
  };
github iotexproject / iotex-explorer / src / shared / wallet / contract / deploy.tsx View on Github external
public renderConfirmation = () => {
    const { form, address } = this.props;
    const { showConfirmation } = this.state;

    const { byteCode, gasLimit, gasPrice, amount } = form.getFieldsValue();

    const dataSource = {
      address: address,
      data: byteCode,
      amount: `${Number(amount).toLocaleString()} IOTX`,
      price: toRau(gasPrice, "Qev"),
      limit: gasLimit
    };

    return (
      
    );
  };
github iotexproject / iotex-explorer / src / shared / wallet / transfer / erc20-transfer.tsx View on Github external
public confirmTransfer = () => {
    const { address, form } = this.props;
    const { showConfirmTransfer } = this.state;

    const { recipient, amount, gasLimit, gasPrice } = form.getFieldsValue();
    const dataSource = {
      address: address,
      toAddress: recipient,
      amount: toRau(amount, "Iotx"),
      limit: gasLimit,
      price: toRau(gasPrice, "Qev")
    };

    return (
      
    );
  };
github iotexproject / iotex-explorer / src / shared / wallet / transfer / erc20-transfer.tsx View on Github external
public confirmTransfer = () => {
    const { address, form } = this.props;
    const { showConfirmTransfer } = this.state;

    const { recipient, amount, gasLimit, gasPrice } = form.getFieldsValue();
    const dataSource = {
      address: address,
      toAddress: recipient,
      amount: toRau(amount, "Iotx"),
      limit: gasLimit,
      price: toRau(gasPrice, "Qev")
    };

    return (
      
    );
  };
github iotexproject / iotex-explorer / src / shared / wallet / bid-form-modal.tsx View on Github external
transform: (value: string) => {
                  return new BigNumber(toRau(value, "IoTx"));
                },
                validator: async (_, value: BigNumber, callback) => {