MyCrypto/common/actions/wallet/actionCreators.ts
skubakdj c9c147db52 Wallet Decrypt - Web3 (MetaMask / Mist) (#303)
* add support for web3, disabled, and hidden in node dropdown header

* add web3 node config actions

* add web3 wallet actions

* add web3 node support

* add web3 wallet & web3 wallet ui selection

* add web3 wallet & config sagas

* add web3 transaction support to SendTransaction tab

* add web3 node check & reset to redux store

* remove comments from Web3.tsx

* update comment

* correct spacing display issue in Web3 component

* convert getTransactionCount response to string

* disable web3 wallets in offline mode

* implement sendCallRequest method on Web3 node

* remove unused vars

* make typescript happy

* convert wallet constants to enum & apply to wallet action files

* update wallet reducer to use TypeKeys enum

* remove unnecessary console log

* remove unnecessary await

* make token balance math more readable

* use NewTabLink in Web3.tsx, allow NewTabLink to accept className

* move web3.ts to non-deterministic folder

* update imports & method names, implement message signing

* add web3 wallet export

* use bufferToHex
2017-11-09 19:30:20 -08:00

115 lines
2.6 KiB
TypeScript

import { BigNumber } from 'bignumber.js';
import { Wei } from 'libs/units';
import { IWallet } from 'libs/wallet/IWallet';
import * as types from './actionTypes';
import { TypeKeys } from './constants';
export type TUnlockPrivateKey = typeof unlockPrivateKey;
export function unlockPrivateKey(
value: types.PrivateKeyUnlockParams
): types.UnlockPrivateKeyAction {
return {
type: TypeKeys.WALLET_UNLOCK_PRIVATE_KEY,
payload: value
};
}
export type TUnlockKeystore = typeof unlockKeystore;
export function unlockKeystore(
value: types.KeystoreUnlockParams
): types.UnlockKeystoreAction {
return {
type: TypeKeys.WALLET_UNLOCK_KEYSTORE,
payload: value
};
}
export type TUnlockMnemonic = typeof unlockMnemonic;
export function unlockMnemonic(
value: types.MnemonicUnlockParams
): types.UnlockMnemonicAction {
return {
type: TypeKeys.WALLET_UNLOCK_MNEMONIC,
payload: value
};
}
export type TUnlockWeb3 = typeof unlockWeb3;
export function unlockWeb3(): types.UnlockWeb3Action {
return {
type: TypeKeys.WALLET_UNLOCK_WEB3
};
}
export type TSetWallet = typeof setWallet;
export function setWallet(value: IWallet): types.SetWalletAction {
return {
type: TypeKeys.WALLET_SET,
payload: value
};
}
export type TSetBalance = typeof setBalance;
export function setBalance(value: Wei): types.SetBalanceAction {
return {
type: TypeKeys.WALLET_SET_BALANCE,
payload: value
};
}
export type TSetTokenBalances = typeof setTokenBalances;
export function setTokenBalances(payload: {
[key: string]: BigNumber;
}): types.SetTokenBalancesAction {
return {
type: TypeKeys.WALLET_SET_TOKEN_BALANCES,
payload
};
}
export type TBroadcastTx = typeof broadcastTx;
export function broadcastTx(
signedTx: string
): types.BroadcastTxRequestedAction {
return {
type: TypeKeys.WALLET_BROADCAST_TX_REQUESTED,
payload: {
signedTx
}
};
}
export type TBroadcastTxSucceded = typeof broadcastTxSucceded;
export function broadcastTxSucceded(
txHash: string,
signedTx: string
): types.BroadcastTxSuccededAction {
return {
type: TypeKeys.WALLET_BROADCAST_TX_SUCCEEDED,
payload: {
txHash,
signedTx
}
};
}
export type TBroadCastTxFailed = typeof broadCastTxFailed;
export function broadCastTxFailed(
signedTx: string,
errorMsg: string
): types.BroadcastTxFailedAction {
return {
type: TypeKeys.WALLET_BROADCAST_TX_FAILED,
payload: {
signedTx,
error: errorMsg
}
};
}
export type TResetWallet = typeof resetWallet;
export function resetWallet() {
return {
type: TypeKeys.WALLET_RESET
};
}