How to use the iotex-antenna/lib/action/envelop.SealedEnvelop.sign 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 / erc20 / erc20.ts View on Github external
method: string,
    account: Account,
    amount: string,
    // tslint:disable-next-line
    ...args: Array
  ): Promise {
    const execution = this.contract.pureEncodeMethod(amount, method, ...args);
    const executionMethod = new ExecutionMethod(
      getAntenna().iotx,
      account,
      execution
    );
    const { gasPrice } = await getAntenna().iotx.suggestGasPrice({});
    const envelop = await executionMethod.baseEnvelop("100000", `${gasPrice}`);
    envelop.execution = execution;
    const selp = SealedEnvelop.sign(
      account.privateKey,
      account.publicKey,
      envelop
    );

    let gasLimit = "400000";
    try {
      const { gas } = await getAntenna().iotx.estimateGasForAction({
        action: selp.action()
      });
      gasLimit = new BigNumber(gas)
        .multipliedBy(GAS_LIMIT_MULTIPLIED_BY)
        .toFixed(0);
    } catch (e) {
      window.console.log("estimateGasForAction failed!");
    }
github iotexproject / iotex-explorer / src / shared / wallet / sign-and-send-envelop-modal.tsx View on Github external
public async signAndSend(): Promise {
    const { fromAddress, reqId } = this.props;
    const acct = getAntenna().iotx.accounts.getAccount(fromAddress);
    const sealed = SealedEnvelop.sign(
      String(acct && acct.privateKey),
      String(acct && acct.publicKey),
      this.envelop
    );
    const { actionHash } = await getAntenna().iotx.sendAction({
      action: sealed.action()
    });

    if (window.signed && !this.sendList.includes(reqId as number)) {
      window.signed(reqId, JSON.stringify({ actionHash, reqId }));
      this.sendList.push(reqId as number);
      message.success(t("wallet.sign_and_send.success", { actionHash }));
    }
    this.props.history.push(`/wallet/transfer/${actionHash}`);
  }