Skip to content

Commit

Permalink
feat: remove stacks tx estimated time, LEA-1686
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Oct 30, 2024
1 parent 8625fe7 commit fe2a20b
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 40 deletions.
14 changes: 0 additions & 14 deletions src/app/common/transactions/stacks/transaction.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { bytesToHex } from '@stacks/common';
import { TransactionTypes } from '@stacks/connect';
import {
CoinbaseTransaction,
NetworkBlockTimesResponse,
TransactionEventFungibleAsset,
} from '@stacks/stacks-blockchain-api-types';
import {
Expand Down Expand Up @@ -127,19 +126,6 @@ export function getTxSenderAddress(tx: StacksTransaction): string | undefined {
return txSender;
}

export function getEstimatedConfirmationTime(
isTestnet: boolean,
blockTime?: NetworkBlockTimesResponse
) {
const arrivesIn = isTestnet
? blockTime?.testnet.target_block_time
: blockTime?.mainnet.target_block_time;

if (!arrivesIn) return '~10 – 20 min';

return `~${arrivesIn / 60} min`;
}

export function isPendingTx(tx: StacksTx) {
return tx.tx_status === 'pending';
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import {
import BigNumber from 'bignumber.js';

import type { CryptoCurrency } from '@leather.io/models';
import {
useCryptoCurrencyMarketDataMeanAverage,
useGetStacksNetworkBlockTimeQuery,
} from '@leather.io/query';
import { useCryptoCurrencyMarketDataMeanAverage } from '@leather.io/query';
import {
baseCurrencyAmountInQuote,
convertToMoneyTypeWithDefaultOfZero,
Expand All @@ -26,15 +23,11 @@ import {
microStxToStx,
} from '@leather.io/utils';

import { getEstimatedConfirmationTime } from '@app/common/transactions/stacks/transaction.utils';
import { removeTrailingNullCharacters } from '@app/common/utils';
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';

export function useStacksTransactionSummary(token: CryptoCurrency) {
// TODO: unsafe type assumption
const tokenMarketData = useCryptoCurrencyMarketDataMeanAverage(token as 'BTC' | 'STX');
const { isTestnet } = useCurrentNetworkState();
const { data: blockTime } = useGetStacksNetworkBlockTimeQuery();

function formSentSummaryTxState(txId: string, signedTx: StacksTransaction, decimals?: number) {
return {
Expand Down Expand Up @@ -64,7 +57,6 @@ export function useStacksTransactionSummary(token: CryptoCurrency) {
recipient: addressToString(payload.recipient.address),
fee: formatMoney(convertToMoneyTypeWithDefaultOfZero('STX', Number(fee))),
totalSpend: formatMoney(convertToMoneyTypeWithDefaultOfZero('STX', Number(txValue + fee))),
arrivesIn: getEstimatedConfirmationTime(isTestnet, blockTime),
symbol: 'STX',
txValue: microStxToStx(Number(txValue)).toString(),
sendingValue: formatMoney(convertToMoneyTypeWithDefaultOfZero('STX', Number(txValue))),
Expand Down Expand Up @@ -109,7 +101,6 @@ export function useStacksTransactionSummary(token: CryptoCurrency) {

return {
recipient: cvToString(payload.functionArgs[2]),
arrivesIn: getEstimatedConfirmationTime(isTestnet, blockTime),
txValue: new BigNumber(txValue).shiftedBy(-decimals).toString(),
nonce: String(tx.auth.spendingCondition.nonce),
fee: feeValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface SendFormConfirmationProps {
recipient: string;
fee?: string;
totalSpend: string;
arrivesIn: string;
symbol: string;
txValue: string | number;
sendingValue: string;
Expand All @@ -35,7 +34,6 @@ export function SendFormConfirmation({
fee,
totalSpend,
sendingValue,
arrivesIn,
isLoading,
onBroadcastTransaction,
nonce,
Expand Down Expand Up @@ -96,7 +94,6 @@ export function SendFormConfirmation({
data-testid={SendCryptoAssetSelectors.ConfirmationDetailsMemo}
/>
<InfoCardRow title="Nonce" value={nonce} />
<InfoCardRow title="Estimated confirmation time" value={arrivesIn} />
</Stack>
</Card>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function StacksSendFormConfirmation() {
fee,
totalSpend,
sendingValue,
arrivesIn,
nonce,
memoDisplayText,
} = formReviewTxSummary(stacksDeserializedTransaction, symbol, decimals);
Expand Down Expand Up @@ -80,7 +79,6 @@ export function StacksSendFormConfirmation() {
fee={fee}
totalSpend={totalSpend}
sendingValue={sendingValue}
arrivesIn={arrivesIn}
nonce={nonce}
memoDisplayText={memoDisplayText}
symbol={symbol.toUpperCase()}
Expand Down
2 changes: 0 additions & 2 deletions src/app/pages/send/sent-summary/stx-sent-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export function StxSentSummary() {
txFiatValueSymbol,
symbol,
txLink,
arrivesIn,
fee,
recipient,
txId,
Expand Down Expand Up @@ -77,7 +76,6 @@ export function StxSentSummary() {

<InfoCardRow title="Sending" value={sendingValue} />
<InfoCardRow title="Fee" value={fee} />
<InfoCardRow title="Estimated confirmation time" value={arrivesIn} />
</Stack>
</Card>
</Page>
Expand Down
9 changes: 0 additions & 9 deletions src/app/pages/swap/components/swap-details/swap-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { SwapSelectors } from '@tests/selectors/swap.selectors';
import BigNumber from 'bignumber.js';
import { HStack, styled } from 'leather-styles/jsx';

import { useGetStacksNetworkBlockTimeQuery } from '@leather.io/query';
import { ChevronRightIcon } from '@leather.io/ui';
import {
createMoneyFromDecimal,
Expand All @@ -12,9 +11,7 @@ import {
microStxToStx,
} from '@leather.io/utils';

import { getEstimatedConfirmationTime } from '@app/common/transactions/stacks/transaction.utils';
import { SwapSubmissionData, useSwapContext } from '@app/pages/swap/swap.context';
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';

import { toCommaSeparatedWithAnd } from '../../swap.utils';
import { SwapDetailLayout } from './swap-detail.layout';
Expand All @@ -37,8 +34,6 @@ const sponsoredFeeLabel =

export function SwapDetails() {
const { swapSubmissionData } = useSwapContext();
const { isTestnet } = useCurrentNetworkState();
const { data: blockTime } = useGetStacksNetworkBlockTimeQuery();

if (
isUndefined(swapSubmissionData) ||
Expand Down Expand Up @@ -97,10 +92,6 @@ export function SwapDetails() {
: `${microStxToStx(swapSubmissionData.fee).toString()} STX`
}
/>
<SwapDetailLayout
title="Estimated confirmation time"
value={getEstimatedConfirmationTime(isTestnet, blockTime)}
/>
<SwapDetailLayout title="Nonce" value={swapSubmissionData.nonce?.toString() ?? 'Unknown'} />
</SwapDetailsLayout>
);
Expand Down

0 comments on commit fe2a20b

Please sign in to comment.