1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-13 20:08:56 +00:00
trezor-wallet/src/js/actions/AccountsActions.js

62 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-04-16 21:19:50 +00:00
/* @flow */
'use strict';
import * as ACCOUNT from './constants/account';
import type { Action, TrezorDevice } from '~/flowtype';
2018-04-23 10:20:15 +00:00
import type { State } from '../reducers/AccountsReducer';
2018-04-16 21:19:50 +00:00
export type AccountAction =
AccountFromStorageAction
| AccountCreateAction
| AccountSetBalanceAction
| AccountSetNonceAction;
2018-04-23 10:20:15 +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,
2018-04-23 10:20:15 +00:00
device: TrezorDevice,
network: string,
index: number,
path: Array<number>,
address: string
}
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
}
export const setBalance = (address: string, network: string, deviceState: string, balance: string): Action => {
2018-04-23 10:20:15 +00:00
return {
type: ACCOUNT.SET_BALANCE,
2018-04-23 10:20:15 +00:00
address,
network,
deviceState,
2018-04-23 10:20:15 +00:00
balance
}
}
export const setNonce = (address: string, network: string, deviceState: string, nonce: number): Action => {
return {
type: ACCOUNT.SET_NONCE,
address,
network,
deviceState,
nonce
}
2018-04-16 21:19:50 +00:00
}