Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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!");
}
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}`);
}