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 ACCOUNT from 'actions/constants/account';
import * as NOTIFICATION from 'actions/constants/notification'; import * as NOTIFICATION from 'actions/constants/notification';
import * as SEND from 'actions/constants/send'; import * as SEND from 'actions/constants/send';
import * as PENDING from 'actions/constants/pendingTx';
import * as WEB3 from 'actions/constants/web3'; import * as WEB3 from 'actions/constants/web3';
import { initialState } from 'reducers/SendFormEthereumReducer'; import { initialState } from 'reducers/SendFormEthereumReducer';
import { findToken } from 'reducers/TokensReducer'; 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: SEND.TX_COMPLETE });
dispatch({ // ugly blockbook workaround:
type: PENDING.ADD, // since blockbook can't emit pending notifications
payload: { // need to trigger this event from here, where we know everything about this transaction
type: 'send', // blockchainNotification is 'trezor-connect' BlockchainLinkTransaction type
deviceState: account.deviceState, const fee = ValidationActions.calculateFee(currentState.gasLimit, currentState.gasPrice);
sequence: nonce, const blockchainNotification = {
hash: txid, type: 'send',
network: account.network, status: 'pending',
address: account.address, date: '',
currency: currentState.currency, address: account.address,
amount: currentState.amount, inputs: [
total: currentState.total, {
fee: '0', // TODO: calculate fee addresses: [account.address],
}, amount: currentState.amount,
}); fee,
total: currentState.total,
},
],
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 // clear session storage
dispatch(SessionStorageActions.clear()); dispatch(SessionStorageActions.clear());