diff --git a/src/routes/safe/component/Withdraw/withdraw.js b/src/routes/safe/component/Withdraw/withdraw.js index 80486497..f18e433e 100644 --- a/src/routes/safe/component/Withdraw/withdraw.js +++ b/src/routes/safe/component/Withdraw/withdraw.js @@ -1,10 +1,12 @@ // @flow +import { List } from 'immutable' import { getWeb3 } from '~/wallets/getWeb3' import { getGnosisSafeContract, getCreateDailyLimitExtensionContract } from '~/wallets/safeContracts' import { type DailyLimitProps } from '~/routes/safe/store/model/dailyLimit' import { checkReceiptStatus, calculateGasOf, calculateGasPrice } from '~/wallets/ethTransactions' import { type Safe } from '~/routes/safe/store/model/safe' import { buildExecutedConfirmationFrom, storeTransaction } from '~/routes/safe/component/AddTransaction/createTransactions' +import { type Confirmation } from '~/routes/safe/store/model/confirmation' export const LIMIT_POSITION = 0 export const SPENT_TODAY_POS = 1 @@ -44,7 +46,7 @@ export const getDailyLimitAddress = async (safeAddress: string) => { return dailyLimitModule.address } -export const getEditDailyLimitData = async (safeAddress: string, token: string, dailyLimit: string) => { +export const getEditDailyLimitData = async (safeAddress: string, token: number, dailyLimit: number) => { const web3 = getWeb3() const dailyLimitModule = await getDailyLimitModuleFrom(safeAddress) const dailyLimitInWei = web3.toWei(dailyLimit, 'ether') diff --git a/src/routes/safe/component/Withdraw/withdraw.test.js b/src/routes/safe/component/Withdraw/withdraw.test.js index c6ca86e0..231aed7c 100644 --- a/src/routes/safe/component/Withdraw/withdraw.test.js +++ b/src/routes/safe/component/Withdraw/withdraw.test.js @@ -4,6 +4,7 @@ import { addEtherTo } from '~/test/utils/etherMovements' import { aDeployedSafe, executeWithdrawOn } from '~/routes/safe/store/test/builder/deployedSafe.builder' import { buildMathPropsFrom } from '~/test/utils/buildReactRouterProps' import { safeSelector } from '~/routes/safe/store/selectors/index' +import { type Match } from 'react-router-dom' describe('Safe Blockchain Test', () => { let store @@ -21,10 +22,12 @@ describe('Safe Blockchain Test', () => { // WHEN const match: Match = buildMathPropsFrom(safeAddress) const safe = safeSelector(store.getState(), { match }) + if (!safe) throw new Error() + await executeWithdrawOn(safe, value) await executeWithdrawOn(safe, value) // THEN - expect(executeWithdrawOn(safeAddress, value)).rejects.toThrow('VM Exception while processing transaction: revert') + expect(executeWithdrawOn(safe, value)).rejects.toThrow('VM Exception while processing transaction: revert') }) }) diff --git a/src/routes/safe/test/Safe.withdraw.test.js b/src/routes/safe/test/Safe.withdraw.test.js index d708a83e..9eb74372 100644 --- a/src/routes/safe/test/Safe.withdraw.test.js +++ b/src/routes/safe/test/Safe.withdraw.test.js @@ -3,6 +3,7 @@ import * as React from 'react' import TestUtils from 'react-dom/test-utils' import { Provider } from 'react-redux' import { ConnectedRouter } from 'react-router-redux' +import { type Match } from 'react-router-dom' import Button from '~/components/layout/Button' import { aNewStore, history } from '~/store' import { addEtherTo } from '~/test/utils/etherMovements' @@ -84,6 +85,7 @@ describe('React DOM TESTS > Withdraw funds from safe', () => { const match: Match = buildMathPropsFrom(address) const safe = safeSelector(store.getState(), { match }) + if (!safe) throw new Error() await executeWithdrawOn(safe, 0.01) await executeWithdrawOn(safe, 0.01) diff --git a/src/test/builder/safe.dom.builder.js b/src/test/builder/safe.dom.builder.js index 03f0f5e7..7a1faf49 100644 --- a/src/test/builder/safe.dom.builder.js +++ b/src/test/builder/safe.dom.builder.js @@ -102,6 +102,7 @@ export type DomSafe = { safeButtons: Element[], safe: React$Component, accounts: string[], + store: Store, } export const renderSafeInDom = async ( diff --git a/src/test/builder/safe.dom.utils.js b/src/test/builder/safe.dom.utils.js index 27aedd6d..b4ed3d86 100644 --- a/src/test/builder/safe.dom.utils.js +++ b/src/test/builder/safe.dom.utils.js @@ -4,6 +4,7 @@ import ListItemText from '~/components/List/ListItemText/index' import { SEE_MULTISIG_BUTTON_TEXT } from '~/routes/safe/component/Safe/MultisigTx' import fetchTransactions from '~/routes/safe/store/actions/fetchTransactions' import { sleep } from '~/utils/timer' +import { type GlobalState } from '~/store/index' export const EXPAND_OWNERS_INDEX = 0 export const ADD_OWNERS_INDEX = 1 @@ -79,7 +80,7 @@ export const checkPendingTx = async ( } } -export const refreshTransactions = async (store) => { +export const refreshTransactions = async (store: Store) => { await store.dispatch(fetchTransactions()) await sleep(1500) } diff --git a/src/test/utils/etherMovements.js b/src/test/utils/etherMovements.js index 1e9cfc98..c84c34dc 100644 --- a/src/test/utils/etherMovements.js +++ b/src/test/utils/etherMovements.js @@ -2,6 +2,7 @@ import { getProviderInfo, getBalanceInEtherOf, getWeb3 } from '~/wallets/getWeb3' import { promisify } from '~/utils/promisify' import withdraw, { DESTINATION_PARAM, VALUE_PARAM } from '~/routes/safe/component/Withdraw/withdraw' +import { type Safe } from '~/routes/safe/store/model/safe' export const addEtherTo = async (address: string, eth: string) => { const web3 = getWeb3() @@ -10,7 +11,7 @@ export const addEtherTo = async (address: string, eth: string) => { return promisify(cb => web3.eth.sendTransaction(txData, cb)) } -export const executeWithdrawOn = async (safeAddress: string, value: number) => { +export const executeWithdrawOn = async (safe: Safe, value: number) => { const providerInfo = await getProviderInfo() const userAddress = providerInfo.account @@ -19,7 +20,7 @@ export const executeWithdrawOn = async (safeAddress: string, value: number) => { [VALUE_PARAM]: `${value}`, } - return withdraw(values, safeAddress, userAddress) + return withdraw(values, safe, userAddress) } export const checkBalanceOf = async (addressToTest: string, value: string) => { diff --git a/src/test/utils/ethereumErrors.js b/src/test/utils/ethereumErrors.js index c7319cf4..b28a3b7d 100644 --- a/src/test/utils/ethereumErrors.js +++ b/src/test/utils/ethereumErrors.js @@ -3,7 +3,7 @@ import { getWeb3 } from '~/wallets/getWeb3' import abi from 'ethereumjs-abi' import { promisify } from '~/utils/promisify' -export const getErrorMessage = async (to, value, data, from) => { +export const getErrorMessage = async (to: string, value: number, data: string, from: string) => { const web3 = getWeb3() const returnData = await promisify(cb => web3.eth.call({ to, from, value, data, diff --git a/src/test/utils/transactions/withdraw.helper.js b/src/test/utils/transactions/withdraw.helper.js index 8a7c33e6..d9081f4b 100644 --- a/src/test/utils/transactions/withdraw.helper.js +++ b/src/test/utils/transactions/withdraw.helper.js @@ -36,7 +36,7 @@ export const checkMinedWithdrawTx = async ( Transaction: React$Component, name: string, address: string, - funds: number, + funds: string, ) => { await checkBalanceOf(address, funds)