Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/routes/open/container/Open.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)
Expand Down
14 changes: 9 additions & 5 deletions src/routes/safe/component/AddTransaction/createTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'))
}
10 changes: 6 additions & 4 deletions src/routes/safe/component/Transactions/processTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -125,7 +127,7 @@ export const processTransaction = async (
txValue,
userAddress,
executedConfirmations,
thresholdReached ? txReceipt : '',
thresholdReached ? txHash : '',
safeAddress,
threshold,
)
Expand Down
5 changes: 3 additions & 2 deletions src/routes/safe/component/Withdrawn/withdrawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/routes/safe/test/Safe.multisig.3owners1threshold.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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((
Expand Down Expand Up @@ -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]')
Expand Down
19 changes: 19 additions & 0 deletions src/wallets/ethTransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down