Skip to content

Commit

Permalink
Merge branch 'master' into ci/sdk-update/latest
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Mar 29, 2024
2 parents e60cb3a + 1427f2b commit 6d69a79
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-buses-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels-wallet": patch
---

fix: transaction id available on transaction approved page, it was taking the user to a broken page (undefined id).
5 changes: 5 additions & 0 deletions packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const selectors = {
txResult(state: TransactionRequestState) {
return state.context.response?.txResult;
},
approvedTx(state: TransactionRequestState) {
return state.context.response?.approvedTx;
},
isLoadingAccounts(state: TransactionRequestState) {
return state.matches('fetchingAccount');
},
Expand Down Expand Up @@ -100,6 +103,7 @@ export function useTransactionRequest(opts: UseTransactionRequestOpts = {}) {
const txStatus = useSelector(service, txStatusSelector);
const title = useSelector(service, selectors.title);
const txResult = useSelector(service, selectors.txResult);
const approvedTx = useSelector(service, selectors.approvedTx);
const origin = useSelector(service, selectors.origin);
const originTitle = useSelector(service, selectors.originTitle);
const favIconUrl = useSelector(service, selectors.favIconUrl);
Expand Down Expand Up @@ -159,6 +163,7 @@ export function useTransactionRequest(opts: UseTransactionRequestOpts = {}) {
title,
txResult,
txStatus,
approvedTx,
isSendingTx,
shouldShowTx,
shouldShowLoader,
Expand Down
23 changes: 12 additions & 11 deletions packages/app/src/systems/Transaction/hooks/useExplorerLink.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
import { buildBlockExplorerUrl } from 'fuels';
import { useCallback } from 'react';
import { useCallback, useMemo } from 'react';
import { EXPLORER_URL, IS_CRX, VITE_FUEL_PROVIDER_URL } from '~/config';
import { openTab } from '~/systems/CRX/utils';
import { urlJoin } from '~/systems/Core';

export function useExplorerLink(providerUrl: string, id?: string) {
let href = buildBlockExplorerUrl({
txId: id,
providerUrl,
});
const href = useMemo<string>(() => {
// Use the new explorer only if the provider is the default one
if (providerUrl === VITE_FUEL_PROVIDER_URL) {
return urlJoin(EXPLORER_URL, `/tx/${id}`);
}

// Use the new explorer only if the provider is the default one
if (providerUrl === VITE_FUEL_PROVIDER_URL) {
href = urlJoin(EXPLORER_URL, `/tx/${id}`);
}
return buildBlockExplorerUrl({
txId: id,
providerUrl,
});
}, [id, providerUrl]);

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
const openExplorer = useCallback(() => {
if (IS_CRX) {
openTab(href);
} else {
window.location.href = href;
}
}, [providerUrl, id]);
}, [href]);

return {
href,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const TxApprove = () => {
assets={assets}
header={
<TxHeader
id={ctx.txResult?.id}
id={ctx.txResult?.id || ctx.approvedTx?.id}
type={ctx.txResult?.type}
status={ctx.approveStatus()}
providerUrl={ctx.providerUrl}
Expand Down

0 comments on commit 6d69a79

Please sign in to comment.