From 324ea7a790bd95f16d768ca04dd1075be5b2821c Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Wed, 18 Nov 2020 11:52:06 +0100 Subject: [PATCH] fix: move to isStackingCall pending prop --- .../transaction-list/transaction-list-item-pending.tsx | 4 ++-- app/modals/stacking/stacking-modal.tsx | 9 +++------ app/modals/transaction/transaction-modal.tsx | 8 ++------ .../pending-transaction/pending-transaction.reducer.ts | 2 +- app/store/stacking/stacking.reducer.ts | 3 ++- app/store/transaction/transaction.actions.ts | 7 ++++--- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/app/components/home/transaction-list/transaction-list-item-pending.tsx b/app/components/home/transaction-list/transaction-list-item-pending.tsx index 79dd073d3..06673cb3c 100644 --- a/app/components/home/transaction-list/transaction-list-item-pending.tsx +++ b/app/components/home/transaction-list/transaction-list-item-pending.tsx @@ -44,7 +44,7 @@ export const TransactionListItemPending: FC = p - {tx.txType === 'token_transfer' ? 'Sending' : 'Initiating Stacking…'} + {tx.isStackingCall ? 'Initiating Stacking…' : 'Sending'} {tx.tx_id.substr(0, 28)}… @@ -52,7 +52,7 @@ export const TransactionListItemPending: FC = p - {tx.txType === 'token_transfer' ? '−' : ''} + {tx.isStackingCall ? '' : '-'} {toHumanReadableStx(tx.amount)} diff --git a/app/modals/stacking/stacking-modal.tsx b/app/modals/stacking/stacking-modal.tsx index 6fdf71719..6a2dba44a 100644 --- a/app/modals/stacking/stacking-modal.tsx +++ b/app/modals/stacking/stacking-modal.tsx @@ -172,6 +172,7 @@ export const StackingModal: FC = ({ onClose, numCycles, poxA const broadcastActions = { amount: new BigNumber(balance), + isStackingCall: true, onBroadcastSuccess: () => history.push(routes.HOME), onBroadcastFail: () => setStep(StackingModalStep.FailedContractCall), }; @@ -190,9 +191,7 @@ export const StackingModal: FC = ({ onClose, numCycles, poxA if (transaction) { setIsDecrypting(false); - dispatch( - broadcastTransaction({ ...broadcastActions, txType: 'contract_call', transaction }) - ); + dispatch(broadcastTransaction({ ...broadcastActions, transaction })); } } @@ -210,9 +209,7 @@ export const StackingModal: FC = ({ onClose, numCycles, poxA } if (transaction) { - dispatch( - broadcastTransaction({ ...broadcastActions, txType: 'contract_call', transaction }) - ); + dispatch(broadcastTransaction({ ...broadcastActions, transaction })); } } }; diff --git a/app/modals/transaction/transaction-modal.tsx b/app/modals/transaction/transaction-modal.tsx index cb1cd3ddd..8fe300779 100644 --- a/app/modals/transaction/transaction-modal.tsx +++ b/app/modals/transaction/transaction-modal.tsx @@ -170,9 +170,7 @@ export const TransactionModal: FC = ({ balance, address }) => { if (transaction) { setIsDecrypting(false); - dispatch( - broadcastTransaction({ ...broadcastActions, txType: 'token_transfer', transaction }) - ); + dispatch(broadcastTransaction({ ...broadcastActions, transaction })); } } @@ -192,9 +190,7 @@ export const TransactionModal: FC = ({ balance, address }) => { } if (transaction) { - dispatch( - broadcastTransaction({ ...broadcastActions, txType: 'token_transfer', transaction }) - ); + dispatch(broadcastTransaction({ ...broadcastActions, transaction })); } } }; diff --git a/app/store/pending-transaction/pending-transaction.reducer.ts b/app/store/pending-transaction/pending-transaction.reducer.ts index f06dcb5ec..27321bf92 100644 --- a/app/store/pending-transaction/pending-transaction.reducer.ts +++ b/app/store/pending-transaction/pending-transaction.reducer.ts @@ -7,7 +7,7 @@ import { Transaction } from '@blockstack/stacks-blockchain-api-types'; export interface PendingTransaction extends Pick { amount: string; time: number; - txType: Transaction['tx_type']; + isStackingCall?: boolean; } export type PendingTransactionState = EntityState; diff --git a/app/store/stacking/stacking.reducer.ts b/app/store/stacking/stacking.reducer.ts index c4cdbe75c..b55986075 100644 --- a/app/store/stacking/stacking.reducer.ts +++ b/app/store/stacking/stacking.reducer.ts @@ -118,7 +118,8 @@ export const selectNextCycleInfo = createSelector( const blocksToNextCycle = poxInfo.reward_cycle_length - ((coreNodeInfo.burn_block_height - poxInfo.first_burnchain_block_height) % - poxInfo.reward_cycle_length); + poxInfo.reward_cycle_length) - + 1; const secondsToNextCycle = (poxInfo.reward_cycle_length - diff --git a/app/store/transaction/transaction.actions.ts b/app/store/transaction/transaction.actions.ts index 8cc9e9acd..75357490b 100644 --- a/app/store/transaction/transaction.actions.ts +++ b/app/store/transaction/transaction.actions.ts @@ -11,6 +11,7 @@ import { safelyFormatHexTxid } from '@utils/safe-handle-txid'; import { addPendingTransaction } from '@store/pending-transaction'; import { Dispatch, GetState } from '@store/index'; import { selectActiveNodeApi } from '@store/stacks-node'; +import { isStackingTx } from '../../utils/tx-utils'; export const pendingTransactionSuccessful = createAction( 'transactions/pending-transaction-successful' @@ -55,13 +56,13 @@ export const broadcastTxFail = createAction( interface BroadcastTransactionArgs { transaction: StacksTransaction; - txType: Transaction['tx_type']; amount: BigNumber; + isStackingCall?: boolean; onBroadcastSuccess(txId: string): void; onBroadcastFail(): void; } export function broadcastTransaction(args: BroadcastTransactionArgs) { - const { amount, transaction, txType, onBroadcastSuccess, onBroadcastFail } = args; + const { amount, transaction, isStackingCall = false, onBroadcastSuccess, onBroadcastFail } = args; return async (dispatch: Dispatch, getState: GetState) => { dispatch(broadcastTx()); @@ -87,7 +88,7 @@ export function broadcastTransaction(args: BroadcastTransactionArgs) { tx_id: safelyFormatHexTxid(blockchainResponse), amount: amount.toString(), time: +new Date(), - txType, + isStackingCall, }) ); return blockchainResponse;