Default safe WIP

This commit is contained in:
Mikhail Mikheev 2019-09-18 14:18:22 +04:00
parent a2bb2c2b5c
commit 699f1f8663
3 changed files with 13 additions and 12 deletions

View File

@ -61,6 +61,7 @@ const SafeList = ({ safes, onSafeClick }: SafeListProps) => {
{' '} {' '}
ETH ETH
</Paragraph> </Paragraph>
PIZDOS))
</ListItem> </ListItem>
</Link> </Link>
<Hairline /> <Hairline />

View File

@ -7,7 +7,7 @@ export const PROVIDER_REDUCER_ID = 'providers'
export type State = Provider export type State = Provider
export default handleActions( export default handleActions<State, Function>(
{ {
[ADD_PROVIDER]: (state: State, { payload }: ActionType<typeof addProvider>) => makeProvider(payload), [ADD_PROVIDER]: (state: State, { payload }: ActionType<typeof addProvider>) => makeProvider(payload),
}, },

View File

@ -24,7 +24,7 @@ export const buildSafe = (storedSafe: SafeProps) => {
const addresses = storedSafe.owners.map((owner: OwnerProps) => owner.address) const addresses = storedSafe.owners.map((owner: OwnerProps) => owner.address)
const owners = buildOwnersFrom(Array.from(names), Array.from(addresses)) const owners = buildOwnersFrom(Array.from(names), Array.from(addresses))
const activeTokens = List(storedSafe.activeTokens) const activeTokens = List(storedSafe.activeTokens)
const balances = storedSafe.balances.map(balance => TokenBalance(balance)) const balances = storedSafe.balances.map((balance) => TokenBalance(balance))
const safe: SafeProps = { const safe: SafeProps = {
...storedSafe, ...storedSafe,
@ -67,7 +67,7 @@ export default handleActions<State, *>(
const safe = action.payload const safe = action.payload
const safeAddress = safe.address const safeAddress = safe.address
return state.update(safeAddress, prevSafe => prevSafe.merge(safe)) return state.update(safeAddress, (prevSafe) => prevSafe.merge(safe))
}, },
[ACTIVATE_TOKEN_FOR_ALL_SAFES]: (state: State, action: ActionType<Function>): State => { [ACTIVATE_TOKEN_FOR_ALL_SAFES]: (state: State, action: ActionType<Function>): State => {
const tokenAddress = action.payload const tokenAddress = action.payload
@ -77,7 +77,7 @@ export default handleActions<State, *>(
const safeActiveTokens = map.getIn([safeAddress, 'activeTokens']) const safeActiveTokens = map.getIn([safeAddress, 'activeTokens'])
const activeTokens = safeActiveTokens.push(tokenAddress) const activeTokens = safeActiveTokens.push(tokenAddress)
map.update(safeAddress, prevSafe => prevSafe.merge({ activeTokens })) map.update(safeAddress, (prevSafe) => prevSafe.merge({ activeTokens }))
}) })
}) })
@ -91,7 +91,7 @@ export default handleActions<State, *>(
// with initial props and it would overwrite existing ones // with initial props and it would overwrite existing ones
if (state.has(safe.address)) { if (state.has(safe.address)) {
return state.update(safe.address, prevSafe => prevSafe.merge(safe)) return state.update(safe.address, (prevSafe) => prevSafe.merge(safe))
} }
return state.set(safe.address, SafeRecord(safe)) return state.set(safe.address, SafeRecord(safe))
@ -104,15 +104,15 @@ export default handleActions<State, *>(
[ADD_SAFE_OWNER]: (state: State, action: ActionType<Function>): State => { [ADD_SAFE_OWNER]: (state: State, action: ActionType<Function>): State => {
const { safeAddress, ownerName, ownerAddress } = action.payload const { safeAddress, ownerName, ownerAddress } = action.payload
return state.update(safeAddress, prevSafe => prevSafe.merge({ return state.update(safeAddress, (prevSafe) => prevSafe.merge({
owners: prevSafe.owners.push(makeOwner({ address: ownerAddress, name: ownerName })), owners: prevSafe.owners.push(makeOwner({ address: ownerAddress, name: ownerName })),
})) }))
}, },
[REMOVE_SAFE_OWNER]: (state: State, action: ActionType<Function>): State => { [REMOVE_SAFE_OWNER]: (state: State, action: ActionType<Function>): State => {
const { safeAddress, ownerAddress } = action.payload const { safeAddress, ownerAddress } = action.payload
return state.update(safeAddress, prevSafe => prevSafe.merge({ return state.update(safeAddress, (prevSafe) => prevSafe.merge({
owners: prevSafe.owners.filter(o => o.address.toLowerCase() !== ownerAddress.toLowerCase()), owners: prevSafe.owners.filter((o) => o.address.toLowerCase() !== ownerAddress.toLowerCase()),
})) }))
}, },
[REPLACE_SAFE_OWNER]: (state: State, action: ActionType<Function>): State => { [REPLACE_SAFE_OWNER]: (state: State, action: ActionType<Function>): State => {
@ -120,9 +120,9 @@ export default handleActions<State, *>(
safeAddress, oldOwnerAddress, ownerName, ownerAddress, safeAddress, oldOwnerAddress, ownerName, ownerAddress,
} = action.payload } = action.payload
return state.update(safeAddress, prevSafe => prevSafe.merge({ return state.update(safeAddress, (prevSafe) => prevSafe.merge({
owners: prevSafe.owners owners: prevSafe.owners
.filter(o => o.address.toLowerCase() !== oldOwnerAddress.toLowerCase()) .filter((o) => o.address.toLowerCase() !== oldOwnerAddress.toLowerCase())
.push(makeOwner({ address: ownerAddress, name: ownerName })), .push(makeOwner({ address: ownerAddress, name: ownerName })),
})) }))
}, },
@ -131,9 +131,9 @@ export default handleActions<State, *>(
return state.update(safeAddress, (prevSafe) => { return state.update(safeAddress, (prevSafe) => {
const ownerToUpdateIndex = prevSafe.owners.findIndex( const ownerToUpdateIndex = prevSafe.owners.findIndex(
o => o.address.toLowerCase() === ownerAddress.toLowerCase(), (o) => o.address.toLowerCase() === ownerAddress.toLowerCase(),
) )
const updatedOwners = prevSafe.owners.update(ownerToUpdateIndex, owner => owner.set('name', ownerName)) const updatedOwners = prevSafe.owners.update(ownerToUpdateIndex, (owner) => owner.set('name', ownerName))
return prevSafe.merge({ owners: updatedOwners }) return prevSafe.merge({ owners: updatedOwners })
}) })
}, },