diff --git a/src/logic/safe/safeFrontendOperations.js b/src/logic/safe/safeFrontendOperations.js index 8a3cfc57..ff21ee7c 100644 --- a/src/logic/safe/safeFrontendOperations.js +++ b/src/logic/safe/safeFrontendOperations.js @@ -1,7 +1,7 @@ // @flow import { List } from 'immutable' import { type Transaction } from '~/routes/safe/store/models/transaction' -import { executeTransaction, approveTransaction } from '~/logic/safe/safeBlockchainOperations' +import { executeTransaction, approveTransaction } from '~/logic/safe/transactions' import { EMPTY_DATA } from '~/logic/wallets/ethTransactions' import { getWeb3 } from '~/logic/wallets/getWeb3' import { type Safe } from '~/routes/safe/store/models/safe' diff --git a/src/logic/safe/transactions/gas.js b/src/logic/safe/transactions/gas.js index 3177c677..df34a9f8 100644 --- a/src/logic/safe/transactions/gas.js +++ b/src/logic/safe/transactions/gas.js @@ -4,6 +4,7 @@ import { BigNumber } from 'bignumber.js' import { getWeb3 } from '~/logic/wallets/getWeb3' import { EMPTY_DATA } from '~/logic/wallets/ethTransactions' import { getSafeEthereumInstance } from '../safeFrontendOperations' +import { generateMetamaskSignature } from '~/logic/safe/transactions' const estimateDataGasCosts = (data) => { const reducer = (accumulator, currentValue) => { @@ -119,10 +120,21 @@ export const calculateTxFee = async ( Number(threshold), safeAddress, ) + const signature = await generateMetamaskSignature( + safe, + safeAddress, + '0xbc2BB26a6d821e69A38016f3858561a1D80d4182', + to, + valueInWei, + nonce, + data, + operation, + txGasEstimate, + ) const sigs = getSignaturesFrom(safeInstance.address, nonce) const estimate = await safeInstance.execTransaction.estimateGas( - to, valueInWei, data, operation, txGasEstimate, dataGasEstimate, 0, '0x0000000000000000000000000000000000000000', safeAddress, sigs - ) + to, valueInWei, data, operation, txGasEstimate, dataGasEstimate, 0, '0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', signature, + ) return estimate } catch (error) { diff --git a/src/logic/safe/transactions/index.js b/src/logic/safe/transactions/index.js index adcbe9ce..4f54b80d 100644 --- a/src/logic/safe/transactions/index.js +++ b/src/logic/safe/transactions/index.js @@ -1,2 +1,4 @@ // @flow export * from './gas' +export * from './safeBlockchainOperations' +export * from './safeTxSignerEIP712' diff --git a/src/logic/safe/safeBlockchainOperations.js b/src/logic/safe/transactions/safeBlockchainOperations.js similarity index 98% rename from src/logic/safe/safeBlockchainOperations.js rename to src/logic/safe/transactions/safeBlockchainOperations.js index a52de339..ec6c5c4a 100644 --- a/src/logic/safe/safeBlockchainOperations.js +++ b/src/logic/safe/transactions/safeBlockchainOperations.js @@ -4,7 +4,7 @@ import { calculateGasOf, checkReceiptStatus, calculateGasPrice } from '~/logic/w import { type Operation, submitOperation } from '~/logic/safe/safeTxHistory' import { getSafeEthereumInstance } from '~/logic/safe/safeFrontendOperations' import { buildSignaturesFrom } from '~/logic/safe/safeTxSigner' -import { generateMetamaskSignature, generateTxGasEstimateFrom, estimateDataGas } from '~/logic/safe/safeTxSignerEIP712' +import { generateMetamaskSignature, generateTxGasEstimateFrom, estimateDataGas } from '~/logic/safe/transactions' import { storeSignature, getSignaturesFrom } from '~/utils/storage/signatures' import { signaturesViaMetamask } from '~/config' diff --git a/src/logic/safe/safeTxSignerEIP712.js b/src/logic/safe/transactions/safeTxSignerEIP712.js similarity index 97% rename from src/logic/safe/safeTxSignerEIP712.js rename to src/logic/safe/transactions/safeTxSignerEIP712.js index 31182798..07d78efc 100644 --- a/src/logic/safe/safeTxSignerEIP712.js +++ b/src/logic/safe/transactions/safeTxSignerEIP712.js @@ -82,14 +82,14 @@ export const generateMetamaskSignature = async ( operation, txGasEstimate, ) - + console.log({sender}) const jsonTypedData = JSON.stringify(typedData) const signedTypedData = { method: 'eth_signTypedData_v3', // To change once Metamask fixes their status // https://github.com/MetaMask/metamask-extension/pull/5368 // https://github.com/MetaMask/metamask-extension/issues/5366 - params: [jsonTypedData, sender], + params: [sender, jsonTypedData], from: sender, } const txSignedResponse = await web3.currentProvider.sendAsync(signedTypedData)