Skip to content

Commit

Permalink
feat: remove increase fee summary page, closes #5305
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed May 20, 2024
1 parent 3a42fc9 commit 2db97bd
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 49 deletions.
3 changes: 1 addition & 2 deletions src/app/common/hooks/use-submit-stx-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export function useSubmitTransactionCallback({ loadingKey }: UseSubmitTransactio
rawTx: bytesToHex(transaction.serialize()),
txId: safelyFormatHexTxid(response.txid),
});
await delay(500);
toast.success('Transaction submitted!');

await delay(500);

void analytics.track('broadcast_transaction', { symbol: 'stx' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { useWalletType } from '@app/common/use-wallet-type';
import { Button } from '@app/ui/components/button/button';

interface IncreaseFeeActionsProps {
isDisabled: boolean;
isDisabled?: boolean;
isBroadcasting?: boolean;
onCancel(): void;
}
export function IncreaseFeeActions(props: IncreaseFeeActionsProps) {
const { onCancel, isDisabled } = props;
const { onCancel, isDisabled, isBroadcasting } = props;

const { handleSubmit } = useFormikContext();
const { isLoading } = useLoading(LoadingKeys.INCREASE_FEE_DRAWER);
Expand All @@ -25,9 +26,10 @@ export function IncreaseFeeActions(props: IncreaseFeeActionsProps) {
<Button
type="submit"
onClick={handleSubmit as any}
aria-busy={isLoading}
aria-busy={isLoading || isBroadcasting}
borderRadius="sm"
aria-disabled={isDisabled}
disabled={isDisabled}
flexGrow={1}
>
{actionText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export function useBtcIncreaseFee(btcTx: BitcoinTx) {
await broadcastTx({
tx: tx.hex,
async onSuccess(txid) {
navigate(RouteUrls.IncreaseFeeSent);
toast.success('Fee increased successfully');
navigate(RouteUrls.Activity);
void analytics.track('increase_fee_transaction', {
symbol: 'btc',
txid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { btcToSat } from '@app/common/money/unit-conversion';
import { getBitcoinTxValue } from '@app/common/transactions/bitcoin/utils';
import { BitcoinCustomFeeInput } from '@app/components/bitcoin-custom-fee/bitcoin-custom-fee-input';
import { BitcoinTransactionItem } from '@app/components/bitcoin-transaction-item/bitcoin-transaction-item';
import { LoadingSpinner } from '@app/components/loading-spinner';
import { useBtcCryptoAssetBalanceNativeSegwit } from '@app/query/bitcoin/balance/btc-balance-native-segwit.hooks';
import { useCurrentAccountNativeSegwitIndexZeroSigner } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks';
import { Dialog } from '@app/ui/components/containers/dialog/dialog';
Expand Down Expand Up @@ -72,7 +71,11 @@ export function IncreaseBtcFeeDialog() {
header={<DialogHeader title="Increase fee" />}
footer={
<Footer flexDirection="row">
<IncreaseFeeActions isDisabled={false} onCancel={() => navigate(RouteUrls.Home)} />
<IncreaseFeeActions
isDisabled={isBroadcasting}
isBroadcasting={isBroadcasting}
onCancel={() => navigate(RouteUrls.Home)}
/>
</Footer>
}
>
Expand All @@ -90,7 +93,6 @@ export function IncreaseBtcFeeDialog() {
</Caption>
<Stack gap="space.06">
{btcTx && <BitcoinTransactionItem transaction={btcTx} />}
{isBroadcasting && <LoadingSpinner />}
<Stack gap="space.04">
<Stack gap="space.01">
<BitcoinCustomFeeInput
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export function IncreaseStxFeeDialog() {
const availableUnlockedBalance = useCurrentStxAvailableUnlockedBalance();
const submittedTransactionsActions = useSubmittedTransactionsActions();
const rawTx = useRawDeserializedTxState();
const { stacksBroadcastTransaction } = useStacksBroadcastTransaction('STX');
const { stacksBroadcastTransaction } = useStacksBroadcastTransaction({
token: 'STX',
isIncreaseFeeTransaction: true,
});

const fee = Number(rawTx?.auth.spendingCondition?.fee);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ async function simulateShortDelayToAvoidUndefinedTabId() {
await delay(1000);
}

export function useStacksBroadcastTransaction(token: CryptoCurrencies, decimals?: number) {
interface UseStacksBroadcastTransactionArgs {
token: CryptoCurrencies;
decimals?: number;
isIncreaseFeeTransaction?: boolean;
}

export function useStacksBroadcastTransaction({
token,
decimals,
isIncreaseFeeTransaction,
}: UseStacksBroadcastTransactionArgs) {
const signStacksTransaction = useSignStacksTransaction();
const [isBroadcasting, setIsBroadcasting] = useState(false);
const { tabId } = useDefaultRequestParams();
Expand All @@ -49,6 +59,11 @@ export function useStacksBroadcastTransaction(token: CryptoCurrencies, decimals?
});
}
if (txId) {
if (isIncreaseFeeTransaction) {
navigate(RouteUrls.Activity);
return;
}

navigate(
RouteUrls.SentStxTxSummary.replace(':symbol', token.toLowerCase()).replace(
':txId',
Expand Down Expand Up @@ -79,6 +94,9 @@ export function useStacksBroadcastTransaction(token: CryptoCurrencies, decimals?
},
onSuccess(txId) {
handlePreviewSuccess(signedTx, txId);
if (isIncreaseFeeTransaction) {
toast.success('Fee increased successfully');
}
},
replaceByFee: false,
})(signedTx);
Expand Down Expand Up @@ -117,5 +135,6 @@ export function useStacksBroadcastTransaction(token: CryptoCurrencies, decimals?
toast,
broadcastTransactionFn,
signStacksTransaction,
isIncreaseFeeTransaction,
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export function StacksSendFormConfirmation() {
const { tx, decimals, showFeeChangeWarning } = useStacksSendFormConfirmationState();
const { symbol = 'STX' } = useParams();

const { stacksBroadcastTransaction, isBroadcasting } = useStacksBroadcastTransaction(
symbol.toUpperCase() as CryptoCurrencies,
decimals
);
const { stacksBroadcastTransaction, isBroadcasting } = useStacksBroadcastTransaction({
token: symbol.toUpperCase() as CryptoCurrencies,
decimals,
});

const stacksDeserializedTransaction = deserializeTransaction(tx);

Expand Down
1 change: 1 addition & 0 deletions src/app/pages/swap/hooks/use-stacks-broadcast-swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function useStacksBroadcastSwap() {
navigate(RouteUrls.TransactionBroadcastError, { state: { message } });
},
onSuccess() {
toast.success('Transaction submitted!');
setIsIdle();
navigate(RouteUrls.Activity);
},
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/transaction-request/transaction-request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function TransactionRequestBase() {
const availableUnlockedBalance = useCurrentStxAvailableUnlockedBalance();
const { data: nextNonce } = useNextNonce();
const navigate = useNavigate();
const { stacksBroadcastTransaction } = useStacksBroadcastTransaction('STX');
const { stacksBroadcastTransaction } = useStacksBroadcastTransaction({ token: 'STX' });

useOnMount(() => void analytics.track('view_transaction_signing'));

Expand Down
2 changes: 0 additions & 2 deletions src/app/routes/app-routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { AddNetwork } from '@app/features/add-network/add-network';
import { Container } from '@app/features/container/container';
import { EditNonceDialog } from '@app/features/dialogs/edit-nonce-dialog/edit-nonce-dialog';
import { IncreaseBtcFeeDialog } from '@app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog';
import { IncreaseFeeSentDialog } from '@app/features/dialogs/increase-fee-dialog/increase-fee-sent-dialog';
import { IncreaseStxFeeDialog } from '@app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog';
import { leatherIntroDialogRoutes } from '@app/features/dialogs/leather-intro-dialog/leather-intro-dialog';
import { ledgerBitcoinTxSigningRoutes } from '@app/features/ledger/flows/bitcoin-tx-signing/ledger-bitcoin-sign-tx-container';
Expand Down Expand Up @@ -103,7 +102,6 @@ function useAppRoutes() {
<Route path={RouteUrls.IncreaseBtcFee} element={<IncreaseBtcFeeDialog />}>
{ledgerBitcoinTxSigningRoutes}
</Route>
<Route path={RouteUrls.IncreaseFeeSent} element={<IncreaseFeeSentDialog />} />

{ledgerStacksTxSigningRoutes}

Expand Down
1 change: 0 additions & 1 deletion src/shared/route-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export enum RouteUrls {
FundChooseCurrency = '/fund-choose-currency',
IncreaseStxFee = '/increase-fee/stx',
IncreaseBtcFee = '/increase-fee/btc',
IncreaseFeeSent = '/increase-fee/sent',
Send = '/send-transaction',
ViewSecretKey = '/view-secret-key',

Expand Down

0 comments on commit 2db97bd

Please sign in to comment.