Skip to content

Commit

Permalink
chore: add defensive code and better analytics for broadcast errors, …
Browse files Browse the repository at this point in the history
…ref #5118
  • Loading branch information
pete-watters committed May 20, 2024
1 parent ca9cf0b commit bf36652
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function SendInscriptionReview() {
});
},
onError(e) {
void analytics.track('ordinalbroadcast__error', { error: e });
navigate(`/${RouteUrls.SendOrdinalInscription}/${RouteUrls.SendOrdinalInscriptionError}`, {
state: {
error: e,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export function Brc20SendFormConfirmation() {
});
},
onError(e) {
void analytics.track('broadcast_brc20_error', {
error: e,
});

nav.toErrorPage(e);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export function BtcSendFormConfirmation() {
);
},
onError(e) {
void analytics.track('broadcast_btc_error', {
error: e,
});
nav.toErrorPage(e);
},
});
Expand Down
1 change: 1 addition & 0 deletions src/app/query/stacks/bns/bns.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit bf36652

Please sign in to comment.