2018-04-16 21:19:50 +00:00
|
|
|
/* @flow */
|
|
|
|
'use strict';
|
|
|
|
|
2018-05-10 12:40:25 +00:00
|
|
|
import * as ACCOUNT from './constants/account';
|
2018-05-18 16:54:21 +00:00
|
|
|
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
|
|
|
|
2018-05-10 12:40:25 +00:00
|
|
|
export type AccountAction =
|
|
|
|
AccountFromStorageAction
|
|
|
|
| AccountCreateAction
|
|
|
|
| AccountSetBalanceAction
|
|
|
|
| AccountSetNonceAction;
|
2018-04-23 10:20:15 +00:00
|
|
|
|
2018-05-10 12:40:25 +00:00
|
|
|
export type AccountFromStorageAction = {
|
|
|
|
type: typeof ACCOUNT.FROM_STORAGE,
|
2018-04-23 10:20:15 +00:00
|
|
|
payload: State
|
|
|
|
}
|
|
|
|
|
2018-05-10 12:40:25 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-05-10 12:40:25 +00:00
|
|
|
export type AccountSetBalanceAction = {
|
|
|
|
type: typeof ACCOUNT.SET_BALANCE,
|
2018-04-23 10:20:15 +00:00
|
|
|
address: string,
|
|
|
|
network: string,
|
2018-05-10 11:52:51 +00:00
|
|
|
deviceState: string,
|
2018-04-23 10:20:15 +00:00
|
|
|
balance: string
|
|
|
|
}
|
|
|
|
|
2018-05-10 12:40:25 +00:00
|
|
|
export type AccountSetNonceAction = {
|
|
|
|
type: typeof ACCOUNT.SET_NONCE,
|
2018-04-23 10:20:15 +00:00
|
|
|
address: string,
|
|
|
|
network: string,
|
2018-05-10 11:52:51 +00:00
|
|
|
deviceState: string,
|
2018-04-23 10:20:15 +00:00
|
|
|
nonce: number
|
|
|
|
}
|
|
|
|
|
2018-05-10 11:52:51 +00:00
|
|
|
export const setBalance = (address: string, network: string, deviceState: string, balance: string): Action => {
|
2018-04-23 10:20:15 +00:00
|
|
|
return {
|
2018-05-10 12:40:25 +00:00
|
|
|
type: ACCOUNT.SET_BALANCE,
|
2018-04-23 10:20:15 +00:00
|
|
|
address,
|
|
|
|
network,
|
2018-05-10 11:52:51 +00:00
|
|
|
deviceState,
|
2018-04-23 10:20:15 +00:00
|
|
|
balance
|
|
|
|
}
|
2018-05-10 11:52:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const setNonce = (address: string, network: string, deviceState: string, nonce: number): Action => {
|
|
|
|
return {
|
2018-05-10 12:40:25 +00:00
|
|
|
type: ACCOUNT.SET_NONCE,
|
2018-05-10 11:52:51 +00:00
|
|
|
address,
|
|
|
|
network,
|
|
|
|
deviceState,
|
|
|
|
nonce
|
|
|
|
}
|
2018-04-16 21:19:50 +00:00
|
|
|
}
|