From a36dae45740d597b30e210d63744b14c247ae912 Mon Sep 17 00:00:00 2001 From: Pete Watters <2938440+pete-watters@users.noreply.github.com> Date: Tue, 14 May 2024 15:46:05 +0100 Subject: [PATCH 01/16] chore: add defensive code and better analytics for broadcast errors, ref #5118 --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- .../ledger-sign-stacks-tx-container.tsx | 11 ++++++++++- .../ordinal-inscription/send-inscription-review.tsx | 1 + .../form/brc20/brc20-send-form-confirmation.tsx | 4 ++++ .../form/btc/btc-send-form-confirmation.tsx | 3 +++ src/app/query/stacks/bns/bns.utils.ts | 1 + .../blockchain/bitcoin/native-segwit-account.hooks.ts | 1 + 8 files changed, 25 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 95014c656b0..e3fc5941302 100644 --- a/package.json +++ b/package.json @@ -135,7 +135,7 @@ "@dlc-link/dlc-tools": "1.1.1", "@fungible-systems/zone-file": "2.0.0", "@hirosystems/token-metadata-api-client": "1.2.0", - "@leather-wallet/models": "0.4.4", + "@leather-wallet/models": "0.4.5", "@leather-wallet/tokens": "0.0.14", "@ledgerhq/hw-transport-webusb": "6.27.19", "@noble/hashes": "1.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0935a38655b..88e4c349e34 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,8 +30,8 @@ dependencies: specifier: 1.2.0 version: 1.2.0 '@leather-wallet/models': - specifier: 0.4.4 - version: 0.4.4 + specifier: 0.4.5 + version: 0.4.5 '@leather-wallet/tokens': specifier: 0.0.14 version: 0.0.14 @@ -3702,8 +3702,8 @@ packages: bignumber.js: 9.1.2 dev: true - /@leather-wallet/models@0.4.4: - resolution: {integrity: sha512-dqUTUR0EMM9WFwkeWRahlpixK+Ct2vEpDBhQdvO83tK4GhC/JlopI9hmpaSKyX9+35Ts2LpgycUiCh59kmZbMA==} + /@leather-wallet/models@0.4.5: + resolution: {integrity: sha512-H0NhxYy1C2Byrj1wswL9Zf6bWOejvgVuwgVDT6xh7zqvoPotiAtrfEe3hiBdSeUtUsTh70ha1ZMuGwf/rph67w==} dependencies: bignumber.js: 9.1.2 dev: false diff --git a/src/app/features/ledger/flows/stacks-tx-signing/ledger-sign-stacks-tx-container.tsx b/src/app/features/ledger/flows/stacks-tx-signing/ledger-sign-stacks-tx-container.tsx index f0b1d9cb664..101426eb52b 100644 --- a/src/app/features/ledger/flows/stacks-tx-signing/ledger-sign-stacks-tx-container.tsx +++ b/src/app/features/ledger/flows/stacks-tx-signing/ledger-sign-stacks-tx-container.tsx @@ -7,6 +7,7 @@ import get from 'lodash.get'; import { RouteUrls } from '@shared/route-urls'; import { delay, isError } from '@shared/utils'; +import { analytics } from '@shared/utils/analytics'; import { useScrollLock } from '@app/common/hooks/use-scroll-lock'; import { appEvents } from '@app/common/publish-subscribe'; @@ -129,7 +130,15 @@ function LedgerSignStacksTxContainer() { signedTx, }); } catch (e) { - ledgerNavigate.toBroadcastErrorStep(isError(e) ? e.message : 'Unknown error'); + const error = isError(e) ? e.message : 'Unknown error'; + void analytics.track('ledger_transaction_publish_error', { + error: { + message: error, + error: e, + }, + }); + + ledgerNavigate.toBroadcastErrorStep(error); return; } }, diff --git a/src/app/pages/send/ordinal-inscription/send-inscription-review.tsx b/src/app/pages/send/ordinal-inscription/send-inscription-review.tsx index 2ecddb2c72c..b0530db592e 100644 --- a/src/app/pages/send/ordinal-inscription/send-inscription-review.tsx +++ b/src/app/pages/send/ordinal-inscription/send-inscription-review.tsx @@ -64,6 +64,7 @@ export function SendInscriptionReview() { }); }, onError(e) { + void analytics.track('ordinalbroadcast__error', { error: e }); navigate(`/${RouteUrls.SendOrdinalInscription}/${RouteUrls.SendOrdinalInscriptionError}`, { state: { error: e, diff --git a/src/app/pages/send/send-crypto-asset-form/form/brc20/brc20-send-form-confirmation.tsx b/src/app/pages/send/send-crypto-asset-form/form/brc20/brc20-send-form-confirmation.tsx index d6d176f3e5b..f589aa22c57 100644 --- a/src/app/pages/send/send-crypto-asset-form/form/brc20/brc20-send-form-confirmation.tsx +++ b/src/app/pages/send/send-crypto-asset-form/form/brc20/brc20-send-form-confirmation.tsx @@ -98,6 +98,10 @@ export function Brc20SendFormConfirmation() { }); }, onError(e) { + void analytics.track('broadcast_brc20_error', { + error: e, + }); + nav.toErrorPage(e); }, }); diff --git a/src/app/pages/send/send-crypto-asset-form/form/btc/btc-send-form-confirmation.tsx b/src/app/pages/send/send-crypto-asset-form/form/btc/btc-send-form-confirmation.tsx index 00b9fb55e04..b8fe3651a00 100644 --- a/src/app/pages/send/send-crypto-asset-form/form/btc/btc-send-form-confirmation.tsx +++ b/src/app/pages/send/send-crypto-asset-form/form/btc/btc-send-form-confirmation.tsx @@ -138,6 +138,9 @@ export function BtcSendFormConfirmation() { ); }, onError(e) { + void analytics.track('broadcast_btc_error', { + error: e, + }); nav.toErrorPage(e); }, }); diff --git a/src/app/query/stacks/bns/bns.utils.ts b/src/app/query/stacks/bns/bns.utils.ts index 046818ba1a4..19705a42f8d 100644 --- a/src/app/query/stacks/bns/bns.utils.ts +++ b/src/app/query/stacks/bns/bns.utils.ts @@ -140,6 +140,7 @@ export async function fetchNamesForAddress({ export async function fetchNameOwner(client: StacksClient, name: string, isTestnet: boolean) { const fetchFromApi = async () => { const res = await client.namesApi.getNameInfo({ name }); + if (isUndefined(res.address)) return null; if (!isString(res.address) || res.address.length === 0) return null; return res.address; }; diff --git a/src/app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks.ts b/src/app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks.ts index f0a0aa63e9e..a5c8a799841 100644 --- a/src/app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks.ts +++ b/src/app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks.ts @@ -122,6 +122,7 @@ export function useCurrentAccountNativeSegwitAddressIndexZero() { */ export function useNativeSegwitAccountIndexAddressIndexZero(accountIndex: number) { const signer = useNativeSegwitSigner(accountIndex)?.(0); + // could it be this? return signer?.payment.address as string; } From 9699d761064bfaa451b30ffbcee68e15272bac2a Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Fri, 12 Apr 2024 11:30:40 +0200 Subject: [PATCH 02/16] fix: tsconfig update for tokens pkg --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- theme/typography.ts | 4 ++-- tsconfig.json | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index e3fc5941302..047ee00a27d 100644 --- a/package.json +++ b/package.json @@ -136,7 +136,7 @@ "@fungible-systems/zone-file": "2.0.0", "@hirosystems/token-metadata-api-client": "1.2.0", "@leather-wallet/models": "0.4.5", - "@leather-wallet/tokens": "0.0.14", + "@leather-wallet/tokens": "0.0.15", "@ledgerhq/hw-transport-webusb": "6.27.19", "@noble/hashes": "1.3.2", "@noble/secp256k1": "2.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 88e4c349e34..6f92a7ee96f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,8 +33,8 @@ dependencies: specifier: 0.4.5 version: 0.4.5 '@leather-wallet/tokens': - specifier: 0.0.14 - version: 0.0.14 + specifier: 0.0.15 + version: 0.0.15 '@ledgerhq/hw-transport-webusb': specifier: 6.27.19 version: 6.27.19 @@ -3724,8 +3724,8 @@ packages: '@leather-wallet/models': 0.4.0 dev: true - /@leather-wallet/tokens@0.0.14: - resolution: {integrity: sha512-xCg+aIcn8DexmQhfvxYM85IGP2Q1JNfUBq80ZwV4horKw18MxxTdX5FeEthTrO8quRZu7up+IW6m/l3wElnDsA==} + /@leather-wallet/tokens@0.0.15: + resolution: {integrity: sha512-/jG36yCB8YRtyn1/sUgSeFwQjHhf6OfT0vsf384kbIXCzuaGhJpNl7GN0qWQkrxOKB5ahVuvqRwqaKFgwg1lUg==} dev: false /@ledgerhq/devices@8.2.0: diff --git a/theme/typography.ts b/theme/typography.ts index 48dc8bd6db5..6f378cd773f 100644 --- a/theme/typography.ts +++ b/theme/typography.ts @@ -1,5 +1,5 @@ -import { getExtensionTextVariants } from '@leather-wallet/tokens'; +import { getWebTextVariants } from '@leather-wallet/tokens'; import { defineTextStyles } from '@pandacss/dev'; // ts-unused-exports:disable-next-line -export const textStyles = defineTextStyles({ ...getExtensionTextVariants() }); +export const textStyles = defineTextStyles({ ...getWebTextVariants() }); diff --git a/tsconfig.json b/tsconfig.json index d1cbb016b94..f466731b2ba 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "esnext", - "module": "ESNext", - "moduleResolution": "node", + "module": "preserve", + "moduleResolution": "Bundler", "lib": ["dom", "dom.iterable", "esnext"], "jsx": "react-jsx", "sourceMap": true, From c5e04c144789d94bcdabcea767fa63ce09f98da8 Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Mon, 20 May 2024 09:07:08 +0200 Subject: [PATCH 03/16] fix: investigate stx fee issues --- .../common/validation/forms/amount-validators.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/common/validation/forms/amount-validators.ts b/src/app/common/validation/forms/amount-validators.ts index 248031d0df2..fbb58e2e08e 100644 --- a/src/app/common/validation/forms/amount-validators.ts +++ b/src/app/common/validation/forms/amount-validators.ts @@ -3,6 +3,7 @@ import * as yup from 'yup'; import { Money } from '@shared/models/money.model'; import { isNumber } from '@shared/utils'; +import { analytics } from '@shared/utils/analytics'; import { countDecimals } from '@app/common/math/helpers'; import { @@ -90,8 +91,16 @@ export function stxAvailableBalanceValidator(availableBalance: Money) { microStxToStx(sum.amount).toString() ), test(value: unknown) { - const fee = stxToMicroStx(this.parent.fee); - if (!availableBalance || !isNumber(value)) return false; + const fee = new BigNumber(stxToMicroStx(this.parent.fee)); + if (!fee.isFinite()) { + void analytics.track('unable_to_read_fee_in_stx_validator'); + return this.createError({ message: 'Unable to read current fee' }); + } + if (!isNumber(value)) return false; + if (!availableBalance) { + void analytics.track('unable_to_read_available_balance_in_stx_validator'); + return this.createError({ message: 'Available balance unknown' }); + } const availableBalanceLessFee = availableBalance.amount.minus(fee); return availableBalanceLessFee.isGreaterThanOrEqualTo(stxToMicroStx(value)); }, From 3a42fc9848c124e37035ce8d3a41b82eac998450 Mon Sep 17 00:00:00 2001 From: Pete Watters <2938440+pete-watters@users.noreply.github.com> Date: Fri, 17 May 2024 16:09:16 +0100 Subject: [PATCH 04/16] fix: fix padding on back button, ref leather-wallet/issues#25 --- .../pages/send/ordinal-inscription/send-inscription-review.tsx | 2 +- src/app/ui/components/containers/headers/header.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/pages/send/ordinal-inscription/send-inscription-review.tsx b/src/app/pages/send/ordinal-inscription/send-inscription-review.tsx index b0530db592e..049ce3c4b63 100644 --- a/src/app/pages/send/ordinal-inscription/send-inscription-review.tsx +++ b/src/app/pages/send/ordinal-inscription/send-inscription-review.tsx @@ -64,7 +64,7 @@ export function SendInscriptionReview() { }); }, onError(e) { - void analytics.track('ordinalbroadcast__error', { error: e }); + void analytics.track('broadcast_ordinal_error', { error: e }); navigate(`/${RouteUrls.SendOrdinalInscription}/${RouteUrls.SendOrdinalInscriptionError}`, { state: { error: e, diff --git a/src/app/ui/components/containers/headers/header.tsx b/src/app/ui/components/containers/headers/header.tsx index 8aadac76bdd..f2852122deb 100644 --- a/src/app/ui/components/containers/headers/header.tsx +++ b/src/app/ui/components/containers/headers/header.tsx @@ -40,7 +40,7 @@ export function Header({ justifyContent="center" margin={{ base: 0, md: 'auto' }} p={variant === 'bigTitle' ? 'space.05' : 'space.04'} - paddingLeft={variant === 'onboarding' ? 0 : undefined} + paddingLeft={{ base: undefined, sm: variant === 'onboarding' ? 0 : undefined }} bg="transparent" maxWidth={{ base: '100vw', md: 'fullPageMaxWidth' }} width="100%" From 2db97bd23547985a94d03104836c00b7bda562dc Mon Sep 17 00:00:00 2001 From: alter-eggo Date: Mon, 20 May 2024 20:20:45 +0400 Subject: [PATCH 05/16] feat: remove increase fee summary page, closes #5305 --- .../hooks/use-submit-stx-transaction.ts | 3 +- .../components/increase-fee-actions.tsx | 8 +++-- .../hooks/use-btc-increase-fee.ts | 3 +- .../increase-btc-fee-dialog.tsx | 8 +++-- .../increase-fee-sent-dialog.tsx | 30 ------------------- .../increase-stx-fee-dialog.tsx | 5 +++- .../use-stacks-broadcast-transaction.tsx | 21 ++++++++++++- .../stacks/stacks-send-form-confirmation.tsx | 8 ++--- .../swap/hooks/use-stacks-broadcast-swap.tsx | 1 + .../transaction-request.tsx | 2 +- src/app/routes/app-routes.tsx | 2 -- src/shared/route-urls.ts | 1 - 12 files changed, 43 insertions(+), 49 deletions(-) delete mode 100644 src/app/features/dialogs/increase-fee-dialog/increase-fee-sent-dialog.tsx diff --git a/src/app/common/hooks/use-submit-stx-transaction.ts b/src/app/common/hooks/use-submit-stx-transaction.ts index d58997dcec5..9b070c2cafd 100644 --- a/src/app/common/hooks/use-submit-stx-transaction.ts +++ b/src/app/common/hooks/use-submit-stx-transaction.ts @@ -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' }); diff --git a/src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx b/src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx index 170855c8486..e9bd5aa9bfe 100644 --- a/src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx +++ b/src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx @@ -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); @@ -25,9 +26,10 @@ export function IncreaseFeeActions(props: IncreaseFeeActionsProps) {