From 755db44c17d7959d8d2c70ba35610dd5bba2e83f Mon Sep 17 00:00:00 2001 From: mmv Date: Wed, 22 May 2019 18:36:43 +0400 Subject: [PATCH] generate pre validated signature for gas calculation --- src/logic/safe/transactions/gas.js | 31 +++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/logic/safe/transactions/gas.js b/src/logic/safe/transactions/gas.js index df34a9f8..6af60ce0 100644 --- a/src/logic/safe/transactions/gas.js +++ b/src/logic/safe/transactions/gas.js @@ -4,7 +4,6 @@ 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) => { @@ -120,20 +119,34 @@ export const calculateTxFee = async ( Number(threshold), safeAddress, ) - const signature = await generateMetamaskSignature( - safe, - safeAddress, - '0xbc2BB26a6d821e69A38016f3858561a1D80d4182', + + const sigs = `0x000000000000000000000000${ + '0xbc2BB26a6d821e69A38016f3858561a1D80d4182'.replace('0x', '') + }0000000000000000000000000000000000000000000000000000000000000000` + + '01' + console.log({ to, valueInWei, - nonce, data, operation, txGasEstimate, - ) - const sigs = getSignaturesFrom(safeInstance.address, nonce) + dataGasEstimate, + gasPrice: 0, + txGasToken: '0x0000000000000000000000000000000000000000', + refundReceiver: '0x0000000000000000000000000000000000000000', + sigs, + }) const estimate = await safeInstance.execTransaction.estimateGas( - to, valueInWei, data, operation, txGasEstimate, dataGasEstimate, 0, '0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', signature, + to, + valueInWei, + data, + operation, + txGasEstimate, + dataGasEstimate, + 0, + '0x0000000000000000000000000000000000000000', + '0x0000000000000000000000000000000000000000', + sigs, ) return estimate