MyCrypto/common/actions/wallet.js

69 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-06-29 16:03:11 -07:00
// @flow
import BaseWallet from 'libs/wallet/base';
import Big from 'big.js';
2017-06-29 16:03:11 -07:00
export type PrivateKeyUnlockParams = {
key: string,
password: string
};
2017-06-29 16:03:11 -07:00
export type UnlockPrivateKeyAction = {
2017-07-03 20:21:19 -07:00
type: 'WALLET_UNLOCK_PRIVATE_KEY',
payload: PrivateKeyUnlockParams
2017-06-29 16:03:11 -07:00
};
export type SetWalletAction = {
type: 'WALLET_SET',
2017-07-03 20:21:19 -07:00
payload: BaseWallet
2017-06-29 16:03:11 -07:00
};
export type SetBalanceAction = {
type: 'WALLET_SET_BALANCE',
payload: Big
};
export type SetTokenBalancesAction = {
type: 'WALLET_SET_TOKEN_BALANCES',
payload: {
[string]: Big
}
2017-07-03 16:59:27 -07:00
};
2017-07-03 20:21:19 -07:00
export type WalletAction =
| UnlockPrivateKeyAction
| SetWalletAction
| SetBalanceAction
| SetTokenBalancesAction;
2017-06-29 16:03:11 -07:00
export function unlockPrivateKey(
value: PrivateKeyUnlockParams
): UnlockPrivateKeyAction {
2017-07-03 20:21:19 -07:00
return {
type: 'WALLET_UNLOCK_PRIVATE_KEY',
payload: value
};
2017-06-29 16:03:11 -07:00
}
export function setWallet(value: BaseWallet): SetWalletAction {
return {
type: 'WALLET_SET',
payload: value
};
}
export function setBalance(value: Big): SetBalanceAction {
2017-07-03 20:21:19 -07:00
return {
type: 'WALLET_SET_BALANCE',
2017-07-03 20:21:19 -07:00
payload: value
};
2017-06-29 16:03:11 -07:00
}
2017-07-03 16:59:27 -07:00
export function setTokenBalances(payload: {
[string]: Big
}): SetTokenBalancesAction {
2017-07-03 20:21:19 -07:00
return {
type: 'WALLET_SET_TOKEN_BALANCES',
payload
2017-07-03 20:21:19 -07:00
};
2017-07-03 16:59:27 -07:00
}