WA-230 Adding addBalance and fetchBalance actions

This commit is contained in:
apanizo 2018-04-16 14:45:09 +02:00
parent e643fcd033
commit c2f00976c6
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,19 @@
// @flow
import { createAction } from 'redux-actions'
export const ADD_BALANCE = 'ADD_BALANCE'
type BalanceProps = {
safeAddress: string,
funds: string,
}
const addBalance = createAction(
ADD_BALANCE,
(safeAddress: string, funds: string): BalanceProps => ({
safeAddress,
funds,
}),
)
export default addBalance

View File

@ -0,0 +1,11 @@
// @flow
import type { Dispatch as ReduxDispatch } from 'redux'
import { getBalanceInEtherOf } from '~/wallets/getWeb3'
import { type GlobalState } from '~/store/index'
import addBalance from './addBalance'
export default (safeAddress: string) => async (dispatch: ReduxDispatch<GlobalState>) => {
const balance: string = await getBalanceInEtherOf(safeAddress)
dispatch(addBalance(safeAddress, balance))
}