WA-521 Storing subject again when processing a tx

This commit is contained in:
apanizo 2018-08-14 09:25:26 +02:00
parent be9bdd25c1
commit 51c938a5d6
3 changed files with 23 additions and 13 deletions

View File

@ -57,6 +57,7 @@ export const executeTransaction = async (
export const executeDailyLimit = async ( export const executeDailyLimit = async (
safeAddress: string, safeAddress: string,
to: string, to: string,
nonce: number,
valueInWei: number, valueInWei: number,
sender: string, sender: string,
) => { ) => {
@ -68,7 +69,6 @@ export const executeDailyLimit = async (
const txHash = await dailyLimitModule.executeDailyLimit(0, to, valueInWei, { from: sender, gas, gasPrice }) const txHash = await dailyLimitModule.executeDailyLimit(0, to, valueInWei, { from: sender, gas, gasPrice })
checkReceiptStatus(txHash.tx) checkReceiptStatus(txHash.tx)
const nonce = Date.now()
const operation = 0 // CALL for all currencies const operation = 0 // CALL for all currencies
const data = '' // empty for ETH const data = '' // empty for ETH
await submitOperation(safeAddress, to, valueInWei, data, operation, nonce, txHash, sender, 'execution') await submitOperation(safeAddress, to, valueInWei, data, operation, nonce, txHash, sender, 'execution')

View File

@ -6,6 +6,7 @@ import { getWeb3 } from '~/logic/wallets/getWeb3'
import { DESTINATION_PARAM, VALUE_PARAM } from '~/routes/safe/component/Withdraw/WithdrawForm' import { DESTINATION_PARAM, VALUE_PARAM } from '~/routes/safe/component/Withdraw/WithdrawForm'
import { type Safe } from '~/routes/safe/store/model/safe' import { type Safe } from '~/routes/safe/store/model/safe'
import { getGnosisSafeContract } from '~/logic/contracts/safeContracts' import { getGnosisSafeContract } from '~/logic/contracts/safeContracts'
import { storeSubject } from '~/utils/localStorage/transactions'
export const TX_NAME_PARAM = 'txName' export const TX_NAME_PARAM = 'txName'
export const TX_DESTINATION_PARAM = 'txDestination' export const TX_DESTINATION_PARAM = 'txDestination'
@ -45,9 +46,13 @@ export const createTransaction = async (
const isExecution = hasOneOwner(safe) || threshold === 1 const isExecution = hasOneOwner(safe) || threshold === 1
return isExecution const txHash = isExecution
? executeTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender) ? await executeTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
: approveTransaction(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 ( export const processTransaction = async (
@ -65,9 +70,11 @@ export const processTransaction = async (
const CALL = 0 const CALL = 0
const thresholdReached = threshold === alreadyConfirmed + 1 const thresholdReached = threshold === alreadyConfirmed + 1
return thresholdReached const txHash = thresholdReached
? executeTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender) ? await executeTransaction(safeAddress, to, valueInWei, data, CALL, nonce, sender)
: approveTransaction(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> => { 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 destination = values[DESTINATION_PARAM]
const valueInEth = values[VALUE_PARAM] const valueInEth = values[VALUE_PARAM]
const valueInWei = getWeb3().toWei(valueInEth, 'ether') 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}` storeSubject(safeAddress, nonce, `Withdraw movement of ${valueInEth}`)
return executeDailyLimit(safeAddress, destination, valueInWei, sender)
return txHash
} }

View File

@ -1,10 +1,10 @@
// @flow // @flow
import { type Match } from 'react-router-dom'
import { aNewStore } from '~/store' import { aNewStore } from '~/store'
import { addEtherTo } from '~/test/utils/tokenMovements' import { addEtherTo, executeWithdrawOn } from '~/test/utils/tokenMovements'
import { aDeployedSafe, executeWithdrawOn } from '~/routes/safe/store/test/builder/deployedSafe.builder'
import { buildMathPropsFrom } from '~/test/utils/buildReactRouterProps' import { buildMathPropsFrom } from '~/test/utils/buildReactRouterProps'
import { safeSelector } from '~/routes/safe/store/selectors/index' 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', () => { describe('Safe Blockchain Test', () => {
let store let store
@ -15,7 +15,7 @@ describe('Safe Blockchain Test', () => {
it('wihdrawn should return revert error if exceeded dailyLimit', async () => { it('wihdrawn should return revert error if exceeded dailyLimit', async () => {
// GIVEN // GIVEN
const dailyLimitValue = 0.30 const dailyLimitValue = 0.30
const safeAddress = await aDeployedSafe(store, dailyLimitValue) const safeAddress = await aMinedSafe(store, 1, 1, dailyLimitValue)
await addEtherTo(safeAddress, '0.7') await addEtherTo(safeAddress, '0.7')
const value = 0.15 const value = 0.15