From ee2a6f463df073a083e8f15491ab65b9d0e671b0 Mon Sep 17 00:00:00 2001 From: apanizo Date: Sat, 4 Aug 2018 13:34:33 +0200 Subject: [PATCH] Refactor grab gnosisSafe contract on TX History helper --- src/wallets/safeTxHistory.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/wallets/safeTxHistory.js b/src/wallets/safeTxHistory.js index 4e2dafa6..97c299b5 100644 --- a/src/wallets/safeTxHistory.js +++ b/src/wallets/safeTxHistory.js @@ -1,6 +1,5 @@ // @flow -import { getWeb3 } from '~/wallets/getWeb3' -import { getGnosisSafeContract } from '~/wallets/safeContracts' +import { getSafeEthereumInstance } from '~/wallets/createTransactions' type Type = 'confirmation' | 'execution' type Operation = 0 | 1 | 2 @@ -8,7 +7,7 @@ type Operation = 0 | 1 | 2 const calculateBodyFrom = async ( safeAddress: string, to: string, - value: number, + valueInWei: number, data: string, operation: Operation, nonce: number, @@ -16,15 +15,12 @@ const calculateBodyFrom = async ( sender: string, type: Type, ) => { - const web3 = getWeb3() - const valueInWei = value > 0 ? web3.toWei(value, 'ether') : value - const GnosisSafe = await getGnosisSafeContract(web3) - const gnosisSafe = GnosisSafe.at(safeAddress) + const gnosisSafe = await getSafeEthereumInstance(safeAddress) const contractTransactionHash = await gnosisSafe.getTransactionHash(safeAddress, valueInWei, data, operation, nonce) return JSON.stringify({ to, - value, + value: valueInWei, data, operation, nonce, @@ -38,7 +34,7 @@ const calculateBodyFrom = async ( export const submitOperation = async ( safeAddress: string, to: string, - value: number, + valueInWei: number, data: string, operation: Operation, nonce: number, @@ -53,7 +49,7 @@ export const submitOperation = async ( 'Content-Type': 'application/json', } - const body = await calculateBodyFrom(safeAddress, to, value, data, operation, nonce, txHash, sender, type) + const body = await calculateBodyFrom(safeAddress, to, valueInWei, data, operation, nonce, txHash, sender, type) const response = await fetch(url, { method: 'POST',