1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-30 19:00:53 +00:00

emit BlockchainEvent from ethereum SendForm

This commit is contained in:
Szymon Lesisz 2018-12-18 22:11:35 +01:00
parent 63fb8109cb
commit a8d623b6a7

View File

@ -6,7 +6,6 @@ import BigNumber from 'bignumber.js';
import * as ACCOUNT from 'actions/constants/account';
import * as NOTIFICATION from 'actions/constants/notification';
import * as SEND from 'actions/constants/send';
import * as PENDING from 'actions/constants/pendingTx';
import * as WEB3 from 'actions/constants/web3';
import { initialState } from 'reducers/SendFormEthereumReducer';
import { findToken } from 'reducers/TokensReducer';
@ -525,21 +524,45 @@ export const onSend = (): AsyncAction => async (dispatch: Dispatch, getState: Ge
dispatch({ type: SEND.TX_COMPLETE });
dispatch({
type: PENDING.ADD,
payload: {
// ugly blockbook workaround:
// since blockbook can't emit pending notifications
// need to trigger this event from here, where we know everything about this transaction
// blockchainNotification is 'trezor-connect' BlockchainLinkTransaction type
const fee = ValidationActions.calculateFee(currentState.gasLimit, currentState.gasPrice);
const blockchainNotification = {
type: 'send',
deviceState: account.deviceState,
sequence: nonce,
hash: txid,
network: account.network,
status: 'pending',
date: '',
address: account.address,
currency: currentState.currency,
inputs: [
{
addresses: [account.address],
amount: currentState.amount,
fee,
total: currentState.total,
fee: '0', // TODO: calculate fee
},
});
],
outputs: [
{
addresses: [currentState.address],
amount: currentState.amount,
},
],
hash: txid,
amount: currentState.amount,
fee,
total: currentState.total,
sequence: nonce,
currency: isToken ? currentState.currency : null,
};
dispatch(BlockchainActions.onNotification({
// $FlowIssue: missing coinInfo declaration
coin: {},
notification: blockchainNotification,
}));
// workaround end
// clear session storage
dispatch(SessionStorageActions.clear());