WA-234 Fixing flow errors
This commit is contained in:
parent
b4a293c4ff
commit
e86f7827f0
|
@ -80,7 +80,7 @@ const hasOneOwner = (safe: Safe) => {
|
||||||
return owners.count() === 1
|
return owners.count() === 1
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSafeEthereumInstance = async (safeAddress) => {
|
export const getSafeEthereumInstance = async (safeAddress: string) => {
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
const GnosisSafe = await getGnosisSafeContract(web3)
|
const GnosisSafe = await getGnosisSafeContract(web3)
|
||||||
return GnosisSafe.at(safeAddress)
|
return GnosisSafe.at(safeAddress)
|
||||||
|
|
|
@ -12,18 +12,22 @@ import Row from '~/components/layout/Row'
|
||||||
import { composeValidators, minValue, maxValue, mustBeInteger, required } from '~/components/forms/validator'
|
import { composeValidators, minValue, maxValue, mustBeInteger, required } from '~/components/forms/validator'
|
||||||
import { getSafeEthereumInstance, createTransaction } from '~/routes/safe/component/AddTransaction/createTransactions'
|
import { getSafeEthereumInstance, createTransaction } from '~/routes/safe/component/AddTransaction/createTransactions'
|
||||||
import { sleep } from '~/utils/timer'
|
import { sleep } from '~/utils/timer'
|
||||||
|
import { type Safe } from '~/routes/safe/store/model/safe'
|
||||||
import selector, { type SelectorProps } from './selector'
|
import selector, { type SelectorProps } from './selector'
|
||||||
import actions, { type Actions } from './actions'
|
import actions, { type Actions } from './actions'
|
||||||
|
|
||||||
type Props = SelectorProps & Actions & {
|
type ThresholdProps = {
|
||||||
numOwners: number,
|
numOwners: number,
|
||||||
safe: Safe,
|
safe: Safe,
|
||||||
|
}
|
||||||
|
|
||||||
|
type Props = SelectorProps & Actions & ThresholdProps & {
|
||||||
onReset: () => void,
|
onReset: () => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
const THRESHOLD_PARAM = 'threshold'
|
const THRESHOLD_PARAM = 'threshold'
|
||||||
|
|
||||||
const ThresholdComponent = ({ numOwners, safe }: Props) => () => (
|
const ThresholdComponent = ({ numOwners, safe }: ThresholdProps) => () => (
|
||||||
<Block margin="md">
|
<Block margin="md">
|
||||||
<Heading tag="h2" margin="lg">
|
<Heading tag="h2" margin="lg">
|
||||||
{'Change safe\'s threshold'}
|
{'Change safe\'s threshold'}
|
||||||
|
|
|
@ -53,6 +53,7 @@ describe('React DOM TESTS > Multisig transactions from safe [3 owners & 1 thresh
|
||||||
|
|
||||||
const confirmed = paragraphs[3].innerHTML
|
const confirmed = paragraphs[3].innerHTML
|
||||||
const tx = getTransactionFromReduxStore(store, address)
|
const tx = getTransactionFromReduxStore(store, address)
|
||||||
|
if (!tx) throw new Error()
|
||||||
expect(confirmed).toBe(tx.get('tx'))
|
expect(confirmed).toBe(tx.get('tx'))
|
||||||
|
|
||||||
const ownerTx = paragraphs[6].innerHTML
|
const ownerTx = paragraphs[6].innerHTML
|
||||||
|
|
|
@ -45,6 +45,7 @@ describe('React DOM TESTS > Multisig transactions from safe [3 owners & 3 thresh
|
||||||
|
|
||||||
const getAlreadyConfirmed = () => {
|
const getAlreadyConfirmed = () => {
|
||||||
const tx = getTransactionFromReduxStore(store, address)
|
const tx = getTransactionFromReduxStore(store, address)
|
||||||
|
if (!tx) throw new Error()
|
||||||
const confirmed = confirmationsTransactionSelector(store.getState(), { transaction: tx })
|
const confirmed = confirmationsTransactionSelector(store.getState(), { transaction: tx })
|
||||||
|
|
||||||
return confirmed
|
return confirmed
|
||||||
|
@ -53,6 +54,7 @@ describe('React DOM TESTS > Multisig transactions from safe [3 owners & 3 thresh
|
||||||
const makeConfirmation = async (executor) => {
|
const makeConfirmation = async (executor) => {
|
||||||
const alreadyConfirmed = getAlreadyConfirmed()
|
const alreadyConfirmed = getAlreadyConfirmed()
|
||||||
const tx = getTransactionFromReduxStore(store, address)
|
const tx = getTransactionFromReduxStore(store, address)
|
||||||
|
if (!tx) throw new Error()
|
||||||
await processTransaction(address, tx, alreadyConfirmed, executor)
|
await processTransaction(address, tx, alreadyConfirmed, executor)
|
||||||
await sleep(800)
|
await sleep(800)
|
||||||
store.dispatch(fetchTransactions())
|
store.dispatch(fetchTransactions())
|
||||||
|
@ -96,6 +98,7 @@ describe('React DOM TESTS > Multisig transactions from safe [3 owners & 3 thresh
|
||||||
|
|
||||||
const confirmedExecuted = paragraphsExecuted[3].innerHTML
|
const confirmedExecuted = paragraphsExecuted[3].innerHTML
|
||||||
const tx = getTransactionFromReduxStore(store, address)
|
const tx = getTransactionFromReduxStore(store, address)
|
||||||
|
if (!tx) throw new Error()
|
||||||
expect(confirmedExecuted).toBe(tx.get('tx'))
|
expect(confirmedExecuted).toBe(tx.get('tx'))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { aNewStore } from '~/store'
|
||||||
import { aDeployedSafe } from '~/routes/safe/store/test/builder/deployedSafe.builder'
|
import { aDeployedSafe } from '~/routes/safe/store/test/builder/deployedSafe.builder'
|
||||||
import { getWeb3 } from '~/wallets/getWeb3'
|
import { getWeb3 } from '~/wallets/getWeb3'
|
||||||
import { sleep } from '~/utils/timer'
|
import { sleep } from '~/utils/timer'
|
||||||
|
import { type Match } from 'react-router-dom'
|
||||||
import { promisify } from '~/utils/promisify'
|
import { promisify } from '~/utils/promisify'
|
||||||
import { processTransaction } from '~/routes/safe/component/Transactions/processTransactions'
|
import { processTransaction } from '~/routes/safe/component/Transactions/processTransactions'
|
||||||
import { confirmationsTransactionSelector, safeSelector, safeTransactionsSelector } from '~/routes/safe/store/selectors/index'
|
import { confirmationsTransactionSelector, safeSelector, safeTransactionsSelector } from '~/routes/safe/store/selectors/index'
|
||||||
|
@ -22,6 +23,7 @@ describe('React DOM TESTS > Change threshold', () => {
|
||||||
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
|
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
|
||||||
const match: Match = buildMathPropsFrom(address)
|
const match: Match = buildMathPropsFrom(address)
|
||||||
const safe = safeSelector(store.getState(), { match })
|
const safe = safeSelector(store.getState(), { match })
|
||||||
|
if (!safe) throw new Error()
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
const GnosisSafe = await getGnosisSafeContract(web3)
|
const GnosisSafe = await getGnosisSafeContract(web3)
|
||||||
const gnosisSafe = GnosisSafe.at(address)
|
const gnosisSafe = GnosisSafe.at(address)
|
||||||
|
@ -37,7 +39,8 @@ describe('React DOM TESTS > Change threshold', () => {
|
||||||
const transactions = safeTransactionsSelector(store.getState(), { safeAddress: address })
|
const transactions = safeTransactionsSelector(store.getState(), { safeAddress: address })
|
||||||
expect(transactions.count()).toBe(1)
|
expect(transactions.count()).toBe(1)
|
||||||
|
|
||||||
const thresholdTx: Transaction = transactions.get(0)
|
const thresholdTx = transactions.get(0)
|
||||||
|
if (!thresholdTx) throw new Error()
|
||||||
expect(thresholdTx.get('tx')).not.toBe(null)
|
expect(thresholdTx.get('tx')).not.toBe(null)
|
||||||
expect(thresholdTx.get('tx')).not.toBe(undefined)
|
expect(thresholdTx.get('tx')).not.toBe(undefined)
|
||||||
expect(thresholdTx.get('tx')).not.toBe('')
|
expect(thresholdTx.get('tx')).not.toBe('')
|
||||||
|
@ -48,6 +51,7 @@ describe('React DOM TESTS > Change threshold', () => {
|
||||||
|
|
||||||
const changeThreshold = async (store, safeAddress, executor) => {
|
const changeThreshold = async (store, safeAddress, executor) => {
|
||||||
const tx = getTransactionFromReduxStore(store, safeAddress)
|
const tx = getTransactionFromReduxStore(store, safeAddress)
|
||||||
|
if (!tx) throw new Error()
|
||||||
const confirmed = confirmationsTransactionSelector(store.getState(), { transaction: tx })
|
const confirmed = confirmationsTransactionSelector(store.getState(), { transaction: tx })
|
||||||
const data = tx.get('data')
|
const data = tx.get('data')
|
||||||
expect(data).not.toBe(null)
|
expect(data).not.toBe(null)
|
||||||
|
@ -66,6 +70,7 @@ describe('React DOM TESTS > Change threshold', () => {
|
||||||
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
|
const accounts = await promisify(cb => getWeb3().eth.getAccounts(cb))
|
||||||
const match: Match = buildMathPropsFrom(address)
|
const match: Match = buildMathPropsFrom(address)
|
||||||
const safe = safeSelector(store.getState(), { match })
|
const safe = safeSelector(store.getState(), { match })
|
||||||
|
if (!safe) throw new Error()
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
const GnosisSafe = await getGnosisSafeContract(web3)
|
const GnosisSafe = await getGnosisSafeContract(web3)
|
||||||
const gnosisSafe = GnosisSafe.at(address)
|
const gnosisSafe = GnosisSafe.at(address)
|
||||||
|
@ -78,9 +83,11 @@ describe('React DOM TESTS > Change threshold', () => {
|
||||||
await store.dispatch(fetchTransactions())
|
await store.dispatch(fetchTransactions())
|
||||||
|
|
||||||
let transactions = safeTransactionsSelector(store.getState(), { safeAddress: address })
|
let transactions = safeTransactionsSelector(store.getState(), { safeAddress: address })
|
||||||
|
if (!transactions) throw new Error()
|
||||||
expect(transactions.count()).toBe(1)
|
expect(transactions.count()).toBe(1)
|
||||||
|
|
||||||
let thresholdTx: Transaction = transactions.get(0)
|
let thresholdTx = transactions.get(0)
|
||||||
|
if (!thresholdTx) throw new Error()
|
||||||
expect(thresholdTx.get('tx')).toBe('')
|
expect(thresholdTx.get('tx')).toBe('')
|
||||||
let firstOwnerConfirmation = thresholdTx.get('confirmations').get(0)
|
let firstOwnerConfirmation = thresholdTx.get('confirmations').get(0)
|
||||||
if (!firstOwnerConfirmation) throw new Error()
|
if (!firstOwnerConfirmation) throw new Error()
|
||||||
|
@ -103,6 +110,7 @@ describe('React DOM TESTS > Change threshold', () => {
|
||||||
expect(transactions.count()).toBe(1)
|
expect(transactions.count()).toBe(1)
|
||||||
|
|
||||||
thresholdTx = transactions.get(0)
|
thresholdTx = transactions.get(0)
|
||||||
|
if (!thresholdTx) throw new Error()
|
||||||
expect(thresholdTx.get('tx')).not.toBe(undefined)
|
expect(thresholdTx.get('tx')).not.toBe(undefined)
|
||||||
expect(thresholdTx.get('tx')).not.toBe(null)
|
expect(thresholdTx.get('tx')).not.toBe(null)
|
||||||
expect(thresholdTx.get('tx')).not.toBe('')
|
expect(thresholdTx.get('tx')).not.toBe('')
|
||||||
|
|
|
@ -9,8 +9,13 @@ import SafeView from '~/routes/safe/component/Safe'
|
||||||
import TransactionsComponent from '~/routes/safe/component/Transactions'
|
import TransactionsComponent from '~/routes/safe/component/Transactions'
|
||||||
import TransactionComponent from '~/routes/safe/component/Transactions/Transaction'
|
import TransactionComponent from '~/routes/safe/component/Transactions/Transaction'
|
||||||
import { safeTransactionsSelector } from '~/routes/safe/store/selectors/index'
|
import { safeTransactionsSelector } from '~/routes/safe/store/selectors/index'
|
||||||
|
import { type GlobalState } from '~/store/index'
|
||||||
|
|
||||||
export const createMultisigTxFilling = async (SafeDom, AddTransactionComponent, store) => {
|
export const createMultisigTxFilling = async (
|
||||||
|
SafeDom: React$Component<any, any>,
|
||||||
|
AddTransactionComponent: React$ElementType,
|
||||||
|
store: Store<GlobalState>,
|
||||||
|
) => {
|
||||||
// Get AddTransaction form component
|
// Get AddTransaction form component
|
||||||
const AddTransaction = TestUtils.findRenderedComponentWithType(SafeDom, AddTransactionComponent)
|
const AddTransaction = TestUtils.findRenderedComponentWithType(SafeDom, AddTransactionComponent)
|
||||||
|
|
||||||
|
@ -36,7 +41,7 @@ export const checkBalanceOf = async (addressToTest: string, value: string) => {
|
||||||
expect(safeBalance).toBe(value)
|
expect(safeBalance).toBe(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addFundsTo = async (SafeDom, destination: string) => {
|
export const addFundsTo = async (SafeDom: React$Component<any, any>, destination: string) => {
|
||||||
// add funds to safe
|
// add funds to safe
|
||||||
await addEtherTo(destination, '0.1')
|
await addEtherTo(destination, '0.1')
|
||||||
const Safe = TestUtils.findRenderedComponentWithType(SafeDom, SafeView)
|
const Safe = TestUtils.findRenderedComponentWithType(SafeDom, SafeView)
|
||||||
|
@ -49,7 +54,7 @@ export const addFundsTo = async (SafeDom, destination: string) => {
|
||||||
TestUtils.Simulate.click(TestUtils.scryRenderedDOMComponentsWithTag(addTxButton, 'button')[0])
|
TestUtils.Simulate.click(TestUtils.scryRenderedDOMComponentsWithTag(addTxButton, 'button')[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
export const listTxsOf = (SafeDom) => {
|
export const listTxsOf = (SafeDom: React$Component<any, any>) => {
|
||||||
const Safe = TestUtils.findRenderedComponentWithType(SafeDom, SafeView)
|
const Safe = TestUtils.findRenderedComponentWithType(SafeDom, SafeView)
|
||||||
|
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -59,7 +64,7 @@ export const listTxsOf = (SafeDom) => {
|
||||||
TestUtils.Simulate.click(TestUtils.scryRenderedDOMComponentsWithTag(seeTx, 'button')[0])
|
TestUtils.Simulate.click(TestUtils.scryRenderedDOMComponentsWithTag(seeTx, 'button')[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTagFromTransaction = (SafeDom, tag: string) => {
|
export const getTagFromTransaction = (SafeDom: React$Component<any, any>, tag: string) => {
|
||||||
const Transactions = TestUtils.findRenderedComponentWithType(SafeDom, TransactionsComponent)
|
const Transactions = TestUtils.findRenderedComponentWithType(SafeDom, TransactionsComponent)
|
||||||
if (!Transactions) throw new Error()
|
if (!Transactions) throw new Error()
|
||||||
const Transaction = TestUtils.findRenderedComponentWithType(Transactions, TransactionComponent)
|
const Transaction = TestUtils.findRenderedComponentWithType(Transactions, TransactionComponent)
|
||||||
|
@ -68,7 +73,11 @@ export const getTagFromTransaction = (SafeDom, tag: string) => {
|
||||||
return TestUtils.scryRenderedDOMComponentsWithTag(Transaction, tag)
|
return TestUtils.scryRenderedDOMComponentsWithTag(Transaction, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const expandTransactionOf = async (SafeDom, numOwners, safeThreshold) => {
|
export const expandTransactionOf = async (
|
||||||
|
SafeDom: React$Component<any, any>,
|
||||||
|
numOwners: number,
|
||||||
|
safeThreshold: number,
|
||||||
|
) => {
|
||||||
const paragraphs = getTagFromTransaction(SafeDom, 'p')
|
const paragraphs = getTagFromTransaction(SafeDom, 'p')
|
||||||
TestUtils.Simulate.click(paragraphs[2]) // expanded
|
TestUtils.Simulate.click(paragraphs[2]) // expanded
|
||||||
await sleep(1000) // Time to expand
|
await sleep(1000) // Time to expand
|
||||||
|
@ -80,13 +89,13 @@ export const expandTransactionOf = async (SafeDom, numOwners, safeThreshold) =>
|
||||||
expect(paragraphsExpanded.length).toBe(paragraphs.length + numOwners)
|
expect(paragraphsExpanded.length).toBe(paragraphs.length + numOwners)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTransactionFromReduxStore = (store, address) => {
|
export const getTransactionFromReduxStore = (store: Store<GlobalState>, address: string, index: number = 0) => {
|
||||||
const transactions = safeTransactionsSelector(store.getState(), { safeAddress: address })
|
const transactions = safeTransactionsSelector(store.getState(), { safeAddress: address })
|
||||||
|
|
||||||
return transactions.get(0)
|
return transactions.get(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const confirmOwners = async (SafeDom, ...statusses: string[]) => {
|
export const confirmOwners = async (SafeDom: React$Component<any, any>, ...statusses: string[]) => {
|
||||||
const paragraphsWithOwners = getTagFromTransaction(SafeDom, 'h3')
|
const paragraphsWithOwners = getTagFromTransaction(SafeDom, 'h3')
|
||||||
for (let i = 0; i < statusses.length; i += 1) {
|
for (let i = 0; i < statusses.length; i += 1) {
|
||||||
const ownerIndex = i + 6
|
const ownerIndex = i + 6
|
||||||
|
|
Loading…
Reference in New Issue