Refactor grab gnosisSafe contract on TX History helper
This commit is contained in:
parent
97d7118984
commit
ee2a6f463d
|
@ -1,6 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { getWeb3 } from '~/wallets/getWeb3'
|
import { getSafeEthereumInstance } from '~/wallets/createTransactions'
|
||||||
import { getGnosisSafeContract } from '~/wallets/safeContracts'
|
|
||||||
|
|
||||||
type Type = 'confirmation' | 'execution'
|
type Type = 'confirmation' | 'execution'
|
||||||
type Operation = 0 | 1 | 2
|
type Operation = 0 | 1 | 2
|
||||||
|
@ -8,7 +7,7 @@ type Operation = 0 | 1 | 2
|
||||||
const calculateBodyFrom = async (
|
const calculateBodyFrom = async (
|
||||||
safeAddress: string,
|
safeAddress: string,
|
||||||
to: string,
|
to: string,
|
||||||
value: number,
|
valueInWei: number,
|
||||||
data: string,
|
data: string,
|
||||||
operation: Operation,
|
operation: Operation,
|
||||||
nonce: number,
|
nonce: number,
|
||||||
|
@ -16,15 +15,12 @@ const calculateBodyFrom = async (
|
||||||
sender: string,
|
sender: string,
|
||||||
type: Type,
|
type: Type,
|
||||||
) => {
|
) => {
|
||||||
const web3 = getWeb3()
|
const gnosisSafe = await getSafeEthereumInstance(safeAddress)
|
||||||
const valueInWei = value > 0 ? web3.toWei(value, 'ether') : value
|
|
||||||
const GnosisSafe = await getGnosisSafeContract(web3)
|
|
||||||
const gnosisSafe = GnosisSafe.at(safeAddress)
|
|
||||||
const contractTransactionHash = await gnosisSafe.getTransactionHash(safeAddress, valueInWei, data, operation, nonce)
|
const contractTransactionHash = await gnosisSafe.getTransactionHash(safeAddress, valueInWei, data, operation, nonce)
|
||||||
|
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
to,
|
to,
|
||||||
value,
|
value: valueInWei,
|
||||||
data,
|
data,
|
||||||
operation,
|
operation,
|
||||||
nonce,
|
nonce,
|
||||||
|
@ -38,7 +34,7 @@ const calculateBodyFrom = async (
|
||||||
export const submitOperation = async (
|
export const submitOperation = async (
|
||||||
safeAddress: string,
|
safeAddress: string,
|
||||||
to: string,
|
to: string,
|
||||||
value: number,
|
valueInWei: number,
|
||||||
data: string,
|
data: string,
|
||||||
operation: Operation,
|
operation: Operation,
|
||||||
nonce: number,
|
nonce: number,
|
||||||
|
@ -53,7 +49,7 @@ export const submitOperation = async (
|
||||||
'Content-Type': 'application/json',
|
'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, {
|
const response = await fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
Loading…
Reference in New Issue