@pollar/react 0.10.1-rc.7 → 0.10.1-rc.9
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/dist/index.css +6 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +59 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1035,7 +1035,7 @@ var PollarModalFooter = () => {
|
|
|
1035
1035
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
|
|
1036
1036
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
|
|
1037
1037
|
"v",
|
|
1038
|
-
"0.10.1-rc.
|
|
1038
|
+
"0.10.1-rc.9"
|
|
1039
1039
|
] })
|
|
1040
1040
|
] })
|
|
1041
1041
|
] });
|
|
@@ -2526,6 +2526,13 @@ function RouteDisplay({ quote, onSelect }) {
|
|
|
2526
2526
|
}
|
|
2527
2527
|
);
|
|
2528
2528
|
}
|
|
2529
|
+
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2530
|
+
function isFieldValid(spec, raw) {
|
|
2531
|
+
const value = (raw ?? "").trim();
|
|
2532
|
+
if (!value) return false;
|
|
2533
|
+
if (spec.type === "email") return EMAIL_RE.test(value);
|
|
2534
|
+
return true;
|
|
2535
|
+
}
|
|
2529
2536
|
var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
|
|
2530
2537
|
function flagEmoji(code) {
|
|
2531
2538
|
const cc = code.trim().toUpperCase();
|
|
@@ -2596,6 +2603,7 @@ function RampWidgetTemplate({
|
|
|
2596
2603
|
kycUrl,
|
|
2597
2604
|
tosUrl,
|
|
2598
2605
|
stellarTxHash,
|
|
2606
|
+
explorerUrl,
|
|
2599
2607
|
depositInstructions,
|
|
2600
2608
|
canComplete,
|
|
2601
2609
|
completing,
|
|
@@ -2756,7 +2764,18 @@ function RampWidgetTemplate({
|
|
|
2756
2764
|
step === "contact" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2757
2765
|
requiredFields.map((f) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2758
2766
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-ramp-label", children: f.label }),
|
|
2759
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2767
|
+
f.type === "select" ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2768
|
+
"select",
|
|
2769
|
+
{
|
|
2770
|
+
className: "pollar-ramp-input",
|
|
2771
|
+
value: fieldValues[f.key] ?? "",
|
|
2772
|
+
onChange: (e) => onFieldChange(f.key, e.target.value),
|
|
2773
|
+
children: [
|
|
2774
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select\u2026" }),
|
|
2775
|
+
(f.options ?? []).map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
|
|
2776
|
+
]
|
|
2777
|
+
}
|
|
2778
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2760
2779
|
"input",
|
|
2761
2780
|
{
|
|
2762
2781
|
type: f.type,
|
|
@@ -2765,7 +2784,8 @@ function RampWidgetTemplate({
|
|
|
2765
2784
|
autoComplete: f.type === "email" ? "email" : "off",
|
|
2766
2785
|
onChange: (e) => onFieldChange(f.key, e.target.value)
|
|
2767
2786
|
}
|
|
2768
|
-
)
|
|
2787
|
+
),
|
|
2788
|
+
f.type === "email" && (fieldValues[f.key] ?? "").trim() !== "" && !isFieldValid(f, fieldValues[f.key]) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-field-error", children: "Enter a valid email address." })
|
|
2769
2789
|
] }, f.key)),
|
|
2770
2790
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-actions", children: [
|
|
2771
2791
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onRetry, children: "Back" }),
|
|
@@ -2774,7 +2794,7 @@ function RampWidgetTemplate({
|
|
|
2774
2794
|
{
|
|
2775
2795
|
type: "button",
|
|
2776
2796
|
className: "pollar-btn-primary",
|
|
2777
|
-
disabled: requiredFields.some((f) => !(fieldValues[f.key]
|
|
2797
|
+
disabled: requiredFields.some((f) => !isFieldValid(f, fieldValues[f.key])) || isLoading,
|
|
2778
2798
|
onClick: onContactContinue,
|
|
2779
2799
|
children: isLoading ? "Starting\u2026" : "Continue"
|
|
2780
2800
|
}
|
|
@@ -2792,11 +2812,29 @@ function RampWidgetTemplate({
|
|
|
2792
2812
|
] }),
|
|
2793
2813
|
stellarTxHash && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
2794
2814
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: "Stellar tx" }),
|
|
2795
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2815
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-value", style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
2816
|
+
/* @__PURE__ */ jsxRuntime.jsxs("code", { style: { flex: 1, wordBreak: "break-all" }, children: [
|
|
2817
|
+
stellarTxHash.slice(0, 8),
|
|
2818
|
+
"\u2026",
|
|
2819
|
+
stellarTxHash.slice(-8)
|
|
2820
|
+
] }),
|
|
2821
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: stellarTxHash, label: "Copy transaction hash" }),
|
|
2822
|
+
explorerUrl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2823
|
+
"a",
|
|
2824
|
+
{
|
|
2825
|
+
href: explorerUrl,
|
|
2826
|
+
target: "_blank",
|
|
2827
|
+
rel: "noopener noreferrer",
|
|
2828
|
+
className: "pollar-copy-btn",
|
|
2829
|
+
"aria-label": "View on Stellar Expert",
|
|
2830
|
+
title: "View on Stellar Expert",
|
|
2831
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
|
|
2832
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 3H3v8h8V8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
2833
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8.5 2.5h3v3M11 3L6.5 7.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
2834
|
+
] })
|
|
2835
|
+
}
|
|
2836
|
+
)
|
|
2837
|
+
] })
|
|
2800
2838
|
] }),
|
|
2801
2839
|
depositInstructions && txStatus !== "completed" && flattenInstructions(depositInstructions).map(({ key, label, value, kind }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
2802
2840
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: label }),
|
|
@@ -2807,7 +2845,10 @@ function RampWidgetTemplate({
|
|
|
2807
2845
|
alt: label,
|
|
2808
2846
|
style: { width: "100%", maxWidth: 220, height: "auto", display: "block", margin: "0 auto" }
|
|
2809
2847
|
}
|
|
2810
|
-
) : kind === "datetime" ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: value }) : /* @__PURE__ */ jsxRuntime.
|
|
2848
|
+
) : kind === "datetime" ? /* @__PURE__ */ jsxRuntime.jsx("span", { children: value }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
2849
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { style: { flex: 1, wordBreak: "break-all" }, children: value }),
|
|
2850
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value, label: `Copy ${label}` })
|
|
2851
|
+
] }) })
|
|
2811
2852
|
] }, key)),
|
|
2812
2853
|
tosUrl && !depositInstructions && txStatus !== "completed" && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenTos, children: [
|
|
2813
2854
|
"Accept terms at ",
|
|
@@ -2835,7 +2876,7 @@ function requiredFieldsOf(quote) {
|
|
|
2835
2876
|
return quote.requiredFields ?? [];
|
|
2836
2877
|
}
|
|
2837
2878
|
function RampWidget({ onClose }) {
|
|
2838
|
-
const { getClient, signTx, wallet, styles } = usePollar();
|
|
2879
|
+
const { getClient, signTx, wallet, styles, network } = usePollar();
|
|
2839
2880
|
const walletAddress = wallet?.address ?? "";
|
|
2840
2881
|
const client = getClient();
|
|
2841
2882
|
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
@@ -2933,6 +2974,7 @@ function RampWidget({ onClose }) {
|
|
|
2933
2974
|
setStep("input");
|
|
2934
2975
|
setQuotes([]);
|
|
2935
2976
|
setSelectedQuote(null);
|
|
2977
|
+
setFieldValues({});
|
|
2936
2978
|
setTxId(null);
|
|
2937
2979
|
setProvider("");
|
|
2938
2980
|
setKycUrl(null);
|
|
@@ -3010,12 +3052,16 @@ function RampWidget({ onClose }) {
|
|
|
3010
3052
|
try {
|
|
3011
3053
|
const base = { quoteId: quote.quoteId, amount: Number(amount), currency, country };
|
|
3012
3054
|
if (walletAddress) base.walletAddress = walletAddress;
|
|
3055
|
+
const STANDARD_BODY_KEYS = /* @__PURE__ */ new Set(["email", "fullName", "taxId", "qrCode"]);
|
|
3056
|
+
const extraFields = {};
|
|
3013
3057
|
for (const f of requiredFieldsOf(quote)) {
|
|
3014
3058
|
const val = (fieldValues[f.key] ?? "").trim();
|
|
3015
3059
|
if (!val) continue;
|
|
3016
3060
|
if (f.bankType) base.bankDetails = { type: f.bankType, value: val };
|
|
3017
|
-
else base[f.key] = val;
|
|
3061
|
+
else if (STANDARD_BODY_KEYS.has(f.key)) base[f.key] = val;
|
|
3062
|
+
else extraFields[f.key] = val;
|
|
3018
3063
|
}
|
|
3064
|
+
if (Object.keys(extraFields).length > 0) base.fields = extraFields;
|
|
3019
3065
|
const result = direction === "onramp" ? await client.createOnRamp(base) : await client.createOffRamp(base);
|
|
3020
3066
|
await applyResult(result);
|
|
3021
3067
|
} catch (e) {
|
|
@@ -3075,6 +3121,7 @@ function RampWidget({ onClose }) {
|
|
|
3075
3121
|
kycUrl,
|
|
3076
3122
|
tosUrl,
|
|
3077
3123
|
stellarTxHash,
|
|
3124
|
+
explorerUrl: stellarTxHash ? `https://stellar.expert/explorer/${network === "mainnet" ? "public" : "testnet"}/tx/${stellarTxHash}` : null,
|
|
3078
3125
|
depositInstructions,
|
|
3079
3126
|
canComplete,
|
|
3080
3127
|
completing,
|