Skip to content

Commit 1be9dd6

Browse files
committed
update
1 parent da1a1f6 commit 1be9dd6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

ui/pages/confirmations/hooks/transactions/dapp-swap-comparison/useDappSwapComparisonInfo.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,20 @@ export function useDappSwapComparisonInfo() {
6363

6464
const { commands, quotesInput, amountMin, tokenAddresses } = useMemo(() => {
6565
try {
66-
updateRequestDetectionLatency();
6766
let transactionData = data;
6867
if (nestedTransactions?.length) {
6968
transactionData = nestedTransactions?.find(({ data: trxnData }) =>
7069
trxnData?.startsWith(FOUR_BYTE_EXECUTE_SWAP_CONTRACT),
7170
)?.data;
7271
}
73-
return getDataFromSwap(
72+
const result = getDataFromSwap(
7473
chainId,
7574
transactionData,
7675
txParams?.from as string,
7776
);
77+
console.log('-----------inside getDataFromSwap', result);
78+
updateRequestDetectionLatency();
79+
return result;
7880
} catch (error) {
7981
captureException(error);
8082
captureDappSwapComparisonFailed('error parsing swap data');

ui/pages/confirmations/hooks/transactions/dapp-swap-comparison/useDappSwapComparisonLatencyMetrics.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useEffect, useRef } from 'react';
1+
import { useCallback, useMemo, useRef } from 'react';
22

33
const N_A = 'N/A';
44

@@ -7,7 +7,8 @@ export function useDappSwapComparisonLatencyMetrics() {
77
const requestDetectionLatency = useRef(0);
88
const swapComparisonLatency = useRef(0);
99

10-
useEffect(() => {
10+
// using useMemo here as it is the first hook to be executed
11+
useMemo(() => {
1112
uiInitializedTime.current = new Date().getTime();
1213
}, []);
1314

@@ -24,7 +25,7 @@ export function useDappSwapComparisonLatencyMetrics() {
2425
return swapComparisonLatency.current.toString();
2526
}
2627
swapComparisonLatency.current =
27-
new Date().getTime() - requestDetectionLatency.current;
28+
new Date().getTime() - uiInitializedTime.current;
2829
return swapComparisonLatency.current.toString();
2930
}, []);
3031

0 commit comments

Comments
 (0)