Merge pull request #35 from gnosis/feature/WA-238-check-tx-receipt-status
WA-238 Checking tx receipt status on withdrawn mutlsig txs
This commit is contained in:
commit
b6a04202f7
|
@ -6,6 +6,7 @@ import Page from '~/components/layout/Page'
|
|||
import { getAccountsFrom, getThresholdFrom, getNamesFrom, getSafeNameFrom, getDailyLimitFrom } from '~/routes/open/utils/safeDataExtractor'
|
||||
import { getWeb3 } from '~/wallets/getWeb3'
|
||||
import { getGnosisSafeContract, deploySafeContract, initContracts } from '~/wallets/safeContracts'
|
||||
import { checkReceiptStatus } from '~/wallets/ethTransactions'
|
||||
import selector from './selector'
|
||||
import actions, { type Actions, type AddSafe } from './actions'
|
||||
import Layout from '../components/Layout'
|
||||
|
@ -32,6 +33,7 @@ const createSafe = async (values: Object, userAccount: string, addSafe: AddSafe)
|
|||
|
||||
await initContracts()
|
||||
const safe = await deploySafeContract(accounts, numConfirmations, dailyLimit, userAccount)
|
||||
checkReceiptStatus(safe.tx)
|
||||
|
||||
const param = safe.logs[1].args.proxy
|
||||
const safeContract = GnosisSafe.at(param)
|
||||
|
|
|
@ -8,7 +8,7 @@ import { getGnosisSafeContract } from '~/wallets/safeContracts'
|
|||
import { getWeb3 } from '~/wallets/getWeb3'
|
||||
import { type Safe } from '~/routes/safe/store/model/safe'
|
||||
import { sameAddress } from '~/wallets/ethAddresses'
|
||||
import executeTransaction from '~/wallets/ethTransactions'
|
||||
import executeTransaction, { checkReceiptStatus } from '~/wallets/ethTransactions'
|
||||
|
||||
export const TX_NAME_PARAM = 'txName'
|
||||
export const TX_DESTINATION_PARAM = 'txDestination'
|
||||
|
@ -98,14 +98,18 @@ export const createTransaction = async (
|
|||
const thresholdIsOne = safe.get('confirmations') === 1
|
||||
if (hasOneOwner(safe) || thresholdIsOne) {
|
||||
const txConfirmationData = gnosisSafe.contract.execTransactionIfApproved.getData(txDestination, valueInWei, '0x', CALL, nonce)
|
||||
const txReceipt = await executeTransaction(txConfirmationData, user, safeAddress)
|
||||
const txHash = await executeTransaction(txConfirmationData, user, safeAddress)
|
||||
checkReceiptStatus(txHash)
|
||||
|
||||
const executedConfirmations: List<Confirmation> = buildExecutedConfirmationFrom(safe.get('owners'), user)
|
||||
return storeTransaction(txName, nonce, txDestination, txValue, user, executedConfirmations, txReceipt, safeAddress, safe.get('confirmations'))
|
||||
return storeTransaction(txName, nonce, txDestination, txValue, user, executedConfirmations, txHash, safeAddress, safe.get('confirmations'))
|
||||
}
|
||||
|
||||
const txConfirmationData = gnosisSafe.contract.approveTransactionWithParameters.getData(txDestination, valueInWei, '0x', CALL, nonce)
|
||||
const txConfirmationReceipt = await executeTransaction(txConfirmationData, user, safeAddress)
|
||||
const confirmations: List<Confirmation> = buildConfirmationsFrom(safe.get('owners'), user, txConfirmationReceipt)
|
||||
const txConfirmationHash = await executeTransaction(txConfirmationData, user, safeAddress)
|
||||
checkReceiptStatus(txConfirmationHash)
|
||||
|
||||
const confirmations: List<Confirmation> = buildConfirmationsFrom(safe.get('owners'), user, txConfirmationHash)
|
||||
|
||||
return storeTransaction(txName, nonce, txDestination, txValue, user, confirmations, '', safeAddress, safe.get('confirmations'))
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import { getGnosisSafeContract } from '~/wallets/safeContracts'
|
|||
import { getWeb3 } from '~/wallets/getWeb3'
|
||||
import { sameAddress } from '~/wallets/ethAddresses'
|
||||
import { EXECUTED_CONFIRMATION_HASH } from '~/routes/safe/component/AddTransaction/createTransactions'
|
||||
import executeTransaction from '~/wallets/ethTransactions'
|
||||
import executeTransaction, { checkReceiptStatus } from '~/wallets/ethTransactions'
|
||||
|
||||
export const updateTransaction = (
|
||||
name: string,
|
||||
|
@ -111,11 +111,13 @@ export const processTransaction = async (
|
|||
const txValue = tx.get('value')
|
||||
const txDestination = tx.get('destination')
|
||||
|
||||
const txReceipt = thresholdReached
|
||||
const txHash = thresholdReached
|
||||
? await execTransaction(gnosisSafe, txDestination, txValue, nonce, userAddress)
|
||||
: await execConfirmation(gnosisSafe, txDestination, txValue, nonce, userAddress)
|
||||
|
||||
const confirmationHash = thresholdReached ? EXECUTED_CONFIRMATION_HASH : txReceipt
|
||||
checkReceiptStatus(txHash)
|
||||
|
||||
const confirmationHash = thresholdReached ? EXECUTED_CONFIRMATION_HASH : txHash
|
||||
const executedConfirmations: List<Confirmation> = updateConfirmations(tx.get('confirmations'), userAddress, confirmationHash)
|
||||
|
||||
return updateTransaction(
|
||||
|
@ -125,7 +127,7 @@ export const processTransaction = async (
|
|||
txValue,
|
||||
userAddress,
|
||||
executedConfirmations,
|
||||
thresholdReached ? txReceipt : '',
|
||||
thresholdReached ? txHash : '',
|
||||
safeAddress,
|
||||
threshold,
|
||||
)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { getWeb3 } from '~/wallets/getWeb3'
|
||||
import { getGnosisSafeContract, getCreateDailyLimitExtensionContract } from '~/wallets/safeContracts'
|
||||
import { type DailyLimitProps } from '~/routes/safe/store/model/dailyLimit'
|
||||
import executeTransaction from '~/wallets/ethTransactions'
|
||||
import executeTransaction, { checkReceiptStatus } from '~/wallets/ethTransactions'
|
||||
|
||||
export const LIMIT_POSITION = 0
|
||||
export const SPENT_TODAY_POS = 1
|
||||
|
@ -45,7 +45,8 @@ const withdrawn = async (values: Object, safeAddress: string, userAccount: strin
|
|||
|
||||
const dailyLimitData = dailyLimitModule.contract.executeDailyLimit.getData(0, destination, value)
|
||||
|
||||
return executeTransaction(dailyLimitData, userAccount, dailyLimitModule.address)
|
||||
const txHash = await executeTransaction(dailyLimitData, userAccount, dailyLimitModule.address)
|
||||
checkReceiptStatus(txHash)
|
||||
}
|
||||
|
||||
export default withdrawn
|
||||
|
|
|
@ -9,6 +9,7 @@ import { SAFELIST_ADDRESS } from '~/routes/routes'
|
|||
import AppRoutes from '~/routes'
|
||||
import AddTransactionComponent from '~/routes/safe/component/AddTransaction'
|
||||
import { createMultisigTxFilling, addFundsTo, checkBalanceOf, listTxsOf, getTagFromTransaction, expandTransactionOf, getTransactionFromReduxStore, confirmOwners } from '~/routes/safe/test/testMultisig'
|
||||
import { sleep } from '~/utils/timer'
|
||||
|
||||
const renderSafe = localStore => (
|
||||
TestUtils.renderIntoDocument((
|
||||
|
@ -40,6 +41,7 @@ describe('React DOM TESTS > Multisig transactions from safe [3 owners & 1 thresh
|
|||
await createMultisigTxFilling(SafeDom, AddTransactionComponent, store)
|
||||
await checkBalanceOf(address, '0.09')
|
||||
await listTxsOf(SafeDom)
|
||||
await sleep(2500)
|
||||
|
||||
await expandTransactionOf(SafeDom, 3, 1)
|
||||
await confirmOwners(SafeDom, 'Adolfo 1 Eth Account [Confirmed]', 'Adolfo 2 Eth Account [Not confirmed]', 'Adolfo 3 Eth Account [Not confirmed]')
|
||||
|
|
|
@ -5,6 +5,25 @@ import { promisify } from '~/utils/promisify'
|
|||
|
||||
// const MAINNET_NETWORK = 1
|
||||
|
||||
export const checkReceiptStatus = async (hash: string) => {
|
||||
if (!hash) {
|
||||
throw new Error('No valid Tx hash to get receipt from')
|
||||
}
|
||||
|
||||
const web3 = getWeb3()
|
||||
const txReceipt = await promisify(cb => web3.eth.getTransactionReceipt(hash, cb))
|
||||
|
||||
const { status } = txReceipt
|
||||
if (!status) {
|
||||
throw new Error('No status found on this transaction receipt')
|
||||
}
|
||||
|
||||
const hasError = status === '0x0'
|
||||
if (hasError) {
|
||||
throw new Error('Obtained a transaction failure in the receipt')
|
||||
}
|
||||
}
|
||||
|
||||
export const calculateGasPrice = async () => {
|
||||
/*
|
||||
const web3 = getWeb3()
|
||||
|
|
Loading…
Reference in New Issue