1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-15 12:59:09 +00:00
trezor-wallet/src/actions/AccountsActions.js

65 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-04-16 21:19:50 +00:00
/* @flow */
2018-08-14 13:18:16 +00:00
import * as ACCOUNT from 'actions/constants/account';
2018-09-23 06:49:43 +00:00
import type { Action } from 'flowtype';
import type { Account, State } from 'reducers/AccountsReducer';
2018-04-16 21:19:50 +00:00
export type AccountFromStorageAction = {
type: typeof ACCOUNT.FROM_STORAGE,
2018-04-23 10:20:15 +00:00
payload: State
}
export type AccountCreateAction = {
type: typeof ACCOUNT.CREATE,
payload: Account,
}
export type AccountUpdateAction = {
type: typeof ACCOUNT.UPDATE,
payload: Account,
2018-04-23 10:20:15 +00:00
}
export type AccountSetBalanceAction = {
type: typeof ACCOUNT.SET_BALANCE,
2018-04-23 10:20:15 +00:00
address: string,
network: string,
deviceState: string,
2018-04-23 10:20:15 +00:00
balance: string
}
export type AccountSetNonceAction = {
type: typeof ACCOUNT.SET_NONCE,
2018-04-23 10:20:15 +00:00
address: string,
network: string,
deviceState: string,
2018-04-23 10:20:15 +00:00
nonce: number
}
2018-09-05 14:17:50 +00:00
export type AccountAction =
AccountFromStorageAction
| AccountCreateAction
| AccountUpdateAction
| AccountSetBalanceAction
| AccountSetNonceAction;
2018-09-05 14:17:50 +00:00
2018-07-30 10:52:13 +00:00
export const setBalance = (address: string, network: string, deviceState: string, balance: string): Action => ({
type: ACCOUNT.SET_BALANCE,
address,
network,
deviceState,
balance,
});
export const setNonce = (address: string, network: string, deviceState: string, nonce: number): Action => ({
type: ACCOUNT.SET_NONCE,
address,
network,
deviceState,
nonce,
2018-09-05 14:17:50 +00:00
});
export const update = (account: Account): Action => ({
type: ACCOUNT.UPDATE,
2018-09-23 06:49:43 +00:00
payload: account,
});