WA-232 Fixing flow errors

This commit is contained in:
apanizo 2018-06-26 16:56:28 +02:00
parent b270652f4b
commit 91f3855e97
8 changed files with 17 additions and 7 deletions

View File

@ -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')

View File

@ -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')
})
})

View File

@ -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)

View File

@ -102,6 +102,7 @@ export type DomSafe = {
safeButtons: Element[],
safe: React$Component<any, any>,
accounts: string[],
store: Store<GlobalState>,
}
export const renderSafeInDom = async (

View File

@ -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<GlobalState>) => {
await store.dispatch(fetchTransactions())
await sleep(1500)
}

View File

@ -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) => {

View File

@ -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,

View File

@ -36,7 +36,7 @@ export const checkMinedWithdrawTx = async (
Transaction: React$Component<any, any>,
name: string,
address: string,
funds: number,
funds: string,
) => {
await checkBalanceOf(address, funds)