WA-521 Storing subject again when processing a tx
This commit is contained in:
parent
be9bdd25c1
commit
51c938a5d6
|
@ -57,6 +57,7 @@ export const executeTransaction = async (
|
|||
export const executeDailyLimit = async (
|
||||
safeAddress: string,
|
||||
to: string,
|
||||
nonce: number,
|
||||
valueInWei: number,
|
||||
sender: string,
|
||||
) => {
|
||||
|
@ -68,7 +69,6 @@ export const executeDailyLimit = async (
|
|||
const txHash = await dailyLimitModule.executeDailyLimit(0, to, valueInWei, { from: sender, gas, gasPrice })
|
||||
checkReceiptStatus(txHash.tx)
|
||||
|
||||
const nonce = Date.now()
|
||||
const operation = 0 // CALL for all currencies
|
||||
const data = '' // empty for ETH
|
||||
await submitOperation(safeAddress, to, valueInWei, data, operation, nonce, txHash, sender, 'execution')
|
||||
|
|
|
@ -6,6 +6,7 @@ import { getWeb3 } from '~/logic/wallets/getWeb3'
|
|||
import { DESTINATION_PARAM, VALUE_PARAM } from '~/routes/safe/component/Withdraw/WithdrawForm'
|
||||
import { type Safe } from '~/routes/safe/store/model/safe'
|
||||
import { getGnosisSafeContract } from '~/logic/contracts/safeContracts'
|
||||
import { storeSubject } from '~/utils/localStorage/transactions'
|
||||
|
||||
export const TX_NAME_PARAM = 'txName'
|
||||
export const TX_DESTINATION_PARAM = 'txDestination'
|
||||
|
@ -45,9 +46,13 @@ export const createTransaction = async (
|
|||
|
||||
const isExecution = hasOneOwner(safe) || threshold === 1
|
||||
|
||||
return isExecution
|
||||
? executeTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
|
||||
: approveTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
|
||||
const txHash = isExecution
|
||||
? await executeTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
|
||||
: await approveTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
|
||||
|
||||
storeSubject(safeAddress, nonce, name)
|
||||
|
||||
return txHash
|
||||
}
|
||||
|
||||
export const processTransaction = async (
|
||||
|
@ -65,9 +70,11 @@ export const processTransaction = async (
|
|||
const CALL = 0
|
||||
|
||||
const thresholdReached = threshold === alreadyConfirmed + 1
|
||||
return thresholdReached
|
||||
? executeTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
|
||||
: approveTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
|
||||
const txHash = thresholdReached
|
||||
? await executeTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
|
||||
: await approveTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
|
||||
|
||||
return txHash
|
||||
}
|
||||
|
||||
export const withdraw = async (values: Object, safe: Safe, sender: string): Promise<void> => {
|
||||
|
@ -75,7 +82,10 @@ export const withdraw = async (values: Object, safe: Safe, sender: string): Prom
|
|||
const destination = values[DESTINATION_PARAM]
|
||||
const valueInEth = values[VALUE_PARAM]
|
||||
const valueInWei = getWeb3().toWei(valueInEth, 'ether')
|
||||
const nonce = Date.now()
|
||||
const txHash = await executeDailyLimit(safeAddress, destination, nonce, valueInWei, sender)
|
||||
|
||||
// TODO write subject `Withdraw movement of ${valueInEth}`
|
||||
return executeDailyLimit(safeAddress, destination, valueInWei, sender)
|
||||
storeSubject(safeAddress, nonce, `Withdraw movement of ${valueInEth}`)
|
||||
|
||||
return txHash
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// @flow
|
||||
import { type Match } from 'react-router-dom'
|
||||
import { aNewStore } from '~/store'
|
||||
import { addEtherTo } from '~/test/utils/tokenMovements'
|
||||
import { aDeployedSafe, executeWithdrawOn } from '~/routes/safe/store/test/builder/deployedSafe.builder'
|
||||
import { addEtherTo, executeWithdrawOn } from '~/test/utils/tokenMovements'
|
||||
import { buildMathPropsFrom } from '~/test/utils/buildReactRouterProps'
|
||||
import { safeSelector } from '~/routes/safe/store/selectors/index'
|
||||
import { type Match } from 'react-router-dom'
|
||||
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
|
||||
|
||||
describe('Safe Blockchain Test', () => {
|
||||
let store
|
||||
|
@ -15,7 +15,7 @@ describe('Safe Blockchain Test', () => {
|
|||
it('wihdrawn should return revert error if exceeded dailyLimit', async () => {
|
||||
// GIVEN
|
||||
const dailyLimitValue = 0.30
|
||||
const safeAddress = await aDeployedSafe(store, dailyLimitValue)
|
||||
const safeAddress = await aMinedSafe(store, 1, 1, dailyLimitValue)
|
||||
await addEtherTo(safeAddress, '0.7')
|
||||
const value = 0.15
|
||||
|
Loading…
Reference in New Issue