@coinbase/cdp-react 0.0.28 → 0.0.30

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.
package/README.md CHANGED
@@ -8,6 +8,8 @@ the CDP frontend SDK.
8
8
  - {@link SignOutButton | `SignOutButton`} - a sign out button
9
9
  - {@link AuthButton | `AuthButton`} - the `SignOutButton` when logged in, and the `SignInModal` when logged out
10
10
  - {@link SendTransactionButton | `SendTransactionButton`} - a button that signs and sends a transaction
11
+ - {@link Fund | `Fund`} - the fund flow
12
+ - {@link FundModal | `FundModal`} - a button that triggers a modal with the fund flow
11
13
 
12
14
  ## Quickstart
13
15
 
@@ -1 +1 @@
1
- .AmountInput-module__amount-input___24NlC{box-sizing:border-box;color:var(--cdp-web-colors-page-text-default);font-family:var(--cdp-web-font-family-sans);font-size:var(--cdp-web-font-size-base);line-height:1.2;display:flex;align-items:center;justify-content:flex-start;gap:.25rem;overflow:hidden;position:relative;width:100%}.AmountInput-module__input___Af-R1{appearance:textfield;background-color:transparent;color:var(--cdp-web-colors-page-text-default);border:0;font-size:1em;font-family:var(--cdp-web-font-family-sans);font-weight:600;margin:0;outline:0;padding:0;width:1em}.AmountInput-module__input___Af-R1::placeholder{color:var(--cdp-web-colors-page-text-muted)}.AmountInput-module__amount-unit___48d60{font-size:3.75em;font-weight:600;display:flex;align-items:center;justify-content:flex-start}.AmountInput-module__amount-unit___48d60.AmountInput-module__visible___qmvT0{cursor:text;transform-origin:left center}.AmountInput-module__hidden___cO0sQ{visibility:hidden;position:absolute;pointer-events:none}.AmountInput-module__unit___-zmGz{color:var(--cdp-web-colors-page-text-muted);text-transform:uppercase}
1
+ .AmountInput-module__amount-input___24NlC{box-sizing:border-box;color:var(--cdp-web-colors-page-text-default);font-family:var(--cdp-web-font-family-sans);font-size:var(--cdp-web-font-size-base);line-height:1.2;display:flex;align-items:center;justify-content:flex-start;gap:.25rem;overflow:hidden;position:relative;width:100%}.AmountInput-module__input___Af-R1{appearance:textfield;background-color:transparent;color:var(--cdp-web-colors-page-text-default);border:0;font-size:1em;font-family:var(--cdp-web-font-family-sans);font-weight:500;margin:0;outline:0;padding:0;width:1em}.AmountInput-module__input___Af-R1::placeholder{color:var(--cdp-web-colors-page-text-muted)}.AmountInput-module__amount-unit___48d60{font-size:3.75em;font-weight:500;display:flex;align-items:center;justify-content:flex-start}.AmountInput-module__amount-unit___48d60.AmountInput-module__visible___qmvT0{cursor:text;transform-origin:left center}.AmountInput-module__hidden___cO0sQ{visibility:hidden;position:absolute;pointer-events:none}.AmountInput-module__unit___-zmGz{color:var(--cdp-web-colors-page-text-muted)}
@@ -1 +1 @@
1
- .Button-module__btn___Wj6Dr{--cdp-web-button-ring-color: transparent;--cdp-web-button-ring-width: 2px;--cdp-web-button-ring-inset-color: transparent;--cdp-web-button-ring-inset-width: 2px;border-radius:9999em}.Button-module__link-primary___6Zgkh,.Button-module__link-secondary___S0Qdo{padding:0 .25em}.Button-module__primary___WGT--{background-color:var(--cdp-web-colors-cta-primary-bg-default);color:var(--cdp-web-colors-cta-primary-text-default)}.Button-module__primary___WGT--:hover{background-color:var(--cdp-web-colors-cta-primary-bg-hover);color:var(--cdp-web-colors-cta-primary-text-hover)}.Button-module__primary___WGT--:focus{outline:none}.Button-module__primary___WGT--:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-cta-primary-border-focus);--cdp-web-button-ring-inset-color: var(--cdp-web-colors-page-bg-default);outline:none}.Button-module__secondary___Fx0LJ{background-color:var(--cdp-web-colors-cta-secondary-bg-default);color:var(--cdp-web-colors-cta-secondary-text-default)}.Button-module__secondary___Fx0LJ:hover{background-color:var(--cdp-web-colors-cta-secondary-bg-hover);color:var(--cdp-web-colors-cta-secondary-text-hover)}.Button-module__secondary___Fx0LJ:focus{outline:none}.Button-module__secondary___Fx0LJ:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-cta-secondary-border-focus);--cdp-web-button-ring-inset-color: var(--cdp-web-colors-page-bg-default);outline:none}.Button-module__link-primary___6Zgkh,.Button-module__transparent-primary___iwWv5{background-color:transparent;color:var(--cdp-web-colors-link-primary-text-default)}.Button-module__link-primary___6Zgkh:hover,.Button-module__transparent-primary___iwWv5:hover{color:var(--cdp-web-colors-link-primary-text-hover)}.Button-module__link-primary___6Zgkh:focus,.Button-module__transparent-primary___iwWv5:focus{outline:none}.Button-module__link-primary___6Zgkh:focus-visible,.Button-module__transparent-primary___iwWv5:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-link-primary-text-default);outline:none}.Button-module__link-secondary___S0Qdo,.Button-module__transparent-secondary___GfRXu{background-color:transparent;color:var(--cdp-web-colors-link-secondary-text-default)}.Button-module__link-secondary___S0Qdo:hover,.Button-module__transparent-secondary___GfRXu:hover{color:var(--cdp-web-colors-link-secondary-text-hover)}.Button-module__link-secondary___S0Qdo:focus,.Button-module__transparent-secondary___GfRXu:focus{outline:none}.Button-module__link-secondary___S0Qdo:focus-visible,.Button-module__transparent-secondary___GfRXu:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-link-secondary-text-default);outline:none}.Button-module__control-btn___9Gkoz{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-input-border-default);--cdp-web-button-ring-inset-width: 1px;background-color:var(--cdp-web-colors-input-bg-default);border-radius:.5em;color:var(--cdp-web-colors-input-text-default);font-weight:400}.Button-module__control-btn___9Gkoz:focus{outline:none}.Button-module__control-btn___9Gkoz:focus-visible{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-input-border-focus);--cdp-web-button-ring-inset-width: 2px;outline:none}
1
+ .Button-module__btn___Wj6Dr{--cdp-web-button-ring-color: transparent;--cdp-web-button-ring-width: 2px;--cdp-web-button-ring-inset-color: transparent;--cdp-web-button-ring-inset-width: 2px;border-radius:9999em}.Button-module__link-primary___6Zgkh,.Button-module__link-secondary___S0Qdo{padding:0 .25em}.Button-module__primary___WGT--{background-color:var(--cdp-web-colors-cta-primary-bg-default);color:var(--cdp-web-colors-cta-primary-text-default)}.Button-module__primary___WGT--:hover{background-color:var(--cdp-web-colors-cta-primary-bg-hover);color:var(--cdp-web-colors-cta-primary-text-hover)}.Button-module__primary___WGT--:focus{outline:none}.Button-module__primary___WGT--:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-cta-primary-border-focus);--cdp-web-button-ring-inset-color: var(--cdp-web-colors-page-bg-default);outline:none}.Button-module__secondary___Fx0LJ{background-color:var(--cdp-web-colors-cta-secondary-bg-default);color:var(--cdp-web-colors-cta-secondary-text-default)}.Button-module__secondary___Fx0LJ:hover{background-color:var(--cdp-web-colors-cta-secondary-bg-hover);color:var(--cdp-web-colors-cta-secondary-text-hover)}.Button-module__secondary___Fx0LJ:focus{outline:none}.Button-module__secondary___Fx0LJ:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-cta-secondary-border-focus);--cdp-web-button-ring-inset-color: var(--cdp-web-colors-page-bg-default);outline:none}.Button-module__link-primary___6Zgkh,.Button-module__transparent-primary___iwWv5{background-color:transparent;color:var(--cdp-web-colors-link-primary-text-default)}.Button-module__link-primary___6Zgkh:hover,.Button-module__transparent-primary___iwWv5:hover{color:var(--cdp-web-colors-link-primary-text-hover)}.Button-module__link-primary___6Zgkh:focus,.Button-module__transparent-primary___iwWv5:focus{outline:none}.Button-module__link-primary___6Zgkh:focus-visible,.Button-module__transparent-primary___iwWv5:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-link-primary-text-default);outline:none}.Button-module__link-secondary___S0Qdo,.Button-module__transparent-secondary___GfRXu{background-color:transparent;color:var(--cdp-web-colors-link-secondary-text-default)}.Button-module__link-secondary___S0Qdo:hover,.Button-module__transparent-secondary___GfRXu:hover{color:var(--cdp-web-colors-link-secondary-text-hover)}.Button-module__link-secondary___S0Qdo:focus,.Button-module__transparent-secondary___GfRXu:focus{outline:none}.Button-module__link-secondary___S0Qdo:focus-visible,.Button-module__transparent-secondary___GfRXu:focus-visible{--cdp-web-button-ring-color: var(--cdp-web-colors-link-secondary-text-default);outline:none}.Button-module__control-btn___9Gkoz{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-select-trigger-border-default);--cdp-web-button-ring-inset-width: 1px;background-color:var(--cdp-web-colors-select-trigger-bg-default);border-radius:.5em;color:var(--cdp-web-colors-select-trigger-text-default);font-weight:400}.Button-module__control-btn___9Gkoz:focus{outline:none}.Button-module__control-btn___9Gkoz:focus-visible{--cdp-web-button-ring-inset-color: var(--cdp-web-colors-input-border-focus);--cdp-web-button-ring-inset-width: 2px;outline:none}
@@ -1,68 +1,64 @@
1
1
  import { jsx as r, jsxs as H } from "react/jsx-runtime";
2
- import { useRef as f, useState as p, useCallback as a, useEffect as h, useMemo as J } from "react";
2
+ import { useRef as c, useState as h, useCallback as s, useEffect as y, useMemo as J } from "react";
3
3
  import { Button as Y } from "../ui/Button/index.js";
4
4
  import { SwitchFadeTransition as Q } from "../ui/SwitchFadeTransition/index.js";
5
5
  import { useTimer as X } from "../../hooks/useTimer.js";
6
6
  import { formatFiat as w } from "../../utils/formatFiat.js";
7
7
  import { openPopup as Z } from "../../utils/openPopup.js";
8
- import { FundAmountInput as O } from "./components/FundAmountInput.js";
9
- import { FundErrorScreen as tt } from "./components/FundErrorScreen.js";
10
- import { FundPaymentMethods as et } from "./components/FundPaymentMethods.js";
11
- import { FundPresetAmountInputs as rt } from "./components/FundPresetAmountInputs.js";
12
- import { FundTransactionStatus as nt } from "./components/FundTransactionStatus.js";
13
- import { useFundContext as ot } from "./FundProvider.js";
8
+ import { FundAmountInput as tt } from "./components/FundAmountInput.js";
9
+ import { FundErrorScreen as et } from "./components/FundErrorScreen.js";
10
+ import { FundPaymentMethods as rt } from "./components/FundPaymentMethods.js";
11
+ import { FundPresetAmountInputs as nt } from "./components/FundPresetAmountInputs.js";
12
+ import { FundTransactionStatus as ot } from "./components/FundTransactionStatus.js";
13
+ import { useFundContext as st } from "./FundProvider.js";
14
14
  import { usePopupMonitor as it } from "./hooks/usePopupMonitor.js";
15
- import '../../assets/FundForm.css';const at = "FundForm-module__view___5V1qO", st = "FundForm-module__form___TIzVJ", B = {
15
+ import '../../assets/FundForm.css';const at = "FundForm-module__view___5V1qO", ut = "FundForm-module__form___TIzVJ", B = {
16
16
  view: at,
17
- form: st
18
- }, mt = ["form", "error", "transaction-status"], _t = ({
19
- className: E = "",
20
- children: y,
21
- onPopupClose: A,
22
- onPopupOpen: M,
17
+ form: ut
18
+ }, mt = ["form", "error", "transaction-status"], Ft = ({
19
+ className: T = "",
20
+ children: A,
21
+ onPopupClose: N,
22
+ onPopupOpen: S,
23
23
  onSubmit: I,
24
24
  openIn: V,
25
25
  submitLabel: D,
26
- unmountOnTransactionError: s = !1,
27
- unmountOnTransactionSuccess: m = !1,
28
- unmount: u,
29
- ...T
26
+ unmountOnTransactionError: d = !1,
27
+ unmountOnTransactionSuccess: p = !1,
28
+ unmount: a,
29
+ ...$
30
30
  }) => {
31
- const { state: t, dispatch: N, fetchBuyUrl: P } = ot(), g = f(t.fiatAmount === void 0 ? NaN : t.fiatAmount), [$, S] = p(!1), [k, _] = p(!1), F = f(null), [j, K] = p(null), v = f(null), C = f(null), o = f(null), {
32
- timeRemaining: d,
33
- start: R,
34
- reset: U
35
- } = X(), n = a((e) => {
36
- C.current !== e && (C.current = e, v.current?.transition.toggle(e));
37
- }, []), l = a(() => {
38
- u && (o.current === "transactionSuccess" && m || o.current === "error" && s) ? u() : n("form"), o.current = null, N({
31
+ const { state: t, dispatch: M, fetchBuyUrl: P } = st(), g = c(t.fiatAmount === void 0 ? NaN : t.fiatAmount), [k, _] = h(!1), [j, F] = h(!1), E = c(null), [K, L] = h(null), b = c(null), U = c(null), u = c(null), l = s(
32
+ (e) => (e === "transactionSuccess" || e === "transactionSubmitted") && p || e === "error" && d,
33
+ [p, d]
34
+ ), {
35
+ timeRemaining: f,
36
+ start: v,
37
+ reset: C
38
+ } = X(), n = s((e) => {
39
+ U.current !== e && (U.current = e, b.current?.transition.toggle(e));
40
+ }, []), m = s(() => {
41
+ a && l(u.current) ? a() : n("form"), u.current = null, M({
39
42
  type: "SET_TRANSACTION_STATUS",
40
43
  payload: { transactionStatus: { statusName: "init", statusData: null } }
41
44
  });
42
- }, [n, N, u, m, s]), L = a(() => {
43
- u && (o.current === "transactionSuccess" && m || o.current === "error" && s) ? R(3) : o.current === null && l(), A?.();
44
- }, [
45
- R,
46
- A,
47
- l,
48
- u,
49
- m,
50
- s
51
- ]);
52
- h(() => {
53
- d !== null && d <= 0 && (l(), U());
54
- }, [d, l, U]), h(() => {
55
- (t.transactionStatus.statusName === "transactionSuccess" || t.transactionStatus.statusName === "error") && (o.current = t.transactionStatus.statusName);
56
- }, [t.transactionStatus.statusName]), h(() => {
45
+ }, [n, M, a, l]), O = s(() => {
46
+ a && l(u.current) ? v(3) : u.current === null && m(), N?.();
47
+ }, [v, N, m, a, l]);
48
+ y(() => {
49
+ f !== null && f <= 0 && (m(), C());
50
+ }, [f, m, C]), y(() => {
51
+ (t.transactionStatus.statusName === "transactionSubmitted" || t.transactionStatus.statusName === "transactionSuccess" || t.transactionStatus.statusName === "error") && (u.current = t.transactionStatus.statusName);
52
+ }, [t.transactionStatus.statusName]), y(() => {
57
53
  t.paymentMethodsError?.message && n("error");
58
54
  }, [t.paymentMethodsError?.message, n]);
59
- const { startPopupMonitor: b } = it(L), W = a(
55
+ const { startPopupMonitor: R } = it(O), W = s(
60
56
  (e) => {
61
- e && (n("transaction-status"), b(e), M?.(e));
57
+ e && (n("transaction-status"), R(e), S?.(e));
62
58
  },
63
- [M, b, n]
64
- ), q = a(() => {
65
- (t.fiatAmount === void 0 || isNaN(t.fiatAmount)) && isNaN(g.current) || t.fiatAmount === g.current || S(!0);
59
+ [S, R, n]
60
+ ), q = s(() => {
61
+ (t.fiatAmount === void 0 || isNaN(t.fiatAmount)) && isNaN(g.current) || t.fiatAmount === g.current || _(!0);
66
62
  }, [t.fiatAmount]), x = J(() => {
67
63
  if (t.fiatAmount === void 0 || isNaN(t.fiatAmount))
68
64
  return "Enter an amount";
@@ -77,7 +73,7 @@ import '../../assets/FundForm.css';const at = "FundForm-module__view___5V1qO", s
77
73
  t.locale,
78
74
  t.selectedPaymentMethod?.minAmount,
79
75
  t.selectedPaymentMethod?.maxAmount
80
- ]), z = a(async () => {
76
+ ]), z = s(async () => {
81
77
  if (!(t.fiatAmount === void 0 || isNaN(t.fiatAmount) || !t.selectedPaymentMethod?.id))
82
78
  return P(
83
79
  {
@@ -85,7 +81,7 @@ import '../../assets/FundForm.css';const at = "FundForm-module__view___5V1qO", s
85
81
  paymentAmount: t.fiatAmount
86
82
  },
87
83
  (e) => {
88
- K({
84
+ L({
89
85
  code: e?.code || "UNKNOWN_BUY_URL_ERROR",
90
86
  message: e?.debugMessage || "Something went wrong fetching the buy url"
91
87
  }), n("error");
@@ -93,17 +89,17 @@ import '../../assets/FundForm.css';const at = "FundForm-module__view___5V1qO", s
93
89
  );
94
90
  }, [t.fiatAmount, t.selectedPaymentMethod?.id, P, n]), G = async (e) => {
95
91
  if (e.preventDefault(), x) {
96
- S(!0), F.current?.focus();
92
+ _(!0), E.current?.focus();
97
93
  return;
98
94
  }
99
- I?.(e), _(!0);
100
- const c = await z();
101
- if (_(!1), c)
95
+ I?.(e), F(!0);
96
+ const i = await z();
97
+ if (F(!1), i)
102
98
  if (V === "tab")
103
- window.open(c, "_blank");
99
+ window.open(i, "_blank");
104
100
  else {
105
- const i = Z({ url: c, width: 460, height: 720 });
106
- W(i);
101
+ const o = Z({ url: i, width: 460, height: 720 });
102
+ W(o);
107
103
  }
108
104
  };
109
105
  return /* @__PURE__ */ r(
@@ -113,44 +109,44 @@ import '../../assets/FundForm.css';const at = "FundForm-module__view___5V1qO", s
113
109
  timeout: 250,
114
110
  items: mt,
115
111
  initialEntered: !0,
116
- transitionRef: v,
117
- children: ({ itemKey: e, ...c }) => {
118
- let i = null;
119
- return e === "form" && (i = /* @__PURE__ */ H("form", { className: `${B.form} ${E}`, onSubmit: G, ...T, children: [
112
+ transitionRef: b,
113
+ children: ({ itemKey: e, ...i }) => {
114
+ let o = null;
115
+ return e === "form" && (o = /* @__PURE__ */ H("form", { className: `${B.form} ${T}`, onSubmit: G, ...$, children: [
120
116
  /* @__PURE__ */ r("div", { children: /* @__PURE__ */ r(
121
- O,
117
+ tt,
122
118
  {
123
- ref: F,
124
- error: $ ? x : void 0,
119
+ ref: E,
120
+ error: k ? x : void 0,
125
121
  onBlur: q
126
122
  }
127
123
  ) }),
124
+ /* @__PURE__ */ r(nt, {}),
128
125
  /* @__PURE__ */ r(rt, {}),
129
- /* @__PURE__ */ r(et, {}),
130
126
  /* @__PURE__ */ r(
131
127
  Y,
132
128
  {
133
129
  variant: "primary",
134
130
  type: "submit",
135
- isPending: k,
131
+ isPending: j,
136
132
  pendingLabel: "Getting purchase link",
137
133
  children: D || "Deposit"
138
134
  }
139
135
  )
140
- ] })), e === "error" && (i = /* @__PURE__ */ r(tt, { error: t.paymentMethodsError || j })), e === "transaction-status" && (i = /* @__PURE__ */ r(
141
- nt,
136
+ ] })), e === "error" && (o = /* @__PURE__ */ r(et, { error: t.paymentMethodsError || K })), e === "transaction-status" && (o = /* @__PURE__ */ r(
137
+ ot,
142
138
  {
143
- unmountOnSuccess: m,
144
- unmountOnError: s,
145
- reset: l,
146
- timeRemaining: d
139
+ unmountOnSuccess: p,
140
+ unmountOnError: d,
141
+ reset: m,
142
+ timeRemaining: f
147
143
  }
148
- )), /* @__PURE__ */ r("div", { ...c, className: B.view, children: y ? y({ view: e, Content: i }) : i });
144
+ )), /* @__PURE__ */ r("div", { ...i, className: B.view, children: A ? A({ view: e, Content: o }) : o });
149
145
  }
150
146
  }
151
147
  );
152
148
  };
153
149
  export {
154
- _t as FundForm,
150
+ Ft as FundForm,
155
151
  mt as VIEWS
156
152
  };
@@ -1,106 +1,125 @@
1
- import { jsx as s, jsxs as r, Fragment as i } from "react/jsx-runtime";
2
- import { useRef as d, useCallback as h, useEffect as S, useMemo as g } from "react";
3
- import { Button as l } from "../../ui/Button/index.js";
4
- import { LoadingSpinner as T } from "../../ui/LoadingSpinner/index.js";
5
- import { SwitchFadeTransition as N } from "../../ui/SwitchFadeTransition/index.js";
1
+ import { jsx as t, jsxs as c, Fragment as i } from "react/jsx-runtime";
2
+ import { useRef as l, useCallback as _, useEffect as S, useMemo as g } from "react";
3
+ import { Button as o } from "../../ui/Button/index.js";
4
+ import { LoadingSpinner as N } from "../../ui/LoadingSpinner/index.js";
5
+ import { SwitchFadeTransition as T } from "../../ui/SwitchFadeTransition/index.js";
6
6
  import { IconCheck as f } from "../../../icons/IconCheck.js";
7
- import { IconXMark as F } from "../../../icons/IconXMark.js";
7
+ import { IconCurrencies as $ } from "../../../icons/IconCurrencies.js";
8
+ import { IconXMark as w } from "../../../icons/IconXMark.js";
8
9
  import { useFundContext as m } from "../FundProvider.js";
9
- import '../../../assets/FundTransactionStatus.css';const y = "FundTransactionStatus-module__graphic___cam38", $ = "FundTransactionStatus-module__status___2zKJu", k = "FundTransactionStatus-module__pad___-9rGO", w = "FundTransactionStatus-module__spinner___94rMk", C = "FundTransactionStatus-module__icon___0hBQO", b = "FundTransactionStatus-module__subhead___0sHIM", M = "FundTransactionStatus-module__description___W7kK2", v = "FundTransactionStatus-module__ring___1vnCu", t = {
10
+ import '../../../assets/FundTransactionStatus.css';const y = "FundTransactionStatus-module__graphic___cam38", b = "FundTransactionStatus-module__status___2zKJu", C = "FundTransactionStatus-module__pad___-9rGO", F = "FundTransactionStatus-module__spinner___94rMk", k = "FundTransactionStatus-module__icon___0hBQO", v = "FundTransactionStatus-module__subhead___0sHIM", M = "FundTransactionStatus-module__description___W7kK2", W = "FundTransactionStatus-module__ring___1vnCu", s = {
10
11
  graphic: y,
11
- status: $,
12
- pad: k,
13
- spinner: w,
14
- icon: C,
12
+ status: b,
13
+ pad: C,
14
+ spinner: F,
15
+ icon: k,
15
16
  "icon-success": "FundTransactionStatus-module__icon-success___893VG",
16
17
  "icon-error": "FundTransactionStatus-module__icon-error___-aQvD",
17
- subhead: b,
18
+ subhead: v,
18
19
  description: M,
19
- ring: v,
20
+ ring: W,
20
21
  "ring-success": "FundTransactionStatus-module__ring-success___Bxudq",
21
22
  "ring-error": "FundTransactionStatus-module__ring-error___WmTaE"
22
- }, W = ["waiting", "transactionSuccess", "error"], q = (a) => {
23
- const { state: n } = m(), e = d(null), o = d(null), u = h((c) => {
24
- o.current !== c && (o.current = c, e.current?.transition.toggle(c));
23
+ }, P = ["waiting", "transactionSubmitted", "transactionSuccess", "error"], D = (n) => {
24
+ const { state: a } = m(), r = l(null), u = l(null), d = _((e) => {
25
+ u.current !== e && (u.current = e, r.current?.transition.toggle(e));
25
26
  }, []);
26
27
  return S(() => {
27
- (n.transactionStatus.statusName === "transactionSuccess" || n.transactionStatus.statusName === "error") && u(n.transactionStatus.statusName);
28
- }, [n.transactionStatus.statusName, u]), /* @__PURE__ */ s(
29
- N,
28
+ (a.transactionStatus.statusName === "transactionSubmitted" || a.transactionStatus.statusName === "transactionSuccess" || a.transactionStatus.statusName === "error") && d(a.transactionStatus.statusName);
29
+ }, [a.transactionStatus.statusName, d]), /* @__PURE__ */ t(
30
+ T,
30
31
  {
31
32
  animateHeight: !1,
32
33
  timeout: 250,
33
- items: W,
34
+ items: P,
34
35
  initialEntered: !0,
35
- transitionRef: e,
36
- children: ({ itemKey: c, ..._ }) => {
37
- const p = E[c];
38
- return /* @__PURE__ */ s("div", { ..._, className: t.status, children: /* @__PURE__ */ s(p, { ...a }) });
36
+ transitionRef: r,
37
+ children: ({ itemKey: e, ...p }) => {
38
+ const h = E[e];
39
+ return /* @__PURE__ */ t("div", { ...p, className: s.status, children: /* @__PURE__ */ t(h, { ...n }) });
39
40
  }
40
41
  }
41
42
  );
42
43
  }, x = () => {
43
- const { state: a } = m(), n = g(
44
- () => a.paymentMethods?.find((e) => e.id === a.selectedPaymentMethod?.id),
45
- [a.paymentMethods, a.selectedPaymentMethod?.id]
44
+ const { state: n } = m(), a = g(
45
+ () => n.paymentMethods?.find((r) => r.id === n.selectedPaymentMethod?.id),
46
+ [n.paymentMethods, n.selectedPaymentMethod?.id]
46
47
  );
47
- return /* @__PURE__ */ r(i, { children: [
48
- /* @__PURE__ */ r("div", { className: t.graphic, children: [
49
- /* @__PURE__ */ s(
50
- T,
48
+ return /* @__PURE__ */ c(i, { children: [
49
+ /* @__PURE__ */ c("div", { className: s.graphic, children: [
50
+ /* @__PURE__ */ t(
51
+ N,
51
52
  {
52
53
  strokeWidth: "5%",
53
54
  staticStroke: !0,
54
55
  staticStrokeColor: "var(--cdp-web-colors-line-default)",
55
- className: t.spinner
56
+ className: s.spinner
56
57
  }
57
58
  ),
58
- n && /* @__PURE__ */ s("span", { className: t.icon, children: n.icon })
59
+ a && /* @__PURE__ */ t("span", { className: s.icon, children: a.icon })
59
60
  ] }),
60
- /* @__PURE__ */ s("p", { className: t.subhead, children: "Waiting" }),
61
- /* @__PURE__ */ r("p", { className: t.description, children: [
62
- "Deposit ",
63
- a.cryptoAmount,
64
- " ",
65
- a.cryptoCurrency,
66
- n ? ` via ${n.name}` : ""
61
+ /* @__PURE__ */ t("p", { className: s.subhead, children: "Waiting" }),
62
+ /* @__PURE__ */ c("p", { className: s.description, children: [
63
+ "Purchase ",
64
+ n.cryptoCurrency.toUpperCase(),
65
+ " with ",
66
+ n.fiatCurrency.toUpperCase(),
67
+ a ? ` via ${a.name}` : ""
67
68
  ] })
68
69
  ] });
69
- }, P = ({
70
- reset: a,
71
- timeRemaining: n,
72
- unmountOnSuccess: e
73
- }) => /* @__PURE__ */ r(i, { children: [
74
- /* @__PURE__ */ r("div", { className: `${t.graphic} ${t.pad}`, children: [
75
- /* @__PURE__ */ s("span", { className: `${t.ring} ${t["ring-success"]}` }),
76
- /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-success"]}`, children: /* @__PURE__ */ s(f, {}) })
70
+ }, G = ({
71
+ reset: n,
72
+ timeRemaining: a,
73
+ unmountOnSuccess: r
74
+ }) => /* @__PURE__ */ c(i, { children: [
75
+ /* @__PURE__ */ c("div", { className: `${s.graphic} ${s.pad}`, children: [
76
+ /* @__PURE__ */ t("span", { className: `${s.ring} ${s["ring-success"]}` }),
77
+ /* @__PURE__ */ t("span", { className: `${s.icon} ${s["icon-success"]}`, children: /* @__PURE__ */ t($, {}) })
77
78
  ] }),
78
- /* @__PURE__ */ s("p", { className: t.subhead, children: "Success" }),
79
- e && /* @__PURE__ */ r("p", { className: t.description, children: [
79
+ /* @__PURE__ */ t("p", { className: s.subhead, children: "Your funds are on the way" }),
80
+ r && /* @__PURE__ */ c("p", { className: s.description, children: [
80
81
  "This window will automatically close",
81
82
  " ",
82
- n === null ? "soon" : `in ${n}`
83
+ a === null ? "soon" : `in ${a}`
83
84
  ] }),
84
- !e && /* @__PURE__ */ s("p", { className: t.description, children: "Your transaction was successful." }),
85
- !e && a !== void 0 && /* @__PURE__ */ s(l, { fullWidth: !0, onClick: a, children: "Go back" })
86
- ] }), B = ({ reset: a, timeRemaining: n, unmountOnError: e }) => /* @__PURE__ */ r(i, { children: [
87
- /* @__PURE__ */ r("div", { className: `${t.graphic} ${t.pad}`, children: [
88
- /* @__PURE__ */ s("span", { className: `${t.ring} ${t["ring-error"]}` }),
89
- /* @__PURE__ */ s("span", { className: `${t.icon} ${t["icon-error"]}`, children: /* @__PURE__ */ s(F, {}) })
85
+ !r && /* @__PURE__ */ t("p", { className: s.description, children: "Your transaction was submitted." }),
86
+ !r && n !== void 0 && /* @__PURE__ */ t(o, { fullWidth: !0, onClick: n, children: "Go back" })
87
+ ] }), I = ({
88
+ reset: n,
89
+ timeRemaining: a,
90
+ unmountOnSuccess: r
91
+ }) => /* @__PURE__ */ c(i, { children: [
92
+ /* @__PURE__ */ c("div", { className: `${s.graphic} ${s.pad}`, children: [
93
+ /* @__PURE__ */ t("span", { className: `${s.ring} ${s["ring-success"]}` }),
94
+ /* @__PURE__ */ t("span", { className: `${s.icon} ${s["icon-success"]}`, children: /* @__PURE__ */ t(f, {}) })
90
95
  ] }),
91
- /* @__PURE__ */ s("p", { className: t.subhead, children: "Payment failed" }),
92
- e && /* @__PURE__ */ r("p", { className: t.description, children: [
96
+ /* @__PURE__ */ t("p", { className: s.subhead, children: "Success" }),
97
+ r && /* @__PURE__ */ c("p", { className: s.description, children: [
93
98
  "This window will automatically close",
94
99
  " ",
95
- n === null ? "soon" : `in ${n}`
100
+ a === null ? "soon" : `in ${a}`
96
101
  ] }),
97
- !e && /* @__PURE__ */ s("p", { className: t.description, children: "Something went wrong. Please try again." }),
98
- !e && a !== void 0 && /* @__PURE__ */ s(l, { fullWidth: !0, onClick: a, children: "Try again" })
102
+ !r && /* @__PURE__ */ t("p", { className: s.description, children: "Your transaction was successful." }),
103
+ !r && n !== void 0 && /* @__PURE__ */ t(o, { fullWidth: !0, onClick: n, children: "Go back" })
104
+ ] }), B = ({ reset: n, timeRemaining: a, unmountOnError: r }) => /* @__PURE__ */ c(i, { children: [
105
+ /* @__PURE__ */ c("div", { className: `${s.graphic} ${s.pad}`, children: [
106
+ /* @__PURE__ */ t("span", { className: `${s.ring} ${s["ring-error"]}` }),
107
+ /* @__PURE__ */ t("span", { className: `${s.icon} ${s["icon-error"]}`, children: /* @__PURE__ */ t(w, {}) })
108
+ ] }),
109
+ /* @__PURE__ */ t("p", { className: s.subhead, children: "Payment failed" }),
110
+ r && /* @__PURE__ */ c("p", { className: s.description, children: [
111
+ "This window will automatically close",
112
+ " ",
113
+ a === null ? "soon" : `in ${a}`
114
+ ] }),
115
+ !r && /* @__PURE__ */ t("p", { className: s.description, children: "Something went wrong. Please try again." }),
116
+ !r && n !== void 0 && /* @__PURE__ */ t(o, { fullWidth: !0, onClick: n, children: "Try again" })
99
117
  ] }), E = {
100
118
  waiting: x,
101
- transactionSuccess: P,
119
+ transactionSubmitted: G,
120
+ transactionSuccess: I,
102
121
  error: B
103
122
  };
104
123
  export {
105
- q as FundTransactionStatus
124
+ D as FundTransactionStatus
106
125
  };
@@ -1,37 +1,37 @@
1
- import { useCallback as f, useMemo as y } from "react";
2
- const R = ({
3
- country: a,
4
- cryptoCurrency: n,
1
+ import { useCallback as y, useMemo as _ } from "react";
2
+ const N = ({
3
+ country: t,
4
+ cryptoCurrency: a,
5
5
  destinationAddress: o,
6
- fetchBuyQuote: s,
7
- fiatCurrency: t,
6
+ fetchBuyQuote: c,
7
+ fiatCurrency: n,
8
8
  network: u,
9
- onError: c,
10
- subdivision: d
9
+ onError: s,
10
+ subdivision: p
11
11
  }) => {
12
- const l = f(
13
- async ({ paymentMethod: m, paymentAmount: p }, U) => {
14
- if (isNaN(p) || !o || !m)
12
+ const U = y(
13
+ async ({ paymentMethod: d, paymentAmount: i }, l) => {
14
+ if (isNaN(i) || !o || !d)
15
15
  return "";
16
16
  try {
17
- const e = (await s({
18
- purchaseCurrency: n,
19
- purchaseNetwork: u,
20
- paymentCurrency: t,
21
- paymentAmount: p.toFixed(),
22
- paymentMethod: m.replace("_GUEST", ""),
17
+ const e = (await c({
18
+ purchaseCurrency: a.toUpperCase(),
19
+ purchaseNetwork: u.toLowerCase(),
20
+ paymentCurrency: n.toUpperCase(),
21
+ paymentAmount: i.toFixed(),
22
+ paymentMethod: d.replace("_GUEST", ""),
23
23
  // remove "_GUEST" from the payment method since it is not valid in the Buy Quote API
24
- country: a,
25
- subdivision: d,
24
+ country: t.toUpperCase(),
25
+ subdivision: p?.toUpperCase(),
26
26
  destinationAddress: o
27
27
  })).onrampUrl;
28
28
  if (!e) {
29
- const _ = {
29
+ const m = {
30
30
  errorType: "handled_error",
31
31
  code: "NO_ONRAMP_URL",
32
32
  debugMessage: "No payment methods found for the selected country and currency. See docs for more information: https://docs.cdp.coinbase.com/onramp/docs/api-configurations"
33
33
  };
34
- return U?.(_), c?.(_), "";
34
+ return l?.(m), s?.(m), "";
35
35
  }
36
36
  return e;
37
37
  } catch (r) {
@@ -44,22 +44,22 @@ const R = ({
44
44
  errorType: "unknown_error",
45
45
  code: "UNKNOWN_BUY_URL_ERROR",
46
46
  debugMessage: JSON.stringify(r)
47
- }, U?.(e), c?.(e), "";
47
+ }, l?.(e), s?.(e), "";
48
48
  }
49
49
  },
50
50
  [
51
+ t,
51
52
  a,
52
- n,
53
53
  o,
54
- s,
55
- t,
56
- u,
57
54
  c,
58
- d
55
+ n,
56
+ u,
57
+ s,
58
+ p
59
59
  ]
60
60
  );
61
- return y(() => ({ fetchBuyUrl: l }), [l]);
61
+ return _(() => ({ fetchBuyUrl: U }), [U]);
62
62
  };
63
63
  export {
64
- R as useBuyUrl
64
+ N as useBuyUrl
65
65
  };
@@ -1,53 +1,58 @@
1
- import { useCallback as n, useEffect as u } from "react";
2
- import { useFundContext as c } from "../FundProvider.js";
3
- import { setupOnrampEventListeners as i } from "../utils/setupOnrampEventListeners.js";
4
- const e = (t) => ({
1
+ import { useCallback as n, useEffect as o } from "react";
2
+ import { useFundContext as i } from "../FundProvider.js";
3
+ import { setupOnrampEventListeners as c } from "../utils/setupOnrampEventListeners.js";
4
+ const s = (t) => ({
5
5
  type: "SET_TRANSACTION_STATUS",
6
6
  payload: {
7
7
  transactionStatus: t
8
8
  }
9
9
  }), S = () => {
10
- const { dispatch: t } = c(), a = n(
11
- (s) => {
12
- s.eventName === "transition_view" ? t(
13
- e({
10
+ const { dispatch: t } = i(), a = n(
11
+ (e) => {
12
+ e.eventName === "transition_view" ? e.pageRoute.endsWith("/order-submitted") ? t(
13
+ s({
14
+ statusName: "transactionSubmitted",
15
+ statusData: null
16
+ })
17
+ ) : t(
18
+ s({
14
19
  statusName: "transactionPending",
15
20
  statusData: null
16
21
  })
17
- ) : s.eventName === "error" && t(
18
- e({
22
+ ) : e.eventName === "error" && t(
23
+ s({
19
24
  statusName: "error",
20
- statusData: s.error
25
+ statusData: e.error
21
26
  })
22
27
  );
23
28
  },
24
29
  [t]
25
30
  ), r = n(
26
- (s) => {
31
+ (e) => {
27
32
  t(
28
- e({
33
+ s({
29
34
  statusName: "transactionSuccess",
30
- statusData: s || null
35
+ statusData: e || null
31
36
  })
32
37
  );
33
38
  },
34
39
  [t]
35
- ), o = n(() => {
40
+ ), u = n(() => {
36
41
  t(
37
- e({
42
+ s({
38
43
  statusName: "exit",
39
44
  statusData: null
40
45
  })
41
46
  );
42
47
  }, [t]);
43
- u(() => {
44
- const s = i({
48
+ o(() => {
49
+ const e = c({
45
50
  onEvent: a,
46
- onExit: o,
51
+ onExit: u,
47
52
  onSuccess: r
48
53
  });
49
54
  return () => {
50
- s();
55
+ e();
51
56
  };
52
57
  }, []);
53
58
  };
@@ -7,4 +7,4 @@ import { FetchBuyUrlParams } from './hooks/useBuyUrl';
7
7
  import { CamelToSnakeCase, CamelToSnakeCaseNested, FundAction, FetchBuyOptions, FetchBuyQuote, FundPaymentMethod, FundPresetAmountInputs, FundProps, FundState, FundStateError, FundStateProps, FundContextType, FundLifecycleStatus, OnrampAmount, OnrampBuyQuoteResponse, OnrampBuyOptionsResponse, OnrampBuyOptionsSnakeCaseResponse, OnrampBuyQuoteSnakeCaseResponse, OnrampError, OnrampNetwork, OnrampPaymentCurrency, OnrampPaymentMethodLimit, OnrampPurchaseCurrency, OnrampSuccessEventData } from './types';
8
8
  declare const Fund: ({ className, children, openIn, submitLabel, title, ...props }: FundProps) => import("react/jsx-runtime").JSX.Element;
9
9
  declare const FundFooter: (props: HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
10
- export { Fund as unstable_Fund, FundFooter as unstable_FundFooter, FundForm as unstable_FundForm, FundTitle as unstable_FundTitle, useFundContext as unstable_useFundContext, type CamelToSnakeCase as unstable_CamelToSnakeCase, type CamelToSnakeCaseNested as unstable_CamelToSnakeCaseNested, type FundAction as unstable_FundAction, type FetchBuyOptions as unstable_FetchBuyOptions, type FetchBuyQuote as unstable_FetchBuyQuote, type FetchBuyUrlParams as unstable_FetchBuyUrlParams, type FundContextType as unstable_FundContextType, type FundFormProps as unstable_FundFormProps, type FundLifecycleStatus as unstable_FundLifecycleStatus, type FundPaymentMethod as unstable_FundPaymentMethod, type FundPresetAmountInputs as unstable_FundPresetAmountInputs, type FundProps as unstable_FundProps, type FundState as unstable_FundState, type FundStateError as unstable_FundStateError, type FundStateProps as unstable_FundStateProps, type FundTitleProps as unstable_FundTitleProps, type InputType as unstable_InputType, type OnrampAmount as unstable_OnrampAmount, type OnrampBuyQuoteResponse as unstable_OnrampBuyQuoteResponse, type OnrampBuyOptionsResponse as unstable_OnrampBuyOptionsResponse, type OnrampBuyOptionsSnakeCaseResponse as unstable_OnrampBuyOptionsSnakeCaseResponse, type OnrampBuyQuoteSnakeCaseResponse as unstable_OnrampBuyQuoteSnakeCaseResponse, type OnrampError as unstable_OnrampError, type OnrampNetwork as unstable_OnrampNetwork, type OnrampPaymentCurrency as unstable_OnrampPaymentCurrency, type OnrampPaymentMethodLimit as unstable_OnrampPaymentMethodLimit, type OnrampPurchaseCurrency as unstable_OnrampPurchaseCurrency, type OnrampSuccessEventData as unstable_OnrampSuccessEventData, };
10
+ export { Fund, FundFooter, FundForm, FundTitle, useFundContext, type CamelToSnakeCase, type CamelToSnakeCaseNested, type FundAction, type FetchBuyOptions, type FetchBuyQuote, type FetchBuyUrlParams, type FundContextType, type FundFormProps, type FundLifecycleStatus, type FundPaymentMethod, type FundPresetAmountInputs, type FundProps, type FundState, type FundStateError, type FundStateProps, type FundTitleProps, type InputType, type OnrampAmount, type OnrampBuyQuoteResponse, type OnrampBuyOptionsResponse, type OnrampBuyOptionsSnakeCaseResponse, type OnrampBuyQuoteSnakeCaseResponse, type OnrampError, type OnrampNetwork, type OnrampPaymentCurrency, type OnrampPaymentMethodLimit, type OnrampPurchaseCurrency, type OnrampSuccessEventData, };