From c8d31e37abec9ad4799434b9f0608c2921bf1282 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 17 Jun 2024 13:20:54 +0200 Subject: [PATCH] set gaslimit in sendTransaction --- apps/remix-ide/src/blockchain/blockchain.tsx | 70 +++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/apps/remix-ide/src/blockchain/blockchain.tsx b/apps/remix-ide/src/blockchain/blockchain.tsx index 66f3baafc1..3db3ae2820 100644 --- a/apps/remix-ide/src/blockchain/blockchain.tsx +++ b/apps/remix-ide/src/blockchain/blockchain.tsx @@ -39,7 +39,7 @@ export type Transaction = { to: string value: string data: string - gasLimit: number + gasLimit: string useCall: boolean timestamp?: number } @@ -779,40 +779,46 @@ export class Blockchain extends Plugin { */ sendTransaction(tx: Transaction) { return new Promise((resolve, reject) => { - this.executionContext.detectNetwork((error, network) => { - if (error) return reject(error) - if (network.name === 'Main' && network.id === '1') { - return reject(new Error('It is not allowed to make this action against mainnet')) + return this.transactionContextAPI.getGasLimit((err, value) => { + if (err) console.log('error resolving gas limit', err); + else { + tx.gasLimit = value; } - - this.txRunner.rawRun( - tx, - (network, tx, gasEstimation, continueTxExecution, cancelCb) => { - continueTxExecution() - }, - (error, continueTxExecution, cancelCb) => { - if (error) { - reject(error) - } else { + this.executionContext.detectNetwork((error, network) => { + if (error) return reject(error) + if (network.name === 'Main' && network.id === '1') { + return reject(new Error('It is not allowed to make this action against mainnet')) + } + + this.txRunner.rawRun( + tx, + (network, tx, gasEstimation, continueTxExecution, cancelCb) => { continueTxExecution() + }, + (error, continueTxExecution, cancelCb) => { + if (error) { + reject(error) + } else { + continueTxExecution() + } + }, + (okCb, cancelCb) => { + okCb() + }, + async (error, result) => { + if (error) return reject(error) + try { + if (this.executionContext.isVM()) { + const execResult = await this.web3().remix.getExecutionResultFromSimulator(result.transactionHash) + resolve(resultToRemixTx(result, execResult)) + } else resolve(resultToRemixTx(result)) + } catch (e) { + reject(e) + } } - }, - (okCb, cancelCb) => { - okCb() - }, - async (error, result) => { - if (error) return reject(error) - try { - if (this.executionContext.isVM()) { - const execResult = await this.web3().remix.getExecutionResultFromSimulator(result.transactionHash) - resolve(resultToRemixTx(result, execResult)) - } else resolve(resultToRemixTx(result)) - } catch (e) { - reject(e) - } - } - ) - }) + ) + }) + }) }) }