@dynamic-labs-sdk/react-ui 1.52.1 → 1.52.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/flow/components/FlowTermsConsent/FlowTermsConsent.d.ts +74 -0
  2. package/dist/flow/components/FlowTermsConsent/FlowTermsConsent.d.ts.map +1 -0
  3. package/dist/flow/components/FlowTermsConsent/index.d.ts +3 -0
  4. package/dist/flow/components/FlowTermsConsent/index.d.ts.map +1 -0
  5. package/dist/flow/constants.d.ts +12 -0
  6. package/dist/flow/constants.d.ts.map +1 -1
  7. package/dist/flow/hooks/useFlowTermsConsent/index.d.ts +3 -0
  8. package/dist/flow/hooks/useFlowTermsConsent/index.d.ts.map +1 -0
  9. package/dist/flow/hooks/useFlowTermsConsent/useFlowTermsConsent.d.ts +42 -0
  10. package/dist/flow/hooks/useFlowTermsConsent/useFlowTermsConsent.d.ts.map +1 -0
  11. package/dist/flow/utils/resolveFlowTermsUrl/index.d.ts +3 -0
  12. package/dist/flow/utils/resolveFlowTermsUrl/index.d.ts.map +1 -0
  13. package/dist/flow/utils/resolveFlowTermsUrl/resolveFlowTermsUrl.d.ts +23 -0
  14. package/dist/flow/utils/resolveFlowTermsUrl/resolveFlowTermsUrl.d.ts.map +1 -0
  15. package/dist/flow/views/FlowDepositAddressView/FlowDepositAddressView.d.ts +8 -1
  16. package/dist/flow/views/FlowDepositAddressView/FlowDepositAddressView.d.ts.map +1 -1
  17. package/dist/flow/views/FlowDepositAddressView/FlowDepositAddressView.text.d.ts +5 -0
  18. package/dist/flow/views/FlowDepositAddressView/FlowDepositAddressView.text.d.ts.map +1 -1
  19. package/dist/flow/views/FlowDepositAddressView/getFlowDepositAddressQrMessageKey/getFlowDepositAddressQrMessageKey.d.ts +45 -0
  20. package/dist/flow/views/FlowDepositAddressView/getFlowDepositAddressQrMessageKey/getFlowDepositAddressQrMessageKey.d.ts.map +1 -0
  21. package/dist/flow/views/FlowDepositAddressView/getFlowDepositAddressQrMessageKey/index.d.ts +3 -0
  22. package/dist/flow/views/FlowDepositAddressView/getFlowDepositAddressQrMessageKey/index.d.ts.map +1 -0
  23. package/dist/flow/views/FlowDepositAddressView/useFlowDepositAddressTermsGate/index.d.ts +3 -0
  24. package/dist/flow/views/FlowDepositAddressView/useFlowDepositAddressTermsGate/index.d.ts.map +1 -0
  25. package/dist/flow/views/FlowDepositAddressView/useFlowDepositAddressTermsGate/useFlowDepositAddressTermsGate.d.ts +48 -0
  26. package/dist/flow/views/FlowDepositAddressView/useFlowDepositAddressTermsGate/useFlowDepositAddressTermsGate.d.ts.map +1 -0
  27. package/dist/flow/views/FlowExchangeView/FlowExchangeView.d.ts +6 -1
  28. package/dist/flow/views/FlowExchangeView/FlowExchangeView.d.ts.map +1 -1
  29. package/dist/flow/views/FlowExchangeView/FlowExchangeView.text.d.ts +3 -0
  30. package/dist/flow/views/FlowExchangeView/FlowExchangeView.text.d.ts.map +1 -1
  31. package/dist/flow/views/FlowReviewPaymentView/FlowReviewPaymentView.d.ts +3 -1
  32. package/dist/flow/views/FlowReviewPaymentView/FlowReviewPaymentView.d.ts.map +1 -1
  33. package/dist/flow/views/FlowReviewPaymentView/FlowReviewPaymentView.text.d.ts +1 -0
  34. package/dist/flow/views/FlowReviewPaymentView/FlowReviewPaymentView.text.d.ts.map +1 -1
  35. package/dist/flow/views/FlowReviewPaymentView/useFlowReviewPaymentView/useFlowReviewPaymentView.d.ts +12 -17
  36. package/dist/flow/views/FlowReviewPaymentView/useFlowReviewPaymentView/useFlowReviewPaymentView.d.ts.map +1 -1
  37. package/dist/flow.cjs +294 -68
  38. package/dist/flow.cjs.map +1 -1
  39. package/dist/flow.css +1 -1
  40. package/dist/flow.esm.js +294 -68
  41. package/dist/flow.esm.js.map +1 -1
  42. package/dist/index.cjs +1 -1
  43. package/dist/index.css +1 -1
  44. package/dist/index.esm.js +1 -1
  45. package/dist/{package-DC3rhvWk.esm.js → package-BF1tVvUS.esm.js} +2 -2
  46. package/dist/{package-DC3rhvWk.esm.js.map → package-BF1tVvUS.esm.js.map} +1 -1
  47. package/dist/{package-BHItweTV.cjs → package-js0iaGOF.cjs} +2 -2
  48. package/dist/{package-BHItweTV.cjs.map → package-js0iaGOF.cjs.map} +1 -1
  49. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  50. package/package.json +6 -6
package/dist/flow.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as TextProvider, C as CopyField, D as CopyMorphIcon, E as useCopyToClipboard, F as SPRING, N as Button, O as useText, P as PRESS_SCALE, _ as ProviderOption, a as ConnectWalletOptionWidget, b as Panel, d as useGetWalletName, f as TokenMark, g as QRCode, j as CheckboxField, k as TextContext, m as Select, n as version, o as useViewRouter, r as WalletAccountBalances, t as name, u as PanelHost, v as ProviderIcon, w as interpolateText, x as PanelHostContext, y as isValidImageSource } from "./package-DC3rhvWk.esm.js";
1
+ import { A as TextProvider, C as CopyField, D as CopyMorphIcon, E as useCopyToClipboard, F as SPRING, N as Button, O as useText, P as PRESS_SCALE, _ as ProviderOption, a as ConnectWalletOptionWidget, b as Panel, d as useGetWalletName, f as TokenMark, g as QRCode, j as CheckboxField, k as TextContext, m as Select, n as version, o as useViewRouter, r as WalletAccountBalances, t as name, u as PanelHost, v as ProviderIcon, w as interpolateText, x as PanelHostContext, y as isValidImageSource } from "./package-BF1tVvUS.esm.js";
2
2
  import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
  import { AnimatePresence, m } from "motion/react";
@@ -1009,6 +1009,14 @@ const FLOW_PAYMENT_METHODS = [
1009
1009
  "exchange",
1010
1010
  "deposit_address"
1011
1011
  ];
1012
+ /** The placeholder terms consent copy uses for the terms link. */
1013
+ const FLOW_TERMS_TOKEN = "{terms}";
1014
+ /** Default copy for the terms consent every payment method's screen carries. */
1015
+ const FLOW_TERMS_CONSENT_DEFAULT_TEXT = {
1016
+ consent: `I agree to the ${FLOW_TERMS_TOKEN}`,
1017
+ disclaimer: "I'm paying a third party and accept the risk of loss",
1018
+ terms: "Terms of Service"
1019
+ };
1012
1020
 
1013
1021
  //#endregion
1014
1022
  //#region src/utils/formatFiatAmount/formatFiatAmount.ts
@@ -2742,6 +2750,99 @@ const FlowRefundAddressSheet = ({ chain, className, networkName, onSubmit }) =>
2742
2750
  });
2743
2751
  };
2744
2752
 
2753
+ //#endregion
2754
+ //#region src/flow/utils/resolveFlowTermsUrl/resolveFlowTermsUrl.ts
2755
+ /**
2756
+ * Returns a terms link that is safe to open: the given one when it is a web
2757
+ * link, else nothing. A malformed link or one with another scheme, such as
2758
+ * `javascript:`, never reaches an `href`.
2759
+ *
2760
+ * @example
2761
+ * ```ts
2762
+ * resolveFlowTermsUrl({ url: 'https://example.test/terms' }); // 'https://example.test/terms'
2763
+ * resolveFlowTermsUrl({ url: 'javascript:alert(1)' }); // undefined
2764
+ * ```
2765
+ * @param params.url - The terms link to check.
2766
+ * @returns The safe terms link, or undefined when there is none to open.
2767
+ * @see assertSafeNavigationUrl
2768
+ * @see useFlowTermsConsent
2769
+ * @notInstrumented
2770
+ */
2771
+ const resolveFlowTermsUrl = ({ url }) => {
2772
+ if (url === void 0) return;
2773
+ try {
2774
+ const parsedUrl = new URL(url);
2775
+ assertSafeNavigationUrl(parsedUrl);
2776
+ return parsedUrl.href;
2777
+ } catch {
2778
+ return;
2779
+ }
2780
+ };
2781
+
2782
+ //#endregion
2783
+ //#region src/flow/components/FlowTermsConsent/FlowTermsConsent.tsx
2784
+ /**
2785
+ * The Flow terms consent: a checkbox row whose sentence carries a link to the
2786
+ * terms of service. Following the link opens the terms in a new tab without
2787
+ * toggling the checkbox. Without a terms link the row carries a risk
2788
+ * disclaimer instead. Every payment method's screen renders it above the
2789
+ * action it gates.
2790
+ *
2791
+ * @example
2792
+ * ```tsx
2793
+ * import { FlowTermsConsent } from '@/flow/components/FlowTermsConsent';
2794
+ *
2795
+ * const App = () => (
2796
+ * <FlowTermsConsent
2797
+ * checked={accepted}
2798
+ * consentText="I agree to the {terms}"
2799
+ * disclaimerText="You can lose funds."
2800
+ * onCheckedChange={setAccepted}
2801
+ * termsText="Terms of Service"
2802
+ * termsUrl="https://example.com/terms"
2803
+ * />
2804
+ * );
2805
+ * ```
2806
+ * @param params.checked - Whether the payer has accepted the terms.
2807
+ * @param params.className - Extra class names for the root element.
2808
+ * @param params.consentText - The consent sentence, with {terms} where the link goes.
2809
+ * @param params.disabled - Locks the checkbox while the screen is busy.
2810
+ * @param params.disclaimerText - The sentence shown instead when there is no terms link.
2811
+ * @param params.onCheckedChange - Fires with the payer's choice.
2812
+ * @param params.termsText - The text of the terms link.
2813
+ * @param params.termsUrl - Where the terms link points.
2814
+ * @returns The terms consent row.
2815
+ * @see FlowTermsConsentProps
2816
+ * @see CheckboxField
2817
+ * @see useFlowTermsConsent
2818
+ * @see resolveFlowTermsUrl
2819
+ * @notInstrumented
2820
+ */
2821
+ const FlowTermsConsent = ({ checked, className, consentText, disabled = false, disclaimerText, onCheckedChange, termsText, termsUrl }) => {
2822
+ const safeTermsUrl = resolveFlowTermsUrl({ url: termsUrl });
2823
+ const [beforeTermsText, afterTermsText] = consentText.split(FLOW_TERMS_TOKEN);
2824
+ return /* @__PURE__ */ jsx("div", {
2825
+ className,
2826
+ "data-slot": "dyn-flow-terms-consent",
2827
+ children: /* @__PURE__ */ jsx(CheckboxField, {
2828
+ checked,
2829
+ disabled,
2830
+ onCheckedChange: (next) => onCheckedChange(next === true),
2831
+ children: safeTermsUrl === void 0 ? disclaimerText : /* @__PURE__ */ jsxs(Fragment, { children: [
2832
+ beforeTermsText,
2833
+ /* @__PURE__ */ jsx("a", {
2834
+ "data-slot": "dyn-flow-terms-consent-link",
2835
+ href: safeTermsUrl,
2836
+ rel: "noopener noreferrer",
2837
+ target: "_blank",
2838
+ children: termsText
2839
+ }),
2840
+ afterTermsText
2841
+ ] })
2842
+ })
2843
+ });
2844
+ };
2845
+
2745
2846
  //#endregion
2746
2847
  //#region src/flow/utils/getFlowSourceNetworkKey/getFlowSourceNetworkKey.ts
2747
2848
  /**
@@ -2768,8 +2869,11 @@ const getFlowSourceNetworkKey = ({ option }) => `${option.chain.name}:${option.n
2768
2869
  */
2769
2870
  const FLOW_DEPOSIT_ADDRESS_VIEW_TEXT = {
2770
2871
  amountLabel: "amount",
2872
+ consent: FLOW_TERMS_CONSENT_DEFAULT_TEXT.consent,
2873
+ disclaimer: FLOW_TERMS_CONSENT_DEFAULT_TEXT.disclaimer,
2771
2874
  fees: "Fees",
2772
2875
  orderTotal: "Order total",
2876
+ qrAcceptTerms: "Agree to continue",
2773
2877
  qrLabel: "QR code to pay the exact amount to the deposit address",
2774
2878
  qrPlaceholder: "Select a chain and token",
2775
2879
  qrQuoting: "Fetching quote…",
@@ -2779,11 +2883,108 @@ const FLOW_DEPOSIT_ADDRESS_VIEW_TEXT = {
2779
2883
  selectTokenLabel: "Select token",
2780
2884
  selectTokenPlaceholder: "Select token",
2781
2885
  sendExactly: "Send exactly",
2886
+ showDepositAddress: "Show deposit address",
2887
+ terms: FLOW_TERMS_CONSENT_DEFAULT_TEXT.terms,
2782
2888
  title: "Send to address",
2783
2889
  toThisAddress: "To this address",
2784
2890
  waitingForAmount: "Waiting for exactly {amount}"
2785
2891
  };
2786
2892
 
2893
+ //#endregion
2894
+ //#region src/flow/views/FlowDepositAddressView/getFlowDepositAddressQrMessageKey/getFlowDepositAddressQrMessageKey.ts
2895
+ /**
2896
+ * Picks the message shown on the deposit address QR placeholder: progress
2897
+ * while a quote is fetched, a prompt to accept the terms once a quote is ready
2898
+ * but its details are held back, else the prompt to pick a chain and token.
2899
+ *
2900
+ * @example
2901
+ * ```ts
2902
+ * const key = getFlowDepositAddressQrMessageKey({
2903
+ * areDetailsRevealed: false,
2904
+ * hasQuote: true,
2905
+ * isQuoting: false,
2906
+ * });
2907
+ * ```
2908
+ * @param params.areDetailsRevealed - Whether the payer accepted the terms and went on.
2909
+ * @param params.hasQuote - Whether a quote with the deposit details is ready.
2910
+ * @param params.isQuoting - Whether a quote is being fetched.
2911
+ * @returns The text key of the placeholder message.
2912
+ * @see GetFlowDepositAddressQrMessageKeyParams
2913
+ * @see FlowDepositAddressView
2914
+ * @notInstrumented
2915
+ */
2916
+ const getFlowDepositAddressQrMessageKey = ({ areDetailsRevealed, hasQuote, isQuoting }) => {
2917
+ if (isQuoting) return "qrQuoting";
2918
+ if (hasQuote && !areDetailsRevealed) return "qrAcceptTerms";
2919
+ return "qrPlaceholder";
2920
+ };
2921
+
2922
+ //#endregion
2923
+ //#region src/flow/hooks/useFlowTermsConsent/useFlowTermsConsent.ts
2924
+ /**
2925
+ * Tracks whether the payer accepted the terms and resolves the link they open.
2926
+ * The consent is always required: a link that is missing or not safe to open
2927
+ * is left out, and the consent shows its disclaimer instead of a terms link.
2928
+ *
2929
+ * @example
2930
+ * ```tsx
2931
+ * const { hasAcceptedTerms, onCheckedChange, termsUrl } = useFlowTermsConsent({ flow });
2932
+ * ```
2933
+ * @param params.flow - The flow being paid.
2934
+ * @returns The consent state, its setter and the terms link.
2935
+ * @see FlowTermsConsent
2936
+ * @see useFlowUiSettings
2937
+ * @see resolveFlowTermsUrl
2938
+ * @notInstrumented
2939
+ */
2940
+ const useFlowTermsConsent = ({ flow }) => {
2941
+ const [hasAcceptedTerms, setHasAcceptedTerms] = useState(false);
2942
+ const { termsOfServicesUrl } = useFlowUiSettings({ flow });
2943
+ const termsUrl = resolveFlowTermsUrl({ url: termsOfServicesUrl });
2944
+ return {
2945
+ hasAcceptedTerms,
2946
+ onCheckedChange: useCallback((checked) => {
2947
+ setHasAcceptedTerms(checked);
2948
+ }, []),
2949
+ termsUrl
2950
+ };
2951
+ };
2952
+
2953
+ //#endregion
2954
+ //#region src/flow/views/FlowDepositAddressView/useFlowDepositAddressTermsGate/useFlowDepositAddressTermsGate.ts
2955
+ /**
2956
+ * Holds the deposit details back until the payer accepts the terms and goes
2957
+ * on. The terms are only asked for once a quote is ready, so the payer sees
2958
+ * them when there is something to reveal, not while still picking a chain.
2959
+ *
2960
+ * @example
2961
+ * ```tsx
2962
+ * const { confirmTerms, isPromptShown } = useFlowDepositAddressTermsGate({
2963
+ * flow,
2964
+ * hasQuote: true,
2965
+ * });
2966
+ * ```
2967
+ * @param params.flow - The flow being funded.
2968
+ * @param params.hasQuote - Whether a quote with the deposit details is ready.
2969
+ * @returns The consent state, the confirm action and whether to prompt.
2970
+ * @see useFlowTermsConsent
2971
+ * @see FlowDepositAddressView
2972
+ * @notInstrumented
2973
+ */
2974
+ const useFlowDepositAddressTermsGate = ({ flow, hasQuote }) => {
2975
+ const consent = useFlowTermsConsent({ flow });
2976
+ const [hasConfirmedTerms, setHasConfirmedTerms] = useState(false);
2977
+ const confirmTerms = useCallback(() => {
2978
+ setHasConfirmedTerms(true);
2979
+ }, []);
2980
+ return {
2981
+ ...consent,
2982
+ confirmTerms,
2983
+ hasConfirmedTerms,
2984
+ isPromptShown: hasQuote && !hasConfirmedTerms
2985
+ };
2986
+ };
2987
+
2787
2988
  //#endregion
2788
2989
  //#region src/flow/utils/getFlowDepositAddressSourceTokenOptions/getFlowDepositAddressSourceTokenOptions.ts
2789
2990
  /**
@@ -3214,7 +3415,8 @@ const useFlowDepositAddressView = ({ flow, isQuoting, onSourceChange, refundAddr
3214
3415
  * exactly" amount card with a {@link CopyText} for the bare amount, a
3215
3416
  * {@link FlowPaymentLedger} of order total and network fee, a
3216
3417
  * {@link CopyField} for the address, and a {@link FlowStatusTray} that
3217
- * announces the awaited amount. Without a valid address for the picked chain
3418
+ * announces the awaited amount, all of which stay hidden until the payer
3419
+ * accepts the terms. Without a valid address for the picked chain
3218
3420
  * family in `refundAddresses`, a
3219
3421
  * {@link FlowRefundAddressSheet} slides up over the screen to ask for one before
3220
3422
  * anything is quoted.
@@ -3243,7 +3445,12 @@ const useFlowDepositAddressView = ({ flow, isQuoting, onSourceChange, refundAddr
3243
3445
  * @see FlowDepositAddressViewProps
3244
3446
  * @see getFlowDepositAddressSourceTokenOptions
3245
3447
  * @see FlowRefundAddressSheet
3448
+ * @see FlowTermsConsent
3246
3449
  * @copy title - The centered header title.
3450
+ * @copy consent - Consent sentence with a {terms} placeholder for the link.
3451
+ * @copy disclaimer - Consent sentence shown instead when no terms link is set.
3452
+ * @copy terms - Accessible text of the terms link.
3453
+ * @copy showDepositAddress - The button revealing the deposit details once the terms are accepted.
3247
3454
  * @copy selectChainLabel - The chain select's label.
3248
3455
  * @copy selectChainPlaceholder - The chain select's placeholder.
3249
3456
  * @copy selectTokenLabel - The token select's label.
@@ -3251,6 +3458,7 @@ const useFlowDepositAddressView = ({ flow, isQuoting, onSourceChange, refundAddr
3251
3458
  * @copy qrPlaceholder - The QR placeholder's loading message while no quote is live.
3252
3459
  * @copy qrQuoting - The QR placeholder's loading message while a quote is in flight.
3253
3460
  * @copy quoteFailed - The failure banner's message when the last source could not be quoted.
3461
+ * @copy qrAcceptTerms - The QR placeholder's message while a quote is ready but the payer has not agreed yet.
3254
3462
  * @copy qrLabel - The QR code's accessible label once the payment link is set.
3255
3463
  * @copy sendExactly - The amount card's small-caps title.
3256
3464
  * @copy amountLabel - What the amount's copy button copies, used in its accessible name.
@@ -3271,6 +3479,10 @@ const FlowDepositAddressView = ({ className, flow, isQuoting, onBack, onSourceCh
3271
3479
  onSourceChange,
3272
3480
  refundAddresses
3273
3481
  });
3482
+ const { confirmTerms, hasAcceptedTerms, hasConfirmedTerms, isPromptShown, onCheckedChange, termsUrl } = useFlowDepositAddressTermsGate({
3483
+ flow,
3484
+ hasQuote: quoteDetails !== void 0
3485
+ });
3274
3486
  if (retryLoadSourceTokenOptions !== void 0) return /* @__PURE__ */ jsx(FlowLoadError, {
3275
3487
  className,
3276
3488
  isRetrying: isRetryingSourceTokenOptions,
@@ -3287,6 +3499,7 @@ const FlowDepositAddressView = ({ className, flow, isQuoting, onBack, onSourceCh
3287
3499
  id: token.address,
3288
3500
  name: token.symbol
3289
3501
  }));
3502
+ const revealedQuoteDetails = hasConfirmedTerms ? quoteDetails : void 0;
3290
3503
  const ledgerLines = [];
3291
3504
  if (quoteDetails !== void 0) {
3292
3505
  ledgerLines.push({
@@ -3300,10 +3513,10 @@ const FlowDepositAddressView = ({ className, flow, isQuoting, onBack, onSourceCh
3300
3513
  }
3301
3514
  return /* @__PURE__ */ jsx(FlowStatusTray, {
3302
3515
  className,
3303
- status: quoteDetails === void 0 ? void 0 : interpolateText({
3516
+ status: revealedQuoteDetails === void 0 ? void 0 : interpolateText({
3304
3517
  template: text("waitingForAmount"),
3305
3518
  token: "{amount}",
3306
- value: quoteDetails.displayTokenAmount
3519
+ value: revealedQuoteDetails.displayTokenAmount
3307
3520
  }),
3308
3521
  children: /* @__PURE__ */ jsx(Panel, {
3309
3522
  onBack,
@@ -3333,12 +3546,16 @@ const FlowDepositAddressView = ({ className, flow, isQuoting, onBack, onSourceCh
3333
3546
  }),
3334
3547
  quoteFailed === true && /* @__PURE__ */ jsx(FlowErrorBanner, { message: text("quoteFailed") }),
3335
3548
  /* @__PURE__ */ jsx(QRCode, {
3336
- label: quoteDetails !== void 0 ? text("qrLabel") : void 0,
3337
- loadingMessage: isQuoting === true ? text("qrQuoting") : text("qrPlaceholder"),
3549
+ label: revealedQuoteDetails !== void 0 ? text("qrLabel") : void 0,
3550
+ loadingMessage: text(getFlowDepositAddressQrMessageKey({
3551
+ areDetailsRevealed: hasConfirmedTerms,
3552
+ hasQuote: quoteDetails !== void 0,
3553
+ isQuoting: isQuoting === true
3554
+ })),
3338
3555
  logoSrc: qrLogoUrl,
3339
- value: quoteDetails?.depositUri
3556
+ value: revealedQuoteDetails?.depositUri
3340
3557
  }),
3341
- quoteDetails !== void 0 && /* @__PURE__ */ jsxs("div", {
3558
+ revealedQuoteDetails !== void 0 && /* @__PURE__ */ jsxs("div", {
3342
3559
  "data-slot": "dyn-flow-deposit-address-view-details",
3343
3560
  children: [
3344
3561
  /* @__PURE__ */ jsx(FlowPill, { children: /* @__PURE__ */ jsxs("div", {
@@ -3351,25 +3568,40 @@ const FlowDepositAddressView = ({ className, flow, isQuoting, onBack, onSourceCh
3351
3568
  /* @__PURE__ */ jsx("span", {
3352
3569
  "data-slot": "dyn-flow-deposit-address-view-amount-value",
3353
3570
  children: /* @__PURE__ */ jsx(CopyText, {
3354
- copyValue: quoteDetails.tokenAmount,
3355
- display: quoteDetails.displayTokenAmount,
3571
+ copyValue: revealedQuoteDetails.tokenAmount,
3572
+ display: revealedQuoteDetails.displayTokenAmount,
3356
3573
  label: text("amountLabel")
3357
3574
  })
3358
3575
  }),
3359
- quoteDetails.total !== void 0 && /* @__PURE__ */ jsx("span", {
3576
+ revealedQuoteDetails.total !== void 0 && /* @__PURE__ */ jsx("span", {
3360
3577
  "data-slot": "dyn-flow-deposit-address-view-amount-fiat",
3361
- children: quoteDetails.total
3578
+ children: revealedQuoteDetails.total
3362
3579
  })
3363
3580
  ]
3364
3581
  }) }),
3365
3582
  ledgerLines.length > 0 && /* @__PURE__ */ jsx(FlowPaymentLedger, { lines: ledgerLines }),
3366
3583
  /* @__PURE__ */ jsx(CopyField, {
3367
- copyValue: quoteDetails.depositAddress,
3368
- display: quoteDetails.depositAddress,
3584
+ copyValue: revealedQuoteDetails.depositAddress,
3585
+ display: revealedQuoteDetails.depositAddress,
3369
3586
  label: text("toThisAddress")
3370
3587
  })
3371
3588
  ]
3372
3589
  }),
3590
+ isPromptShown && /* @__PURE__ */ jsxs("div", {
3591
+ "data-slot": "dyn-flow-deposit-address-view-terms",
3592
+ children: [/* @__PURE__ */ jsx(FlowTermsConsent, {
3593
+ checked: hasAcceptedTerms,
3594
+ consentText: text("consent"),
3595
+ disclaimerText: text("disclaimer"),
3596
+ onCheckedChange,
3597
+ termsText: text("terms"),
3598
+ termsUrl
3599
+ }), /* @__PURE__ */ jsx(Button, {
3600
+ disabled: !hasAcceptedTerms,
3601
+ onClick: confirmTerms,
3602
+ children: text("showDepositAddress")
3603
+ })]
3604
+ }),
3373
3605
  /* @__PURE__ */ jsx(AnimatePresence, {
3374
3606
  initial: false,
3375
3607
  children: refundPrompt !== void 0 && /* @__PURE__ */ jsx(FlowRefundAddressSheet, {
@@ -4009,13 +4241,16 @@ const getFlowExchangeViewStatusKey = ({ hasOpened, isRenewing }) => {
4009
4241
  //#region src/flow/views/FlowExchangeView/FlowExchangeView.text.ts
4010
4242
  /** Default text for {@link FlowExchangeView}. */
4011
4243
  const FLOW_EXCHANGE_VIEW_TEXT = {
4244
+ consent: FLOW_TERMS_CONSENT_DEFAULT_TEXT.consent,
4012
4245
  continue: "Continue to {exchange}",
4246
+ disclaimer: FLOW_TERMS_CONSENT_DEFAULT_TEXT.disclaimer,
4013
4247
  heading: "Buy {amount} on {exchange}",
4014
4248
  incompatibleError: FLOW_CHOOSE_EXCHANGE_VIEW_TEXT.incompatibleError,
4015
4249
  openHint: "Opens {exchange} in a new tab.",
4016
4250
  renewingStatus: "Getting a new {exchange} link",
4017
4251
  reopen: "Reopen {exchange}",
4018
4252
  temporaryError: FLOW_CHOOSE_EXCHANGE_VIEW_TEXT.temporaryError,
4253
+ terms: FLOW_TERMS_CONSENT_DEFAULT_TEXT.terms,
4019
4254
  title: "Pay with {exchange}",
4020
4255
  unavailableError: FLOW_CHOOSE_EXCHANGE_VIEW_TEXT.unavailableError,
4021
4256
  unknownError: FLOW_CHOOSE_EXCHANGE_VIEW_TEXT.unknownError,
@@ -4028,7 +4263,8 @@ const FLOW_EXCHANGE_VIEW_TEXT = {
4028
4263
  /**
4029
4264
  * The Flow screen where the payer buys the payment amount on an exchange,
4030
4265
  * then waits on it until the exchange confirms the purchase; it shows
4031
- * progress and failures while a new link is fetched.
4266
+ * progress and failures while a new link is fetched. The payer accepts the
4267
+ * terms to enable Continue, or Reopen when the screen resumes already opened.
4032
4268
  *
4033
4269
  * @example
4034
4270
  * ```tsx
@@ -4055,13 +4291,17 @@ const FLOW_EXCHANGE_VIEW_TEXT = {
4055
4291
  * @see FlowExchangeViewProps
4056
4292
  * @see FlowChooseExchangeView
4057
4293
  * @see FlowStatusTray
4294
+ * @see FlowTermsConsent
4295
+ * @copy consent - Consent sentence with a {terms} placeholder for the link.
4058
4296
  * @copy continue - The primary action opening {exchange}.
4297
+ * @copy disclaimer - Consent sentence shown instead when no terms link is set.
4059
4298
  * @copy heading - What the payer buys: {amount} on {exchange}.
4060
4299
  * @copy incompatibleError - Shown when {exchange} can't be used for this payment.
4061
4300
  * @copy openHint - Says {exchange} opens in a new tab.
4062
4301
  * @copy renewingStatus - The progress line while a new {exchange} link is fetched.
4063
4302
  * @copy reopen - The secondary action opening {exchange} again.
4064
4303
  * @copy temporaryError - Shown when {exchange} isn't responding.
4304
+ * @copy terms - Accessible text of the terms link.
4065
4305
  * @copy title - The centered header title naming {exchange}.
4066
4306
  * @copy unavailableError - Shown when {exchange} isn't offered for this payment.
4067
4307
  * @copy unknownError - Shown when a new {exchange} link failed unexpectedly.
@@ -4079,6 +4319,8 @@ const FlowExchangeView = ({ className, exchange, flow, hasOpened, isRenewing = f
4079
4319
  token: FLOW_EXCHANGE_NAME_TOKEN,
4080
4320
  value: exchange.label
4081
4321
  });
4322
+ const { hasAcceptedTerms, onCheckedChange, termsUrl } = useFlowTermsConsent({ flow });
4323
+ const isConsentShown = !hasOpened || !hasAcceptedTerms;
4082
4324
  const statusKey = getFlowExchangeViewStatusKey({
4083
4325
  hasOpened,
4084
4326
  isRenewing
@@ -4109,15 +4351,24 @@ const FlowExchangeView = ({ className, exchange, flow, hasOpened, isRenewing = f
4109
4351
  })
4110
4352
  })
4111
4353
  }),
4354
+ isConsentShown && /* @__PURE__ */ jsx(FlowTermsConsent, {
4355
+ checked: hasAcceptedTerms,
4356
+ consentText: text("consent"),
4357
+ disclaimerText: text("disclaimer"),
4358
+ disabled: isRenewing,
4359
+ onCheckedChange,
4360
+ termsText: text("terms"),
4361
+ termsUrl
4362
+ }),
4112
4363
  /* @__PURE__ */ jsx("div", {
4113
4364
  "data-slot": "dyn-flow-exchange-view-actions",
4114
4365
  children: hasOpened ? /* @__PURE__ */ jsx(Button, {
4115
- disabled: isRenewing,
4366
+ disabled: isRenewing || !hasAcceptedTerms,
4116
4367
  onClick: onOpen,
4117
4368
  variant: "secondary",
4118
4369
  children: withExchange("reopen")
4119
4370
  }) : /* @__PURE__ */ jsx(Button, {
4120
- disabled: isRenewing,
4371
+ disabled: isRenewing || !hasAcceptedTerms,
4121
4372
  onClick: onOpen,
4122
4373
  children: withExchange("continue")
4123
4374
  })
@@ -5478,7 +5729,8 @@ const SUBMIT_ERROR_ACTION_TEXT_KEY = {
5478
5729
  const FLOW_REVIEW_PAYMENT_VIEW_TEXT = {
5479
5730
  back: "Back",
5480
5731
  confirm: "Confirm payment",
5481
- consent: "I agree to the {terms}",
5732
+ consent: FLOW_TERMS_CONSENT_DEFAULT_TEXT.consent,
5733
+ disclaimer: FLOW_TERMS_CONSENT_DEFAULT_TEXT.disclaimer,
5482
5734
  fees: "Fees",
5483
5735
  getNewQuote: "Get a new quote",
5484
5736
  orderTotal: "Order total",
@@ -5488,7 +5740,7 @@ const FLOW_REVIEW_PAYMENT_VIEW_TEXT = {
5488
5740
  submitErrorGasBalance: FLOW_SUBMIT_ERROR_DEFAULT_TEXT.gasBalance,
5489
5741
  submitErrorGeneric: FLOW_SUBMIT_ERROR_DEFAULT_TEXT.generic,
5490
5742
  submitErrorTransferBalance: FLOW_SUBMIT_ERROR_DEFAULT_TEXT.transferBalance,
5491
- terms: "Terms of Service",
5743
+ terms: FLOW_TERMS_CONSENT_DEFAULT_TEXT.terms,
5492
5744
  title: "Review your payment",
5493
5745
  total: "Total",
5494
5746
  tryAgain: "Try again",
@@ -5565,59 +5817,37 @@ const useQuoteCountdown = ({ expiresAt }) => {
5565
5817
  //#endregion
5566
5818
  //#region src/flow/views/FlowReviewPaymentView/useFlowReviewPaymentView/useFlowReviewPaymentView.ts
5567
5819
  /**
5568
- * Tracks terms acceptance and the quote's expiry, and derives whether the
5569
- * payment can be confirmed and which inline error to show.
5820
+ * Tracks the quote's expiry, and derives whether the payment can be confirmed
5821
+ * and which inline error to show.
5570
5822
  * @example
5571
5823
  * ```tsx
5572
- * const { canConfirmPayment, hasAcceptedTerms, onCheckedChange } = useFlowReviewPaymentView({
5573
- * consentText: 'I agree to the {terms}', flow,
5824
+ * const { canConfirmPayment, errorType } = useFlowReviewPaymentView({
5825
+ * flow, hasAcceptedTerms: true,
5574
5826
  * isConfirmingPayment: false, isRequoting: false,
5575
5827
  * });
5576
5828
  * ```
5577
- * @param params.consentText - Localized sentence containing {terms}.
5578
5829
  * @param params.flow - SDK flow being reviewed.
5830
+ * @param params.hasAcceptedTerms - Whether the payer ticked the terms consent.
5579
5831
  * @param params.isConfirmingPayment - Whether confirmation has started.
5580
5832
  * @param params.isRequoting - Whether a new quote is being fetched.
5581
5833
  * @param params.onRequote - Fetches a new quote once the current one expires.
5582
5834
  * @param params.onSubmitErrorAction - The recovery action for the last submission's failure.
5583
5835
  * @param params.submitTransactionErrorType - The kind of the last submission's failure.
5584
- * @returns Consent controls, safe terms URL, the quote's time left, the inline error and confirmation availability.
5836
+ * @returns The quote's time left, the inline error and confirmation availability.
5585
5837
  * @see FlowReviewPaymentView
5586
- * @see assertSafeNavigationUrl
5838
+ * @see useFlowTermsConsent
5587
5839
  * @see useQuoteCountdown
5588
5840
  * @notInstrumented
5589
5841
  */
5590
- const useFlowReviewPaymentView = ({ consentText, flow, isConfirmingPayment, isRequoting, onRequote, onSubmitErrorAction, submitTransactionErrorType }) => {
5591
- const [hasAcceptedTerms, setHasAcceptedTerms] = useState(false);
5842
+ const useFlowReviewPaymentView = ({ flow, hasAcceptedTerms, isConfirmingPayment, isRequoting, onRequote, onSubmitErrorAction, submitTransactionErrorType }) => {
5592
5843
  const { isQuoteExpired, remainingSeconds } = useQuoteCountdown({ expiresAt: flow.quote?.expiresAt });
5593
5844
  const errorType = submitTransactionErrorType ?? (isQuoteExpired && !isConfirmingPayment ? "quote-expired" : void 0);
5594
- const recoveryAction = submitTransactionErrorType === void 0 ? onRequote : onSubmitErrorAction;
5595
- const { termsOfServicesUrl } = useFlowUiSettings({ flow });
5596
- let termsUrl;
5597
- try {
5598
- if (termsOfServicesUrl !== void 0) {
5599
- const parsedTermsUrl = new URL(termsOfServicesUrl);
5600
- assertSafeNavigationUrl(parsedTermsUrl);
5601
- termsUrl = parsedTermsUrl.href;
5602
- }
5603
- } catch {
5604
- termsUrl = void 0;
5605
- }
5606
- const [beforeTermsText, afterTermsText] = consentText.split("{terms}");
5607
- const onCheckedChange = useCallback((checked) => {
5608
- setHasAcceptedTerms(checked);
5609
- }, []);
5610
5845
  return {
5611
- afterTermsText,
5612
- beforeTermsText,
5613
- canConfirmPayment: !isConfirmingPayment && !isRequoting && errorType === void 0 && (termsUrl === void 0 || hasAcceptedTerms),
5614
- errorAction: isConfirmingPayment || isRequoting ? void 0 : recoveryAction,
5846
+ canConfirmPayment: !isConfirmingPayment && !isRequoting && errorType === void 0 && hasAcceptedTerms,
5847
+ errorAction: isConfirmingPayment || isRequoting ? void 0 : submitTransactionErrorType === void 0 ? onRequote : onSubmitErrorAction,
5615
5848
  errorType,
5616
- hasAcceptedTerms,
5617
- onCheckedChange,
5618
5849
  paymentData: formatFlowPayment({ flow }),
5619
- quoteTimeLeft: remainingSeconds === void 0 || isConfirmingPayment ? void 0 : formatQuoteTimeLeft({ seconds: remainingSeconds }),
5620
- termsUrl
5850
+ quoteTimeLeft: remainingSeconds === void 0 || isConfirmingPayment ? void 0 : formatQuoteTimeLeft({ seconds: remainingSeconds })
5621
5851
  };
5622
5852
  };
5623
5853
 
@@ -5625,7 +5855,7 @@ const useFlowReviewPaymentView = ({ consentText, flow, isConfirmingPayment, isRe
5625
5855
  //#region src/flow/views/FlowReviewPaymentView/FlowReviewPaymentView.tsx
5626
5856
  /**
5627
5857
  * The Flow review screen: quoted payment assets, fee estimates, and
5628
- * optional terms consent before confirming payment through the parent. It
5858
+ * terms consent before confirming payment through the parent. It
5629
5859
  * counts down the quote and, once it expires, offers a new one instead.
5630
5860
  * @example
5631
5861
  * ```tsx
@@ -5648,9 +5878,11 @@ const useFlowReviewPaymentView = ({ consentText, flow, isConfirmingPayment, isRe
5648
5878
  * @see FlowReviewPaymentViewProps
5649
5879
  * @see FlowPaymentSwapTile
5650
5880
  * @see FlowPaymentLedger
5881
+ * @see FlowTermsConsent
5651
5882
  * @copy back - Footer action returning to the previous step.
5652
5883
  * @copy confirm - Action confirming the reviewed payment.
5653
5884
  * @copy consent - Consent sentence with a {terms} placeholder for the link.
5885
+ * @copy disclaimer - Consent sentence shown instead when no terms link is set.
5654
5886
  * @copy fees - Label for quoted fees.
5655
5887
  * @copy orderTotal - Ledger label for the order amount before fees.
5656
5888
  * @copy quoteExpiresIn - Countdown at the bottom of the panel; `{time}` is replaced by the time left.
@@ -5672,9 +5904,10 @@ const FlowReviewPaymentView = ({ className, onBack, onConfirmPayment, onSubmitEr
5672
5904
  defaults: FLOW_REVIEW_PAYMENT_VIEW_TEXT,
5673
5905
  slot: "dyn-flow-review-payment-view"
5674
5906
  });
5675
- const { afterTermsText, beforeTermsText, canConfirmPayment, errorAction, errorType, hasAcceptedTerms, onCheckedChange, paymentData, quoteTimeLeft, termsUrl } = useFlowReviewPaymentView({
5676
- consentText: text("consent"),
5907
+ const { hasAcceptedTerms, onCheckedChange, termsUrl } = useFlowTermsConsent({ flow });
5908
+ const { canConfirmPayment, errorAction, errorType, paymentData, quoteTimeLeft } = useFlowReviewPaymentView({
5677
5909
  flow,
5910
+ hasAcceptedTerms,
5678
5911
  isConfirmingPayment,
5679
5912
  isRequoting,
5680
5913
  onRequote,
@@ -5715,21 +5948,14 @@ const FlowReviewPaymentView = ({ className, onBack, onConfirmPayment, onSubmitEr
5715
5948
  }
5716
5949
  })
5717
5950
  }),
5718
- termsUrl !== void 0 && /* @__PURE__ */ jsxs(CheckboxField, {
5951
+ /* @__PURE__ */ jsx(FlowTermsConsent, {
5719
5952
  checked: hasAcceptedTerms,
5953
+ consentText: text("consent"),
5954
+ disclaimerText: text("disclaimer"),
5720
5955
  disabled: isLocked,
5721
- onCheckedChange: (checked) => onCheckedChange(checked === true),
5722
- children: [
5723
- beforeTermsText,
5724
- /* @__PURE__ */ jsx("a", {
5725
- "data-slot": "dyn-flow-review-payment-view-terms",
5726
- href: termsUrl,
5727
- rel: "noopener noreferrer",
5728
- target: "_blank",
5729
- children: text("terms")
5730
- }),
5731
- afterTermsText
5732
- ]
5956
+ onCheckedChange,
5957
+ termsText: text("terms"),
5958
+ termsUrl
5733
5959
  }),
5734
5960
  errorType !== void 0 && /* @__PURE__ */ jsx(FlowErrorBanner, {
5735
5961
  actionLabel: text(SUBMIT_ERROR_ACTION_TEXT_KEY[errorType]),