WA-238 usage of executeTransaction on processTransaction helper

This commit is contained in:
apanizo 2018-05-31 11:25:44 +02:00
parent 99507a0c33
commit b2a02982fe
3 changed files with 11 additions and 9 deletions

View File

@ -105,7 +105,7 @@ export const createTransaction = async (
const txConfirmationData = gnosisSafe.contract.approveTransactionWithParameters.getData(txDestination, valueInWei, '0x', CALL, nonce) const txConfirmationData = gnosisSafe.contract.approveTransactionWithParameters.getData(txDestination, valueInWei, '0x', CALL, nonce)
const txConfirmationReceipt = await executeTransaction(txConfirmationData, user, safeAddress) const txConfirmationReceipt = await executeTransaction(txConfirmationData, user, safeAddress)
const confirmations: List<Confirmation> = buildConfirmationsFrom(safe.get('owners'), user, txConfirmationReceipt.tx) const confirmations: List<Confirmation> = buildConfirmationsFrom(safe.get('owners'), user, txConfirmationReceipt)
return storeTransaction(txName, nonce, txDestination, txValue, user, confirmations, '', safeAddress, safe.get('confirmations')) return storeTransaction(txName, nonce, txDestination, txValue, user, confirmations, '', safeAddress, safe.get('confirmations'))
} }

View File

@ -8,6 +8,7 @@ import { getGnosisSafeContract } from '~/wallets/safeContracts'
import { getWeb3 } from '~/wallets/getWeb3' import { getWeb3 } from '~/wallets/getWeb3'
import { sameAddress } from '~/wallets/ethAddresses' import { sameAddress } from '~/wallets/ethAddresses'
import { EXECUTED_CONFIRMATION_HASH } from '~/routes/safe/component/AddTransaction/createTransactions' import { EXECUTED_CONFIRMATION_HASH } from '~/routes/safe/component/AddTransaction/createTransactions'
import executeTransaction from '~/wallets/ethTransactions'
export const updateTransaction = ( export const updateTransaction = (
name: string, name: string,
@ -49,9 +50,9 @@ const execTransaction = async (
const CALL = getOperation() const CALL = getOperation()
const web3 = getWeb3() const web3 = getWeb3()
const valueInWei = web3.toWei(txValue, 'ether') const valueInWei = web3.toWei(txValue, 'ether')
const txReceipt = await gnosisSafe.execTransactionIfApproved(destination, valueInWei, data, CALL, nonce, { from: executor, gas: '5000000' }) const txData = await gnosisSafe.contract.execTransactionIfApproved.getData(destination, valueInWei, data, CALL, nonce)
return txReceipt return executeTransaction(txData, executor, gnosisSafe.address)
} }
const execConfirmation = async ( const execConfirmation = async (
@ -65,9 +66,10 @@ const execConfirmation = async (
const CALL = getOperation() const CALL = getOperation()
const web3 = getWeb3() const web3 = getWeb3()
const valueInWei = web3.toWei(txValue, 'ether') const valueInWei = web3.toWei(txValue, 'ether')
const txConfirmationReceipt = await gnosisSafe.approveTransactionWithParameters(txDestination, valueInWei, data, CALL, nonce, { from: executor, gas: '5000000' }) const txConfirmationData =
await gnosisSafe.contract.approveTransactionWithParameters.getData(txDestination, valueInWei, data, CALL, nonce)
return txConfirmationReceipt return executeTransaction(txConfirmationData, executor, gnosisSafe.address)
} }
const updateConfirmations = (confirmations: List<Confirmation>, userAddress: string, txHash: string) => const updateConfirmations = (confirmations: List<Confirmation>, userAddress: string, txHash: string) =>
@ -103,7 +105,7 @@ export const processTransaction = async (
} }
const threshold = tx.get('threshold') const threshold = tx.get('threshold')
const thresholdReached = threshold >= alreadyConfirmed + 1 const thresholdReached = threshold === alreadyConfirmed + 1
const nonce = tx.get('nonce') const nonce = tx.get('nonce')
const txName = tx.get('name') const txName = tx.get('name')
const txValue = tx.get('value') const txValue = tx.get('value')
@ -113,7 +115,7 @@ export const processTransaction = async (
? await execTransaction(gnosisSafe, txDestination, txValue, nonce, userAddress) ? await execTransaction(gnosisSafe, txDestination, txValue, nonce, userAddress)
: await execConfirmation(gnosisSafe, txDestination, txValue, nonce, userAddress) : await execConfirmation(gnosisSafe, txDestination, txValue, nonce, userAddress)
const confirmationHash = thresholdReached ? EXECUTED_CONFIRMATION_HASH : txReceipt.tx const confirmationHash = thresholdReached ? EXECUTED_CONFIRMATION_HASH : txReceipt
const executedConfirmations: List<Confirmation> = updateConfirmations(tx.get('confirmations'), userAddress, confirmationHash) const executedConfirmations: List<Confirmation> = updateConfirmations(tx.get('confirmations'), userAddress, confirmationHash)
return updateTransaction( return updateTransaction(
@ -123,7 +125,7 @@ export const processTransaction = async (
txValue, txValue,
userAddress, userAddress,
executedConfirmations, executedConfirmations,
txReceipt.tx, txReceipt,
safeAddress, safeAddress,
threshold, threshold,
) )

View File

@ -35,7 +35,7 @@ const calculateGasOf = async (data: Object, from: string, to: string) => {
const executeTransaction = async (data: Object, from: string, to: string) => { const executeTransaction = async (data: Object, from: string, to: string) => {
const web3 = getWeb3() const web3 = getWeb3()
const gas = await calculateGasOf(data, from, to) + 2000 const gas = await calculateGasOf(data, from, to) * 2
let gasPrice let gasPrice
try { try {