Skip to content

Commit 49a883c

Browse files
authored
Merge pull request #2314 from ethereum/fix_gas_refund
fix eth_estimateGas
2 parents 04b147f + 39039fc commit 49a883c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

libs/remix-simulator/src/methods/transactions.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,22 @@ export class Transactions {
133133

134134
payload.params[0].gas = 10000000 * 10
135135

136-
processTx(this.txRunnerInstance, payload, true, (error, result) => {
136+
processTx(this.txRunnerInstance, payload, true, (error, { result }) => {
137137
if (error) return cb(error)
138-
if (result.result.status === '0x0') {
138+
if (result.status === '0x0') {
139139
try {
140-
const msg = result.result.execResult.returnValue
140+
const msg = result.execResult.returnValue
141141
const abiCoder = new ethers.utils.AbiCoder()
142142
const reason = abiCoder.decode(['string'], msg.slice(4))[0]
143143
return cb('revert ' + reason)
144144
} catch (e) {
145145
return cb(e.message)
146-
}
146+
}
147+
}
148+
let gasUsed = result.execResult.gasUsed.toNumber()
149+
if (result.execResult.gasRefund) {
150+
gasUsed += result.execResult.gasRefund.toNumber()
147151
}
148-
const gasUsed = result.result.execResult.gasUsed.toNumber()
149152
cb(null, Math.ceil(gasUsed + (15 * gasUsed) / 100))
150153
})
151154
}

0 commit comments

Comments
 (0)