submitting tx to history service wip
This commit is contained in:
parent
ee5d7f270b
commit
b240c08783
|
@ -1,4 +1,3 @@
|
|||
// @flow
|
||||
|
||||
export * from './estimateTxGas'
|
||||
export * from './saveTxViaService'
|
|
@ -1,18 +0,0 @@
|
|||
// @flow
|
||||
import axios from 'axios'
|
||||
import { getTxServiceUriFrom, getTxServiceHost } from '~/config/index'
|
||||
|
||||
export const saveTxViaService = (safeAddress: string, to: string, value: string, data, operation = 0) => {
|
||||
const txServiceHost = getTxServiceHost()
|
||||
const txServiceUri = getTxServiceUriFrom(safeAddress)
|
||||
const url = `${txServiceHost}${txServiceUri}`
|
||||
// const estimationValue = isTokenTransfer(tx.data) ? '0' : value.toString(10)
|
||||
|
||||
return axios.post(url, {
|
||||
safe: safeAddress,
|
||||
to,
|
||||
data: '0x',
|
||||
value,
|
||||
operation,
|
||||
})
|
||||
}
|
|
@ -3,3 +3,4 @@ export * from './gas'
|
|||
export * from './send'
|
||||
export * from './safeBlockchainOperations'
|
||||
export * from './safeTxSignerEIP712'
|
||||
export * from './saveTxViaService'
|
||||
|
|
|
@ -5,6 +5,7 @@ import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
|||
import { isEther } from '~/logic/tokens/utils/tokenHelpers'
|
||||
import { type Token } from '~/logic/tokens/store/model/token'
|
||||
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
|
||||
import { saveTxViaService } from '~/logic/safe/transactions'
|
||||
|
||||
export const CALL = 0
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
|
||||
|
@ -38,6 +39,17 @@ export const executeTransaction = async (
|
|||
sigs,
|
||||
{ from: sender },
|
||||
)
|
||||
await saveTxViaService(
|
||||
safeInstance.address,
|
||||
to,
|
||||
valueInWei,
|
||||
data,
|
||||
nonce,
|
||||
0,
|
||||
tx.tx, // tx hash,
|
||||
sender,
|
||||
)
|
||||
console.log(tx.tx)
|
||||
|
||||
return tx
|
||||
} catch (error) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// @flow
|
||||
import axios from 'axios'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { getTxServiceUriFrom, getTxServiceHost } from '~/config'
|
||||
import { getGnosisSafeInstanceAt } from '~/logic/contracts/safeContracts'
|
||||
|
@ -49,7 +50,7 @@ const calculateBodyFrom = async (
|
|||
})
|
||||
}
|
||||
|
||||
export const buildTxServiceUrlFrom = (safeAddress: string) => {
|
||||
export const buildTxServiceUrl = (safeAddress: string) => {
|
||||
const host = getTxServiceHost()
|
||||
const address = getWeb3().toChecksumAddress(safeAddress)
|
||||
const base = getTxServiceUriFrom(address)
|
||||
|
@ -67,18 +68,10 @@ export const submitOperation = async (
|
|||
sender: string,
|
||||
type: TxServiceType,
|
||||
) => {
|
||||
const url = buildTxServiceUrlFrom(safeAddress)
|
||||
const headers = {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
const url = buildTxServiceUrl(safeAddress)
|
||||
const body = await calculateBodyFrom(safeAddress, to, valueInWei, data, operation, nonce, txHash, sender, type)
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body,
|
||||
})
|
||||
const response = await axios.post(url, { body })
|
||||
|
||||
if (response.status !== 202) {
|
||||
return Promise.reject(new Error('Error submitting the transaction'))
|
Loading…
Reference in New Issue