@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 +2 -0
- package/dist/assets/AmountInput.css +1 -1
- package/dist/assets/Button.css +1 -1
- package/dist/components/Fund/FundForm.js +68 -72
- package/dist/components/Fund/components/FundTransactionStatus.js +83 -64
- package/dist/components/Fund/hooks/useBuyUrl.js +29 -29
- package/dist/components/Fund/hooks/useSetupOnrampEventListeners.js +25 -20
- package/dist/components/Fund/index.d.ts +1 -1
- package/dist/components/Fund/index.js +23 -23
- package/dist/components/Fund/types.d.ts +4 -0
- package/dist/components/Fund/utils/buildPaymentMethods.js +12 -12
- package/dist/components/FundModal/index.d.ts +2 -2
- package/dist/components/FundModal/index.js +14 -14
- package/dist/components/forms/AmountInput/index.js +52 -52
- package/dist/icons/IconCurrencies.d.ts +2 -0
- package/dist/icons/IconCurrencies.js +11 -0
- package/dist/index.js +63 -63
- package/dist/theme/theme.d.ts +2 -2
- package/dist/theme/tokens.d.ts +6 -6
- package/dist/theme/tokens.js +2 -2
- package/package.json +5 -5
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:
|
|
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)}
|
package/dist/assets/Button.css
CHANGED
|
@@ -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-
|
|
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
|
|
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
|
|
9
|
-
import { FundErrorScreen as
|
|
10
|
-
import { FundPaymentMethods as
|
|
11
|
-
import { FundPresetAmountInputs as
|
|
12
|
-
import { FundTransactionStatus as
|
|
13
|
-
import { useFundContext as
|
|
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",
|
|
15
|
+
import '../../assets/FundForm.css';const at = "FundForm-module__view___5V1qO", ut = "FundForm-module__form___TIzVJ", B = {
|
|
16
16
|
view: at,
|
|
17
|
-
form:
|
|
18
|
-
}, mt = ["form", "error", "transaction-status"],
|
|
19
|
-
className:
|
|
20
|
-
children:
|
|
21
|
-
onPopupClose:
|
|
22
|
-
onPopupOpen:
|
|
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:
|
|
27
|
-
unmountOnTransactionSuccess:
|
|
28
|
-
unmount:
|
|
29
|
-
|
|
26
|
+
unmountOnTransactionError: d = !1,
|
|
27
|
+
unmountOnTransactionSuccess: p = !1,
|
|
28
|
+
unmount: a,
|
|
29
|
+
...$
|
|
30
30
|
}) => {
|
|
31
|
-
const { state: t, dispatch:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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,
|
|
43
|
-
|
|
44
|
-
}, [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
u
|
|
49
|
-
|
|
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:
|
|
55
|
+
const { startPopupMonitor: R } = it(O), W = s(
|
|
60
56
|
(e) => {
|
|
61
|
-
e && (n("transaction-status"),
|
|
57
|
+
e && (n("transaction-status"), R(e), S?.(e));
|
|
62
58
|
},
|
|
63
|
-
[
|
|
64
|
-
), q =
|
|
65
|
-
(t.fiatAmount === void 0 || isNaN(t.fiatAmount)) && isNaN(g.current) || t.fiatAmount === g.current ||
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
92
|
+
_(!0), E.current?.focus();
|
|
97
93
|
return;
|
|
98
94
|
}
|
|
99
|
-
I?.(e),
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
95
|
+
I?.(e), F(!0);
|
|
96
|
+
const i = await z();
|
|
97
|
+
if (F(!1), i)
|
|
102
98
|
if (V === "tab")
|
|
103
|
-
window.open(
|
|
99
|
+
window.open(i, "_blank");
|
|
104
100
|
else {
|
|
105
|
-
const
|
|
106
|
-
W(
|
|
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:
|
|
117
|
-
children: ({ itemKey: e, ...
|
|
118
|
-
let
|
|
119
|
-
return e === "form" && (
|
|
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
|
-
|
|
117
|
+
tt,
|
|
122
118
|
{
|
|
123
|
-
ref:
|
|
124
|
-
error:
|
|
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:
|
|
131
|
+
isPending: j,
|
|
136
132
|
pendingLabel: "Getting purchase link",
|
|
137
133
|
children: D || "Deposit"
|
|
138
134
|
}
|
|
139
135
|
)
|
|
140
|
-
] })), e === "error" && (
|
|
141
|
-
|
|
136
|
+
] })), e === "error" && (o = /* @__PURE__ */ r(et, { error: t.paymentMethodsError || K })), e === "transaction-status" && (o = /* @__PURE__ */ r(
|
|
137
|
+
ot,
|
|
142
138
|
{
|
|
143
|
-
unmountOnSuccess:
|
|
144
|
-
unmountOnError:
|
|
145
|
-
reset:
|
|
146
|
-
timeRemaining:
|
|
139
|
+
unmountOnSuccess: p,
|
|
140
|
+
unmountOnError: d,
|
|
141
|
+
reset: m,
|
|
142
|
+
timeRemaining: f
|
|
147
143
|
}
|
|
148
|
-
)), /* @__PURE__ */ r("div", { ...
|
|
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
|
-
|
|
150
|
+
Ft as FundForm,
|
|
155
151
|
mt as VIEWS
|
|
156
152
|
};
|
|
@@ -1,106 +1,125 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { Button as
|
|
4
|
-
import { LoadingSpinner as
|
|
5
|
-
import { SwitchFadeTransition as
|
|
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 {
|
|
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",
|
|
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:
|
|
13
|
-
spinner:
|
|
14
|
-
icon:
|
|
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:
|
|
18
|
+
subhead: v,
|
|
18
19
|
description: M,
|
|
19
|
-
ring:
|
|
20
|
+
ring: W,
|
|
20
21
|
"ring-success": "FundTransactionStatus-module__ring-success___Bxudq",
|
|
21
22
|
"ring-error": "FundTransactionStatus-module__ring-error___WmTaE"
|
|
22
|
-
},
|
|
23
|
-
const { state:
|
|
24
|
-
|
|
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
|
-
(
|
|
28
|
-
}, [
|
|
29
|
-
|
|
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:
|
|
34
|
+
items: P,
|
|
34
35
|
initialEntered: !0,
|
|
35
|
-
transitionRef:
|
|
36
|
-
children: ({ itemKey:
|
|
37
|
-
const
|
|
38
|
-
return /* @__PURE__ */
|
|
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:
|
|
44
|
-
() =>
|
|
45
|
-
[
|
|
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__ */
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
|
|
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:
|
|
56
|
+
className: s.spinner
|
|
56
57
|
}
|
|
57
58
|
),
|
|
58
|
-
|
|
59
|
+
a && /* @__PURE__ */ t("span", { className: s.icon, children: a.icon })
|
|
59
60
|
] }),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
" ",
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
},
|
|
70
|
-
reset:
|
|
71
|
-
timeRemaining:
|
|
72
|
-
unmountOnSuccess:
|
|
73
|
-
}) => /* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
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__ */
|
|
79
|
-
|
|
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
|
-
|
|
83
|
+
a === null ? "soon" : `in ${a}`
|
|
83
84
|
] }),
|
|
84
|
-
!
|
|
85
|
-
!
|
|
86
|
-
] }),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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__ */
|
|
92
|
-
|
|
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
|
-
|
|
100
|
+
a === null ? "soon" : `in ${a}`
|
|
96
101
|
] }),
|
|
97
|
-
!
|
|
98
|
-
!
|
|
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
|
-
|
|
119
|
+
transactionSubmitted: G,
|
|
120
|
+
transactionSuccess: I,
|
|
102
121
|
error: B
|
|
103
122
|
};
|
|
104
123
|
export {
|
|
105
|
-
|
|
124
|
+
D as FundTransactionStatus
|
|
106
125
|
};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
const
|
|
3
|
-
country:
|
|
4
|
-
cryptoCurrency:
|
|
1
|
+
import { useCallback as y, useMemo as _ } from "react";
|
|
2
|
+
const N = ({
|
|
3
|
+
country: t,
|
|
4
|
+
cryptoCurrency: a,
|
|
5
5
|
destinationAddress: o,
|
|
6
|
-
fetchBuyQuote:
|
|
7
|
-
fiatCurrency:
|
|
6
|
+
fetchBuyQuote: c,
|
|
7
|
+
fiatCurrency: n,
|
|
8
8
|
network: u,
|
|
9
|
-
onError:
|
|
10
|
-
subdivision:
|
|
9
|
+
onError: s,
|
|
10
|
+
subdivision: p
|
|
11
11
|
}) => {
|
|
12
|
-
const
|
|
13
|
-
async ({ paymentMethod:
|
|
14
|
-
if (isNaN(
|
|
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
|
|
18
|
-
purchaseCurrency:
|
|
19
|
-
purchaseNetwork: u,
|
|
20
|
-
paymentCurrency:
|
|
21
|
-
paymentAmount:
|
|
22
|
-
paymentMethod:
|
|
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:
|
|
25
|
-
subdivision:
|
|
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
|
|
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
|
-
},
|
|
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
|
-
|
|
55
|
+
n,
|
|
56
|
+
u,
|
|
57
|
+
s,
|
|
58
|
+
p
|
|
59
59
|
]
|
|
60
60
|
);
|
|
61
|
-
return
|
|
61
|
+
return _(() => ({ fetchBuyUrl: U }), [U]);
|
|
62
62
|
};
|
|
63
63
|
export {
|
|
64
|
-
|
|
64
|
+
N as useBuyUrl
|
|
65
65
|
};
|
|
@@ -1,53 +1,58 @@
|
|
|
1
|
-
import { useCallback as n, useEffect as
|
|
2
|
-
import { useFundContext as
|
|
3
|
-
import { setupOnrampEventListeners as
|
|
4
|
-
const
|
|
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 } =
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
) :
|
|
18
|
-
|
|
22
|
+
) : e.eventName === "error" && t(
|
|
23
|
+
s({
|
|
19
24
|
statusName: "error",
|
|
20
|
-
statusData:
|
|
25
|
+
statusData: e.error
|
|
21
26
|
})
|
|
22
27
|
);
|
|
23
28
|
},
|
|
24
29
|
[t]
|
|
25
30
|
), r = n(
|
|
26
|
-
(
|
|
31
|
+
(e) => {
|
|
27
32
|
t(
|
|
28
|
-
|
|
33
|
+
s({
|
|
29
34
|
statusName: "transactionSuccess",
|
|
30
|
-
statusData:
|
|
35
|
+
statusData: e || null
|
|
31
36
|
})
|
|
32
37
|
);
|
|
33
38
|
},
|
|
34
39
|
[t]
|
|
35
|
-
),
|
|
40
|
+
), u = n(() => {
|
|
36
41
|
t(
|
|
37
|
-
|
|
42
|
+
s({
|
|
38
43
|
statusName: "exit",
|
|
39
44
|
statusData: null
|
|
40
45
|
})
|
|
41
46
|
);
|
|
42
47
|
}, [t]);
|
|
43
|
-
|
|
44
|
-
const
|
|
48
|
+
o(() => {
|
|
49
|
+
const e = c({
|
|
45
50
|
onEvent: a,
|
|
46
|
-
onExit:
|
|
51
|
+
onExit: u,
|
|
47
52
|
onSuccess: r
|
|
48
53
|
});
|
|
49
54
|
return () => {
|
|
50
|
-
|
|
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
|
|
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, };
|