2017-06-29 23:03:11 +00:00
|
|
|
// @flow
|
|
|
|
import BaseWallet from 'libs/wallet/base';
|
2017-08-08 03:45:08 +00:00
|
|
|
import Big from 'bignumber.js';
|
2017-06-29 23:03:11 +00:00
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
/*** Unlock Private Key ***/
|
2017-07-16 21:02:13 +00:00
|
|
|
export type PrivateKeyUnlockParams = {
|
|
|
|
key: string,
|
|
|
|
password: string
|
|
|
|
};
|
|
|
|
|
2017-06-29 23:03:11 +00:00
|
|
|
export type UnlockPrivateKeyAction = {
|
2017-07-04 03:21:19 +00:00
|
|
|
type: 'WALLET_UNLOCK_PRIVATE_KEY',
|
|
|
|
payload: PrivateKeyUnlockParams
|
2017-06-29 23:03:11 +00:00
|
|
|
};
|
|
|
|
|
2017-07-16 21:02:13 +00:00
|
|
|
export function unlockPrivateKey(
|
|
|
|
value: PrivateKeyUnlockParams
|
|
|
|
): UnlockPrivateKeyAction {
|
2017-07-04 03:21:19 +00:00
|
|
|
return {
|
|
|
|
type: 'WALLET_UNLOCK_PRIVATE_KEY',
|
|
|
|
payload: value
|
|
|
|
};
|
2017-06-29 23:03:11 +00:00
|
|
|
}
|
|
|
|
|
2017-08-20 20:28:47 +00:00
|
|
|
/*** Unlock Keystore File ***/
|
|
|
|
export type KeystoreUnlockParams = {
|
|
|
|
file: string,
|
|
|
|
password: string
|
|
|
|
};
|
|
|
|
|
|
|
|
export type UnlockKeystoreAction = {
|
|
|
|
type: 'WALLET_UNLOCK_KEYSTORE',
|
|
|
|
payload: KeystoreUnlockParams
|
|
|
|
};
|
|
|
|
|
|
|
|
export function unlockKeystore(
|
|
|
|
value: KeystoreUnlockParams
|
|
|
|
): UnlockKeystoreAction {
|
|
|
|
return {
|
|
|
|
type: 'WALLET_UNLOCK_KEYSTORE',
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
/*** Set Wallet ***/
|
|
|
|
export type SetWalletAction = {
|
|
|
|
type: 'WALLET_SET',
|
|
|
|
payload: BaseWallet
|
|
|
|
};
|
|
|
|
|
2017-07-13 21:02:39 +00:00
|
|
|
export function setWallet(value: BaseWallet): SetWalletAction {
|
|
|
|
return {
|
|
|
|
type: 'WALLET_SET',
|
|
|
|
payload: value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
/*** Set Balance ***/
|
|
|
|
export type SetBalanceAction = {
|
|
|
|
type: 'WALLET_SET_BALANCE',
|
|
|
|
payload: Big
|
|
|
|
};
|
|
|
|
|
2017-07-13 21:02:39 +00:00
|
|
|
export function setBalance(value: Big): SetBalanceAction {
|
2017-07-04 03:21:19 +00:00
|
|
|
return {
|
2017-07-13 21:02:39 +00:00
|
|
|
type: 'WALLET_SET_BALANCE',
|
2017-07-04 03:21:19 +00:00
|
|
|
payload: value
|
|
|
|
};
|
2017-06-29 23:03:11 +00:00
|
|
|
}
|
2017-07-03 23:59:27 +00:00
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
/*** Set Token Balance ***/
|
|
|
|
export type SetTokenBalancesAction = {
|
|
|
|
type: 'WALLET_SET_TOKEN_BALANCES',
|
|
|
|
payload: {
|
|
|
|
[string]: Big
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-16 21:02:13 +00:00
|
|
|
export function setTokenBalances(payload: {
|
|
|
|
[string]: Big
|
|
|
|
}): SetTokenBalancesAction {
|
2017-07-04 03:21:19 +00:00
|
|
|
return {
|
2017-07-13 21:02:39 +00:00
|
|
|
type: 'WALLET_SET_TOKEN_BALANCES',
|
|
|
|
payload
|
2017-07-04 03:21:19 +00:00
|
|
|
};
|
2017-07-03 23:59:27 +00:00
|
|
|
}
|
2017-07-27 17:05:09 +00:00
|
|
|
|
2017-08-31 04:00:31 +00:00
|
|
|
/*** Broadcast Tx ***/
|
|
|
|
export type BroadcastTxRequestedAction = {
|
|
|
|
type: 'WALLET_BROADCAST_TX_REQUESTED',
|
|
|
|
payload: {
|
|
|
|
signedTx: string
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
export function broadcastTx(signedTx: string): BroadcastTxRequestedAction {
|
|
|
|
return {
|
|
|
|
type: 'WALLET_BROADCAST_TX_REQUESTED',
|
|
|
|
payload: {
|
|
|
|
signedTx
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-07-27 17:05:09 +00:00
|
|
|
/*** Union Type ***/
|
|
|
|
export type WalletAction =
|
|
|
|
| UnlockPrivateKeyAction
|
|
|
|
| SetWalletAction
|
|
|
|
| SetBalanceAction
|
2017-08-31 04:00:31 +00:00
|
|
|
| SetTokenBalancesAction
|
|
|
|
| BroadcastTxRequestedAction;
|