submitting tx to history service wip

This commit is contained in:
Mikhail Mikheev 2019-06-14 16:31:18 +04:00
parent cf4a58f7a3
commit 1bcd90d57b
2 changed files with 8 additions and 10 deletions

View File

@ -9,7 +9,7 @@ import { saveTxToHistory } from '~/logic/safe/transactions'
export const CALL = 0 export const CALL = 0
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
export const EXECUTION_TX_TYPE = 'execution' export const TX_TYPE_EXECUTION = 'execution'
export const executeTransaction = async ( export const executeTransaction = async (
safeInstance: any, safeInstance: any,
@ -42,7 +42,7 @@ export const executeTransaction = async (
) )
await saveTxToHistory( await saveTxToHistory(
safeInstance.address, safeInstance,
to, to,
valueInWei, valueInWei,
data, data,
@ -50,7 +50,7 @@ export const executeTransaction = async (
nonce, nonce,
tx.tx, // tx hash, tx.tx, // tx hash,
sender, sender,
EXECUTION_TX_TYPE, TX_TYPE_EXECUTION,
) )
return tx return tx

View File

@ -2,14 +2,13 @@
import axios from 'axios' import axios from 'axios'
import { getWeb3 } from '~/logic/wallets/getWeb3' import { getWeb3 } from '~/logic/wallets/getWeb3'
import { getTxServiceUriFrom, getTxServiceHost } from '~/config' import { getTxServiceUriFrom, getTxServiceHost } from '~/config'
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses' import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'
export type TxServiceType = 'confirmation' | 'execution' | 'initialised' export type TxServiceType = 'confirmation' | 'execution' | 'initialised'
export type Operation = 0 | 1 | 2 export type Operation = 0 | 1 | 2
const calculateBodyFrom = async ( const calculateBodyFrom = async (
safeAddress: string, safeInstance: any,
to: string, to: string,
valueInWei: number, valueInWei: number,
data: string, data: string,
@ -19,8 +18,7 @@ const calculateBodyFrom = async (
sender: string, sender: string,
type: TxServiceType, type: TxServiceType,
) => { ) => {
const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) const contractTransactionHash = await safeInstance.getTransactionHash(
const contractTransactionHash = await gnosisSafe.getTransactionHash(
to, to,
valueInWei, valueInWei,
data, data,
@ -59,7 +57,7 @@ export const buildTxServiceUrl = (safeAddress: string) => {
} }
export const saveTxToHistory = async ( export const saveTxToHistory = async (
safeAddress: string, safeInstance: any,
to: string, to: string,
valueInWei: number, valueInWei: number,
data: string, data: string,
@ -69,8 +67,8 @@ export const saveTxToHistory = async (
sender: string, sender: string,
type: TxServiceType, type: TxServiceType,
) => { ) => {
const url = buildTxServiceUrl(safeAddress) const url = buildTxServiceUrl(safeInstance.address)
const body = await calculateBodyFrom(safeAddress, to, valueInWei, data, operation, nonce, txHash, sender, type) const body = await calculateBodyFrom(safeInstance, to, valueInWei, data, operation, nonce, txHash, sender, type)
const response = await axios.post(url, body) const response = await axios.post(url, body)
if (response.status !== 202) { if (response.status !== 202) {