How to use the web3-core-helpers.formatters.inputCallFormatter function in web3-core-helpers

To help you get started, we’ve selected a few web3-core-helpers 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 MyEtherWallet / MyEtherWallet / src / store / actions.js View on Github external
const gas = await (arr[i].gas === undefined
            ? web3Instance.eth.estimateGas(localTx)
            : arr[i].gas);
          const nonce = await (arr[i].nonce === undefined
            ? web3Instance.eth.getTransactionCount(state.account.address)
            : arr[i].nonce);
          arr[i].nonce = new BigNumber(nonce + i).toFixed();
          arr[i].gas = gas;
          arr[i].chainId = !arr[i].chainId
            ? state.network.type.chainID
            : arr[i].chainId;
          arr[i].gasPrice =
            arr[i].gasPrice === undefined
              ? unit.toWei(state.gasPrice, 'gwei')
              : arr[i].gasPrice;
          arr[i] = formatters.inputCallFormatter(arr[i]);
        }

        const batchSignCallback = promises => {
          resolve(promises);
        };
        this._vm.$eventHub.$emit(
          'showTxCollectionConfirmModal',
          arr,
          batchSignCallback,
          state.wallet.isHardware
        );
      });
    };
github MyEtherWallet / MyEtherWallet / src / store / main / actions.js View on Github external
const gas = await (arr[i].gas === undefined
            ? web3Instance.eth.estimateGas(localTx)
            : arr[i].gas);
          const nonce = await (arr[i].nonce === undefined
            ? web3Instance.eth.getTransactionCount(state.account.address)
            : arr[i].nonce);
          arr[i].nonce = new BigNumber(nonce + i).toFixed();
          arr[i].gas = gas;
          arr[i].chainId = !arr[i].chainId
            ? state.network.type.chainID
            : arr[i].chainId;
          arr[i].gasPrice =
            arr[i].gasPrice === undefined
              ? unit.toWei(state.gasPrice, 'gwei')
              : arr[i].gasPrice;
          arr[i] = formatters.inputCallFormatter(arr[i]);
        }

        const batchSignCallback = promises => {
          resolve(promises);
        };
        this._vm.$eventHub.$emit(
          'showTxCollectionConfirmModal',
          arr,
          batchSignCallback,
          state.wallet.isHardware
        );
      });
    };
github MyEtherWallet / MyEtherWallet / src / wallets / web3-provider / methods / utils.js View on Github external
return new Promise((resolve, reject) => {
    if (!tx.gas && !tx.gasLimit && !tx.chainId)
      return reject(new Error('"gas" or "chainId" is missing'));
    if (tx.nonce < 0 || tx.gas < 0 || tx.gasPrice < 0 || tx.chainId < 0)
      return reject(
        new Error('Gas, gasPrice, nonce or chainId is lower than 0')
      );

    try {
      tx = formatters.inputCallFormatter(tx);
      const transaction = tx;
      if (tx.to) transaction.to = tx.to;
      transaction.data = tx.data || '0x';
      transaction.value = tx.value || '0x';
      transaction.chainId = tx.chainId;
      resolve(transaction);
    } catch (e) {
      reject(e);
    }
  });
};