WA-230 Adding addBalance and fetchBalance actions
This commit is contained in:
parent
e643fcd033
commit
c2f00976c6
|
@ -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
|
|
@ -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))
|
||||
}
|
Loading…
Reference in New Issue