@pollar/react 0.10.1-rc.4 → 0.10.1-rc.5
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 +27 -27
- package/dist/index.css +52 -7
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +377 -272
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +377 -272
- 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.5"
|
|
1039
1039
|
] })
|
|
1040
1040
|
] })
|
|
1041
1041
|
] });
|
|
@@ -1067,16 +1067,7 @@ function CopyButton({ value, label = "Copy", className }) {
|
|
|
1067
1067
|
className: `pollar-copy-btn${className ? ` ${className}` : ""}`,
|
|
1068
1068
|
onClick: handleCopy,
|
|
1069
1069
|
"aria-label": copied ? "Copied" : label,
|
|
1070
|
-
children: copied ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1071
|
-
"path",
|
|
1072
|
-
{
|
|
1073
|
-
d: "M3.5 7l2.5 2.5 4.5-5",
|
|
1074
|
-
stroke: "currentColor",
|
|
1075
|
-
strokeWidth: "1.5",
|
|
1076
|
-
strokeLinecap: "round",
|
|
1077
|
-
strokeLinejoin: "round"
|
|
1078
|
-
}
|
|
1079
|
-
) }) : /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
1070
|
+
children: copied ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M3.5 7l2.5 2.5 4.5-5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) : /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
1080
1071
|
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
1081
1072
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1082
1073
|
"path",
|
|
@@ -2283,12 +2274,38 @@ function PrivyLoginSubmodal({
|
|
|
2283
2274
|
fail(error);
|
|
2284
2275
|
}
|
|
2285
2276
|
}
|
|
2286
|
-
const BackButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2277
|
+
const BackButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2278
|
+
"svg",
|
|
2279
|
+
{
|
|
2280
|
+
width: "20",
|
|
2281
|
+
height: "20",
|
|
2282
|
+
viewBox: "0 0 24 24",
|
|
2283
|
+
fill: "none",
|
|
2284
|
+
stroke: "currentColor",
|
|
2285
|
+
strokeWidth: "2.5",
|
|
2286
|
+
strokeLinecap: "round",
|
|
2287
|
+
strokeLinejoin: "round",
|
|
2288
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 19l-7-7 7-7" })
|
|
2289
|
+
}
|
|
2290
|
+
) });
|
|
2287
2291
|
const showEmail = options.includes("email");
|
|
2288
2292
|
const showGoogle = options.includes("google");
|
|
2289
2293
|
const showGithub = options.includes("github");
|
|
2290
2294
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
|
|
2291
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2295
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2296
|
+
"svg",
|
|
2297
|
+
{
|
|
2298
|
+
width: "18",
|
|
2299
|
+
height: "18",
|
|
2300
|
+
viewBox: "0 0 24 24",
|
|
2301
|
+
fill: "none",
|
|
2302
|
+
stroke: "currentColor",
|
|
2303
|
+
strokeWidth: "2.5",
|
|
2304
|
+
strokeLinecap: "round",
|
|
2305
|
+
strokeLinejoin: "round",
|
|
2306
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" })
|
|
2307
|
+
}
|
|
2308
|
+
) }),
|
|
2292
2309
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-header", children: [
|
|
2293
2310
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoUrl ?? LOGO_POLLAR, alt: "Logo", className: "pollar-logo" }) }),
|
|
2294
2311
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-title", children: appName }),
|
|
@@ -2541,8 +2558,7 @@ function flattenInstructions(instr) {
|
|
|
2541
2558
|
for (const [k, v] of Object.entries(instr)) {
|
|
2542
2559
|
let value = "";
|
|
2543
2560
|
if (typeof v === "string" || typeof v === "number") value = String(v);
|
|
2544
|
-
else if (Array.isArray(v))
|
|
2545
|
-
value = v.filter((x) => typeof x === "string" || typeof x === "number").join(", ");
|
|
2561
|
+
else if (Array.isArray(v)) value = v.filter((x) => typeof x === "string" || typeof x === "number").join(", ");
|
|
2546
2562
|
else continue;
|
|
2547
2563
|
if (!value) continue;
|
|
2548
2564
|
out.push({ key: k, label: INSTRUCTION_LABELS[k] ?? k, value });
|
|
@@ -2567,6 +2583,7 @@ function RampWidgetTemplate({
|
|
|
2567
2583
|
provider,
|
|
2568
2584
|
txStatus,
|
|
2569
2585
|
kycUrl,
|
|
2586
|
+
tosUrl,
|
|
2570
2587
|
stellarTxHash,
|
|
2571
2588
|
depositInstructions,
|
|
2572
2589
|
canComplete,
|
|
@@ -2580,6 +2597,7 @@ function RampWidgetTemplate({
|
|
|
2580
2597
|
onSelectQuote,
|
|
2581
2598
|
onContactContinue,
|
|
2582
2599
|
onOpenKyc,
|
|
2600
|
+
onOpenTos,
|
|
2583
2601
|
onCompleteWithdraw,
|
|
2584
2602
|
onRetry,
|
|
2585
2603
|
onRefresh,
|
|
@@ -2773,7 +2791,11 @@ function RampWidgetTemplate({
|
|
|
2773
2791
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-payment-label", children: label }),
|
|
2774
2792
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-ramp-payment-value", children: /* @__PURE__ */ jsxRuntime.jsx("code", { style: { wordBreak: "break-all" }, children: value }) })
|
|
2775
2793
|
] }, key)),
|
|
2776
|
-
|
|
2794
|
+
tosUrl && !depositInstructions && txStatus !== "completed" && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenTos, children: [
|
|
2795
|
+
"Accept terms at ",
|
|
2796
|
+
provider
|
|
2797
|
+
] }),
|
|
2798
|
+
kycUrl && !depositInstructions && txStatus !== "completed" && /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenKyc, children: [
|
|
2777
2799
|
"Continue at ",
|
|
2778
2800
|
provider
|
|
2779
2801
|
] }),
|
|
@@ -2815,6 +2837,7 @@ function RampWidget({ onClose }) {
|
|
|
2815
2837
|
const [txId, setTxId] = react.useState(null);
|
|
2816
2838
|
const [provider, setProvider] = react.useState("");
|
|
2817
2839
|
const [kycUrl, setKycUrl] = react.useState(null);
|
|
2840
|
+
const [tosUrl, setTosUrl] = react.useState(null);
|
|
2818
2841
|
const [txStatus, setTxStatus] = react.useState(null);
|
|
2819
2842
|
const [stellarTxHash, setStellarTxHash] = react.useState(null);
|
|
2820
2843
|
const [depositInstructions, setDepositInstructions] = react.useState(null);
|
|
@@ -2833,8 +2856,7 @@ function RampWidget({ onClose }) {
|
|
|
2833
2856
|
setTxStatus(tx.status);
|
|
2834
2857
|
if (tx.stellarTxHash) setStellarTxHash(tx.stellarTxHash);
|
|
2835
2858
|
if (tx.kycUrl) setKycUrl(tx.kycUrl);
|
|
2836
|
-
|
|
2837
|
-
if (di) setDepositInstructions(di);
|
|
2859
|
+
if (tx.depositInstructions) setDepositInstructions(tx.depositInstructions);
|
|
2838
2860
|
if (TERMINAL.includes(tx.status)) clearInterval(id);
|
|
2839
2861
|
} catch {
|
|
2840
2862
|
}
|
|
@@ -2882,8 +2904,7 @@ function RampWidget({ onClose }) {
|
|
|
2882
2904
|
setTxStatus(tx.status);
|
|
2883
2905
|
if (tx.stellarTxHash) setStellarTxHash(tx.stellarTxHash);
|
|
2884
2906
|
if (tx.kycUrl) setKycUrl(tx.kycUrl);
|
|
2885
|
-
|
|
2886
|
-
if (di) setDepositInstructions(di);
|
|
2907
|
+
if (tx.depositInstructions) setDepositInstructions(tx.depositInstructions);
|
|
2887
2908
|
}
|
|
2888
2909
|
} catch {
|
|
2889
2910
|
} finally {
|
|
@@ -2897,6 +2918,7 @@ function RampWidget({ onClose }) {
|
|
|
2897
2918
|
setTxId(null);
|
|
2898
2919
|
setProvider("");
|
|
2899
2920
|
setKycUrl(null);
|
|
2921
|
+
setTosUrl(null);
|
|
2900
2922
|
setTxStatus(null);
|
|
2901
2923
|
setStellarTxHash(null);
|
|
2902
2924
|
setDepositInstructions(null);
|
|
@@ -2923,6 +2945,7 @@ function RampWidget({ onClose }) {
|
|
|
2923
2945
|
return;
|
|
2924
2946
|
}
|
|
2925
2947
|
setKycUrl(result.kycUrl ?? null);
|
|
2948
|
+
setTosUrl(result.tosUrl ?? null);
|
|
2926
2949
|
setTxStatus(result.status);
|
|
2927
2950
|
setStellarTxHash(result.stellarTxHash ?? null);
|
|
2928
2951
|
setDepositInstructions(result.depositInstructions ?? null);
|
|
@@ -2987,6 +3010,9 @@ function RampWidget({ onClose }) {
|
|
|
2987
3010
|
function handleOpenKyc() {
|
|
2988
3011
|
if (kycUrl) window.open(kycUrl, "_blank", "noopener,noreferrer");
|
|
2989
3012
|
}
|
|
3013
|
+
function handleOpenTos() {
|
|
3014
|
+
if (tosUrl) window.open(tosUrl, "_blank", "noopener,noreferrer");
|
|
3015
|
+
}
|
|
2990
3016
|
async function handleCompleteWithdraw() {
|
|
2991
3017
|
if (!txId) return;
|
|
2992
3018
|
setCompleting(true);
|
|
@@ -3029,6 +3055,7 @@ function RampWidget({ onClose }) {
|
|
|
3029
3055
|
provider,
|
|
3030
3056
|
txStatus,
|
|
3031
3057
|
kycUrl,
|
|
3058
|
+
tosUrl,
|
|
3032
3059
|
stellarTxHash,
|
|
3033
3060
|
depositInstructions,
|
|
3034
3061
|
canComplete,
|
|
@@ -3042,6 +3069,7 @@ function RampWidget({ onClose }) {
|
|
|
3042
3069
|
onSelectQuote: handleSelectQuote,
|
|
3043
3070
|
onContactContinue: handleContactContinue,
|
|
3044
3071
|
onOpenKyc: handleOpenKyc,
|
|
3072
|
+
onOpenTos: handleOpenTos,
|
|
3045
3073
|
onCompleteWithdraw: handleCompleteWithdraw,
|
|
3046
3074
|
onRetry: resetToInput,
|
|
3047
3075
|
onRefresh: handleRefresh,
|
|
@@ -3207,6 +3235,43 @@ function ReceiveModal({ onClose }) {
|
|
|
3207
3235
|
}
|
|
3208
3236
|
) });
|
|
3209
3237
|
}
|
|
3238
|
+
function formatAmount2(value) {
|
|
3239
|
+
const n = parseFloat(value);
|
|
3240
|
+
return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
3241
|
+
}
|
|
3242
|
+
var optionLabel = (o) => o.available !== void 0 ? `${o.code} \u2014 ${formatAmount2(o.available)} available` : o.code;
|
|
3243
|
+
function AssetSelect({
|
|
3244
|
+
label,
|
|
3245
|
+
value,
|
|
3246
|
+
options,
|
|
3247
|
+
onChange,
|
|
3248
|
+
loading = false,
|
|
3249
|
+
disabled = false,
|
|
3250
|
+
appGroupLabel = "App assets",
|
|
3251
|
+
otherGroupLabel = "Other assets",
|
|
3252
|
+
children
|
|
3253
|
+
}) {
|
|
3254
|
+
const appAssets = options.filter((o) => o.enabledInApp);
|
|
3255
|
+
const otherAssets = options.filter((o) => !o.enabledInApp);
|
|
3256
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
3257
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: label }),
|
|
3258
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3259
|
+
"select",
|
|
3260
|
+
{
|
|
3261
|
+
className: "pollar-input pollar-send-select",
|
|
3262
|
+
value,
|
|
3263
|
+
disabled,
|
|
3264
|
+
onChange: (e) => onChange(e.target.value),
|
|
3265
|
+
children: [
|
|
3266
|
+
value === "" && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, hidden: true }),
|
|
3267
|
+
appAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: appGroupLabel, children: appAssets.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.key, children: optionLabel(o) }, o.key)) }),
|
|
3268
|
+
otherAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: otherGroupLabel, children: otherAssets.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.key, children: optionLabel(o) }, o.key)) })
|
|
3269
|
+
]
|
|
3270
|
+
}
|
|
3271
|
+
),
|
|
3272
|
+
!loading && children
|
|
3273
|
+
] });
|
|
3274
|
+
}
|
|
3210
3275
|
var STATUS_MESSAGES = {
|
|
3211
3276
|
idle: "",
|
|
3212
3277
|
building: "Building transaction\u2026",
|
|
@@ -3459,8 +3524,6 @@ function SendModalTemplate({
|
|
|
3459
3524
|
"--pollar-input-border-radius": "0.5rem",
|
|
3460
3525
|
"--pollar-card-border-radius": "10px"
|
|
3461
3526
|
};
|
|
3462
|
-
const enabledAssets = assets.filter((a) => a.enabledInApp);
|
|
3463
|
-
const otherAssets = assets.filter((a) => !a.enabledInApp);
|
|
3464
3527
|
const selectedKey = selectedAsset ? assetKey3(selectedAsset) : "";
|
|
3465
3528
|
const canSubmit = !!selectedAsset && !!amount && !!destination.trim() && !isLoadingBalance;
|
|
3466
3529
|
const title = step === "form" ? "Send" : txTitle;
|
|
@@ -3480,36 +3543,24 @@ function SendModalTemplate({
|
|
|
3480
3543
|
!isInProgress && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
|
|
3481
3544
|
] }),
|
|
3482
3545
|
step === "form" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3483
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
"
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
a.code,
|
|
3499
|
-
" \u2014 ",
|
|
3500
|
-
formatBalance(a.available),
|
|
3501
|
-
" available"
|
|
3502
|
-
] }, assetKey3(a))) }),
|
|
3503
|
-
otherAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: "Other assets", children: otherAssets.map((a) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetKey3(a), children: [
|
|
3504
|
-
a.code,
|
|
3505
|
-
" \u2014 ",
|
|
3506
|
-
formatBalance(a.available),
|
|
3507
|
-
" available"
|
|
3508
|
-
] }, assetKey3(a))) })
|
|
3509
|
-
]
|
|
3546
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3547
|
+
AssetSelect,
|
|
3548
|
+
{
|
|
3549
|
+
label: "Asset",
|
|
3550
|
+
value: selectedKey,
|
|
3551
|
+
loading: isLoadingBalance,
|
|
3552
|
+
options: assets.map((a) => ({
|
|
3553
|
+
key: assetKey3(a),
|
|
3554
|
+
code: a.code,
|
|
3555
|
+
available: a.available,
|
|
3556
|
+
enabledInApp: a.enabledInApp
|
|
3557
|
+
})),
|
|
3558
|
+
onChange: (key) => {
|
|
3559
|
+
const found = assets.find((a) => assetKey3(a) === key);
|
|
3560
|
+
if (found) onSelectAsset(found);
|
|
3510
3561
|
}
|
|
3511
|
-
|
|
3512
|
-
|
|
3562
|
+
}
|
|
3563
|
+
),
|
|
3513
3564
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
3514
3565
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
|
|
3515
3566
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Amount" }),
|
|
@@ -3609,8 +3660,11 @@ function SendModal({ onClose }) {
|
|
|
3609
3660
|
const allAssets = balanceData?.balances ?? [];
|
|
3610
3661
|
const sortedAssets = [
|
|
3611
3662
|
...allAssets.filter((b) => b.enabledInApp),
|
|
3612
|
-
...allAssets.filter((b) => !b.enabledInApp && parseFloat(b.balance) > 0)
|
|
3663
|
+
...allAssets.filter((b) => !b.enabledInApp && (b.type === "native" || parseFloat(b.balance) > 0))
|
|
3613
3664
|
];
|
|
3665
|
+
react.useEffect(() => {
|
|
3666
|
+
if (!selectedAsset && sortedAssets.length > 0) setSelectedAsset(sortedAssets[0]);
|
|
3667
|
+
}, [sortedAssets, selectedAsset]);
|
|
3614
3668
|
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
3615
3669
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
3616
3670
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
@@ -3717,7 +3771,7 @@ var PROVIDER_LABELS = {
|
|
|
3717
3771
|
soroswap: "Soroswap",
|
|
3718
3772
|
sdex: "Stellar DEX"
|
|
3719
3773
|
};
|
|
3720
|
-
function
|
|
3774
|
+
function formatAmount3(value) {
|
|
3721
3775
|
const n = parseFloat(value);
|
|
3722
3776
|
return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
3723
3777
|
}
|
|
@@ -3800,214 +3854,229 @@ function SwapModalTemplate({
|
|
|
3800
3854
|
const buyKey = selectedBuy ? assetOptionKey(selectedBuy) : "";
|
|
3801
3855
|
const canSwap = !smartUnsupported && !!selectedSell && !!selectedBuy && !!amount && !!quote && !quoteLoading && !isLoadingData;
|
|
3802
3856
|
const title = step === "form" ? "Swap" : txTitle;
|
|
3803
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
{
|
|
3813
|
-
type: "button",
|
|
3814
|
-
className: "pollar-modal-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
"
|
|
3818
|
-
|
|
3819
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3820
|
-
"path",
|
|
3857
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3858
|
+
"div",
|
|
3859
|
+
{
|
|
3860
|
+
className: "pollar-modal-card pollar-send-modal",
|
|
3861
|
+
"data-theme": theme,
|
|
3862
|
+
style: cssVars,
|
|
3863
|
+
onClick: (e) => e.stopPropagation(),
|
|
3864
|
+
children: [
|
|
3865
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
|
|
3866
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-header-left", children: [
|
|
3867
|
+
showBack && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
3868
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: title })
|
|
3869
|
+
] }),
|
|
3870
|
+
!isInProgress && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
3871
|
+
step === "form" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3872
|
+
"button",
|
|
3821
3873
|
{
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3874
|
+
type: "button",
|
|
3875
|
+
className: "pollar-modal-close",
|
|
3876
|
+
onClick: onRefresh,
|
|
3877
|
+
disabled: configLoading || isLoadingData,
|
|
3878
|
+
"aria-label": "Refresh",
|
|
3879
|
+
title: "Refresh balances and options",
|
|
3880
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3881
|
+
"path",
|
|
3882
|
+
{
|
|
3883
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3",
|
|
3884
|
+
stroke: "currentColor",
|
|
3885
|
+
strokeWidth: "1.6",
|
|
3886
|
+
strokeLinecap: "round",
|
|
3887
|
+
strokeLinejoin: "round"
|
|
3888
|
+
}
|
|
3889
|
+
) })
|
|
3827
3890
|
}
|
|
3828
|
-
)
|
|
3829
|
-
|
|
3830
|
-
),
|
|
3831
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
3832
|
-
] })
|
|
3833
|
-
] }),
|
|
3834
|
-
step === "form" && configLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "Loading swap options\u2026" }),
|
|
3835
|
-
step === "form" && !configLoading && swapUnavailable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swap is not available for this app." }),
|
|
3836
|
-
step === "form" && !configLoading && !swapUnavailable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3837
|
-
smartUnsupported && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swaps are not yet available for smart (passkey) wallets." }),
|
|
3838
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
3839
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "You pay" }),
|
|
3840
|
-
isLoadingData ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3841
|
-
"select",
|
|
3842
|
-
{
|
|
3843
|
-
className: "pollar-input pollar-send-select",
|
|
3844
|
-
value: sellKey,
|
|
3845
|
-
onChange: (e) => {
|
|
3846
|
-
const found = sellOptions.find((o) => assetOptionKey(o) === e.target.value);
|
|
3847
|
-
if (found) onSelectSell(found);
|
|
3848
|
-
},
|
|
3849
|
-
children: [
|
|
3850
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select asset to sell" }),
|
|
3851
|
-
sellOptions.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetOptionKey(o), children: [
|
|
3852
|
-
o.code,
|
|
3853
|
-
o.available !== void 0 ? ` \u2014 ${formatAmount2(o.available)} available` : ""
|
|
3854
|
-
] }, assetOptionKey(o)))
|
|
3855
|
-
]
|
|
3856
|
-
}
|
|
3857
|
-
)
|
|
3858
|
-
] }),
|
|
3859
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
3860
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
|
|
3861
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Amount" }),
|
|
3862
|
-
selectedSell?.available !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-send-hint", children: [
|
|
3863
|
-
"Available: ",
|
|
3864
|
-
formatAmount2(selectedSell.available),
|
|
3865
|
-
" ",
|
|
3866
|
-
selectedSell.code
|
|
3891
|
+
),
|
|
3892
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
3867
3893
|
] })
|
|
3868
3894
|
] }),
|
|
3869
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
type: "text",
|
|
3874
|
-
inputMode: "decimal",
|
|
3875
|
-
placeholder: "0.00",
|
|
3876
|
-
value: amount,
|
|
3877
|
-
onChange: (e) => onAmountChange(e.target.value)
|
|
3878
|
-
}
|
|
3879
|
-
)
|
|
3880
|
-
] }),
|
|
3881
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
3882
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "You receive" }),
|
|
3883
|
-
isLoadingData ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3884
|
-
"select",
|
|
3885
|
-
{
|
|
3886
|
-
className: "pollar-input pollar-send-select",
|
|
3887
|
-
value: buyKey,
|
|
3888
|
-
onChange: (e) => {
|
|
3889
|
-
const found = buyOptions.find((o) => assetOptionKey(o) === e.target.value);
|
|
3890
|
-
if (found) onSelectBuy(found);
|
|
3891
|
-
},
|
|
3892
|
-
children: [
|
|
3893
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select asset to buy" }),
|
|
3894
|
-
buyOptions.map((o) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetOptionKey(o), children: [
|
|
3895
|
-
o.code,
|
|
3896
|
-
o.enabledInApp ? "" : " (external)"
|
|
3897
|
-
] }, assetOptionKey(o)))
|
|
3898
|
-
]
|
|
3899
|
-
}
|
|
3900
|
-
),
|
|
3901
|
-
!isLoadingData && (customOpen ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-custom", children: [
|
|
3895
|
+
step === "form" && configLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "Loading swap options\u2026" }),
|
|
3896
|
+
step === "form" && !configLoading && swapUnavailable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swap is not available for this app." }),
|
|
3897
|
+
step === "form" && !swapUnavailable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3898
|
+
smartUnsupported && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: "Swaps are not yet available for smart (passkey) wallets." }),
|
|
3902
3899
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3903
|
-
|
|
3900
|
+
AssetSelect,
|
|
3904
3901
|
{
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3902
|
+
label: "You pay",
|
|
3903
|
+
value: sellKey,
|
|
3904
|
+
loading: isLoadingData,
|
|
3905
|
+
disabled: configLoading,
|
|
3906
|
+
options: sellOptions.map((o) => ({
|
|
3907
|
+
key: assetOptionKey(o),
|
|
3908
|
+
code: o.code,
|
|
3909
|
+
available: o.available,
|
|
3910
|
+
enabledInApp: o.enabledInApp
|
|
3911
|
+
})),
|
|
3912
|
+
onChange: (key) => {
|
|
3913
|
+
const found = sellOptions.find((o) => assetOptionKey(o) === key);
|
|
3914
|
+
if (found) onSelectSell(found);
|
|
3915
|
+
}
|
|
3910
3916
|
}
|
|
3911
3917
|
),
|
|
3918
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
3919
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
|
|
3920
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Amount" }),
|
|
3921
|
+
selectedSell?.available !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-send-hint", children: [
|
|
3922
|
+
"Available: ",
|
|
3923
|
+
formatAmount3(selectedSell.available),
|
|
3924
|
+
" ",
|
|
3925
|
+
selectedSell.code
|
|
3926
|
+
] })
|
|
3927
|
+
] }),
|
|
3928
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3929
|
+
"input",
|
|
3930
|
+
{
|
|
3931
|
+
className: "pollar-input",
|
|
3932
|
+
type: "text",
|
|
3933
|
+
inputMode: "decimal",
|
|
3934
|
+
placeholder: "0.00",
|
|
3935
|
+
value: amount,
|
|
3936
|
+
disabled: configLoading,
|
|
3937
|
+
onChange: (e) => onAmountChange(e.target.value)
|
|
3938
|
+
}
|
|
3939
|
+
)
|
|
3940
|
+
] }),
|
|
3912
3941
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3913
|
-
|
|
3942
|
+
AssetSelect,
|
|
3914
3943
|
{
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3944
|
+
label: "You receive",
|
|
3945
|
+
value: buyKey,
|
|
3946
|
+
loading: isLoadingData,
|
|
3947
|
+
disabled: configLoading,
|
|
3948
|
+
options: buyOptions.map((o) => ({
|
|
3949
|
+
key: assetOptionKey(o),
|
|
3950
|
+
code: o.code,
|
|
3951
|
+
enabledInApp: o.enabledInApp
|
|
3952
|
+
})),
|
|
3953
|
+
onChange: (key) => {
|
|
3954
|
+
const found = buyOptions.find((o) => assetOptionKey(o) === key);
|
|
3955
|
+
if (found) onSelectBuy(found);
|
|
3956
|
+
},
|
|
3957
|
+
children: customOpen ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-custom", children: [
|
|
3958
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3959
|
+
"input",
|
|
3960
|
+
{
|
|
3961
|
+
className: "pollar-input",
|
|
3962
|
+
type: "text",
|
|
3963
|
+
placeholder: "Code (e.g. USDC)",
|
|
3964
|
+
value: customCode,
|
|
3965
|
+
onChange: (e) => setCustomCode(e.target.value)
|
|
3966
|
+
}
|
|
3967
|
+
),
|
|
3968
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3969
|
+
"input",
|
|
3970
|
+
{
|
|
3971
|
+
className: "pollar-input",
|
|
3972
|
+
type: "text",
|
|
3973
|
+
placeholder: "Issuer (G...)",
|
|
3974
|
+
value: customIssuer,
|
|
3975
|
+
onChange: (e) => setCustomIssuer(e.target.value)
|
|
3976
|
+
}
|
|
3977
|
+
),
|
|
3978
|
+
customError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: customError }),
|
|
3979
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-custom-actions", children: [
|
|
3980
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submitCustomToken, children: "Add token" }),
|
|
3981
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3982
|
+
"button",
|
|
3983
|
+
{
|
|
3984
|
+
type: "button",
|
|
3985
|
+
className: "pollar-swap-custom-cancel",
|
|
3986
|
+
onClick: () => {
|
|
3987
|
+
setCustomOpen(false);
|
|
3988
|
+
setCustomError("");
|
|
3989
|
+
},
|
|
3990
|
+
children: "Cancel"
|
|
3991
|
+
}
|
|
3992
|
+
)
|
|
3993
|
+
] })
|
|
3994
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3995
|
+
"button",
|
|
3996
|
+
{
|
|
3997
|
+
type: "button",
|
|
3998
|
+
className: "pollar-swap-custom-toggle",
|
|
3999
|
+
disabled: configLoading,
|
|
4000
|
+
onClick: () => setCustomOpen(true),
|
|
4001
|
+
children: "+ Add a token by code / issuer"
|
|
4002
|
+
}
|
|
4003
|
+
)
|
|
3920
4004
|
}
|
|
3921
4005
|
),
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submitCustomToken, children: "Add token" }),
|
|
4006
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
|
|
4007
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Route" }),
|
|
3925
4008
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3926
|
-
"
|
|
4009
|
+
"select",
|
|
3927
4010
|
{
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
},
|
|
3934
|
-
children: "Cancel"
|
|
4011
|
+
className: "pollar-input pollar-send-select",
|
|
4012
|
+
value: provider,
|
|
4013
|
+
disabled: configLoading || providers.length === 0,
|
|
4014
|
+
onChange: (e) => onProviderChange(e.target.value),
|
|
4015
|
+
children: providers.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("option", { value: provider, children: configLoading ? "Loading\u2026" : PROVIDER_LABELS[provider] }) : providers.map((p) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: p, children: PROVIDER_LABELS[p] }, p))
|
|
3935
4016
|
}
|
|
3936
4017
|
)
|
|
3937
|
-
] })
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
4018
|
+
] }),
|
|
4019
|
+
quoteLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "Fetching best price\u2026" }),
|
|
4020
|
+
!quoteLoading && quoteError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: quoteError }),
|
|
4021
|
+
!quoteLoading && !quoteError && quote && selectedBuy && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote", children: [
|
|
4022
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4023
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "You receive" }),
|
|
4024
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
4025
|
+
"~ ",
|
|
4026
|
+
formatAmount3(quote.amountOut),
|
|
4027
|
+
" ",
|
|
4028
|
+
selectedBuy.code
|
|
4029
|
+
] })
|
|
4030
|
+
] }),
|
|
4031
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4032
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Minimum received" }),
|
|
4033
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
4034
|
+
formatAmount3(quote.minReceived),
|
|
4035
|
+
" ",
|
|
4036
|
+
selectedBuy.code
|
|
4037
|
+
] })
|
|
4038
|
+
] }),
|
|
4039
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4040
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Price impact" }),
|
|
4041
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
4042
|
+
quote.priceImpactPct,
|
|
4043
|
+
"%"
|
|
4044
|
+
] })
|
|
4045
|
+
] }),
|
|
4046
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4047
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Route" }),
|
|
4048
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: PROVIDER_LABELS[quote.provider] })
|
|
4049
|
+
] })
|
|
4050
|
+
] }),
|
|
4051
|
+
!quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "No route found for this pair." }),
|
|
4052
|
+
buyNeedsTrustline && selectedBuy && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-trustline-notice", children: [
|
|
4053
|
+
"To receive ",
|
|
4054
|
+
selectedBuy.code,
|
|
4055
|
+
" your wallet needs a trustline. Swapping will create it first (~0.5 XLM reserve, refundable if you later remove it)."
|
|
4056
|
+
] }),
|
|
4057
|
+
formError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: formError }),
|
|
4058
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary", onClick: onSwap, disabled: !canSwap, children: buyNeedsTrustline ? "Create trustline & swap" : "Swap" }) })
|
|
4059
|
+
] }),
|
|
4060
|
+
step === "tx" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4061
|
+
TxStatusView,
|
|
3944
4062
|
{
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
4063
|
+
transaction,
|
|
4064
|
+
showXdr,
|
|
4065
|
+
copied,
|
|
4066
|
+
explorerUrl,
|
|
4067
|
+
walletType,
|
|
4068
|
+
onSignAndSend: () => {
|
|
4069
|
+
},
|
|
4070
|
+
onToggleXdr,
|
|
4071
|
+
onCopyHash,
|
|
4072
|
+
onRetry,
|
|
4073
|
+
onDone
|
|
3949
4074
|
}
|
|
3950
|
-
)
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
3956
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "You receive" }),
|
|
3957
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3958
|
-
"~ ",
|
|
3959
|
-
formatAmount2(quote.amountOut),
|
|
3960
|
-
" ",
|
|
3961
|
-
selectedBuy.code
|
|
3962
|
-
] })
|
|
3963
|
-
] }),
|
|
3964
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
3965
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Minimum received" }),
|
|
3966
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3967
|
-
formatAmount2(quote.minReceived),
|
|
3968
|
-
" ",
|
|
3969
|
-
selectedBuy.code
|
|
3970
|
-
] })
|
|
3971
|
-
] }),
|
|
3972
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
3973
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Price impact" }),
|
|
3974
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3975
|
-
quote.priceImpactPct,
|
|
3976
|
-
"%"
|
|
3977
|
-
] })
|
|
3978
|
-
] }),
|
|
3979
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
3980
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-send-hint", children: "Route" }),
|
|
3981
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: PROVIDER_LABELS[quote.provider] })
|
|
3982
|
-
] })
|
|
3983
|
-
] }),
|
|
3984
|
-
!quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-hint", children: "No route found for this pair." }),
|
|
3985
|
-
buyNeedsTrustline && selectedBuy && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-swap-trustline-notice", children: [
|
|
3986
|
-
"To receive ",
|
|
3987
|
-
selectedBuy.code,
|
|
3988
|
-
" your wallet needs a trustline. Swapping will create it first (~0.5 XLM reserve, refundable if you later remove it)."
|
|
3989
|
-
] }),
|
|
3990
|
-
formError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: formError }),
|
|
3991
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary", onClick: onSwap, disabled: !canSwap, children: buyNeedsTrustline ? "Create trustline & swap" : "Swap" }) })
|
|
3992
|
-
] }),
|
|
3993
|
-
step === "tx" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3994
|
-
TxStatusView,
|
|
3995
|
-
{
|
|
3996
|
-
transaction,
|
|
3997
|
-
showXdr,
|
|
3998
|
-
copied,
|
|
3999
|
-
explorerUrl,
|
|
4000
|
-
walletType,
|
|
4001
|
-
onSignAndSend: () => {
|
|
4002
|
-
},
|
|
4003
|
-
onToggleXdr,
|
|
4004
|
-
onCopyHash,
|
|
4005
|
-
onRetry,
|
|
4006
|
-
onDone
|
|
4007
|
-
}
|
|
4008
|
-
),
|
|
4009
|
-
/* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
|
|
4010
|
-
] });
|
|
4075
|
+
),
|
|
4076
|
+
/* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
|
|
4077
|
+
]
|
|
4078
|
+
}
|
|
4079
|
+
);
|
|
4011
4080
|
}
|
|
4012
4081
|
var QUOTE_DEBOUNCE_MS = 400;
|
|
4013
4082
|
function toRef(a) {
|
|
@@ -4085,7 +4154,7 @@ function SwapModal({ onClose }) {
|
|
|
4085
4154
|
const balances = walletBalance.step === "loaded" ? walletBalance.data.balances : [];
|
|
4086
4155
|
const assetRecords = enabledAssets.step === "loaded" ? enabledAssets.data.assets : [];
|
|
4087
4156
|
const isLoadingData = walletBalance.step === "loading" || enabledAssets.step === "loading";
|
|
4088
|
-
const sellOptions = balances.filter((b) =>
|
|
4157
|
+
const sellOptions = balances.filter((b) => b.type === "native" || !b.trustlineRemoved).map((b) => ({ ref: toRef(b), code: b.code, issuer: b.issuer, available: b.available, enabledInApp: b.enabledInApp }));
|
|
4089
4158
|
const buyKeyOfSell = selectedSell ? `${selectedSell.code}:${selectedSell.issuer ?? "native"}` : "";
|
|
4090
4159
|
const optKey = (o) => `${o.code}:${o.issuer ?? "native"}`;
|
|
4091
4160
|
const enabledBuy = assetRecords.map((a) => ({
|
|
@@ -4103,9 +4172,19 @@ function SwapModal({ onClose }) {
|
|
|
4103
4172
|
})).filter((o) => !enabledKeys.has(optKey(o)));
|
|
4104
4173
|
const knownKeys = /* @__PURE__ */ new Set([...enabledKeys, ...catalogBuy.map(optKey)]);
|
|
4105
4174
|
const customBuy = customTokens.filter((o) => !knownKeys.has(optKey(o)));
|
|
4106
|
-
const buyOptions = [...enabledBuy, ...catalogBuy, ...customBuy].filter(
|
|
4107
|
-
|
|
4108
|
-
|
|
4175
|
+
const buyOptions = [...enabledBuy, ...catalogBuy, ...customBuy].filter((o) => optKey(o) !== buyKeyOfSell);
|
|
4176
|
+
react.useEffect(() => {
|
|
4177
|
+
if (sellOptions.length === 0) return;
|
|
4178
|
+
if (!selectedSell || !sellOptions.some((o) => optKey(o) === optKey(selectedSell))) {
|
|
4179
|
+
setSelectedSell(sellOptions[0]);
|
|
4180
|
+
}
|
|
4181
|
+
}, [sellOptions, selectedSell]);
|
|
4182
|
+
react.useEffect(() => {
|
|
4183
|
+
if (buyOptions.length === 0) return;
|
|
4184
|
+
if (!selectedBuy || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
|
|
4185
|
+
setSelectedBuy(buyOptions[0]);
|
|
4186
|
+
}
|
|
4187
|
+
}, [buyOptions, selectedBuy]);
|
|
4109
4188
|
function addCustomToken(code, issuer) {
|
|
4110
4189
|
const c = code.trim().toUpperCase();
|
|
4111
4190
|
const i = issuer.trim();
|
|
@@ -4615,6 +4694,9 @@ function StatusBadge({ status }) {
|
|
|
4615
4694
|
function formatDate(iso) {
|
|
4616
4695
|
return new Date(iso).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
|
|
4617
4696
|
}
|
|
4697
|
+
function truncateMiddle(value, head = 4, tail = 4) {
|
|
4698
|
+
return value.length <= head + tail + 1 ? value : `${value.slice(0, head)}\u2026${value.slice(-tail)}`;
|
|
4699
|
+
}
|
|
4618
4700
|
function TxHistoryModalTemplate({
|
|
4619
4701
|
theme,
|
|
4620
4702
|
accentColor,
|
|
@@ -4687,11 +4769,31 @@ function TxHistoryModalTemplate({
|
|
|
4687
4769
|
txHistory.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: txHistory.message }),
|
|
4688
4770
|
txHistory.step === "loaded" && records.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No transactions yet." }),
|
|
4689
4771
|
records.map((record) => {
|
|
4690
|
-
const
|
|
4772
|
+
const hash = typeof record.hash === "string" && record.hash.length > 0 ? record.hash : void 0;
|
|
4773
|
+
const explorerUrl = hash ? `https://stellar.expert/explorer/${record.network === "testnet" ? "testnet" : "public"}/tx/${hash}` : void 0;
|
|
4691
4774
|
const destination = typeof record.details?.destination === "string" ? record.details.destination : void 0;
|
|
4775
|
+
const asset = typeof record.details?.asset === "string" ? record.details.asset : void 0;
|
|
4776
|
+
const colon = asset ? asset.indexOf(":") : -1;
|
|
4777
|
+
const trustline = record.operation === "change_trust" && asset && colon > 0 ? {
|
|
4778
|
+
prefix: record.summary.split(":")[0],
|
|
4779
|
+
code: asset.slice(0, colon),
|
|
4780
|
+
issuer: asset.slice(colon + 1)
|
|
4781
|
+
} : void 0;
|
|
4692
4782
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item", children: [
|
|
4693
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4694
|
-
|
|
4783
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item-top", children: [
|
|
4784
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-summary", children: trustline ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4785
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-title", children: [
|
|
4786
|
+
trustline.prefix,
|
|
4787
|
+
": ",
|
|
4788
|
+
trustline.code
|
|
4789
|
+
] }),
|
|
4790
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-issuer", children: [
|
|
4791
|
+
truncateMiddle(trustline.issuer),
|
|
4792
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: trustline.issuer, label: "Copy issuer", className: "pollar-copy-btn-sm" })
|
|
4793
|
+
] })
|
|
4794
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-title", children: record.summary }) }),
|
|
4795
|
+
/* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: record.status })
|
|
4796
|
+
] }),
|
|
4695
4797
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-meta", children: [
|
|
4696
4798
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: record.operation }),
|
|
4697
4799
|
typeof record.details?.sponsored === "boolean" && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
@@ -4703,25 +4805,29 @@ function TxHistoryModalTemplate({
|
|
|
4703
4805
|
record.feeXlm,
|
|
4704
4806
|
" XLM"
|
|
4705
4807
|
] }),
|
|
4706
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
4707
|
-
"\xB7 ",
|
|
4708
|
-
formatDate(record.createdAt)
|
|
4709
|
-
] }),
|
|
4710
4808
|
destination && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4711
4809
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7" }),
|
|
4712
|
-
/* @__PURE__ */ jsxRuntime.
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4810
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-issuer", children: [
|
|
4811
|
+
truncateMiddle(destination),
|
|
4812
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: destination, label: "Copy wallet address", className: "pollar-copy-btn-sm" })
|
|
4813
|
+
] })
|
|
4814
|
+
] })
|
|
4815
|
+
] }),
|
|
4816
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item-footer", children: [
|
|
4817
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDate(record.createdAt) }),
|
|
4818
|
+
hash && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4819
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-dot", children: "\xB7" }),
|
|
4820
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-hash", children: truncateMiddle(hash, 6, 6) }),
|
|
4821
|
+
/* @__PURE__ */ jsxRuntime.jsx(CopyButton, { value: hash, label: "Copy transaction hash", className: "pollar-copy-btn-sm" }),
|
|
4822
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4823
|
+
"a",
|
|
4824
|
+
{
|
|
4825
|
+
className: "pollar-hist-item-explorer",
|
|
4826
|
+
href: explorerUrl,
|
|
4827
|
+
target: "_blank",
|
|
4828
|
+
rel: "noopener noreferrer",
|
|
4829
|
+
"aria-label": "View on Stellar Explorer",
|
|
4830
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "12", height: "12", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
4725
4831
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4726
4832
|
"path",
|
|
4727
4833
|
{
|
|
@@ -4741,11 +4847,10 @@ function TxHistoryModalTemplate({
|
|
|
4741
4847
|
strokeLinejoin: "round"
|
|
4742
4848
|
}
|
|
4743
4849
|
)
|
|
4744
|
-
] })
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
)
|
|
4850
|
+
] })
|
|
4851
|
+
}
|
|
4852
|
+
)
|
|
4853
|
+
] })
|
|
4749
4854
|
] })
|
|
4750
4855
|
] }, record.id);
|
|
4751
4856
|
})
|