set gaslimit in sendTransaction

pull/5370/head
yann300 8 months ago
parent 4a0ac52c82
commit c8d31e37ab
  1. 70
      apps/remix-ide/src/blockchain/blockchain.tsx

@ -39,7 +39,7 @@ export type Transaction = {
to: string to: string
value: string value: string
data: string data: string
gasLimit: number gasLimit: string
useCall: boolean useCall: boolean
timestamp?: number timestamp?: number
} }
@ -779,40 +779,46 @@ export class Blockchain extends Plugin {
*/ */
sendTransaction(tx: Transaction) { sendTransaction(tx: Transaction) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.executionContext.detectNetwork((error, network) => { return this.transactionContextAPI.getGasLimit((err, value) => {
if (error) return reject(error) if (err) console.log('error resolving gas limit', err);
if (network.name === 'Main' && network.id === '1') { else {
return reject(new Error('It is not allowed to make this action against mainnet')) tx.gasLimit = value;
} }
this.executionContext.detectNetwork((error, network) => {
this.txRunner.rawRun( if (error) return reject(error)
tx, if (network.name === 'Main' && network.id === '1') {
(network, tx, gasEstimation, continueTxExecution, cancelCb) => { return reject(new Error('It is not allowed to make this action against mainnet'))
continueTxExecution() }
},
(error, continueTxExecution, cancelCb) => { this.txRunner.rawRun(
if (error) { tx,
reject(error) (network, tx, gasEstimation, continueTxExecution, cancelCb) => {
} else {
continueTxExecution() 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)
}
}
)
})
}) })
} }

Loading…
Cancel
Save