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