Skip to content

Commit

Permalink
fix: move to isStackingCall pending prop
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Dec 2, 2020
1 parent 76ff82c commit 324ea7a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ export const TransactionListItemPending: FC<TransactionListItemPendingProps> = p
<TransactionIcon variant="pending" mr="base-loose" />
<Box flex={1}>
<Text textStyle="body.large.medium" display="block">
{tx.txType === 'token_transfer' ? 'Sending' : 'Initiating Stacking…'}
{tx.isStackingCall ? 'Initiating Stacking…' : 'Sending'}
</Text>
<Text textStyle="body.small" color="ink.600">
{tx.tx_id.substr(0, 28)}
</Text>
</Box>
<Box textAlign="right">
<Text textStyle="body.large" color="ink.900" display="block">
{tx.txType === 'token_transfer' ? '' : ''}
{tx.isStackingCall ? '' : '-'}
{toHumanReadableStx(tx.amount)}
</Text>
<Text textStyle="body.small" color="ink.600">
Expand Down
9 changes: 3 additions & 6 deletions app/modals/stacking/stacking-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export const StackingModal: FC<StackingModalProps> = ({ onClose, numCycles, poxA

const broadcastActions = {
amount: new BigNumber(balance),
isStackingCall: true,
onBroadcastSuccess: () => history.push(routes.HOME),
onBroadcastFail: () => setStep(StackingModalStep.FailedContractCall),
};
Expand All @@ -190,9 +191,7 @@ export const StackingModal: FC<StackingModalProps> = ({ onClose, numCycles, poxA

if (transaction) {
setIsDecrypting(false);
dispatch(
broadcastTransaction({ ...broadcastActions, txType: 'contract_call', transaction })
);
dispatch(broadcastTransaction({ ...broadcastActions, transaction }));
}
}

Expand All @@ -210,9 +209,7 @@ export const StackingModal: FC<StackingModalProps> = ({ onClose, numCycles, poxA
}

if (transaction) {
dispatch(
broadcastTransaction({ ...broadcastActions, txType: 'contract_call', transaction })
);
dispatch(broadcastTransaction({ ...broadcastActions, transaction }));
}
}
};
Expand Down
8 changes: 2 additions & 6 deletions app/modals/transaction/transaction-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ export const TransactionModal: FC<TxModalProps> = ({ balance, address }) => {

if (transaction) {
setIsDecrypting(false);
dispatch(
broadcastTransaction({ ...broadcastActions, txType: 'token_transfer', transaction })
);
dispatch(broadcastTransaction({ ...broadcastActions, transaction }));
}
}

Expand All @@ -192,9 +190,7 @@ export const TransactionModal: FC<TxModalProps> = ({ balance, address }) => {
}

if (transaction) {
dispatch(
broadcastTransaction({ ...broadcastActions, txType: 'token_transfer', transaction })
);
dispatch(broadcastTransaction({ ...broadcastActions, transaction }));
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Transaction } from '@blockstack/stacks-blockchain-api-types';
export interface PendingTransaction extends Pick<Transaction, 'tx_id'> {
amount: string;
time: number;
txType: Transaction['tx_type'];
isStackingCall?: boolean;
}

export type PendingTransactionState = EntityState<PendingTransaction>;
Expand Down
3 changes: 2 additions & 1 deletion app/store/stacking/stacking.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
7 changes: 4 additions & 3 deletions app/store/transaction/transaction.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Transaction>(
'transactions/pending-transaction-successful'
Expand Down Expand Up @@ -55,13 +56,13 @@ export const broadcastTxFail = createAction<BroadcastTxFail>(

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());

Expand All @@ -87,7 +88,7 @@ export function broadcastTransaction(args: BroadcastTransactionArgs) {
tx_id: safelyFormatHexTxid(blockchainResponse),
amount: amount.toString(),
time: +new Date(),
txType,
isStackingCall,
})
);
return blockchainResponse;
Expand Down

0 comments on commit 324ea7a

Please sign in to comment.