From 1bcd90d57b9a63636325f587c6746e72583310b0 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Fri, 14 Jun 2019 16:31:18 +0400 Subject: [PATCH] submitting tx to history service wip --- src/logic/safe/transactions/send.js | 6 +++--- src/logic/safe/transactions/txHistory.js | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/logic/safe/transactions/send.js b/src/logic/safe/transactions/send.js index 3a4ff401..8d9114ab 100644 --- a/src/logic/safe/transactions/send.js +++ b/src/logic/safe/transactions/send.js @@ -9,7 +9,7 @@ import { saveTxToHistory } from '~/logic/safe/transactions' export const CALL = 0 const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' -export const EXECUTION_TX_TYPE = 'execution' +export const TX_TYPE_EXECUTION = 'execution' export const executeTransaction = async ( safeInstance: any, @@ -42,7 +42,7 @@ export const executeTransaction = async ( ) await saveTxToHistory( - safeInstance.address, + safeInstance, to, valueInWei, data, @@ -50,7 +50,7 @@ export const executeTransaction = async ( nonce, tx.tx, // tx hash, sender, - EXECUTION_TX_TYPE, + TX_TYPE_EXECUTION, ) return tx diff --git a/src/logic/safe/transactions/txHistory.js b/src/logic/safe/transactions/txHistory.js index fc3e4403..d1fc04e3 100644 --- a/src/logic/safe/transactions/txHistory.js +++ b/src/logic/safe/transactions/txHistory.js @@ -2,14 +2,13 @@ import axios from 'axios' import { getWeb3 } from '~/logic/wallets/getWeb3' import { getTxServiceUriFrom, getTxServiceHost } from '~/config' -import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts' import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses' export type TxServiceType = 'confirmation' | 'execution' | 'initialised' export type Operation = 0 | 1 | 2 const calculateBodyFrom = async ( - safeAddress: string, + safeInstance: any, to: string, valueInWei: number, data: string, @@ -19,8 +18,7 @@ const calculateBodyFrom = async ( sender: string, type: TxServiceType, ) => { - const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) - const contractTransactionHash = await gnosisSafe.getTransactionHash( + const contractTransactionHash = await safeInstance.getTransactionHash( to, valueInWei, data, @@ -59,7 +57,7 @@ export const buildTxServiceUrl = (safeAddress: string) => { } export const saveTxToHistory = async ( - safeAddress: string, + safeInstance: any, to: string, valueInWei: number, data: string, @@ -69,8 +67,8 @@ export const saveTxToHistory = async ( sender: string, type: TxServiceType, ) => { - const url = buildTxServiceUrl(safeAddress) - const body = await calculateBodyFrom(safeAddress, to, valueInWei, data, operation, nonce, txHash, sender, type) + const url = buildTxServiceUrl(safeInstance.address) + const body = await calculateBodyFrom(safeInstance, to, valueInWei, data, operation, nonce, txHash, sender, type) const response = await axios.post(url, body) if (response.status !== 202) {