mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-09 10:41:56 +00:00
12d29e5b94
* Fix #1569 * Use common component for handling "to" address * If to address becomes invalid, hide contract interact explorer * Add IS_CONTRACT_INTERACTION mode - fix bugs related to contract interact * Bump shepherd version to fix bugs related to metamask + network switches * Update mycrypto link downloads * Update facebook link * Remove console log from checktx * Fix dollar sign on contract address in conf modal * Fix unchecksummed address for metamask signing * Cleanup unused classname * Update generate keystore file description to be correct * Add space to create new wallet banner * Remove extra variable * Do checksumming in library function instead of component * Clear state on address change
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import { State } from './typings';
|
|
import {
|
|
TypeKeys as TK,
|
|
SignLocalTransactionSucceededAction,
|
|
SignWeb3TransactionSucceededAction,
|
|
SignAction,
|
|
ResetTransactionSuccessfulAction
|
|
} from 'actions/transaction';
|
|
|
|
const INITIAL_STATE: State = {
|
|
local: { signedTransaction: null },
|
|
web3: { transaction: null },
|
|
indexingHash: null,
|
|
pending: false
|
|
};
|
|
|
|
const signTransactionRequested = (): State => ({
|
|
...INITIAL_STATE,
|
|
pending: true
|
|
});
|
|
|
|
const signLocalTransactionSucceeded = (
|
|
_: State,
|
|
{ payload }: SignLocalTransactionSucceededAction
|
|
): State => ({
|
|
indexingHash: payload.indexingHash,
|
|
pending: false,
|
|
|
|
local: { signedTransaction: payload.signedTransaction },
|
|
web3: { transaction: null }
|
|
});
|
|
|
|
const signWeb3TranscationSucceeded = (
|
|
_: State,
|
|
{ payload }: SignWeb3TransactionSucceededAction
|
|
): State => ({
|
|
indexingHash: payload.indexingHash,
|
|
pending: false,
|
|
|
|
local: { signedTransaction: null },
|
|
web3: { transaction: payload.transaction }
|
|
});
|
|
|
|
const signTransactionFailed = () => INITIAL_STATE;
|
|
|
|
const reset = () => INITIAL_STATE;
|
|
|
|
export const sign = (
|
|
state: State = INITIAL_STATE,
|
|
action: SignAction | ResetTransactionSuccessfulAction
|
|
) => {
|
|
switch (action.type) {
|
|
case TK.SIGN_TRANSACTION_REQUESTED:
|
|
return signTransactionRequested();
|
|
case TK.SIGN_LOCAL_TRANSACTION_SUCCEEDED:
|
|
return signLocalTransactionSucceeded(state, action);
|
|
case TK.SIGN_WEB3_TRANSACTION_SUCCEEDED:
|
|
return signWeb3TranscationSucceeded(state, action);
|
|
case TK.SIGN_TRANSACTION_FAILED:
|
|
return signTransactionFailed();
|
|
case TK.RESET_SUCCESSFUL:
|
|
return reset();
|
|
default:
|
|
return state;
|
|
}
|
|
};
|