From 3b233024ba1ae17d0152dfc98a73986d17f6ea15 Mon Sep 17 00:00:00 2001 From: mmv Date: Thu, 14 Nov 2019 10:30:07 +0400 Subject: [PATCH 1/4] Set value to 0 when sending txs/deploying new safe --- src/logic/contracts/safeContracts.js | 4 +++- src/logic/safe/transactions/gas.js | 4 ++-- src/logic/safe/transactions/gasNew.js | 2 +- src/logic/safe/transactions/send.js | 4 ++-- src/routes/safe/store/actions/createTransaction.js | 2 +- src/routes/safe/store/actions/processTransaction.js | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/logic/contracts/safeContracts.js b/src/logic/contracts/safeContracts.js index fef6b2a7..a1fad299 100644 --- a/src/logic/contracts/safeContracts.js +++ b/src/logic/contracts/safeContracts.js @@ -74,7 +74,9 @@ export const deploySafeContract = async (safeAccounts: string[], numConfirmation const gas = await calculateGasOf(proxyFactoryData, userAccount, proxyFactoryMaster.address) const gasPrice = await calculateGasPrice() - return proxyFactoryMaster.createProxy(safeMaster.address, gnosisSafeData, { from: userAccount, gas, gasPrice }) + return proxyFactoryMaster.createProxy(safeMaster.address, gnosisSafeData, { + from: userAccount, gas, gasPrice, value: 0, + }) } export const estimateGasForDeployingSafe = async ( diff --git a/src/logic/safe/transactions/gas.js b/src/logic/safe/transactions/gas.js index 2a0da8cb..baaed920 100644 --- a/src/logic/safe/transactions/gas.js +++ b/src/logic/safe/transactions/gas.js @@ -48,7 +48,7 @@ export const estimateDataGas = ( '', )}000000000000000000000000000000000000000000000000000000000000000001` const payload = safe.contract.methods - .execTransaction(to, valueInWei, data, operation, txGasEstimate, 0, gasPrice, gasToken, refundReceiver, sigs) + .execTransaction(to, valueInWei, data, operation, txGasEstimate, 0, gasPrice, gasToken, refundReceiver, sigs, { value: 0 }) .encodeABI() // eslint-disable-next-line @@ -122,7 +122,7 @@ export const calculateTxFee = async ( '0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', sigs, - { from: '0xbc2BB26a6d821e69A38016f3858561a1D80d4182' }, + { from: '0xbc2BB26a6d821e69A38016f3858561a1D80d4182', value: 0 }, ) return estimate diff --git a/src/logic/safe/transactions/gasNew.js b/src/logic/safe/transactions/gasNew.js index a1aff18c..b1fea4e1 100644 --- a/src/logic/safe/transactions/gasNew.js +++ b/src/logic/safe/transactions/gasNew.js @@ -33,7 +33,7 @@ export const estimateTxGasCosts = async ( '', )}000000000000000000000000000000000000000000000000000000000000000001` txData = await safeInstance.methods - .execTransaction(to, tx ? tx.value : 0, data, CALL, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, signatures) + .execTransaction(to, tx ? tx.value : 0, data, CALL, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, signatures, { value: 0 }) .encodeABI() } else { const txHash = await safeInstance.methods diff --git a/src/logic/safe/transactions/send.js b/src/logic/safe/transactions/send.js index ba1044a3..a2ed9030 100644 --- a/src/logic/safe/transactions/send.js +++ b/src/logic/safe/transactions/send.js @@ -37,7 +37,7 @@ export const getApprovalTransaction = async ( const web3 = getWeb3() const contract = new web3.eth.Contract(GnosisSafeSol.abi, safeInstance.address) - return contract.methods.approveHash(txHash) + return contract.methods.approveHash(txHash, { value: 0 }) } catch (err) { console.error(`Error while approving transaction: ${err}`) @@ -59,7 +59,7 @@ export const getExecutionTransaction = async ( const web3 = getWeb3() const contract = new web3.eth.Contract(GnosisSafeSol.abi, safeInstance.address) - return contract.methods.execTransaction(to, valueInWei, data, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs) + return contract.methods.execTransaction(to, valueInWei, data, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs, { value: 0 }) } catch (err) { console.error(`Error while creating transaction: ${err}`) diff --git a/src/routes/safe/store/actions/createTransaction.js b/src/routes/safe/store/actions/createTransaction.js index 9802e89e..b54d9d7c 100644 --- a/src/routes/safe/store/actions/createTransaction.js +++ b/src/routes/safe/store/actions/createTransaction.js @@ -121,7 +121,7 @@ const createTransaction = ( showSnackbar(notificationsQueue.afterExecutionError, enqueueSnackbar, closeSnackbar) const executeDataUsedSignatures = safeInstance.contract.methods - .execTransaction(to, valueInWei, txData, CALL, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs) + .execTransaction(to, valueInWei, txData, CALL, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs, { value: 0 }) .encodeABI() const errMsg = await getErrorMessage(safeInstance.address, 0, executeDataUsedSignatures, from) console.error(`Error executing the TX: ${errMsg}`) diff --git a/src/routes/safe/store/actions/processTransaction.js b/src/routes/safe/store/actions/processTransaction.js index e2cb52b3..ec851032 100644 --- a/src/routes/safe/store/actions/processTransaction.js +++ b/src/routes/safe/store/actions/processTransaction.js @@ -145,7 +145,7 @@ const processTransaction = ( closeSnackbar(pendingExecutionKey) showSnackbar(notificationsQueue.afterExecutionError, enqueueSnackbar, closeSnackbar) - const executeData = safeInstance.contract.methods.approveHash(txHash).encodeABI() + const executeData = safeInstance.contract.methods.approveHash(txHash, { value: 0 }).encodeABI() const errMsg = await getErrorMessage(safeInstance.address, 0, executeData, from) console.error(`Error executing the TX: ${errMsg}`) } From 80d033aa02bc700d19d914ab673a0b930bf93bbb Mon Sep 17 00:00:00 2001 From: mmv Date: Thu, 14 Nov 2019 11:19:52 +0400 Subject: [PATCH 2/4] remove value:0 where it's not needed --- src/logic/safe/transactions/gas.js | 4 ++-- src/logic/safe/transactions/gasNew.js | 2 +- src/routes/safe/store/actions/createTransaction.js | 2 +- src/routes/safe/store/actions/processTransaction.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/logic/safe/transactions/gas.js b/src/logic/safe/transactions/gas.js index baaed920..2a0da8cb 100644 --- a/src/logic/safe/transactions/gas.js +++ b/src/logic/safe/transactions/gas.js @@ -48,7 +48,7 @@ export const estimateDataGas = ( '', )}000000000000000000000000000000000000000000000000000000000000000001` const payload = safe.contract.methods - .execTransaction(to, valueInWei, data, operation, txGasEstimate, 0, gasPrice, gasToken, refundReceiver, sigs, { value: 0 }) + .execTransaction(to, valueInWei, data, operation, txGasEstimate, 0, gasPrice, gasToken, refundReceiver, sigs) .encodeABI() // eslint-disable-next-line @@ -122,7 +122,7 @@ export const calculateTxFee = async ( '0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', sigs, - { from: '0xbc2BB26a6d821e69A38016f3858561a1D80d4182', value: 0 }, + { from: '0xbc2BB26a6d821e69A38016f3858561a1D80d4182' }, ) return estimate diff --git a/src/logic/safe/transactions/gasNew.js b/src/logic/safe/transactions/gasNew.js index b1fea4e1..a1aff18c 100644 --- a/src/logic/safe/transactions/gasNew.js +++ b/src/logic/safe/transactions/gasNew.js @@ -33,7 +33,7 @@ export const estimateTxGasCosts = async ( '', )}000000000000000000000000000000000000000000000000000000000000000001` txData = await safeInstance.methods - .execTransaction(to, tx ? tx.value : 0, data, CALL, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, signatures, { value: 0 }) + .execTransaction(to, tx ? tx.value : 0, data, CALL, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, signatures) .encodeABI() } else { const txHash = await safeInstance.methods diff --git a/src/routes/safe/store/actions/createTransaction.js b/src/routes/safe/store/actions/createTransaction.js index 84942cd3..431e762d 100644 --- a/src/routes/safe/store/actions/createTransaction.js +++ b/src/routes/safe/store/actions/createTransaction.js @@ -113,7 +113,7 @@ const createTransaction = ( showSnackbar(notificationsQueue.afterExecutionError, enqueueSnackbar, closeSnackbar) const executeDataUsedSignatures = safeInstance.contract.methods - .execTransaction(to, valueInWei, txData, CALL, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs, { value: 0 }) + .execTransaction(to, valueInWei, txData, CALL, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs) .encodeABI() const errMsg = await getErrorMessage(safeInstance.address, 0, executeDataUsedSignatures, from) console.error(`Error executing the TX: ${errMsg}`) diff --git a/src/routes/safe/store/actions/processTransaction.js b/src/routes/safe/store/actions/processTransaction.js index 222cc54e..d870a1a1 100644 --- a/src/routes/safe/store/actions/processTransaction.js +++ b/src/routes/safe/store/actions/processTransaction.js @@ -147,7 +147,7 @@ const processTransaction = ( closeSnackbar(pendingExecutionKey) showSnackbar(notificationsQueue.afterExecutionError, enqueueSnackbar, closeSnackbar) - const executeData = safeInstance.contract.methods.approveHash(txHash, { value: 0 }).encodeABI() + const executeData = safeInstance.contract.methods.approveHash(txHash).encodeABI() const errMsg = await getErrorMessage(safeInstance.address, 0, executeData, from) console.error(`Error executing the TX: ${errMsg}`) } From 2e5d2c8f0e811dbe6cb5bc472a80b78aaaf0cc46 Mon Sep 17 00:00:00 2001 From: mmv Date: Thu, 14 Nov 2019 12:19:26 +0400 Subject: [PATCH 3/4] hardcode safe-contracts version to 1.0.0 --- package.json | 2 +- yarn.lock | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index a71c96e5..236958d9 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "precommit" ], "dependencies": { - "@gnosis.pm/safe-contracts": "^1.0.0", + "@gnosis.pm/safe-contracts": "1.0.0", "@gnosis.pm/util-contracts": "2.0.4", "@material-ui/core": "4.6.1", "@material-ui/icons": "4.5.1", diff --git a/yarn.lock b/yarn.lock index 7ec22c30..631ba2e3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1352,15 +1352,13 @@ "@ethersproject/constants" ">=5.0.0-beta.128" "@ethersproject/logger" ">=5.0.0-beta.129" -"@gnosis.pm/safe-contracts@^1.0.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-contracts/-/safe-contracts-1.1.0.tgz#84e579645249c3cb0001520f67c9ea0fdec2e121" - integrity sha512-SwODUJcO/NNh1KfMxWlb1/opcj2emuYVS+DJjrpMhfMbs8zgxE/1G/wXKEfgvhxBRd/xND6wVrG0UDd3U0C0Zw== +"@gnosis.pm/safe-contracts@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-contracts/-/safe-contracts-1.0.0.tgz#2b562b1e23a0da1047a9f38ef71a70f811e75dd9" + integrity sha512-IT40DhKr1tAWRcSTpZ0wRfC9thrHzNzHzaPBQHP0Jq8fLVj+MIrRxY1adBZUppQ4W58XXnK0K/qj7IbyyigHlA== dependencies: - dotenv "^8.0.0" openzeppelin-solidity "^2.0.0" - shelljs "^0.8.3" - solc "^0.5.9" + solc "^0.5.0" truffle-hdwallet-provider "0.0.7-beta.1" "@gnosis.pm/util-contracts@2.0.4": @@ -5126,9 +5124,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30000989, caniuse-lite@^1.0.30001004, caniuse-lite@^1.0.30001006: - version "1.0.30001009" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001009.tgz#69b77997b882a7aee6af24c8d7d2fa27ee41f348" - integrity sha512-M3rEqHN6SaVjgo4bIik7HsGcWXsi+lI9WA0p51RPMFx5gXfduyOXWJrc0R4xBkSK1pgNf4CNgy5M+6H+WiEP8g== + version "1.0.30001010" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001010.tgz#397a14034d384260453cc81994f494626d34b938" + integrity sha512-RA5GH9YjFNea4ZQszdWgh2SC+dpLiRAg4VDQS2b5JRI45OxmbGrYocYHTa9x0bKMQUE7uvHkNPNffUr+pCxSGw== capture-exit@^2.0.0: version "2.0.0" @@ -15947,7 +15945,7 @@ sockjs@0.3.19: faye-websocket "^0.10.0" uuid "^3.0.1" -solc@^0.5.0, solc@^0.5.9: +solc@^0.5.0: version "0.5.12" resolved "https://registry.yarnpkg.com/solc/-/solc-0.5.12.tgz#e63047dce04c82ec6f469f6e28febfbde713b808" integrity sha512-OX/AGZT04tuUsagoVXSZBiBZYJReA02hdwZOfRkB03/eeYP9Dl3pr+M+au+1MhssgiuWBlFPN7sRXFiqwkAW2g== From 896198236692f6432353cba695c662410e753025 Mon Sep 17 00:00:00 2001 From: mmv Date: Thu, 14 Nov 2019 14:58:33 +0400 Subject: [PATCH 4/4] Fix send params for approval/execution txs --- src/logic/safe/transactions/send.js | 4 ++-- src/routes/safe/store/actions/createTransaction.js | 2 +- src/routes/safe/store/actions/processTransaction.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/logic/safe/transactions/send.js b/src/logic/safe/transactions/send.js index a2ed9030..ba1044a3 100644 --- a/src/logic/safe/transactions/send.js +++ b/src/logic/safe/transactions/send.js @@ -37,7 +37,7 @@ export const getApprovalTransaction = async ( const web3 = getWeb3() const contract = new web3.eth.Contract(GnosisSafeSol.abi, safeInstance.address) - return contract.methods.approveHash(txHash, { value: 0 }) + return contract.methods.approveHash(txHash) } catch (err) { console.error(`Error while approving transaction: ${err}`) @@ -59,7 +59,7 @@ export const getExecutionTransaction = async ( const web3 = getWeb3() const contract = new web3.eth.Contract(GnosisSafeSol.abi, safeInstance.address) - return contract.methods.execTransaction(to, valueInWei, data, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs, { value: 0 }) + return contract.methods.execTransaction(to, valueInWei, data, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs) } catch (err) { console.error(`Error while creating transaction: ${err}`) diff --git a/src/routes/safe/store/actions/createTransaction.js b/src/routes/safe/store/actions/createTransaction.js index 431e762d..2b85ee40 100644 --- a/src/routes/safe/store/actions/createTransaction.js +++ b/src/routes/safe/store/actions/createTransaction.js @@ -59,7 +59,7 @@ const createTransaction = ( tx = await getApprovalTransaction(safeInstance, to, valueInWei, txData, CALL, nonce, from) } - const sendParams = { from } + const sendParams = { from, value: 0 } // if not set owner management tests will fail on ganache if (process.env.NODE_ENV === 'test') { sendParams.gas = '7000000' diff --git a/src/routes/safe/store/actions/processTransaction.js b/src/routes/safe/store/actions/processTransaction.js index d870a1a1..1df89980 100644 --- a/src/routes/safe/store/actions/processTransaction.js +++ b/src/routes/safe/store/actions/processTransaction.js @@ -95,7 +95,7 @@ const processTransaction = ( transaction = await getApprovalTransaction(safeInstance, tx.recipient, tx.value, tx.data, CALL, nonce, from) } - const sendParams = { from } + const sendParams = { from, value: 0 } // if not set owner management tests will fail on ganache if (process.env.NODE_ENV === 'test') { sendParams.gas = '7000000'