Calculate gas for deposit & withdrawal transactions via fee oracle instead of web3 naive methods
This commit is contained in:
parent
879c8549e6
commit
6137e1328a
@ -24,7 +24,7 @@
|
||||
"@metamask/onboarding": "^1.0.0",
|
||||
"@nuxtjs/moment": "^1.6.0",
|
||||
"@tornado/snarkjs": "0.1.20-p2",
|
||||
"@tornado/tornado-oracles": "1.4.0",
|
||||
"@tornado/tornado-oracles": "^2.0.0",
|
||||
"@tornado/websnark": "0.0.4-p1",
|
||||
"@walletconnect/web3-provider": "1.7.8",
|
||||
"ajv": "^6.10.2",
|
||||
|
@ -543,16 +543,17 @@ const actions = {
|
||||
}
|
||||
|
||||
const data = contractInstance.methods.deposit(...params).encodeABI()
|
||||
const gas = await contractInstance.methods.deposit(...params).estimateGas({ from: ethAccount, value })
|
||||
const incompletedTx = {
|
||||
from: ethAccount,
|
||||
to: contractInstance._address,
|
||||
value: numberToHex(value),
|
||||
data
|
||||
}
|
||||
const gasLimit = await rootGetters['fees/oracle'].getGasLimit(incompletedTx, 'other', 10)
|
||||
|
||||
const callParams = {
|
||||
method: 'eth_sendTransaction',
|
||||
params: {
|
||||
to: contractInstance._address,
|
||||
gas: numberToHex(gas + 50000),
|
||||
value: numberToHex(value),
|
||||
data
|
||||
},
|
||||
params: Object.assign({ gasLimit }, incompletedTx),
|
||||
watcherParams: {
|
||||
title: { path: 'depositing', amount, currency },
|
||||
successTitle: {
|
||||
@ -775,18 +776,16 @@ const actions = {
|
||||
const params = [instance, proof, ...args]
|
||||
|
||||
const data = contractInstance.methods.withdraw(...params).encodeABI()
|
||||
const gas = await contractInstance.methods
|
||||
.withdraw(...params)
|
||||
.estimateGas({ from: ethAccount, value: args[5] })
|
||||
const incompletedTx = {
|
||||
data,
|
||||
value: args[5],
|
||||
to: contractInstance._address
|
||||
}
|
||||
const gasLimit = await rootGetters['fees/oracle'].getGasLimit(incompletedTx, 'user_withdrawal')
|
||||
|
||||
const callParams = {
|
||||
method: 'eth_sendTransaction',
|
||||
params: {
|
||||
data,
|
||||
value: args[5],
|
||||
to: contractInstance._address,
|
||||
gas: numberToHex(gas + 200000)
|
||||
},
|
||||
params: Object.assign({ gasLimit }, incompletedTx),
|
||||
watcherParams: {
|
||||
title: { path: 'withdrawing', amount, currency },
|
||||
successTitle: {
|
||||
|
@ -2477,10 +2477,10 @@
|
||||
resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ftornado-config/-/2.0.0/tornado-config-2.0.0.tgz#52bbc179ecb2385f71b4d56e060b68e7dd6fb8b4"
|
||||
integrity sha512-7EkpWNfEm34VEOrbLnPpvd/aUJYnA1L+6/qx2fZ/AfmuJFkjSZ18Z4jvVGNY7ktKIhTu3/Tbze+9l3eNueCNIA==
|
||||
|
||||
"@tornado/tornado-oracles@1.4.0":
|
||||
version "1.4.0"
|
||||
resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ftornado-oracles/-/1.4.0/tornado-oracles-1.4.0.tgz#78bdb44c538f57abdbecf9deac951d85adc5b74a"
|
||||
integrity sha512-Qrq0p/AYxUhTs0ZAISumwUhlLRQKoBgAW95P1uMbAGOwKO5z32XS5S17E5CaWzCGZmewVUpx4AxCCSmqY9JNiQ==
|
||||
"@tornado/tornado-oracles@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ftornado-oracles/-/2.0.0/tornado-oracles-2.0.0.tgz#846761fd65cf5803ead1ad8e69f9d9b57bc1494e"
|
||||
integrity sha512-dQAJFS3OJPWQ6falfYG2b26A7YGqtQ4bJVvRUebYCyB/AyYmXThAlKaEw+Kd2H8iR4h/qNxUWHMgQykBDOi8Tw==
|
||||
dependencies:
|
||||
"@tornado/gas-price-oracle" "^0.5.3"
|
||||
"@tornado/tornado-config" "^2.0.0"
|
||||
|
Loading…
Reference in New Issue
Block a user