Skip to content

Commit

Permalink
Get userJourney from prop
Browse files Browse the repository at this point in the history
  • Loading branch information
mimi-imtbl committed Jan 10, 2025
1 parent fca4191 commit 1d63464
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/checkout/widgets-lib/src/lib/squid/hooks/useExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { isRejectedError } from '../../../functions/errorType';
const TRANSACTION_NOT_COMPLETED = 'transaction not completed';

export const useExecute = (
onTransactionError: (err: unknown) => void,
userJourney: UserJourney,
onTransactionError?: (err: unknown) => void,
) => {
const { user } = useAnalytics();

Expand Down Expand Up @@ -79,7 +80,7 @@ export const useExecute = (

return ethers.constants.MaxUint256; // no approval is needed for native tokens
} catch (error) {
onTransactionError(error);
onTransactionError?.(error);
return undefined;
}
};
Expand Down Expand Up @@ -135,14 +136,14 @@ export const useExecute = (
if (!isSquidNativeToken(routeResponse?.route?.params.fromToken)) {
return await withMetricsAsync(
(flow) => callApprove(flow, fromProviderInfo, provider, routeResponse),
`${UserJourney.ADD_TOKENS}_Approve`,
`${userJourney}_Approve`,
await getAnonymousId(),
(error) => (isRejectedError(error) ? 'rejected' : ''),
);
}
return undefined;
} catch (error) {
onTransactionError(error);
onTransactionError?.(error);
return undefined;
}
};
Expand Down Expand Up @@ -175,12 +176,12 @@ export const useExecute = (
try {
return await withMetricsAsync(
(flow) => callExecute(flow, squid, fromProviderInfo, provider, routeResponse),
`${UserJourney.ADD_TOKENS}_Execute`,
`${userJourney}_Execute`,
await getAnonymousId(),
(error) => (isRejectedError(error) ? 'rejected' : ''),
);
} catch (error) {
onTransactionError(error);
onTransactionError?.(error);
return undefined;
}
};
Expand Down Expand Up @@ -222,7 +223,7 @@ export const useExecute = (
},
);
} catch (error) {
onTransactionError(error);
onTransactionError?.(error);
return undefined;
}
};
Expand Down

0 comments on commit 1d63464

Please sign in to comment.