mirror of
https://github.com/status-im/safe-react.git
synced 2025-02-17 12:07:09 +00:00
WA-230 Adding addBalance and fetchBalance actions
This commit is contained in:
parent
e643fcd033
commit
c2f00976c6
19
src/routes/safe/store/actions/addBalance.js
Normal file
19
src/routes/safe/store/actions/addBalance.js
Normal 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
|
11
src/routes/safe/store/actions/fetchBalance.js
Normal file
11
src/routes/safe/store/actions/fetchBalance.js
Normal 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))
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user