@pollar/react 0.10.1-rc.1 → 0.10.1-rc.10
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 +244 -176
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +66 -8
- package/dist/index.d.ts +66 -8
- package/dist/index.js +1464 -459
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1464 -460
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1033,11 +1033,53 @@ var PollarModalFooter = () => {
|
|
|
1033
1033
|
/* @__PURE__ */ jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
|
|
1034
1034
|
/* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
|
|
1035
1035
|
"v",
|
|
1036
|
-
"0.10.1-rc.
|
|
1036
|
+
"0.10.1-rc.10"
|
|
1037
1037
|
] })
|
|
1038
1038
|
] })
|
|
1039
1039
|
] });
|
|
1040
1040
|
};
|
|
1041
|
+
function CopyButton({ value, label = "Copy", className }) {
|
|
1042
|
+
const [copied, setCopied] = useState(false);
|
|
1043
|
+
const timerRef = useRef(null);
|
|
1044
|
+
useEffect(() => {
|
|
1045
|
+
return () => {
|
|
1046
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1047
|
+
};
|
|
1048
|
+
}, []);
|
|
1049
|
+
function handleCopy(e) {
|
|
1050
|
+
e.stopPropagation();
|
|
1051
|
+
if (!value || !navigator.clipboard) return;
|
|
1052
|
+
void navigator.clipboard.writeText(value).then(() => {
|
|
1053
|
+
setCopied(true);
|
|
1054
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1055
|
+
timerRef.current = setTimeout(() => {
|
|
1056
|
+
setCopied(false);
|
|
1057
|
+
timerRef.current = null;
|
|
1058
|
+
}, 1500);
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
return /* @__PURE__ */ jsx(
|
|
1062
|
+
"button",
|
|
1063
|
+
{
|
|
1064
|
+
type: "button",
|
|
1065
|
+
className: `pollar-copy-btn${className ? ` ${className}` : ""}`,
|
|
1066
|
+
onClick: handleCopy,
|
|
1067
|
+
"aria-label": copied ? "Copied" : label,
|
|
1068
|
+
children: copied ? /* @__PURE__ */ jsx("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M3.5 7l2.5 2.5 4.5-5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) : /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
1069
|
+
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
1070
|
+
/* @__PURE__ */ jsx(
|
|
1071
|
+
"path",
|
|
1072
|
+
{
|
|
1073
|
+
d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
|
|
1074
|
+
stroke: "currentColor",
|
|
1075
|
+
strokeWidth: "1.5",
|
|
1076
|
+
strokeLinecap: "round"
|
|
1077
|
+
}
|
|
1078
|
+
)
|
|
1079
|
+
] })
|
|
1080
|
+
}
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1041
1083
|
function ModalStatusBanner({ message, status, onCancel, onRetry }) {
|
|
1042
1084
|
if (!message && status === "NONE") {
|
|
1043
1085
|
return /* @__PURE__ */ jsx("div", { className: "pollar-status" });
|
|
@@ -1116,7 +1158,10 @@ function RuleCard({
|
|
|
1116
1158
|
validity
|
|
1117
1159
|
] })
|
|
1118
1160
|
] }),
|
|
1119
|
-
/* @__PURE__ */ jsx("div", { className: "pollar-dist-item-action", children: isClaimed ? /* @__PURE__ */ jsx("span", { className: "pollar-dist-item-status", "data-kind": "claimed", children: "Claimed" }) : effectivelyClaimable ? /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary pollar-dist-claim-btn", onClick: onClaim, disabled: isClaiming, children: isClaiming ?
|
|
1161
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-dist-item-action", children: isClaimed ? /* @__PURE__ */ jsx("span", { className: "pollar-dist-item-status", "data-kind": "claimed", children: "Claimed" }) : effectivelyClaimable ? /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary pollar-dist-claim-btn", onClick: onClaim, disabled: isClaiming, children: isClaiming ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1162
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
1163
|
+
"Claiming\u2026"
|
|
1164
|
+
] }) : "Claim" }) : /* @__PURE__ */ jsx("span", { className: "pollar-dist-item-status", "data-kind": "unavailable", children: reasonLabel(rule.reason) }) }),
|
|
1120
1165
|
errorMessage && /* @__PURE__ */ jsx("div", { className: "pollar-dist-item-error", children: errorMessage })
|
|
1121
1166
|
] });
|
|
1122
1167
|
}
|
|
@@ -1162,29 +1207,46 @@ function DistributionRulesModalTemplate({
|
|
|
1162
1207
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
1163
1208
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Distribution Rules" }),
|
|
1164
1209
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1210
|
+
/* @__PURE__ */ jsx(
|
|
1211
|
+
"button",
|
|
1212
|
+
{
|
|
1213
|
+
type: "button",
|
|
1214
|
+
className: "pollar-modal-close",
|
|
1215
|
+
onClick: onRefresh,
|
|
1216
|
+
disabled: isLoading,
|
|
1217
|
+
"aria-label": "Refresh",
|
|
1218
|
+
title: "Refresh",
|
|
1219
|
+
children: /* @__PURE__ */ jsx(
|
|
1220
|
+
"svg",
|
|
1221
|
+
{
|
|
1222
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
1223
|
+
width: "16",
|
|
1224
|
+
height: "16",
|
|
1225
|
+
viewBox: "0 0 16 16",
|
|
1226
|
+
fill: "none",
|
|
1227
|
+
"aria-hidden": true,
|
|
1228
|
+
children: /* @__PURE__ */ jsx(
|
|
1229
|
+
"path",
|
|
1230
|
+
{
|
|
1231
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
1232
|
+
stroke: "currentColor",
|
|
1233
|
+
strokeWidth: "1.6",
|
|
1234
|
+
strokeLinecap: "round",
|
|
1235
|
+
strokeLinejoin: "round"
|
|
1236
|
+
}
|
|
1237
|
+
)
|
|
1238
|
+
}
|
|
1239
|
+
)
|
|
1240
|
+
}
|
|
1241
|
+
),
|
|
1183
1242
|
/* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
1184
1243
|
] })
|
|
1185
1244
|
] }),
|
|
1186
1245
|
/* @__PURE__ */ jsxs("div", { className: "pollar-dist-list", children: [
|
|
1187
|
-
isLoading && /* @__PURE__ */
|
|
1246
|
+
isLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
1247
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
1248
|
+
/* @__PURE__ */ jsx("span", { children: "Loading\u2026" })
|
|
1249
|
+
] }),
|
|
1188
1250
|
state.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: state.message }),
|
|
1189
1251
|
state.step === "loaded" && rules.length === 0 && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No distribution rules available." }),
|
|
1190
1252
|
rules.map((rule) => /* @__PURE__ */ jsx(
|
|
@@ -1309,14 +1371,14 @@ function AssetItem({
|
|
|
1309
1371
|
!isNative && record.enabledInApp && /* @__PURE__ */ jsx("span", { className: "pollar-asset-sponsor", children: record.sponsored ? "Reserve sponsored by the app" : "You pay the reserve (~0.5 XLM)" })
|
|
1310
1372
|
] }),
|
|
1311
1373
|
/* @__PURE__ */ jsxs("div", { className: "pollar-asset-actions", children: [
|
|
1312
|
-
/* @__PURE__ */ jsx("span", { className: `pollar-asset-trustline${established ? " established" : ""}`, children: established ? "Trustline active" : "Needs trustline" }),
|
|
1374
|
+
/* @__PURE__ */ jsx("span", { className: `pollar-asset-trustline${established ? " pollar-established" : ""}`, children: established ? "Trustline active" : "Needs trustline" }),
|
|
1313
1375
|
!isNative && /* @__PURE__ */ jsx(
|
|
1314
1376
|
"button",
|
|
1315
1377
|
{
|
|
1316
|
-
className: `pollar-asset-btn${established ? " danger" : ""}`,
|
|
1378
|
+
className: `pollar-asset-btn${established ? " pollar-danger" : ""}`,
|
|
1317
1379
|
onClick: () => onToggle(record),
|
|
1318
1380
|
disabled: busy || disabled,
|
|
1319
|
-
children: busy ? "
|
|
1381
|
+
children: busy ? /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }) : established ? "Disable" : "Enable"
|
|
1320
1382
|
}
|
|
1321
1383
|
)
|
|
1322
1384
|
] })
|
|
@@ -1349,29 +1411,46 @@ function EnabledAssetsModalTemplate({
|
|
|
1349
1411
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
1350
1412
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Trustlines" }),
|
|
1351
1413
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
1352
|
-
/* @__PURE__ */
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1414
|
+
/* @__PURE__ */ jsx(
|
|
1415
|
+
"button",
|
|
1416
|
+
{
|
|
1417
|
+
type: "button",
|
|
1418
|
+
className: "pollar-modal-close",
|
|
1419
|
+
onClick: onRefresh,
|
|
1420
|
+
disabled: isLoading || busy,
|
|
1421
|
+
"aria-label": "Refresh",
|
|
1422
|
+
title: "Refresh",
|
|
1423
|
+
children: /* @__PURE__ */ jsx(
|
|
1424
|
+
"svg",
|
|
1425
|
+
{
|
|
1426
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
1427
|
+
width: "16",
|
|
1428
|
+
height: "16",
|
|
1429
|
+
viewBox: "0 0 16 16",
|
|
1430
|
+
fill: "none",
|
|
1431
|
+
"aria-hidden": true,
|
|
1432
|
+
children: /* @__PURE__ */ jsx(
|
|
1433
|
+
"path",
|
|
1434
|
+
{
|
|
1435
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
1436
|
+
stroke: "currentColor",
|
|
1437
|
+
strokeWidth: "1.6",
|
|
1438
|
+
strokeLinecap: "round",
|
|
1439
|
+
strokeLinejoin: "round"
|
|
1440
|
+
}
|
|
1441
|
+
)
|
|
1442
|
+
}
|
|
1443
|
+
)
|
|
1444
|
+
}
|
|
1445
|
+
),
|
|
1370
1446
|
/* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
1371
1447
|
] })
|
|
1372
1448
|
] }),
|
|
1373
1449
|
walletAddress && /* @__PURE__ */ jsx("div", { className: "pollar-asset-address", children: cropAddress(walletAddress) }),
|
|
1374
|
-
isLoading && /* @__PURE__ */
|
|
1450
|
+
isLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
1451
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
1452
|
+
/* @__PURE__ */ jsx("span", { children: "Loading\u2026" })
|
|
1453
|
+
] }),
|
|
1375
1454
|
enabledAssets.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: enabledAssets.message }),
|
|
1376
1455
|
actionError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-action-error", children: actionError }),
|
|
1377
1456
|
data && !data.exists && /* @__PURE__ */ jsxs("div", { className: "pollar-modal-empty", children: [
|
|
@@ -1430,7 +1509,7 @@ function CustomTrustlineModalTemplate({
|
|
|
1430
1509
|
children: [
|
|
1431
1510
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
1432
1511
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
1433
|
-
/* @__PURE__ */ jsx("button", { className: "pollar-modal-
|
|
1512
|
+
/* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onBack, disabled: busy, "aria-label": "Back", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
1434
1513
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Add custom trustline" })
|
|
1435
1514
|
] }),
|
|
1436
1515
|
/* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
@@ -1491,7 +1570,10 @@ function CustomTrustlineModalTemplate({
|
|
|
1491
1570
|
)
|
|
1492
1571
|
] }),
|
|
1493
1572
|
actionError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-action-error", children: actionError }),
|
|
1494
|
-
/* @__PURE__ */ jsx("button", { className: "pollar-
|
|
1573
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submit, disabled: !canSubmit, children: busy ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1574
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
1575
|
+
"Enabling\u2026"
|
|
1576
|
+
] }) : "Enable trustline" }) }),
|
|
1495
1577
|
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
1496
1578
|
]
|
|
1497
1579
|
}
|
|
@@ -1612,6 +1694,7 @@ function KycModalTemplate({
|
|
|
1612
1694
|
isLoading,
|
|
1613
1695
|
onSelectProvider,
|
|
1614
1696
|
onDoneVerifying,
|
|
1697
|
+
onRefresh,
|
|
1615
1698
|
onClose
|
|
1616
1699
|
}) {
|
|
1617
1700
|
const isDark = theme === "dark";
|
|
@@ -1636,16 +1719,56 @@ function KycModalTemplate({
|
|
|
1636
1719
|
"--pollar-modal-subtitle-size": "0.9rem"
|
|
1637
1720
|
};
|
|
1638
1721
|
return /* @__PURE__ */ jsxs("div", { className: "pollar-modal-card pollar-kyc-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
|
|
1639
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-
|
|
1640
|
-
/* @__PURE__ */
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1722
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
1723
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-kyc-header-text", children: [
|
|
1724
|
+
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Identity verification" }),
|
|
1725
|
+
/* @__PURE__ */ jsxs("p", { className: "pollar-kyc-subtitle", children: [
|
|
1726
|
+
step === "select_provider" && "Choose your verification provider",
|
|
1727
|
+
step === "verifying" && `Verifying with ${selectedProvider?.name}`,
|
|
1728
|
+
step === "polling" && "Waiting for verification result",
|
|
1729
|
+
step === "done" && "Verification complete"
|
|
1730
|
+
] })
|
|
1731
|
+
] }),
|
|
1732
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
1733
|
+
step === "select_provider" && /* @__PURE__ */ jsx(
|
|
1734
|
+
"button",
|
|
1735
|
+
{
|
|
1736
|
+
type: "button",
|
|
1737
|
+
className: "pollar-modal-close",
|
|
1738
|
+
onClick: onRefresh,
|
|
1739
|
+
disabled: isLoading,
|
|
1740
|
+
"aria-label": "Refresh",
|
|
1741
|
+
title: "Refresh providers",
|
|
1742
|
+
children: /* @__PURE__ */ jsx(
|
|
1743
|
+
"svg",
|
|
1744
|
+
{
|
|
1745
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
1746
|
+
width: "16",
|
|
1747
|
+
height: "16",
|
|
1748
|
+
viewBox: "0 0 16 16",
|
|
1749
|
+
fill: "none",
|
|
1750
|
+
"aria-hidden": true,
|
|
1751
|
+
children: /* @__PURE__ */ jsx(
|
|
1752
|
+
"path",
|
|
1753
|
+
{
|
|
1754
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
1755
|
+
stroke: "currentColor",
|
|
1756
|
+
strokeWidth: "1.6",
|
|
1757
|
+
strokeLinecap: "round",
|
|
1758
|
+
strokeLinejoin: "round"
|
|
1759
|
+
}
|
|
1760
|
+
)
|
|
1761
|
+
}
|
|
1762
|
+
)
|
|
1763
|
+
}
|
|
1764
|
+
),
|
|
1765
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
1646
1766
|
] })
|
|
1647
1767
|
] }),
|
|
1648
|
-
step === "select_provider" && /* @__PURE__ */ jsxs("div", { className: "pollar-
|
|
1768
|
+
step === "select_provider" && (isLoading && providers.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
1769
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
1770
|
+
/* @__PURE__ */ jsx("span", { children: "Loading providers\u2026" })
|
|
1771
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "pollar-kyc-providers", children: [
|
|
1649
1772
|
providers.length === 0 && /* @__PURE__ */ jsx("p", { style: { color: "var(--pollar-muted)", textAlign: "center" }, children: "No providers available for your country." }),
|
|
1650
1773
|
providers.map((p) => /* @__PURE__ */ jsxs(
|
|
1651
1774
|
"button",
|
|
@@ -1661,7 +1784,7 @@ function KycModalTemplate({
|
|
|
1661
1784
|
},
|
|
1662
1785
|
p.id
|
|
1663
1786
|
))
|
|
1664
|
-
] }),
|
|
1787
|
+
] })),
|
|
1665
1788
|
step === "verifying" && selectedProvider && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1666
1789
|
/* @__PURE__ */ jsx("div", { className: "pollar-kyc-iframe-wrap", children: session?.kycUrl ? /* @__PURE__ */ jsx("iframe", { className: "pollar-kyc-iframe", src: session.kycUrl, title: "KYC verification", allow: "camera; microphone" }) : /* @__PURE__ */ jsxs("div", { className: "pollar-kyc-iframe-mock", children: [
|
|
1667
1790
|
/* @__PURE__ */ jsx("span", { children: "\u{1F512}" }),
|
|
@@ -1694,10 +1817,13 @@ function KycModal({ onClose, country = "MX", level = "basic", onApproved }) {
|
|
|
1694
1817
|
const [isLoading, setIsLoading] = useState(false);
|
|
1695
1818
|
const client = getClient();
|
|
1696
1819
|
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
1697
|
-
|
|
1820
|
+
const loadProviders = useCallback(() => {
|
|
1698
1821
|
setIsLoading(true);
|
|
1699
|
-
getClient().getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
|
|
1822
|
+
return getClient().getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
|
|
1700
1823
|
}, [getClient, country]);
|
|
1824
|
+
useEffect(() => {
|
|
1825
|
+
void loadProviders();
|
|
1826
|
+
}, [loadProviders]);
|
|
1701
1827
|
async function handleSelectProvider(provider) {
|
|
1702
1828
|
setSelectedProvider(provider);
|
|
1703
1829
|
setIsLoading(true);
|
|
@@ -1743,6 +1869,7 @@ function KycModal({ onClose, country = "MX", level = "basic", onApproved }) {
|
|
|
1743
1869
|
isLoading,
|
|
1744
1870
|
onSelectProvider: handleSelectProvider,
|
|
1745
1871
|
onDoneVerifying: handleDoneVerifying,
|
|
1872
|
+
onRefresh: () => void loadProviders(),
|
|
1746
1873
|
onClose
|
|
1747
1874
|
}
|
|
1748
1875
|
) });
|
|
@@ -1798,8 +1925,8 @@ function EmailCodeInput({ email, onSubmit }) {
|
|
|
1798
1925
|
] });
|
|
1799
1926
|
}
|
|
1800
1927
|
var GithubButton = ({ disabled, onClick }) => {
|
|
1801
|
-
return /* @__PURE__ */ jsxs("button", { className: "github-button", disabled, onClick, children: [
|
|
1802
|
-
/* @__PURE__ */ jsx("svg", { className: "github-button-icon", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
1928
|
+
return /* @__PURE__ */ jsxs("button", { className: "pollar-github-button", disabled, onClick, children: [
|
|
1929
|
+
/* @__PURE__ */ jsx("svg", { className: "pollar-github-button-icon", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
1803
1930
|
"path",
|
|
1804
1931
|
{
|
|
1805
1932
|
fillRule: "evenodd",
|
|
@@ -1807,14 +1934,14 @@ var GithubButton = ({ disabled, onClick }) => {
|
|
|
1807
1934
|
clipRule: "evenodd"
|
|
1808
1935
|
}
|
|
1809
1936
|
) }),
|
|
1810
|
-
/* @__PURE__ */ jsx("span", { className: "github-button-contents", children: "GitHub" })
|
|
1937
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-github-button-contents", children: "GitHub" })
|
|
1811
1938
|
] });
|
|
1812
1939
|
};
|
|
1813
1940
|
var GoogleButton = ({ disabled, onClick }) => {
|
|
1814
|
-
return /* @__PURE__ */ jsxs("button", { className: "gsi-material-button", disabled, onClick, children: [
|
|
1815
|
-
/* @__PURE__ */ jsx("div", { className: "gsi-material-button-state" }),
|
|
1816
|
-
/* @__PURE__ */ jsxs("div", { className: "gsi-material-button-content-wrapper", children: [
|
|
1817
|
-
/* @__PURE__ */ jsx("div", { className: "gsi-material-button-icon", children: /* @__PURE__ */ jsxs("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", style: { display: "block" }, children: [
|
|
1941
|
+
return /* @__PURE__ */ jsxs("button", { className: "pollar-gsi-material-button", disabled, onClick, children: [
|
|
1942
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-gsi-material-button-state" }),
|
|
1943
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-gsi-material-button-content-wrapper", children: [
|
|
1944
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-gsi-material-button-icon", children: /* @__PURE__ */ jsxs("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48", style: { display: "block" }, children: [
|
|
1818
1945
|
/* @__PURE__ */ jsx(
|
|
1819
1946
|
"path",
|
|
1820
1947
|
{
|
|
@@ -1845,7 +1972,7 @@ var GoogleButton = ({ disabled, onClick }) => {
|
|
|
1845
1972
|
),
|
|
1846
1973
|
/* @__PURE__ */ jsx("path", { fill: "none", d: "M0 0h48v48H0z" })
|
|
1847
1974
|
] }) }),
|
|
1848
|
-
/* @__PURE__ */ jsx("span", { className: "gsi-material-button-contents", children: "Google" }),
|
|
1975
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-gsi-material-button-contents", children: "Google" }),
|
|
1849
1976
|
/* @__PURE__ */ jsx("span", { style: { display: "none" }, children: "Google" })
|
|
1850
1977
|
] })
|
|
1851
1978
|
] });
|
|
@@ -2051,7 +2178,7 @@ function LoginModalTemplate({
|
|
|
2051
2178
|
placeholder: "you@email.com",
|
|
2052
2179
|
value: email,
|
|
2053
2180
|
disabled: isLoading,
|
|
2054
|
-
className: "pollar-
|
|
2181
|
+
className: "pollar-input",
|
|
2055
2182
|
onChange: (e) => onEmailChange?.(e.target.value),
|
|
2056
2183
|
onKeyDown: (e) => e.key === "Enter" && onEmailSubmit?.()
|
|
2057
2184
|
}
|
|
@@ -2230,12 +2357,38 @@ function PrivyLoginSubmodal({
|
|
|
2230
2357
|
fail(error);
|
|
2231
2358
|
}
|
|
2232
2359
|
}
|
|
2233
|
-
const BackButton = ({ onClick }) => /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": "Back", children: /* @__PURE__ */ jsx(
|
|
2360
|
+
const BackButton = ({ onClick }) => /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": "Back", children: /* @__PURE__ */ jsx(
|
|
2361
|
+
"svg",
|
|
2362
|
+
{
|
|
2363
|
+
width: "20",
|
|
2364
|
+
height: "20",
|
|
2365
|
+
viewBox: "0 0 24 24",
|
|
2366
|
+
fill: "none",
|
|
2367
|
+
stroke: "currentColor",
|
|
2368
|
+
strokeWidth: "2.5",
|
|
2369
|
+
strokeLinecap: "round",
|
|
2370
|
+
strokeLinejoin: "round",
|
|
2371
|
+
children: /* @__PURE__ */ jsx("path", { d: "M15 19l-7-7 7-7" })
|
|
2372
|
+
}
|
|
2373
|
+
) });
|
|
2234
2374
|
const showEmail = options.includes("email");
|
|
2235
2375
|
const showGoogle = options.includes("google");
|
|
2236
2376
|
const showGithub = options.includes("github");
|
|
2237
2377
|
return /* @__PURE__ */ jsxs("div", { className: "pollar-modal-card pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
|
|
2238
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": "Close", children: /* @__PURE__ */ jsx(
|
|
2378
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": "Close", children: /* @__PURE__ */ jsx(
|
|
2379
|
+
"svg",
|
|
2380
|
+
{
|
|
2381
|
+
width: "18",
|
|
2382
|
+
height: "18",
|
|
2383
|
+
viewBox: "0 0 24 24",
|
|
2384
|
+
fill: "none",
|
|
2385
|
+
stroke: "currentColor",
|
|
2386
|
+
strokeWidth: "2.5",
|
|
2387
|
+
strokeLinecap: "round",
|
|
2388
|
+
strokeLinejoin: "round",
|
|
2389
|
+
children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
|
|
2390
|
+
}
|
|
2391
|
+
) }),
|
|
2239
2392
|
/* @__PURE__ */ jsxs("div", { className: "pollar-header", children: [
|
|
2240
2393
|
/* @__PURE__ */ jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsx("img", { src: logoUrl ?? LOGO_POLLAR, alt: "Logo", className: "pollar-logo" }) }),
|
|
2241
2394
|
/* @__PURE__ */ jsx("h2", { className: "pollar-title", children: appName }),
|
|
@@ -2254,7 +2407,7 @@ function PrivyLoginSubmodal({
|
|
|
2254
2407
|
placeholder: "you@email.com",
|
|
2255
2408
|
value: email,
|
|
2256
2409
|
disabled: isLoading,
|
|
2257
|
-
className: "pollar-
|
|
2410
|
+
className: "pollar-input",
|
|
2258
2411
|
onChange: (e) => setEmail(e.target.value),
|
|
2259
2412
|
onKeyDown: (e) => e.key === "Enter" && handleEmailSubmit()
|
|
2260
2413
|
}
|
|
@@ -2456,6 +2609,13 @@ function RouteDisplay({ quote, onSelect }) {
|
|
|
2456
2609
|
}
|
|
2457
2610
|
);
|
|
2458
2611
|
}
|
|
2612
|
+
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
2613
|
+
function isFieldValid(spec, raw) {
|
|
2614
|
+
const value = (raw ?? "").trim();
|
|
2615
|
+
if (!value) return false;
|
|
2616
|
+
if (spec.type === "email") return EMAIL_RE.test(value);
|
|
2617
|
+
return true;
|
|
2618
|
+
}
|
|
2459
2619
|
var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
|
|
2460
2620
|
function flagEmoji(code) {
|
|
2461
2621
|
const cc = code.trim().toUpperCase();
|
|
@@ -2469,6 +2629,43 @@ var STATUS_LABEL = {
|
|
|
2469
2629
|
completed: "Completed",
|
|
2470
2630
|
failed: "Failed"
|
|
2471
2631
|
};
|
|
2632
|
+
var INSTRUCTION_LABELS = {
|
|
2633
|
+
br_code: "Pix code",
|
|
2634
|
+
account_holder_name: "Account holder",
|
|
2635
|
+
bank_name: "Bank",
|
|
2636
|
+
bank_address: "Bank address",
|
|
2637
|
+
bank_account_number: "Account number",
|
|
2638
|
+
bank_routing_number: "Routing number",
|
|
2639
|
+
iban: "IBAN",
|
|
2640
|
+
bic: "BIC",
|
|
2641
|
+
clabe: "CLABE",
|
|
2642
|
+
amount: "Amount",
|
|
2643
|
+
currency: "Currency",
|
|
2644
|
+
payment_rails: "Rails"
|
|
2645
|
+
};
|
|
2646
|
+
function flattenInstructions(instr) {
|
|
2647
|
+
const out = [];
|
|
2648
|
+
for (const [k, v] of Object.entries(instr)) {
|
|
2649
|
+
if (k === "qrBase64") {
|
|
2650
|
+
if (typeof v === "string" && v) out.push({ key: k, label: INSTRUCTION_LABELS[k] ?? "Payment QR", value: v, kind: "qr" });
|
|
2651
|
+
continue;
|
|
2652
|
+
}
|
|
2653
|
+
if ((k === "expiresAt" || k === "expires_at") && (typeof v === "number" || typeof v === "string")) {
|
|
2654
|
+
const ms = Number(v);
|
|
2655
|
+
if (Number.isFinite(ms) && ms > 0) {
|
|
2656
|
+
out.push({ key: k, label: INSTRUCTION_LABELS[k] ?? "Expires", value: new Date(ms).toLocaleString(), kind: "datetime" });
|
|
2657
|
+
}
|
|
2658
|
+
continue;
|
|
2659
|
+
}
|
|
2660
|
+
let value;
|
|
2661
|
+
if (typeof v === "string" || typeof v === "number") value = String(v);
|
|
2662
|
+
else if (Array.isArray(v)) value = v.filter((x) => typeof x === "string" || typeof x === "number").join(", ");
|
|
2663
|
+
else continue;
|
|
2664
|
+
if (!value) continue;
|
|
2665
|
+
out.push({ key: k, label: INSTRUCTION_LABELS[k] ?? k, value, kind: "text" });
|
|
2666
|
+
}
|
|
2667
|
+
return out;
|
|
2668
|
+
}
|
|
2472
2669
|
function RampWidgetTemplate({
|
|
2473
2670
|
theme,
|
|
2474
2671
|
accentColor,
|
|
@@ -2477,6 +2674,8 @@ function RampWidgetTemplate({
|
|
|
2477
2674
|
amount,
|
|
2478
2675
|
currency,
|
|
2479
2676
|
country,
|
|
2677
|
+
requiredFields,
|
|
2678
|
+
fieldValues,
|
|
2480
2679
|
countries,
|
|
2481
2680
|
countriesLoading,
|
|
2482
2681
|
refreshing,
|
|
@@ -2485,17 +2684,22 @@ function RampWidgetTemplate({
|
|
|
2485
2684
|
provider,
|
|
2486
2685
|
txStatus,
|
|
2487
2686
|
kycUrl,
|
|
2687
|
+
tosUrl,
|
|
2488
2688
|
stellarTxHash,
|
|
2689
|
+
explorerUrl,
|
|
2690
|
+
depositInstructions,
|
|
2489
2691
|
canComplete,
|
|
2490
2692
|
completing,
|
|
2491
2693
|
errorMsg,
|
|
2492
2694
|
onDirectionChange,
|
|
2493
2695
|
onAmountChange,
|
|
2494
|
-
|
|
2696
|
+
onFieldChange,
|
|
2495
2697
|
onCountryChange,
|
|
2496
2698
|
onFindRoute,
|
|
2497
2699
|
onSelectQuote,
|
|
2700
|
+
onContactContinue,
|
|
2498
2701
|
onOpenKyc,
|
|
2702
|
+
onOpenTos,
|
|
2499
2703
|
onCompleteWithdraw,
|
|
2500
2704
|
onRetry,
|
|
2501
2705
|
onRefresh,
|
|
@@ -2526,6 +2730,7 @@ function RampWidgetTemplate({
|
|
|
2526
2730
|
input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
|
|
2527
2731
|
loading_quote: "Finding best route",
|
|
2528
2732
|
select_route: "Select provider",
|
|
2733
|
+
contact: "Your details",
|
|
2529
2734
|
status: direction === "onramp" ? "Complete your deposit" : "Complete your withdrawal",
|
|
2530
2735
|
error: "Something went wrong"
|
|
2531
2736
|
};
|
|
@@ -2533,6 +2738,7 @@ function RampWidgetTemplate({
|
|
|
2533
2738
|
input: direction === "onramp" ? "Enter the amount you want to deposit" : "Enter the amount you want to withdraw",
|
|
2534
2739
|
loading_quote: "Comparing providers in real time\u2026",
|
|
2535
2740
|
select_route: "All prices include fees",
|
|
2741
|
+
contact: `${provider || "This provider"} needs your name and email to verify you`,
|
|
2536
2742
|
status: `Finish the flow at ${provider || "the provider"} to continue`,
|
|
2537
2743
|
error: "Please try again"
|
|
2538
2744
|
};
|
|
@@ -2546,7 +2752,7 @@ function RampWidgetTemplate({
|
|
|
2546
2752
|
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onRefresh, disabled: refreshing, "aria-label": "Refresh", children: /* @__PURE__ */ jsx(
|
|
2547
2753
|
"svg",
|
|
2548
2754
|
{
|
|
2549
|
-
className: refreshing ? "pollar-modal-refresh-icon spinning" : "pollar-modal-refresh-icon",
|
|
2755
|
+
className: refreshing ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
2550
2756
|
width: "16",
|
|
2551
2757
|
height: "16",
|
|
2552
2758
|
viewBox: "0 0 16 16",
|
|
@@ -2568,12 +2774,12 @@ function RampWidgetTemplate({
|
|
|
2568
2774
|
] })
|
|
2569
2775
|
] }),
|
|
2570
2776
|
step === "input" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2571
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-
|
|
2777
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-tabs", children: [
|
|
2572
2778
|
/* @__PURE__ */ jsx(
|
|
2573
2779
|
"button",
|
|
2574
2780
|
{
|
|
2575
2781
|
type: "button",
|
|
2576
|
-
className: "pollar-
|
|
2782
|
+
className: "pollar-tab",
|
|
2577
2783
|
"data-active": direction === "onramp",
|
|
2578
2784
|
onClick: () => onDirectionChange("onramp"),
|
|
2579
2785
|
children: "Buy"
|
|
@@ -2583,52 +2789,42 @@ function RampWidgetTemplate({
|
|
|
2583
2789
|
"button",
|
|
2584
2790
|
{
|
|
2585
2791
|
type: "button",
|
|
2586
|
-
className: "pollar-
|
|
2792
|
+
className: "pollar-tab",
|
|
2587
2793
|
"data-active": direction === "offramp",
|
|
2588
2794
|
onClick: () => onDirectionChange("offramp"),
|
|
2589
2795
|
children: "Sell"
|
|
2590
2796
|
}
|
|
2591
2797
|
)
|
|
2592
2798
|
] }),
|
|
2593
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-input-row", children: [
|
|
2594
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2595
|
-
/* @__PURE__ */ jsx("label", { className: "pollar-ramp-label", children: "Amount" }),
|
|
2596
|
-
/* @__PURE__ */ jsx(
|
|
2597
|
-
"input",
|
|
2598
|
-
{
|
|
2599
|
-
type: "number",
|
|
2600
|
-
className: "pollar-ramp-input",
|
|
2601
|
-
placeholder: "0.00",
|
|
2602
|
-
value: amount,
|
|
2603
|
-
min: "0",
|
|
2604
|
-
onChange: (e) => onAmountChange(e.target.value)
|
|
2605
|
-
}
|
|
2606
|
-
)
|
|
2607
|
-
] }),
|
|
2608
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-field", style: { maxWidth: 90 }, children: [
|
|
2609
|
-
/* @__PURE__ */ jsx("label", { className: "pollar-ramp-label", children: "Currency" }),
|
|
2610
|
-
/* @__PURE__ */ jsx(
|
|
2611
|
-
"input",
|
|
2612
|
-
{
|
|
2613
|
-
type: "text",
|
|
2614
|
-
className: "pollar-ramp-input",
|
|
2615
|
-
placeholder: "MXN",
|
|
2616
|
-
value: currency,
|
|
2617
|
-
maxLength: 5,
|
|
2618
|
-
onChange: (e) => onCurrencyChange(e.target.value.toUpperCase())
|
|
2619
|
-
}
|
|
2620
|
-
)
|
|
2621
|
-
] })
|
|
2622
|
-
] }),
|
|
2623
2799
|
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2624
2800
|
/* @__PURE__ */ jsx("label", { className: "pollar-ramp-label", children: "Country" }),
|
|
2625
|
-
countriesLoading ? /* @__PURE__ */
|
|
2801
|
+
countriesLoading ? /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-input pollar-ramp-input-loading", children: [
|
|
2802
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
2803
|
+
/* @__PURE__ */ jsx("span", { children: "Loading countries\u2026" })
|
|
2804
|
+
] }) : countries.length === 0 ? /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "No ramp providers available on this network yet." }) : /* @__PURE__ */ jsx("select", { className: "pollar-ramp-input", value: country, onChange: (e) => onCountryChange(e.target.value), children: countries.map((c) => /* @__PURE__ */ jsxs("option", { value: c.code, children: [
|
|
2626
2805
|
flagEmoji(c.code),
|
|
2627
2806
|
" ",
|
|
2628
2807
|
c.code,
|
|
2629
2808
|
c.currency ? ` \u2014 ${c.currency}` : ""
|
|
2630
2809
|
] }, c.code)) })
|
|
2631
2810
|
] }),
|
|
2811
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2812
|
+
/* @__PURE__ */ jsxs("label", { className: "pollar-ramp-label", children: [
|
|
2813
|
+
"Amount",
|
|
2814
|
+
currency ? ` (${currency})` : ""
|
|
2815
|
+
] }),
|
|
2816
|
+
/* @__PURE__ */ jsx(
|
|
2817
|
+
"input",
|
|
2818
|
+
{
|
|
2819
|
+
type: "number",
|
|
2820
|
+
className: "pollar-ramp-input",
|
|
2821
|
+
placeholder: "0.00",
|
|
2822
|
+
value: amount,
|
|
2823
|
+
min: "0",
|
|
2824
|
+
onChange: (e) => onAmountChange(e.target.value)
|
|
2825
|
+
}
|
|
2826
|
+
)
|
|
2827
|
+
] }),
|
|
2632
2828
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-actions", children: [
|
|
2633
2829
|
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" }),
|
|
2634
2830
|
/* @__PURE__ */ jsx(
|
|
@@ -2643,14 +2839,60 @@ function RampWidgetTemplate({
|
|
|
2643
2839
|
)
|
|
2644
2840
|
] })
|
|
2645
2841
|
] }),
|
|
2646
|
-
step === "loading_quote" && /* @__PURE__ */
|
|
2647
|
-
/* @__PURE__ */ jsx("div", { className: "pollar-ramp-loading-
|
|
2648
|
-
/* @__PURE__ */
|
|
2649
|
-
|
|
2842
|
+
step === "loading_quote" && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-loading", children: [
|
|
2843
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner pollar-ramp-loading-spinner" }),
|
|
2844
|
+
LOADING_STEPS.map((text, i) => /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-loading-row", children: [
|
|
2845
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-ramp-loading-dot" }),
|
|
2846
|
+
/* @__PURE__ */ jsx("span", { children: text })
|
|
2847
|
+
] }, i))
|
|
2848
|
+
] }),
|
|
2650
2849
|
step === "select_route" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2651
2850
|
/* @__PURE__ */ jsx("div", { className: "pollar-ramp-route-list", children: quotes.map((q, i) => /* @__PURE__ */ jsx(RouteDisplay, { quote: q, onSelect: onSelectQuote }, i)) }),
|
|
2652
2851
|
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" })
|
|
2653
2852
|
] }),
|
|
2853
|
+
step === "contact" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2854
|
+
requiredFields.map((f) => /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2855
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-ramp-label", children: f.label }),
|
|
2856
|
+
f.type === "select" ? /* @__PURE__ */ jsxs(
|
|
2857
|
+
"select",
|
|
2858
|
+
{
|
|
2859
|
+
className: "pollar-ramp-input",
|
|
2860
|
+
value: fieldValues[f.key] ?? "",
|
|
2861
|
+
onChange: (e) => onFieldChange(f.key, e.target.value),
|
|
2862
|
+
children: [
|
|
2863
|
+
/* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select\u2026" }),
|
|
2864
|
+
(f.options ?? []).map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
|
|
2865
|
+
]
|
|
2866
|
+
}
|
|
2867
|
+
) : /* @__PURE__ */ jsx(
|
|
2868
|
+
"input",
|
|
2869
|
+
{
|
|
2870
|
+
type: f.type,
|
|
2871
|
+
className: "pollar-ramp-input",
|
|
2872
|
+
value: fieldValues[f.key] ?? "",
|
|
2873
|
+
autoComplete: f.type === "email" ? "email" : "off",
|
|
2874
|
+
onChange: (e) => onFieldChange(f.key, e.target.value)
|
|
2875
|
+
}
|
|
2876
|
+
),
|
|
2877
|
+
f.type === "email" && (fieldValues[f.key] ?? "").trim() !== "" && !isFieldValid(f, fieldValues[f.key]) && /* @__PURE__ */ jsx("span", { className: "pollar-ramp-field-error", children: "Enter a valid email address." })
|
|
2878
|
+
] }, f.key)),
|
|
2879
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-actions", children: [
|
|
2880
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onRetry, children: "Back" }),
|
|
2881
|
+
/* @__PURE__ */ jsx(
|
|
2882
|
+
"button",
|
|
2883
|
+
{
|
|
2884
|
+
type: "button",
|
|
2885
|
+
className: "pollar-btn-primary",
|
|
2886
|
+
disabled: requiredFields.some((f) => !isFieldValid(f, fieldValues[f.key])) || isLoading,
|
|
2887
|
+
onClick: onContactContinue,
|
|
2888
|
+
children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2889
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
2890
|
+
"Starting\u2026"
|
|
2891
|
+
] }) : "Continue"
|
|
2892
|
+
}
|
|
2893
|
+
)
|
|
2894
|
+
] })
|
|
2895
|
+
] }),
|
|
2654
2896
|
step === "status" && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment", children: [
|
|
2655
2897
|
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
2656
2898
|
/* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: "Provider" }),
|
|
@@ -2658,21 +2900,81 @@ function RampWidgetTemplate({
|
|
|
2658
2900
|
] }),
|
|
2659
2901
|
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
2660
2902
|
/* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: "Status" }),
|
|
2661
|
-
/* @__PURE__ */
|
|
2903
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-value", children: [
|
|
2904
|
+
/* @__PURE__ */ jsx("code", { style: { color: txStatus === "completed" ? "var(--pollar-success-text)" : void 0 }, children: txStatus ? STATUS_LABEL[txStatus] : "Processing" }),
|
|
2905
|
+
txStatus !== "completed" && txStatus !== "failed" && /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-label": "Checking status" })
|
|
2906
|
+
] })
|
|
2662
2907
|
] }),
|
|
2663
2908
|
stellarTxHash && /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
2664
2909
|
/* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: "Stellar tx" }),
|
|
2665
|
-
/* @__PURE__ */
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2910
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-value", style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
2911
|
+
/* @__PURE__ */ jsxs("code", { style: { flex: 1, wordBreak: "break-all" }, children: [
|
|
2912
|
+
stellarTxHash.slice(0, 8),
|
|
2913
|
+
"\u2026",
|
|
2914
|
+
stellarTxHash.slice(-8)
|
|
2915
|
+
] }),
|
|
2916
|
+
/* @__PURE__ */ jsx(CopyButton, { value: stellarTxHash, label: "Copy transaction hash" }),
|
|
2917
|
+
explorerUrl && /* @__PURE__ */ jsx(
|
|
2918
|
+
"a",
|
|
2919
|
+
{
|
|
2920
|
+
href: explorerUrl,
|
|
2921
|
+
target: "_blank",
|
|
2922
|
+
rel: "noopener noreferrer",
|
|
2923
|
+
className: "pollar-copy-btn",
|
|
2924
|
+
"aria-label": "View on Stellar Expert",
|
|
2925
|
+
title: "View on Stellar Expert",
|
|
2926
|
+
children: /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
|
|
2927
|
+
/* @__PURE__ */ jsx(
|
|
2928
|
+
"path",
|
|
2929
|
+
{
|
|
2930
|
+
d: "M6 3H3v8h8V8",
|
|
2931
|
+
stroke: "currentColor",
|
|
2932
|
+
strokeWidth: "1.5",
|
|
2933
|
+
strokeLinecap: "round",
|
|
2934
|
+
strokeLinejoin: "round"
|
|
2935
|
+
}
|
|
2936
|
+
),
|
|
2937
|
+
/* @__PURE__ */ jsx(
|
|
2938
|
+
"path",
|
|
2939
|
+
{
|
|
2940
|
+
d: "M8.5 2.5h3v3M11 3L6.5 7.5",
|
|
2941
|
+
stroke: "currentColor",
|
|
2942
|
+
strokeWidth: "1.5",
|
|
2943
|
+
strokeLinecap: "round",
|
|
2944
|
+
strokeLinejoin: "round"
|
|
2945
|
+
}
|
|
2946
|
+
)
|
|
2947
|
+
] })
|
|
2948
|
+
}
|
|
2949
|
+
)
|
|
2950
|
+
] })
|
|
2951
|
+
] }),
|
|
2952
|
+
depositInstructions && txStatus !== "completed" && flattenInstructions(depositInstructions).map(({ key, label, value, kind }) => /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-payment-field", children: [
|
|
2953
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-ramp-payment-label", children: label }),
|
|
2954
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-ramp-payment-value", children: kind === "qr" ? /* @__PURE__ */ jsx(
|
|
2955
|
+
"img",
|
|
2956
|
+
{
|
|
2957
|
+
src: value.startsWith("data:") ? value : `data:image/png;base64,${value}`,
|
|
2958
|
+
alt: label,
|
|
2959
|
+
style: { width: "100%", maxWidth: 220, height: "auto", display: "block", margin: "0 auto" }
|
|
2960
|
+
}
|
|
2961
|
+
) : kind === "datetime" ? /* @__PURE__ */ jsx("span", { children: value }) : /* @__PURE__ */ jsxs("span", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
2962
|
+
/* @__PURE__ */ jsx("code", { style: { flex: 1, wordBreak: "break-all" }, children: value }),
|
|
2963
|
+
/* @__PURE__ */ jsx(CopyButton, { value, label: `Copy ${label}` })
|
|
2669
2964
|
] }) })
|
|
2965
|
+
] }, key)),
|
|
2966
|
+
tosUrl && !depositInstructions && txStatus !== "completed" && /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenTos, children: [
|
|
2967
|
+
"Accept terms at ",
|
|
2968
|
+
provider
|
|
2670
2969
|
] }),
|
|
2671
|
-
kycUrl && txStatus !== "completed" && /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenKyc, children: [
|
|
2970
|
+
kycUrl && !depositInstructions && txStatus !== "completed" && /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-btn-primary", onClick: onOpenKyc, children: [
|
|
2672
2971
|
"Continue at ",
|
|
2673
2972
|
provider
|
|
2674
2973
|
] }),
|
|
2675
|
-
canComplete && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", disabled: completing, onClick: onCompleteWithdraw, children: completing ?
|
|
2974
|
+
canComplete && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", disabled: completing, onClick: onCompleteWithdraw, children: completing ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2975
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
2976
|
+
"Submitting\u2026"
|
|
2977
|
+
] }) : "I've completed KYC \u2014 withdraw" }),
|
|
2676
2978
|
errorMsg && /* @__PURE__ */ jsx("p", { className: "pollar-ramp-payment-note", style: { color: "var(--pollar-error-text)" }, children: errorMsg }),
|
|
2677
2979
|
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: txStatus === "completed" ? "Done" : "Close" })
|
|
2678
2980
|
] }),
|
|
@@ -2686,8 +2988,11 @@ function RampWidgetTemplate({
|
|
|
2686
2988
|
] });
|
|
2687
2989
|
}
|
|
2688
2990
|
var TERMINAL = ["completed", "failed"];
|
|
2991
|
+
function requiredFieldsOf(quote) {
|
|
2992
|
+
return quote.requiredFields ?? [];
|
|
2993
|
+
}
|
|
2689
2994
|
function RampWidget({ onClose }) {
|
|
2690
|
-
const { getClient, signTx, wallet, styles } = usePollar();
|
|
2995
|
+
const { getClient, signTx, wallet, styles, network } = usePollar();
|
|
2691
2996
|
const walletAddress = wallet?.address ?? "";
|
|
2692
2997
|
const client = getClient();
|
|
2693
2998
|
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
@@ -2696,16 +3001,21 @@ function RampWidget({ onClose }) {
|
|
|
2696
3001
|
const [amount, setAmount] = useState("");
|
|
2697
3002
|
const [currency, setCurrency] = useState("");
|
|
2698
3003
|
const [country, setCountry] = useState("");
|
|
3004
|
+
const [fieldValues, setFieldValues] = useState({});
|
|
3005
|
+
const setFieldValue = (key, value) => setFieldValues((v) => ({ ...v, [key]: value }));
|
|
2699
3006
|
const [countries, setCountries] = useState([]);
|
|
2700
3007
|
const [countriesLoading, setCountriesLoading] = useState(true);
|
|
2701
3008
|
const [refreshing, setRefreshing] = useState(false);
|
|
2702
3009
|
const [quotes, setQuotes] = useState([]);
|
|
3010
|
+
const [selectedQuote, setSelectedQuote] = useState(null);
|
|
2703
3011
|
const [isLoading, setIsLoading] = useState(false);
|
|
2704
3012
|
const [txId, setTxId] = useState(null);
|
|
2705
3013
|
const [provider, setProvider] = useState("");
|
|
2706
3014
|
const [kycUrl, setKycUrl] = useState(null);
|
|
3015
|
+
const [tosUrl, setTosUrl] = useState(null);
|
|
2707
3016
|
const [txStatus, setTxStatus] = useState(null);
|
|
2708
3017
|
const [stellarTxHash, setStellarTxHash] = useState(null);
|
|
3018
|
+
const [depositInstructions, setDepositInstructions] = useState(null);
|
|
2709
3019
|
const [completing, setCompleting] = useState(false);
|
|
2710
3020
|
const [errorMsg, setErrorMsg] = useState(null);
|
|
2711
3021
|
const directionRef = useRef(direction);
|
|
@@ -2721,6 +3031,7 @@ function RampWidget({ onClose }) {
|
|
|
2721
3031
|
setTxStatus(tx.status);
|
|
2722
3032
|
if (tx.stellarTxHash) setStellarTxHash(tx.stellarTxHash);
|
|
2723
3033
|
if (tx.kycUrl) setKycUrl(tx.kycUrl);
|
|
3034
|
+
if (tx.depositInstructions) setDepositInstructions(tx.depositInstructions);
|
|
2724
3035
|
if (TERMINAL.includes(tx.status)) clearInterval(id);
|
|
2725
3036
|
} catch {
|
|
2726
3037
|
}
|
|
@@ -2768,6 +3079,7 @@ function RampWidget({ onClose }) {
|
|
|
2768
3079
|
setTxStatus(tx.status);
|
|
2769
3080
|
if (tx.stellarTxHash) setStellarTxHash(tx.stellarTxHash);
|
|
2770
3081
|
if (tx.kycUrl) setKycUrl(tx.kycUrl);
|
|
3082
|
+
if (tx.depositInstructions) setDepositInstructions(tx.depositInstructions);
|
|
2771
3083
|
}
|
|
2772
3084
|
} catch {
|
|
2773
3085
|
} finally {
|
|
@@ -2777,11 +3089,15 @@ function RampWidget({ onClose }) {
|
|
|
2777
3089
|
function resetToInput() {
|
|
2778
3090
|
setStep("input");
|
|
2779
3091
|
setQuotes([]);
|
|
3092
|
+
setSelectedQuote(null);
|
|
3093
|
+
setFieldValues({});
|
|
2780
3094
|
setTxId(null);
|
|
2781
3095
|
setProvider("");
|
|
2782
3096
|
setKycUrl(null);
|
|
3097
|
+
setTosUrl(null);
|
|
2783
3098
|
setTxStatus(null);
|
|
2784
3099
|
setStellarTxHash(null);
|
|
3100
|
+
setDepositInstructions(null);
|
|
2785
3101
|
setErrorMsg(null);
|
|
2786
3102
|
}
|
|
2787
3103
|
async function resumeWithSignature(id, ps) {
|
|
@@ -2805,8 +3121,10 @@ function RampWidget({ onClose }) {
|
|
|
2805
3121
|
return;
|
|
2806
3122
|
}
|
|
2807
3123
|
setKycUrl(result.kycUrl ?? null);
|
|
3124
|
+
setTosUrl(result.tosUrl ?? null);
|
|
2808
3125
|
setTxStatus(result.status);
|
|
2809
3126
|
setStellarTxHash(result.stellarTxHash ?? null);
|
|
3127
|
+
setDepositInstructions(result.depositInstructions ?? null);
|
|
2810
3128
|
setStep("status");
|
|
2811
3129
|
}
|
|
2812
3130
|
async function handleFindRoute() {
|
|
@@ -2830,12 +3148,37 @@ function RampWidget({ onClose }) {
|
|
|
2830
3148
|
setIsLoading(false);
|
|
2831
3149
|
}
|
|
2832
3150
|
}
|
|
2833
|
-
|
|
3151
|
+
function handleSelectQuote(quote) {
|
|
3152
|
+
setSelectedQuote(quote);
|
|
3153
|
+
setErrorMsg(null);
|
|
3154
|
+
const fields = requiredFieldsOf(quote);
|
|
3155
|
+
const missing = fields.some((f) => !(fieldValues[f.key] ?? "").trim());
|
|
3156
|
+
if (fields.length > 0 && missing) {
|
|
3157
|
+
setStep("contact");
|
|
3158
|
+
return;
|
|
3159
|
+
}
|
|
3160
|
+
void startRamp(quote);
|
|
3161
|
+
}
|
|
3162
|
+
function handleContactContinue() {
|
|
3163
|
+
if (selectedQuote) void startRamp(selectedQuote);
|
|
3164
|
+
}
|
|
3165
|
+
async function startRamp(quote) {
|
|
2834
3166
|
setIsLoading(true);
|
|
2835
3167
|
setErrorMsg(null);
|
|
2836
3168
|
try {
|
|
2837
3169
|
const base = { quoteId: quote.quoteId, amount: Number(amount), currency, country };
|
|
2838
|
-
|
|
3170
|
+
if (walletAddress) base.walletAddress = walletAddress;
|
|
3171
|
+
const STANDARD_BODY_KEYS = /* @__PURE__ */ new Set(["email", "fullName", "taxId", "qrCode"]);
|
|
3172
|
+
const extraFields = {};
|
|
3173
|
+
for (const f of requiredFieldsOf(quote)) {
|
|
3174
|
+
const val = (fieldValues[f.key] ?? "").trim();
|
|
3175
|
+
if (!val) continue;
|
|
3176
|
+
if (f.bankType) base.bankDetails = { type: f.bankType, value: val };
|
|
3177
|
+
else if (STANDARD_BODY_KEYS.has(f.key)) base[f.key] = val;
|
|
3178
|
+
else extraFields[f.key] = val;
|
|
3179
|
+
}
|
|
3180
|
+
if (Object.keys(extraFields).length > 0) base.fields = extraFields;
|
|
3181
|
+
const result = direction === "onramp" ? await client.createOnRamp(base) : await client.createOffRamp(base);
|
|
2839
3182
|
await applyResult(result);
|
|
2840
3183
|
} catch (e) {
|
|
2841
3184
|
setErrorMsg(e instanceof Error ? e.message : "Failed to start the ramp.");
|
|
@@ -2847,6 +3190,9 @@ function RampWidget({ onClose }) {
|
|
|
2847
3190
|
function handleOpenKyc() {
|
|
2848
3191
|
if (kycUrl) window.open(kycUrl, "_blank", "noopener,noreferrer");
|
|
2849
3192
|
}
|
|
3193
|
+
function handleOpenTos() {
|
|
3194
|
+
if (tosUrl) window.open(tosUrl, "_blank", "noopener,noreferrer");
|
|
3195
|
+
}
|
|
2850
3196
|
async function handleCompleteWithdraw() {
|
|
2851
3197
|
if (!txId) return;
|
|
2852
3198
|
setCompleting(true);
|
|
@@ -2879,6 +3225,8 @@ function RampWidget({ onClose }) {
|
|
|
2879
3225
|
amount,
|
|
2880
3226
|
currency,
|
|
2881
3227
|
country,
|
|
3228
|
+
requiredFields: selectedQuote ? requiredFieldsOf(selectedQuote) : [],
|
|
3229
|
+
fieldValues,
|
|
2882
3230
|
countries,
|
|
2883
3231
|
countriesLoading,
|
|
2884
3232
|
refreshing,
|
|
@@ -2887,17 +3235,22 @@ function RampWidget({ onClose }) {
|
|
|
2887
3235
|
provider,
|
|
2888
3236
|
txStatus,
|
|
2889
3237
|
kycUrl,
|
|
3238
|
+
tosUrl,
|
|
2890
3239
|
stellarTxHash,
|
|
3240
|
+
explorerUrl: stellarTxHash ? `https://stellar.expert/explorer/${network === "mainnet" ? "public" : "testnet"}/tx/${stellarTxHash}` : null,
|
|
3241
|
+
depositInstructions,
|
|
2891
3242
|
canComplete,
|
|
2892
3243
|
completing,
|
|
2893
3244
|
errorMsg,
|
|
2894
3245
|
onDirectionChange: setDirection,
|
|
2895
3246
|
onAmountChange: setAmount,
|
|
2896
|
-
|
|
3247
|
+
onFieldChange: setFieldValue,
|
|
2897
3248
|
onCountryChange: handleCountryChange,
|
|
2898
3249
|
onFindRoute: handleFindRoute,
|
|
2899
3250
|
onSelectQuote: handleSelectQuote,
|
|
3251
|
+
onContactContinue: handleContactContinue,
|
|
2900
3252
|
onOpenKyc: handleOpenKyc,
|
|
3253
|
+
onOpenTos: handleOpenTos,
|
|
2901
3254
|
onCompleteWithdraw: handleCompleteWithdraw,
|
|
2902
3255
|
onRetry: resetToInput,
|
|
2903
3256
|
onRefresh: handleRefresh,
|
|
@@ -3063,6 +3416,43 @@ function ReceiveModal({ onClose }) {
|
|
|
3063
3416
|
}
|
|
3064
3417
|
) });
|
|
3065
3418
|
}
|
|
3419
|
+
function formatAmount2(value) {
|
|
3420
|
+
const n = parseFloat(value);
|
|
3421
|
+
return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
3422
|
+
}
|
|
3423
|
+
var optionLabel = (o) => o.available !== void 0 ? `${o.code} \u2014 ${formatAmount2(o.available)} available` : o.code;
|
|
3424
|
+
function AssetSelect({
|
|
3425
|
+
label,
|
|
3426
|
+
value,
|
|
3427
|
+
options,
|
|
3428
|
+
onChange,
|
|
3429
|
+
loading = false,
|
|
3430
|
+
disabled = false,
|
|
3431
|
+
appGroupLabel = "App assets",
|
|
3432
|
+
otherGroupLabel = "Other assets",
|
|
3433
|
+
children
|
|
3434
|
+
}) {
|
|
3435
|
+
const appAssets = options.filter((o) => o.enabledInApp);
|
|
3436
|
+
const otherAssets = options.filter((o) => !o.enabledInApp);
|
|
3437
|
+
return /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
3438
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: label }),
|
|
3439
|
+
loading ? /* @__PURE__ */ jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxs(
|
|
3440
|
+
"select",
|
|
3441
|
+
{
|
|
3442
|
+
className: "pollar-input pollar-send-select",
|
|
3443
|
+
value,
|
|
3444
|
+
disabled,
|
|
3445
|
+
onChange: (e) => onChange(e.target.value),
|
|
3446
|
+
children: [
|
|
3447
|
+
value === "" && /* @__PURE__ */ jsx("option", { value: "", disabled: true, hidden: true }),
|
|
3448
|
+
appAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: appGroupLabel, children: appAssets.map((o) => /* @__PURE__ */ jsx("option", { value: o.key, children: optionLabel(o) }, o.key)) }),
|
|
3449
|
+
otherAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: otherGroupLabel, children: otherAssets.map((o) => /* @__PURE__ */ jsx("option", { value: o.key, children: optionLabel(o) }, o.key)) })
|
|
3450
|
+
]
|
|
3451
|
+
}
|
|
3452
|
+
),
|
|
3453
|
+
!loading && children
|
|
3454
|
+
] });
|
|
3455
|
+
}
|
|
3066
3456
|
var STATUS_MESSAGES = {
|
|
3067
3457
|
idle: "",
|
|
3068
3458
|
building: "Building transaction\u2026",
|
|
@@ -3287,6 +3677,7 @@ function SendModalTemplate({
|
|
|
3287
3677
|
isInProgress,
|
|
3288
3678
|
onClose,
|
|
3289
3679
|
onBack,
|
|
3680
|
+
onRefresh,
|
|
3290
3681
|
onSelectAsset,
|
|
3291
3682
|
onAmountChange,
|
|
3292
3683
|
onDestinationChange,
|
|
@@ -3315,8 +3706,6 @@ function SendModalTemplate({
|
|
|
3315
3706
|
"--pollar-input-border-radius": "0.5rem",
|
|
3316
3707
|
"--pollar-card-border-radius": "10px"
|
|
3317
3708
|
};
|
|
3318
|
-
const enabledAssets = assets.filter((a) => a.enabledInApp);
|
|
3319
|
-
const otherAssets = assets.filter((a) => !a.enabledInApp);
|
|
3320
3709
|
const selectedKey = selectedAsset ? assetKey3(selectedAsset) : "";
|
|
3321
3710
|
const canSubmit = !!selectedAsset && !!amount && !!destination.trim() && !isLoadingBalance;
|
|
3322
3711
|
const title = step === "form" ? "Send" : txTitle;
|
|
@@ -3333,39 +3722,61 @@ function SendModalTemplate({
|
|
|
3333
3722
|
showBack && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
3334
3723
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: title })
|
|
3335
3724
|
] }),
|
|
3336
|
-
!isInProgress && /* @__PURE__ */
|
|
3725
|
+
!isInProgress && /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
3726
|
+
step === "form" && /* @__PURE__ */ jsx(
|
|
3727
|
+
"button",
|
|
3728
|
+
{
|
|
3729
|
+
type: "button",
|
|
3730
|
+
className: "pollar-modal-close",
|
|
3731
|
+
onClick: onRefresh,
|
|
3732
|
+
disabled: isLoadingBalance,
|
|
3733
|
+
"aria-label": "Refresh",
|
|
3734
|
+
title: "Refresh balances",
|
|
3735
|
+
children: /* @__PURE__ */ jsx(
|
|
3736
|
+
"svg",
|
|
3737
|
+
{
|
|
3738
|
+
className: isLoadingBalance ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
3739
|
+
width: "16",
|
|
3740
|
+
height: "16",
|
|
3741
|
+
viewBox: "0 0 16 16",
|
|
3742
|
+
fill: "none",
|
|
3743
|
+
"aria-hidden": true,
|
|
3744
|
+
children: /* @__PURE__ */ jsx(
|
|
3745
|
+
"path",
|
|
3746
|
+
{
|
|
3747
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
3748
|
+
stroke: "currentColor",
|
|
3749
|
+
strokeWidth: "1.6",
|
|
3750
|
+
strokeLinecap: "round",
|
|
3751
|
+
strokeLinejoin: "round"
|
|
3752
|
+
}
|
|
3753
|
+
)
|
|
3754
|
+
}
|
|
3755
|
+
)
|
|
3756
|
+
}
|
|
3757
|
+
),
|
|
3758
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
3759
|
+
] })
|
|
3337
3760
|
] }),
|
|
3338
3761
|
step === "form" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3339
|
-
/* @__PURE__ */
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
"
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
a.code,
|
|
3355
|
-
" \u2014 ",
|
|
3356
|
-
formatBalance(a.available),
|
|
3357
|
-
" available"
|
|
3358
|
-
] }, assetKey3(a))) }),
|
|
3359
|
-
otherAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: "Other assets", children: otherAssets.map((a) => /* @__PURE__ */ jsxs("option", { value: assetKey3(a), children: [
|
|
3360
|
-
a.code,
|
|
3361
|
-
" \u2014 ",
|
|
3362
|
-
formatBalance(a.available),
|
|
3363
|
-
" available"
|
|
3364
|
-
] }, assetKey3(a))) })
|
|
3365
|
-
]
|
|
3762
|
+
/* @__PURE__ */ jsx(
|
|
3763
|
+
AssetSelect,
|
|
3764
|
+
{
|
|
3765
|
+
label: "Asset",
|
|
3766
|
+
value: selectedKey,
|
|
3767
|
+
loading: isLoadingBalance,
|
|
3768
|
+
options: assets.map((a) => ({
|
|
3769
|
+
key: assetKey3(a),
|
|
3770
|
+
code: a.code,
|
|
3771
|
+
available: a.available,
|
|
3772
|
+
enabledInApp: a.enabledInApp
|
|
3773
|
+
})),
|
|
3774
|
+
onChange: (key) => {
|
|
3775
|
+
const found = assets.find((a) => assetKey3(a) === key);
|
|
3776
|
+
if (found) onSelectAsset(found);
|
|
3366
3777
|
}
|
|
3367
|
-
|
|
3368
|
-
|
|
3778
|
+
}
|
|
3779
|
+
),
|
|
3369
3780
|
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
3370
3781
|
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
3371
3782
|
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Amount" }),
|
|
@@ -3465,13 +3876,16 @@ function SendModal({ onClose }) {
|
|
|
3465
3876
|
const allAssets = balanceData?.balances ?? [];
|
|
3466
3877
|
const sortedAssets = [
|
|
3467
3878
|
...allAssets.filter((b) => b.enabledInApp),
|
|
3468
|
-
...allAssets.filter((b) => !b.enabledInApp && parseFloat(b.balance) > 0)
|
|
3879
|
+
...allAssets.filter((b) => !b.enabledInApp && (b.type === "native" || parseFloat(b.balance) > 0))
|
|
3469
3880
|
];
|
|
3881
|
+
useEffect(() => {
|
|
3882
|
+
if (!selectedAsset && sortedAssets.length > 0) setSelectedAsset(sortedAssets[0]);
|
|
3883
|
+
}, [sortedAssets, selectedAsset]);
|
|
3470
3884
|
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
3471
3885
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
3472
3886
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
3473
3887
|
const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
|
|
3474
|
-
const
|
|
3888
|
+
const IN_FLIGHT_STEPS3 = [
|
|
3475
3889
|
"building",
|
|
3476
3890
|
"signing",
|
|
3477
3891
|
"submitting",
|
|
@@ -3479,7 +3893,7 @@ function SendModal({ onClose }) {
|
|
|
3479
3893
|
"signing-submitting",
|
|
3480
3894
|
"building-signing-submitting"
|
|
3481
3895
|
];
|
|
3482
|
-
const isInProgress =
|
|
3896
|
+
const isInProgress = IN_FLIGHT_STEPS3.includes(transaction.step);
|
|
3483
3897
|
const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
|
|
3484
3898
|
const txTitle = isInProgress ? "Sending\u2026" : transaction.step === "success" ? "Sent!" : transaction.step === "error" ? "Send failed" : "Confirm Send";
|
|
3485
3899
|
async function handleSubmit() {
|
|
@@ -3552,6 +3966,7 @@ function SendModal({ onClose }) {
|
|
|
3552
3966
|
isInProgress,
|
|
3553
3967
|
onClose,
|
|
3554
3968
|
onBack: handleBack,
|
|
3969
|
+
onRefresh: () => void refreshWalletBalance(),
|
|
3555
3970
|
onSelectAsset: setSelectedAsset,
|
|
3556
3971
|
onAmountChange: setAmount,
|
|
3557
3972
|
onDestinationChange: setDestination,
|
|
@@ -3573,7 +3988,7 @@ var PROVIDER_LABELS = {
|
|
|
3573
3988
|
soroswap: "Soroswap",
|
|
3574
3989
|
sdex: "Stellar DEX"
|
|
3575
3990
|
};
|
|
3576
|
-
function
|
|
3991
|
+
function formatAmount3(value) {
|
|
3577
3992
|
const n = parseFloat(value);
|
|
3578
3993
|
return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
3579
3994
|
}
|
|
@@ -3656,214 +4071,235 @@ function SwapModalTemplate({
|
|
|
3656
4071
|
const buyKey = selectedBuy ? assetOptionKey(selectedBuy) : "";
|
|
3657
4072
|
const canSwap = !smartUnsupported && !!selectedSell && !!selectedBuy && !!amount && !!quote && !quoteLoading && !isLoadingData;
|
|
3658
4073
|
const title = step === "form" ? "Swap" : txTitle;
|
|
3659
|
-
return /* @__PURE__ */ jsxs(
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
{
|
|
3669
|
-
type: "button",
|
|
3670
|
-
className: "pollar-modal-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
"
|
|
3674
|
-
|
|
3675
|
-
children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
3676
|
-
"path",
|
|
4074
|
+
return /* @__PURE__ */ jsxs(
|
|
4075
|
+
"div",
|
|
4076
|
+
{
|
|
4077
|
+
className: "pollar-modal-card pollar-send-modal",
|
|
4078
|
+
"data-theme": theme,
|
|
4079
|
+
style: cssVars,
|
|
4080
|
+
onClick: (e) => e.stopPropagation(),
|
|
4081
|
+
children: [
|
|
4082
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4083
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-header-left", children: [
|
|
4084
|
+
showBack && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
4085
|
+
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: title })
|
|
4086
|
+
] }),
|
|
4087
|
+
!isInProgress && /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
4088
|
+
step === "form" && /* @__PURE__ */ jsx(
|
|
4089
|
+
"button",
|
|
3677
4090
|
{
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
4091
|
+
type: "button",
|
|
4092
|
+
className: "pollar-modal-close",
|
|
4093
|
+
onClick: onRefresh,
|
|
4094
|
+
disabled: configLoading || isLoadingData,
|
|
4095
|
+
"aria-label": "Refresh",
|
|
4096
|
+
title: "Refresh balances and options",
|
|
4097
|
+
children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
4098
|
+
"path",
|
|
4099
|
+
{
|
|
4100
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3",
|
|
4101
|
+
stroke: "currentColor",
|
|
4102
|
+
strokeWidth: "1.6",
|
|
4103
|
+
strokeLinecap: "round",
|
|
4104
|
+
strokeLinejoin: "round"
|
|
4105
|
+
}
|
|
4106
|
+
) })
|
|
3683
4107
|
}
|
|
3684
|
-
)
|
|
3685
|
-
|
|
3686
|
-
),
|
|
3687
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
3688
|
-
] })
|
|
3689
|
-
] }),
|
|
3690
|
-
step === "form" && configLoading && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: "Loading swap options\u2026" }),
|
|
3691
|
-
step === "form" && !configLoading && swapUnavailable && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "Swap is not available for this app." }),
|
|
3692
|
-
step === "form" && !configLoading && !swapUnavailable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3693
|
-
smartUnsupported && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "Swaps are not yet available for smart (passkey) wallets." }),
|
|
3694
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
3695
|
-
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "You pay" }),
|
|
3696
|
-
isLoadingData ? /* @__PURE__ */ jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxs(
|
|
3697
|
-
"select",
|
|
3698
|
-
{
|
|
3699
|
-
className: "pollar-input pollar-send-select",
|
|
3700
|
-
value: sellKey,
|
|
3701
|
-
onChange: (e) => {
|
|
3702
|
-
const found = sellOptions.find((o) => assetOptionKey(o) === e.target.value);
|
|
3703
|
-
if (found) onSelectSell(found);
|
|
3704
|
-
},
|
|
3705
|
-
children: [
|
|
3706
|
-
/* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select asset to sell" }),
|
|
3707
|
-
sellOptions.map((o) => /* @__PURE__ */ jsxs("option", { value: assetOptionKey(o), children: [
|
|
3708
|
-
o.code,
|
|
3709
|
-
o.available !== void 0 ? ` \u2014 ${formatAmount2(o.available)} available` : ""
|
|
3710
|
-
] }, assetOptionKey(o)))
|
|
3711
|
-
]
|
|
3712
|
-
}
|
|
3713
|
-
)
|
|
3714
|
-
] }),
|
|
3715
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
3716
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
3717
|
-
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Amount" }),
|
|
3718
|
-
selectedSell?.available !== void 0 && /* @__PURE__ */ jsxs("span", { className: "pollar-send-hint", children: [
|
|
3719
|
-
"Available: ",
|
|
3720
|
-
formatAmount2(selectedSell.available),
|
|
3721
|
-
" ",
|
|
3722
|
-
selectedSell.code
|
|
4108
|
+
),
|
|
4109
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
3723
4110
|
] })
|
|
3724
4111
|
] }),
|
|
3725
|
-
/* @__PURE__ */
|
|
3726
|
-
"
|
|
3727
|
-
{
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
value: amount,
|
|
3733
|
-
onChange: (e) => onAmountChange(e.target.value)
|
|
3734
|
-
}
|
|
3735
|
-
)
|
|
3736
|
-
] }),
|
|
3737
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
3738
|
-
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "You receive" }),
|
|
3739
|
-
isLoadingData ? /* @__PURE__ */ jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxs(
|
|
3740
|
-
"select",
|
|
3741
|
-
{
|
|
3742
|
-
className: "pollar-input pollar-send-select",
|
|
3743
|
-
value: buyKey,
|
|
3744
|
-
onChange: (e) => {
|
|
3745
|
-
const found = buyOptions.find((o) => assetOptionKey(o) === e.target.value);
|
|
3746
|
-
if (found) onSelectBuy(found);
|
|
3747
|
-
},
|
|
3748
|
-
children: [
|
|
3749
|
-
/* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select asset to buy" }),
|
|
3750
|
-
buyOptions.map((o) => /* @__PURE__ */ jsxs("option", { value: assetOptionKey(o), children: [
|
|
3751
|
-
o.code,
|
|
3752
|
-
o.enabledInApp ? "" : " (external)"
|
|
3753
|
-
] }, assetOptionKey(o)))
|
|
3754
|
-
]
|
|
3755
|
-
}
|
|
3756
|
-
),
|
|
3757
|
-
!isLoadingData && (customOpen ? /* @__PURE__ */ jsxs("div", { className: "pollar-swap-custom", children: [
|
|
4112
|
+
step === "form" && configLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
4113
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
4114
|
+
/* @__PURE__ */ jsx("span", { children: "Loading swap options\u2026" })
|
|
4115
|
+
] }),
|
|
4116
|
+
step === "form" && !configLoading && swapUnavailable && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "Swap is not available for this app." }),
|
|
4117
|
+
step === "form" && !swapUnavailable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4118
|
+
smartUnsupported && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "Swaps are not yet available for smart (passkey) wallets." }),
|
|
3758
4119
|
/* @__PURE__ */ jsx(
|
|
3759
|
-
|
|
4120
|
+
AssetSelect,
|
|
3760
4121
|
{
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
4122
|
+
label: "You pay",
|
|
4123
|
+
value: sellKey,
|
|
4124
|
+
loading: isLoadingData,
|
|
4125
|
+
disabled: configLoading,
|
|
4126
|
+
options: sellOptions.map((o) => ({
|
|
4127
|
+
key: assetOptionKey(o),
|
|
4128
|
+
code: o.code,
|
|
4129
|
+
available: o.available,
|
|
4130
|
+
enabledInApp: o.enabledInApp
|
|
4131
|
+
})),
|
|
4132
|
+
onChange: (key) => {
|
|
4133
|
+
const found = sellOptions.find((o) => assetOptionKey(o) === key);
|
|
4134
|
+
if (found) onSelectSell(found);
|
|
4135
|
+
}
|
|
3766
4136
|
}
|
|
3767
4137
|
),
|
|
4138
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4139
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
4140
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Amount" }),
|
|
4141
|
+
selectedSell?.available !== void 0 && /* @__PURE__ */ jsxs("span", { className: "pollar-send-hint", children: [
|
|
4142
|
+
"Available: ",
|
|
4143
|
+
formatAmount3(selectedSell.available),
|
|
4144
|
+
" ",
|
|
4145
|
+
selectedSell.code
|
|
4146
|
+
] })
|
|
4147
|
+
] }),
|
|
4148
|
+
/* @__PURE__ */ jsx(
|
|
4149
|
+
"input",
|
|
4150
|
+
{
|
|
4151
|
+
className: "pollar-input",
|
|
4152
|
+
type: "text",
|
|
4153
|
+
inputMode: "decimal",
|
|
4154
|
+
placeholder: "0.00",
|
|
4155
|
+
value: amount,
|
|
4156
|
+
disabled: configLoading,
|
|
4157
|
+
onChange: (e) => onAmountChange(e.target.value)
|
|
4158
|
+
}
|
|
4159
|
+
)
|
|
4160
|
+
] }),
|
|
3768
4161
|
/* @__PURE__ */ jsx(
|
|
3769
|
-
|
|
4162
|
+
AssetSelect,
|
|
3770
4163
|
{
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
4164
|
+
label: "You receive",
|
|
4165
|
+
value: buyKey,
|
|
4166
|
+
loading: isLoadingData,
|
|
4167
|
+
disabled: configLoading,
|
|
4168
|
+
options: buyOptions.map((o) => ({
|
|
4169
|
+
key: assetOptionKey(o),
|
|
4170
|
+
code: o.code,
|
|
4171
|
+
enabledInApp: o.enabledInApp
|
|
4172
|
+
})),
|
|
4173
|
+
onChange: (key) => {
|
|
4174
|
+
const found = buyOptions.find((o) => assetOptionKey(o) === key);
|
|
4175
|
+
if (found) onSelectBuy(found);
|
|
4176
|
+
},
|
|
4177
|
+
children: customOpen ? /* @__PURE__ */ jsxs("div", { className: "pollar-swap-custom", children: [
|
|
4178
|
+
/* @__PURE__ */ jsx(
|
|
4179
|
+
"input",
|
|
4180
|
+
{
|
|
4181
|
+
className: "pollar-input",
|
|
4182
|
+
type: "text",
|
|
4183
|
+
placeholder: "Code (e.g. USDC)",
|
|
4184
|
+
value: customCode,
|
|
4185
|
+
onChange: (e) => setCustomCode(e.target.value)
|
|
4186
|
+
}
|
|
4187
|
+
),
|
|
4188
|
+
/* @__PURE__ */ jsx(
|
|
4189
|
+
"input",
|
|
4190
|
+
{
|
|
4191
|
+
className: "pollar-input",
|
|
4192
|
+
type: "text",
|
|
4193
|
+
placeholder: "Issuer (G...)",
|
|
4194
|
+
value: customIssuer,
|
|
4195
|
+
onChange: (e) => setCustomIssuer(e.target.value)
|
|
4196
|
+
}
|
|
4197
|
+
),
|
|
4198
|
+
customError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: customError }),
|
|
4199
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-custom-actions", children: [
|
|
4200
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submitCustomToken, children: "Add token" }),
|
|
4201
|
+
/* @__PURE__ */ jsx(
|
|
4202
|
+
"button",
|
|
4203
|
+
{
|
|
4204
|
+
type: "button",
|
|
4205
|
+
className: "pollar-swap-custom-cancel",
|
|
4206
|
+
onClick: () => {
|
|
4207
|
+
setCustomOpen(false);
|
|
4208
|
+
setCustomError("");
|
|
4209
|
+
},
|
|
4210
|
+
children: "Cancel"
|
|
4211
|
+
}
|
|
4212
|
+
)
|
|
4213
|
+
] })
|
|
4214
|
+
] }) : /* @__PURE__ */ jsx(
|
|
4215
|
+
"button",
|
|
4216
|
+
{
|
|
4217
|
+
type: "button",
|
|
4218
|
+
className: "pollar-swap-custom-toggle",
|
|
4219
|
+
disabled: configLoading,
|
|
4220
|
+
onClick: () => setCustomOpen(true),
|
|
4221
|
+
children: "+ Add a token by code / issuer"
|
|
4222
|
+
}
|
|
4223
|
+
)
|
|
3776
4224
|
}
|
|
3777
4225
|
),
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submitCustomToken, children: "Add token" }),
|
|
4226
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4227
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Route" }),
|
|
3781
4228
|
/* @__PURE__ */ jsx(
|
|
3782
|
-
"
|
|
4229
|
+
"select",
|
|
3783
4230
|
{
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
},
|
|
3790
|
-
children: "Cancel"
|
|
4231
|
+
className: "pollar-input pollar-send-select",
|
|
4232
|
+
value: provider,
|
|
4233
|
+
disabled: configLoading || providers.length === 0,
|
|
4234
|
+
onChange: (e) => onProviderChange(e.target.value),
|
|
4235
|
+
children: providers.length === 0 ? /* @__PURE__ */ jsx("option", { value: provider, children: configLoading ? "Loading\u2026" : PROVIDER_LABELS[provider] }) : providers.map((p) => /* @__PURE__ */ jsx("option", { value: p, children: PROVIDER_LABELS[p] }, p))
|
|
3791
4236
|
}
|
|
3792
4237
|
)
|
|
3793
|
-
] })
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
"
|
|
4238
|
+
] }),
|
|
4239
|
+
quoteLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-send-hint pollar-inline-loading", children: [
|
|
4240
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
4241
|
+
"Fetching best price\u2026"
|
|
4242
|
+
] }),
|
|
4243
|
+
!quoteLoading && quoteError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: quoteError }),
|
|
4244
|
+
!quoteLoading && !quoteError && quote && selectedBuy && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote", children: [
|
|
4245
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4246
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "You receive" }),
|
|
4247
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4248
|
+
"~ ",
|
|
4249
|
+
formatAmount3(quote.amountOut),
|
|
4250
|
+
" ",
|
|
4251
|
+
selectedBuy.code
|
|
4252
|
+
] })
|
|
4253
|
+
] }),
|
|
4254
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4255
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Minimum received" }),
|
|
4256
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4257
|
+
formatAmount3(quote.minReceived),
|
|
4258
|
+
" ",
|
|
4259
|
+
selectedBuy.code
|
|
4260
|
+
] })
|
|
4261
|
+
] }),
|
|
4262
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4263
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Price impact" }),
|
|
4264
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4265
|
+
quote.priceImpactPct,
|
|
4266
|
+
"%"
|
|
4267
|
+
] })
|
|
4268
|
+
] }),
|
|
4269
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4270
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Route" }),
|
|
4271
|
+
/* @__PURE__ */ jsx("span", { children: PROVIDER_LABELS[quote.provider] })
|
|
4272
|
+
] })
|
|
4273
|
+
] }),
|
|
4274
|
+
!quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: "No route found for this pair." }),
|
|
4275
|
+
buyNeedsTrustline && selectedBuy && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-trustline-notice", children: [
|
|
4276
|
+
"To receive ",
|
|
4277
|
+
selectedBuy.code,
|
|
4278
|
+
" your wallet needs a trustline. Swapping will create it first (~0.5 XLM reserve, refundable if you later remove it)."
|
|
4279
|
+
] }),
|
|
4280
|
+
formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
|
|
4281
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary", onClick: onSwap, disabled: !canSwap, children: buyNeedsTrustline ? "Create trustline & swap" : "Swap" }) })
|
|
4282
|
+
] }),
|
|
4283
|
+
step === "tx" && /* @__PURE__ */ jsx(
|
|
4284
|
+
TxStatusView,
|
|
3800
4285
|
{
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
4286
|
+
transaction,
|
|
4287
|
+
showXdr,
|
|
4288
|
+
copied,
|
|
4289
|
+
explorerUrl,
|
|
4290
|
+
walletType,
|
|
4291
|
+
onSignAndSend: () => {
|
|
4292
|
+
},
|
|
4293
|
+
onToggleXdr,
|
|
4294
|
+
onCopyHash,
|
|
4295
|
+
onRetry,
|
|
4296
|
+
onDone
|
|
3805
4297
|
}
|
|
3806
|
-
)
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
3812
|
-
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "You receive" }),
|
|
3813
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
3814
|
-
"~ ",
|
|
3815
|
-
formatAmount2(quote.amountOut),
|
|
3816
|
-
" ",
|
|
3817
|
-
selectedBuy.code
|
|
3818
|
-
] })
|
|
3819
|
-
] }),
|
|
3820
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
3821
|
-
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Minimum received" }),
|
|
3822
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
3823
|
-
formatAmount2(quote.minReceived),
|
|
3824
|
-
" ",
|
|
3825
|
-
selectedBuy.code
|
|
3826
|
-
] })
|
|
3827
|
-
] }),
|
|
3828
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
3829
|
-
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Price impact" }),
|
|
3830
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
3831
|
-
quote.priceImpactPct,
|
|
3832
|
-
"%"
|
|
3833
|
-
] })
|
|
3834
|
-
] }),
|
|
3835
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
3836
|
-
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Route" }),
|
|
3837
|
-
/* @__PURE__ */ jsx("span", { children: PROVIDER_LABELS[quote.provider] })
|
|
3838
|
-
] })
|
|
3839
|
-
] }),
|
|
3840
|
-
!quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: "No route found for this pair." }),
|
|
3841
|
-
buyNeedsTrustline && selectedBuy && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-trustline-notice", children: [
|
|
3842
|
-
"To receive ",
|
|
3843
|
-
selectedBuy.code,
|
|
3844
|
-
" your wallet needs a trustline. Swapping will create it first (~0.5 XLM reserve, refundable if you later remove it)."
|
|
3845
|
-
] }),
|
|
3846
|
-
formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
|
|
3847
|
-
/* @__PURE__ */ jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary", onClick: onSwap, disabled: !canSwap, children: buyNeedsTrustline ? "Create trustline & swap" : "Swap" }) })
|
|
3848
|
-
] }),
|
|
3849
|
-
step === "tx" && /* @__PURE__ */ jsx(
|
|
3850
|
-
TxStatusView,
|
|
3851
|
-
{
|
|
3852
|
-
transaction,
|
|
3853
|
-
showXdr,
|
|
3854
|
-
copied,
|
|
3855
|
-
explorerUrl,
|
|
3856
|
-
walletType,
|
|
3857
|
-
onSignAndSend: () => {
|
|
3858
|
-
},
|
|
3859
|
-
onToggleXdr,
|
|
3860
|
-
onCopyHash,
|
|
3861
|
-
onRetry,
|
|
3862
|
-
onDone
|
|
3863
|
-
}
|
|
3864
|
-
),
|
|
3865
|
-
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
3866
|
-
] });
|
|
4298
|
+
),
|
|
4299
|
+
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
4300
|
+
]
|
|
4301
|
+
}
|
|
4302
|
+
);
|
|
3867
4303
|
}
|
|
3868
4304
|
var QUOTE_DEBOUNCE_MS = 400;
|
|
3869
4305
|
function toRef(a) {
|
|
@@ -3941,7 +4377,7 @@ function SwapModal({ onClose }) {
|
|
|
3941
4377
|
const balances = walletBalance.step === "loaded" ? walletBalance.data.balances : [];
|
|
3942
4378
|
const assetRecords = enabledAssets.step === "loaded" ? enabledAssets.data.assets : [];
|
|
3943
4379
|
const isLoadingData = walletBalance.step === "loading" || enabledAssets.step === "loading";
|
|
3944
|
-
const sellOptions = balances.filter((b) =>
|
|
4380
|
+
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 }));
|
|
3945
4381
|
const buyKeyOfSell = selectedSell ? `${selectedSell.code}:${selectedSell.issuer ?? "native"}` : "";
|
|
3946
4382
|
const optKey = (o) => `${o.code}:${o.issuer ?? "native"}`;
|
|
3947
4383
|
const enabledBuy = assetRecords.map((a) => ({
|
|
@@ -3959,9 +4395,19 @@ function SwapModal({ onClose }) {
|
|
|
3959
4395
|
})).filter((o) => !enabledKeys.has(optKey(o)));
|
|
3960
4396
|
const knownKeys = /* @__PURE__ */ new Set([...enabledKeys, ...catalogBuy.map(optKey)]);
|
|
3961
4397
|
const customBuy = customTokens.filter((o) => !knownKeys.has(optKey(o)));
|
|
3962
|
-
const buyOptions = [...enabledBuy, ...catalogBuy, ...customBuy].filter(
|
|
3963
|
-
|
|
3964
|
-
|
|
4398
|
+
const buyOptions = [...enabledBuy, ...catalogBuy, ...customBuy].filter((o) => optKey(o) !== buyKeyOfSell);
|
|
4399
|
+
useEffect(() => {
|
|
4400
|
+
if (sellOptions.length === 0) return;
|
|
4401
|
+
if (!selectedSell || !sellOptions.some((o) => optKey(o) === optKey(selectedSell))) {
|
|
4402
|
+
setSelectedSell(sellOptions[0]);
|
|
4403
|
+
}
|
|
4404
|
+
}, [sellOptions, selectedSell]);
|
|
4405
|
+
useEffect(() => {
|
|
4406
|
+
if (buyOptions.length === 0) return;
|
|
4407
|
+
if (!selectedBuy || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
|
|
4408
|
+
setSelectedBuy(buyOptions[0]);
|
|
4409
|
+
}
|
|
4410
|
+
}, [buyOptions, selectedBuy]);
|
|
3965
4411
|
function addCustomToken(code, issuer) {
|
|
3966
4412
|
const c = code.trim().toUpperCase();
|
|
3967
4413
|
const i = issuer.trim();
|
|
@@ -4020,7 +4466,7 @@ function SwapModal({ onClose }) {
|
|
|
4020
4466
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
4021
4467
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
4022
4468
|
const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
|
|
4023
|
-
const
|
|
4469
|
+
const IN_FLIGHT_STEPS3 = [
|
|
4024
4470
|
"building",
|
|
4025
4471
|
"signing",
|
|
4026
4472
|
"submitting",
|
|
@@ -4028,7 +4474,7 @@ function SwapModal({ onClose }) {
|
|
|
4028
4474
|
"signing-submitting",
|
|
4029
4475
|
"building-signing-submitting"
|
|
4030
4476
|
];
|
|
4031
|
-
const isInProgress =
|
|
4477
|
+
const isInProgress = IN_FLIGHT_STEPS3.includes(transaction.step);
|
|
4032
4478
|
const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
|
|
4033
4479
|
const txTitle = isInProgress ? "Swapping\u2026" : transaction.step === "success" ? "Swapped!" : transaction.step === "error" ? "Swap failed" : "Confirm Swap";
|
|
4034
4480
|
async function handleSwap() {
|
|
@@ -4122,6 +4568,377 @@ function SwapModal({ onClose }) {
|
|
|
4122
4568
|
}
|
|
4123
4569
|
) });
|
|
4124
4570
|
}
|
|
4571
|
+
var POSITION_POLL_MS = 1e4;
|
|
4572
|
+
var PROVIDER_LABELS2 = {
|
|
4573
|
+
blend: "Blend",
|
|
4574
|
+
defindex: "DeFindex"
|
|
4575
|
+
};
|
|
4576
|
+
var IN_FLIGHT_STEPS2 = [
|
|
4577
|
+
"building",
|
|
4578
|
+
"signing",
|
|
4579
|
+
"submitting",
|
|
4580
|
+
"submitted",
|
|
4581
|
+
"signing-submitting",
|
|
4582
|
+
"building-signing-submitting"
|
|
4583
|
+
];
|
|
4584
|
+
function formatAmount4(value) {
|
|
4585
|
+
const n = parseFloat(value);
|
|
4586
|
+
return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
4587
|
+
}
|
|
4588
|
+
function EarnModal({ onClose }) {
|
|
4589
|
+
const {
|
|
4590
|
+
getEarnProviders,
|
|
4591
|
+
getEarnOpportunities,
|
|
4592
|
+
getEarnPosition,
|
|
4593
|
+
earnDeposit,
|
|
4594
|
+
earnWithdraw,
|
|
4595
|
+
tx: transaction,
|
|
4596
|
+
wallet,
|
|
4597
|
+
network,
|
|
4598
|
+
styles
|
|
4599
|
+
} = usePollar();
|
|
4600
|
+
const walletType = wallet?.custody === "external" ? wallet.provider : null;
|
|
4601
|
+
const smartUnsupported = wallet?.custody === "smart";
|
|
4602
|
+
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
4603
|
+
const isDark = theme === "dark";
|
|
4604
|
+
const [step, setStep] = useState("form");
|
|
4605
|
+
const [tab, setTab] = useState("deposit");
|
|
4606
|
+
const [providers, setProviders] = useState(null);
|
|
4607
|
+
const [provider, setProvider] = useState(null);
|
|
4608
|
+
const [opportunities, setOpportunities] = useState([]);
|
|
4609
|
+
const [opportunityId, setOpportunityId] = useState("");
|
|
4610
|
+
const [position, setPosition] = useState(null);
|
|
4611
|
+
const [amount, setAmount] = useState("");
|
|
4612
|
+
const [loadingOpps, setLoadingOpps] = useState(false);
|
|
4613
|
+
const [formError, setFormError] = useState("");
|
|
4614
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
4615
|
+
const [showXdr, setShowXdr] = useState(false);
|
|
4616
|
+
const [copied, setCopied] = useState(false);
|
|
4617
|
+
const copyTimerRef = useRef(null);
|
|
4618
|
+
const loadProviders = useCallback(() => {
|
|
4619
|
+
setProviders(null);
|
|
4620
|
+
return getEarnProviders().then((ps) => {
|
|
4621
|
+
setProviders(ps);
|
|
4622
|
+
setProvider((cur) => cur ?? ps[0] ?? null);
|
|
4623
|
+
}).catch(() => setProviders([]));
|
|
4624
|
+
}, [getEarnProviders]);
|
|
4625
|
+
useEffect(() => {
|
|
4626
|
+
void loadProviders();
|
|
4627
|
+
}, [loadProviders]);
|
|
4628
|
+
useEffect(() => {
|
|
4629
|
+
if (!provider) return;
|
|
4630
|
+
let cancelled = false;
|
|
4631
|
+
setLoadingOpps(true);
|
|
4632
|
+
getEarnOpportunities(provider).then((opps) => {
|
|
4633
|
+
if (cancelled) return;
|
|
4634
|
+
setOpportunities(opps);
|
|
4635
|
+
setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
|
|
4636
|
+
}).catch(() => {
|
|
4637
|
+
if (!cancelled) setOpportunities([]);
|
|
4638
|
+
}).finally(() => {
|
|
4639
|
+
if (!cancelled) setLoadingOpps(false);
|
|
4640
|
+
});
|
|
4641
|
+
return () => {
|
|
4642
|
+
cancelled = true;
|
|
4643
|
+
};
|
|
4644
|
+
}, [provider, getEarnOpportunities]);
|
|
4645
|
+
const selectedOpportunity = opportunities.find((o) => o.id === opportunityId) ?? null;
|
|
4646
|
+
const refreshPosition = useCallback(() => {
|
|
4647
|
+
if (!provider || !opportunityId || !wallet) return;
|
|
4648
|
+
getEarnPosition({ provider, opportunity: opportunityId }).then(setPosition).catch(() => {
|
|
4649
|
+
});
|
|
4650
|
+
}, [provider, opportunityId, wallet, getEarnPosition]);
|
|
4651
|
+
useEffect(() => {
|
|
4652
|
+
setPosition(null);
|
|
4653
|
+
refreshPosition();
|
|
4654
|
+
}, [refreshPosition]);
|
|
4655
|
+
useEffect(() => {
|
|
4656
|
+
if (step !== "form" || !provider || !opportunityId) return;
|
|
4657
|
+
const id = setInterval(refreshPosition, POSITION_POLL_MS);
|
|
4658
|
+
return () => clearInterval(id);
|
|
4659
|
+
}, [step, provider, opportunityId, refreshPosition]);
|
|
4660
|
+
useEffect(
|
|
4661
|
+
() => () => {
|
|
4662
|
+
if (copyTimerRef.current !== null) clearTimeout(copyTimerRef.current);
|
|
4663
|
+
},
|
|
4664
|
+
[]
|
|
4665
|
+
);
|
|
4666
|
+
const providersLoading = providers === null;
|
|
4667
|
+
const earnUnavailable = providers !== null && providers.length === 0;
|
|
4668
|
+
const withdrawUnit = position?.withdrawUnit ?? "asset";
|
|
4669
|
+
const assetCode = selectedOpportunity?.asset.code ?? "";
|
|
4670
|
+
const amountUnitLabel = tab === "deposit" ? assetCode : withdrawUnit === "shares" ? "shares" : assetCode;
|
|
4671
|
+
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
4672
|
+
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
4673
|
+
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
4674
|
+
const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
|
|
4675
|
+
const isInProgress = IN_FLIGHT_STEPS2.includes(transaction.step);
|
|
4676
|
+
const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
|
|
4677
|
+
const txTitle = isInProgress ? tab === "deposit" ? "Depositing\u2026" : "Withdrawing\u2026" : transaction.step === "success" ? "Done!" : transaction.step === "error" ? tab === "deposit" ? "Deposit failed" : "Withdraw failed" : "Confirm";
|
|
4678
|
+
const canSubmit = !smartUnsupported && !!provider && !!opportunityId && !!amount && parseFloat(amount) > 0 && !providersLoading && !loadingOpps;
|
|
4679
|
+
const cssVars = {
|
|
4680
|
+
"--pollar-accent": accentColor,
|
|
4681
|
+
"--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
|
|
4682
|
+
"--pollar-border": isDark ? "#374151" : "#e5e7eb",
|
|
4683
|
+
"--pollar-text": isDark ? "#ffffff" : "#111827",
|
|
4684
|
+
"--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
|
|
4685
|
+
"--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
|
|
4686
|
+
"--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
|
|
4687
|
+
"--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
|
|
4688
|
+
"--pollar-error-text": isDark ? "#f87171" : "#dc2626",
|
|
4689
|
+
"--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
|
|
4690
|
+
"--pollar-buttons-border-radius": "6px",
|
|
4691
|
+
"--pollar-buttons-height": "44px",
|
|
4692
|
+
"--pollar-input-height": "44px",
|
|
4693
|
+
"--pollar-input-border-radius": "0.5rem",
|
|
4694
|
+
"--pollar-card-border-radius": "10px"
|
|
4695
|
+
};
|
|
4696
|
+
async function handleSubmit() {
|
|
4697
|
+
setFormError("");
|
|
4698
|
+
if (smartUnsupported) {
|
|
4699
|
+
setFormError("Earn is not yet supported for smart (passkey) wallets");
|
|
4700
|
+
return;
|
|
4701
|
+
}
|
|
4702
|
+
if (!provider || !opportunityId) {
|
|
4703
|
+
setFormError("Select a vault or pool");
|
|
4704
|
+
return;
|
|
4705
|
+
}
|
|
4706
|
+
const parsed = parseFloat(amount);
|
|
4707
|
+
if (!amount || isNaN(parsed) || parsed <= 0) {
|
|
4708
|
+
setFormError("Enter a valid amount");
|
|
4709
|
+
return;
|
|
4710
|
+
}
|
|
4711
|
+
if (tab === "withdraw" && position && parsed > parseFloat(position.withdrawable)) {
|
|
4712
|
+
setFormError("Amount exceeds your position");
|
|
4713
|
+
return;
|
|
4714
|
+
}
|
|
4715
|
+
setStep("tx");
|
|
4716
|
+
const params = { provider, opportunity: opportunityId, amount };
|
|
4717
|
+
const outcome = tab === "deposit" ? await earnDeposit(params) : await earnWithdraw(params);
|
|
4718
|
+
if (outcome.status === "success" || outcome.status === "pending") {
|
|
4719
|
+
setAmount("");
|
|
4720
|
+
refreshPosition();
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
async function handleRetry() {
|
|
4724
|
+
if (transaction.step !== "error" || !provider || !opportunityId) return;
|
|
4725
|
+
const params = { provider, opportunity: opportunityId, amount };
|
|
4726
|
+
if (tab === "deposit") await earnDeposit(params);
|
|
4727
|
+
else await earnWithdraw(params);
|
|
4728
|
+
}
|
|
4729
|
+
function handleCopyHash() {
|
|
4730
|
+
if (!hash) return;
|
|
4731
|
+
navigator.clipboard.writeText(hash).then(() => {
|
|
4732
|
+
setCopied(true);
|
|
4733
|
+
if (copyTimerRef.current !== null) clearTimeout(copyTimerRef.current);
|
|
4734
|
+
copyTimerRef.current = setTimeout(() => {
|
|
4735
|
+
copyTimerRef.current = null;
|
|
4736
|
+
setCopied(false);
|
|
4737
|
+
}, 2e3);
|
|
4738
|
+
});
|
|
4739
|
+
}
|
|
4740
|
+
function handleBack() {
|
|
4741
|
+
setStep("form");
|
|
4742
|
+
setShowXdr(false);
|
|
4743
|
+
setCopied(false);
|
|
4744
|
+
refreshPosition();
|
|
4745
|
+
}
|
|
4746
|
+
async function handleRefresh() {
|
|
4747
|
+
if (refreshing || !provider) return;
|
|
4748
|
+
setRefreshing(true);
|
|
4749
|
+
try {
|
|
4750
|
+
const opps = await getEarnOpportunities(provider);
|
|
4751
|
+
setOpportunities(opps);
|
|
4752
|
+
setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
|
|
4753
|
+
refreshPosition();
|
|
4754
|
+
} catch {
|
|
4755
|
+
} finally {
|
|
4756
|
+
setRefreshing(false);
|
|
4757
|
+
}
|
|
4758
|
+
}
|
|
4759
|
+
const title = step === "form" ? "Earn" : txTitle;
|
|
4760
|
+
return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxs(
|
|
4761
|
+
"div",
|
|
4762
|
+
{
|
|
4763
|
+
className: "pollar-modal-card pollar-send-modal",
|
|
4764
|
+
"data-theme": theme,
|
|
4765
|
+
style: cssVars,
|
|
4766
|
+
onClick: (e) => e.stopPropagation(),
|
|
4767
|
+
children: [
|
|
4768
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4769
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-header-left", children: [
|
|
4770
|
+
showBack && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: handleBack, "aria-label": "Back", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
|
|
4771
|
+
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: title })
|
|
4772
|
+
] }),
|
|
4773
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
4774
|
+
step === "form" && !earnUnavailable && !smartUnsupported && /* @__PURE__ */ jsx(
|
|
4775
|
+
"button",
|
|
4776
|
+
{
|
|
4777
|
+
type: "button",
|
|
4778
|
+
className: "pollar-modal-close",
|
|
4779
|
+
onClick: () => void handleRefresh(),
|
|
4780
|
+
disabled: refreshing || providersLoading,
|
|
4781
|
+
"aria-label": "Refresh",
|
|
4782
|
+
children: /* @__PURE__ */ jsx(
|
|
4783
|
+
"svg",
|
|
4784
|
+
{
|
|
4785
|
+
className: refreshing ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
4786
|
+
width: "16",
|
|
4787
|
+
height: "16",
|
|
4788
|
+
viewBox: "0 0 16 16",
|
|
4789
|
+
fill: "none",
|
|
4790
|
+
"aria-hidden": true,
|
|
4791
|
+
children: /* @__PURE__ */ jsx(
|
|
4792
|
+
"path",
|
|
4793
|
+
{
|
|
4794
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
4795
|
+
stroke: "currentColor",
|
|
4796
|
+
strokeWidth: "1.6",
|
|
4797
|
+
strokeLinecap: "round",
|
|
4798
|
+
strokeLinejoin: "round"
|
|
4799
|
+
}
|
|
4800
|
+
)
|
|
4801
|
+
}
|
|
4802
|
+
)
|
|
4803
|
+
}
|
|
4804
|
+
),
|
|
4805
|
+
!isInProgress && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
4806
|
+
] })
|
|
4807
|
+
] }),
|
|
4808
|
+
step === "form" && providersLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
4809
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
4810
|
+
/* @__PURE__ */ jsx("span", { children: "Loading Earn options\u2026" })
|
|
4811
|
+
] }),
|
|
4812
|
+
step === "form" && earnUnavailable && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "Earn is not available for this app." }),
|
|
4813
|
+
step === "form" && !earnUnavailable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4814
|
+
smartUnsupported && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "Earn is not yet available for smart (passkey) wallets." }),
|
|
4815
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-tabs", children: [
|
|
4816
|
+
/* @__PURE__ */ jsx(
|
|
4817
|
+
"button",
|
|
4818
|
+
{
|
|
4819
|
+
type: "button",
|
|
4820
|
+
className: "pollar-tab",
|
|
4821
|
+
"data-active": tab === "deposit",
|
|
4822
|
+
onClick: () => {
|
|
4823
|
+
setTab("deposit");
|
|
4824
|
+
setFormError("");
|
|
4825
|
+
},
|
|
4826
|
+
children: "Deposit"
|
|
4827
|
+
}
|
|
4828
|
+
),
|
|
4829
|
+
/* @__PURE__ */ jsx(
|
|
4830
|
+
"button",
|
|
4831
|
+
{
|
|
4832
|
+
type: "button",
|
|
4833
|
+
className: "pollar-tab",
|
|
4834
|
+
"data-active": tab === "withdraw",
|
|
4835
|
+
onClick: () => {
|
|
4836
|
+
setTab("withdraw");
|
|
4837
|
+
setFormError("");
|
|
4838
|
+
},
|
|
4839
|
+
children: "Withdraw"
|
|
4840
|
+
}
|
|
4841
|
+
)
|
|
4842
|
+
] }),
|
|
4843
|
+
providers && providers.length > 1 && /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4844
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Provider" }),
|
|
4845
|
+
/* @__PURE__ */ jsx(
|
|
4846
|
+
"select",
|
|
4847
|
+
{
|
|
4848
|
+
className: "pollar-input pollar-send-select",
|
|
4849
|
+
value: provider ?? "",
|
|
4850
|
+
onChange: (e) => setProvider(e.target.value),
|
|
4851
|
+
children: providers.map((p) => /* @__PURE__ */ jsx("option", { value: p, children: PROVIDER_LABELS2[p] }, p))
|
|
4852
|
+
}
|
|
4853
|
+
)
|
|
4854
|
+
] }),
|
|
4855
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4856
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
4857
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: provider === "defindex" ? "Vault" : "Pool" }),
|
|
4858
|
+
loadingOpps && /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-label": "Loading options" })
|
|
4859
|
+
] }),
|
|
4860
|
+
/* @__PURE__ */ jsx(
|
|
4861
|
+
"select",
|
|
4862
|
+
{
|
|
4863
|
+
className: "pollar-input pollar-send-select",
|
|
4864
|
+
value: opportunityId,
|
|
4865
|
+
disabled: loadingOpps || opportunities.length === 0,
|
|
4866
|
+
onChange: (e) => setOpportunityId(e.target.value),
|
|
4867
|
+
children: opportunities.length === 0 ? /* @__PURE__ */ jsx("option", { value: "", children: loadingOpps ? "Loading\u2026" : "None available" }) : opportunities.map((o) => /* @__PURE__ */ jsxs("option", { value: o.id, children: [
|
|
4868
|
+
o.name,
|
|
4869
|
+
" \xB7 ",
|
|
4870
|
+
o.apy.toFixed(2),
|
|
4871
|
+
"% APY"
|
|
4872
|
+
] }, o.id))
|
|
4873
|
+
}
|
|
4874
|
+
)
|
|
4875
|
+
] }),
|
|
4876
|
+
selectedOpportunity && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote", children: [
|
|
4877
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4878
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Your position" }),
|
|
4879
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4880
|
+
position ? formatAmount4(position.balance) : "\u2026",
|
|
4881
|
+
" ",
|
|
4882
|
+
assetCode
|
|
4883
|
+
] })
|
|
4884
|
+
] }),
|
|
4885
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4886
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "APY" }),
|
|
4887
|
+
/* @__PURE__ */ jsxs("span", { className: "pollar-earn-live", children: [
|
|
4888
|
+
selectedOpportunity.apy.toFixed(2),
|
|
4889
|
+
"%"
|
|
4890
|
+
] })
|
|
4891
|
+
] })
|
|
4892
|
+
] }),
|
|
4893
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4894
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
4895
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: tab === "deposit" ? "Amount" : "Withdraw amount" }),
|
|
4896
|
+
tab === "withdraw" && position && /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-swap-custom-toggle", onClick: () => setAmount(position.withdrawable), children: [
|
|
4897
|
+
"Max: ",
|
|
4898
|
+
formatAmount4(position.withdrawable),
|
|
4899
|
+
" ",
|
|
4900
|
+
amountUnitLabel
|
|
4901
|
+
] })
|
|
4902
|
+
] }),
|
|
4903
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-earn-amount", children: [
|
|
4904
|
+
/* @__PURE__ */ jsx(
|
|
4905
|
+
"input",
|
|
4906
|
+
{
|
|
4907
|
+
className: "pollar-input",
|
|
4908
|
+
type: "text",
|
|
4909
|
+
inputMode: "decimal",
|
|
4910
|
+
placeholder: "0.00",
|
|
4911
|
+
value: amount,
|
|
4912
|
+
onChange: (e) => setAmount(e.target.value)
|
|
4913
|
+
}
|
|
4914
|
+
),
|
|
4915
|
+
amountUnitLabel && /* @__PURE__ */ jsx("span", { className: "pollar-earn-amount-unit", children: amountUnitLabel })
|
|
4916
|
+
] })
|
|
4917
|
+
] }),
|
|
4918
|
+
formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
|
|
4919
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary", onClick: () => void handleSubmit(), disabled: !canSubmit, children: tab === "deposit" ? "Deposit" : "Withdraw" }) })
|
|
4920
|
+
] }),
|
|
4921
|
+
step === "tx" && /* @__PURE__ */ jsx(
|
|
4922
|
+
TxStatusView,
|
|
4923
|
+
{
|
|
4924
|
+
transaction,
|
|
4925
|
+
showXdr,
|
|
4926
|
+
copied,
|
|
4927
|
+
explorerUrl,
|
|
4928
|
+
walletType,
|
|
4929
|
+
onSignAndSend: () => {
|
|
4930
|
+
},
|
|
4931
|
+
onToggleXdr: () => setShowXdr((v) => !v),
|
|
4932
|
+
onCopyHash: handleCopyHash,
|
|
4933
|
+
onRetry: () => void handleRetry(),
|
|
4934
|
+
onDone: onClose
|
|
4935
|
+
}
|
|
4936
|
+
),
|
|
4937
|
+
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
4938
|
+
]
|
|
4939
|
+
}
|
|
4940
|
+
) });
|
|
4941
|
+
}
|
|
4125
4942
|
function describeDevice(s) {
|
|
4126
4943
|
if (s.deviceLabel) return s.deviceLabel;
|
|
4127
4944
|
if (!s.userAgent) return "Unknown device";
|
|
@@ -4213,30 +5030,46 @@ function SessionsModalTemplate({
|
|
|
4213
5030
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4214
5031
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Active sessions" }),
|
|
4215
5032
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
4216
|
-
/* @__PURE__ */
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
5033
|
+
/* @__PURE__ */ jsx(
|
|
5034
|
+
"button",
|
|
5035
|
+
{
|
|
5036
|
+
type: "button",
|
|
5037
|
+
className: "pollar-modal-close",
|
|
5038
|
+
onClick: onRefresh,
|
|
5039
|
+
disabled: isLoading,
|
|
5040
|
+
"aria-label": "Refresh",
|
|
5041
|
+
title: "Refresh",
|
|
5042
|
+
children: /* @__PURE__ */ jsx(
|
|
5043
|
+
"svg",
|
|
5044
|
+
{
|
|
5045
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
5046
|
+
width: "16",
|
|
5047
|
+
height: "16",
|
|
5048
|
+
viewBox: "0 0 16 16",
|
|
5049
|
+
fill: "none",
|
|
5050
|
+
"aria-hidden": true,
|
|
5051
|
+
children: /* @__PURE__ */ jsx(
|
|
5052
|
+
"path",
|
|
5053
|
+
{
|
|
5054
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
5055
|
+
stroke: "currentColor",
|
|
5056
|
+
strokeWidth: "1.6",
|
|
5057
|
+
strokeLinecap: "round",
|
|
5058
|
+
strokeLinejoin: "round"
|
|
5059
|
+
}
|
|
5060
|
+
)
|
|
5061
|
+
}
|
|
5062
|
+
)
|
|
5063
|
+
}
|
|
5064
|
+
),
|
|
4234
5065
|
/* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
4235
5066
|
] })
|
|
4236
5067
|
] }),
|
|
4237
5068
|
/* @__PURE__ */ jsxs("div", { className: "pollar-sessions-list", children: [
|
|
4238
|
-
state.step === "idle" && /* @__PURE__ */
|
|
4239
|
-
|
|
5069
|
+
(state.step === "idle" || isLoading) && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
5070
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
5071
|
+
/* @__PURE__ */ jsx("span", { children: "Loading\u2026" })
|
|
5072
|
+
] }),
|
|
4240
5073
|
state.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: state.message }),
|
|
4241
5074
|
state.step === "loaded" && sessions.length === 0 && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No active sessions." }),
|
|
4242
5075
|
sessions.map((s) => {
|
|
@@ -4265,7 +5098,10 @@ function SessionsModalTemplate({
|
|
|
4265
5098
|
className: "pollar-sessions-item-revoke",
|
|
4266
5099
|
onClick: () => onRevoke(s.familyId),
|
|
4267
5100
|
disabled: isRevoking || signingOutEverywhere,
|
|
4268
|
-
children: isRevoking ?
|
|
5101
|
+
children: isRevoking ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5102
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }),
|
|
5103
|
+
"Revoking\u2026"
|
|
5104
|
+
] }) : "Revoke"
|
|
4269
5105
|
}
|
|
4270
5106
|
)
|
|
4271
5107
|
] }, s.familyId);
|
|
@@ -4278,7 +5114,10 @@ function SessionsModalTemplate({
|
|
|
4278
5114
|
onClick: onLogoutEverywhere,
|
|
4279
5115
|
disabled: signingOutEverywhere || otherCount === 0,
|
|
4280
5116
|
title: otherCount === 0 ? "No other devices to sign out" : void 0,
|
|
4281
|
-
children: signingOutEverywhere ?
|
|
5117
|
+
children: signingOutEverywhere ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5118
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }),
|
|
5119
|
+
"Signing out\u2026"
|
|
5120
|
+
] }) : "Sign out everywhere"
|
|
4282
5121
|
}
|
|
4283
5122
|
) }),
|
|
4284
5123
|
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
@@ -4471,6 +5310,33 @@ function StatusBadge({ status }) {
|
|
|
4471
5310
|
function formatDate(iso) {
|
|
4472
5311
|
return new Date(iso).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
|
|
4473
5312
|
}
|
|
5313
|
+
function truncateMiddle(value, head = 4, tail = 4) {
|
|
5314
|
+
return value.length <= head + tail + 1 ? value : `${value.slice(0, head)}\u2026${value.slice(-tail)}`;
|
|
5315
|
+
}
|
|
5316
|
+
var STELLAR_ADDRESS = /\b[GC][A-Z2-7]{55}\b/g;
|
|
5317
|
+
function AddressChip({ value, label }) {
|
|
5318
|
+
return /* @__PURE__ */ jsxs("span", { className: "pollar-hist-item-issuer", children: [
|
|
5319
|
+
truncateMiddle(value),
|
|
5320
|
+
/* @__PURE__ */ jsx(CopyButton, { value, label, className: "pollar-copy-btn-sm" })
|
|
5321
|
+
] });
|
|
5322
|
+
}
|
|
5323
|
+
function renderSummary(summary) {
|
|
5324
|
+
const parts = [];
|
|
5325
|
+
let last = 0;
|
|
5326
|
+
let key = 0;
|
|
5327
|
+
STELLAR_ADDRESS.lastIndex = 0;
|
|
5328
|
+
for (let m = STELLAR_ADDRESS.exec(summary); m !== null; m = STELLAR_ADDRESS.exec(summary)) {
|
|
5329
|
+
if (m.index > last) parts.push(/* @__PURE__ */ jsx("span", { children: summary.slice(last, m.index) }, key++));
|
|
5330
|
+
const address = m[0];
|
|
5331
|
+
parts.push(
|
|
5332
|
+
/* @__PURE__ */ jsx(AddressChip, { value: address, label: address[0] === "C" ? "Copy contract address" : "Copy wallet address" }, key++)
|
|
5333
|
+
);
|
|
5334
|
+
last = m.index + address.length;
|
|
5335
|
+
}
|
|
5336
|
+
if (parts.length === 0) return /* @__PURE__ */ jsx("span", { className: "pollar-hist-item-title", children: summary });
|
|
5337
|
+
if (last < summary.length) parts.push(/* @__PURE__ */ jsx("span", { children: summary.slice(last) }, key));
|
|
5338
|
+
return parts;
|
|
5339
|
+
}
|
|
4474
5340
|
function TxHistoryModalTemplate({
|
|
4475
5341
|
theme,
|
|
4476
5342
|
accentColor,
|
|
@@ -4516,59 +5382,106 @@ function TxHistoryModalTemplate({
|
|
|
4516
5382
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4517
5383
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Transaction History" }),
|
|
4518
5384
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
4519
|
-
/* @__PURE__ */
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
5385
|
+
/* @__PURE__ */ jsx(
|
|
5386
|
+
"button",
|
|
5387
|
+
{
|
|
5388
|
+
type: "button",
|
|
5389
|
+
className: "pollar-modal-close",
|
|
5390
|
+
onClick: onRefresh,
|
|
5391
|
+
disabled: isLoading,
|
|
5392
|
+
"aria-label": "Refresh",
|
|
5393
|
+
title: "Refresh",
|
|
5394
|
+
children: /* @__PURE__ */ jsx(
|
|
5395
|
+
"svg",
|
|
5396
|
+
{
|
|
5397
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
5398
|
+
width: "16",
|
|
5399
|
+
height: "16",
|
|
5400
|
+
viewBox: "0 0 16 16",
|
|
5401
|
+
fill: "none",
|
|
5402
|
+
"aria-hidden": true,
|
|
5403
|
+
children: /* @__PURE__ */ jsx(
|
|
5404
|
+
"path",
|
|
5405
|
+
{
|
|
5406
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
5407
|
+
stroke: "currentColor",
|
|
5408
|
+
strokeWidth: "1.6",
|
|
5409
|
+
strokeLinecap: "round",
|
|
5410
|
+
strokeLinejoin: "round"
|
|
5411
|
+
}
|
|
5412
|
+
)
|
|
5413
|
+
}
|
|
5414
|
+
)
|
|
5415
|
+
}
|
|
5416
|
+
),
|
|
4537
5417
|
/* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
4538
5418
|
] })
|
|
4539
5419
|
] }),
|
|
4540
5420
|
/* @__PURE__ */ jsxs("div", { className: "pollar-hist-list", children: [
|
|
4541
5421
|
txHistory.step === "idle" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "Click Refresh to load transactions." }),
|
|
4542
|
-
isLoading && /* @__PURE__ */
|
|
5422
|
+
isLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
5423
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
5424
|
+
/* @__PURE__ */ jsx("span", { children: "Loading\u2026" })
|
|
5425
|
+
] }),
|
|
4543
5426
|
txHistory.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: txHistory.message }),
|
|
4544
5427
|
txHistory.step === "loaded" && records.length === 0 && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No transactions yet." }),
|
|
4545
5428
|
records.map((record) => {
|
|
4546
|
-
const
|
|
5429
|
+
const hash = typeof record.hash === "string" && record.hash.length > 0 ? record.hash : void 0;
|
|
5430
|
+
const explorerUrl = hash ? `https://stellar.expert/explorer/${record.network === "testnet" ? "testnet" : "public"}/tx/${hash}` : void 0;
|
|
5431
|
+
const asset = typeof record.details?.asset === "string" ? record.details.asset : void 0;
|
|
5432
|
+
const colon = asset ? asset.indexOf(":") : -1;
|
|
5433
|
+
const trustline = record.operation === "change_trust" && asset && colon > 0 ? {
|
|
5434
|
+
prefix: record.summary.split(":")[0],
|
|
5435
|
+
code: asset.slice(0, colon),
|
|
5436
|
+
issuer: asset.slice(colon + 1)
|
|
5437
|
+
} : void 0;
|
|
5438
|
+
const contract = record.operation === "invoke_contract" && typeof record.details?.contractId === "string" && typeof record.details?.method === "string" ? { method: record.details.method, contractId: record.details.contractId } : void 0;
|
|
4547
5439
|
return /* @__PURE__ */ jsxs("div", { className: "pollar-hist-item", children: [
|
|
4548
|
-
/* @__PURE__ */
|
|
4549
|
-
|
|
5440
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-hist-item-top", children: [
|
|
5441
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-hist-item-summary", children: trustline ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5442
|
+
/* @__PURE__ */ jsxs("span", { className: "pollar-hist-item-title", children: [
|
|
5443
|
+
trustline.prefix,
|
|
5444
|
+
": ",
|
|
5445
|
+
trustline.code
|
|
5446
|
+
] }),
|
|
5447
|
+
/* @__PURE__ */ jsx(AddressChip, { value: trustline.issuer, label: "Copy issuer" })
|
|
5448
|
+
] }) : contract ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5449
|
+
/* @__PURE__ */ jsxs("span", { className: "pollar-hist-item-title", children: [
|
|
5450
|
+
"Invoke ",
|
|
5451
|
+
contract.method,
|
|
5452
|
+
"() on"
|
|
5453
|
+
] }),
|
|
5454
|
+
/* @__PURE__ */ jsx(AddressChip, { value: contract.contractId, label: "Copy contract address" })
|
|
5455
|
+
] }) : renderSummary(record.summary) }),
|
|
5456
|
+
/* @__PURE__ */ jsx(StatusBadge, { status: record.status })
|
|
5457
|
+
] }),
|
|
4550
5458
|
/* @__PURE__ */ jsxs("span", { className: "pollar-hist-item-meta", children: [
|
|
4551
5459
|
/* @__PURE__ */ jsx("span", { children: record.operation }),
|
|
5460
|
+
typeof record.details?.sponsored === "boolean" && /* @__PURE__ */ jsxs("span", { children: [
|
|
5461
|
+
"\xB7 ",
|
|
5462
|
+
record.details.sponsored ? "Sponsored" : "Self-paid"
|
|
5463
|
+
] }),
|
|
4552
5464
|
record.feeXlm && /* @__PURE__ */ jsxs("span", { children: [
|
|
4553
5465
|
"\xB7 ",
|
|
4554
5466
|
record.feeXlm,
|
|
4555
5467
|
" XLM"
|
|
4556
|
-
] })
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
"
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
5468
|
+
] })
|
|
5469
|
+
] }),
|
|
5470
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-hist-item-footer", children: [
|
|
5471
|
+
/* @__PURE__ */ jsx("span", { children: formatDate(record.createdAt) }),
|
|
5472
|
+
hash && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5473
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-hist-item-dot", children: "\xB7" }),
|
|
5474
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-hist-item-hash", children: truncateMiddle(hash, 6, 6) }),
|
|
5475
|
+
/* @__PURE__ */ jsx(CopyButton, { value: hash, label: "Copy transaction hash", className: "pollar-copy-btn-sm" }),
|
|
5476
|
+
/* @__PURE__ */ jsx(
|
|
5477
|
+
"a",
|
|
5478
|
+
{
|
|
5479
|
+
className: "pollar-hist-item-explorer",
|
|
5480
|
+
href: explorerUrl,
|
|
5481
|
+
target: "_blank",
|
|
5482
|
+
rel: "noopener noreferrer",
|
|
5483
|
+
"aria-label": "View on Stellar Explorer",
|
|
5484
|
+
children: /* @__PURE__ */ jsxs("svg", { width: "12", height: "12", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
4572
5485
|
/* @__PURE__ */ jsx(
|
|
4573
5486
|
"path",
|
|
4574
5487
|
{
|
|
@@ -4588,11 +5501,10 @@ function TxHistoryModalTemplate({
|
|
|
4588
5501
|
strokeLinejoin: "round"
|
|
4589
5502
|
}
|
|
4590
5503
|
)
|
|
4591
|
-
] })
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
)
|
|
5504
|
+
] })
|
|
5505
|
+
}
|
|
5506
|
+
)
|
|
5507
|
+
] })
|
|
4596
5508
|
] })
|
|
4597
5509
|
] }, record.id);
|
|
4598
5510
|
})
|
|
@@ -4646,7 +5558,7 @@ function TxHistoryModal({ onClose }) {
|
|
|
4646
5558
|
}
|
|
4647
5559
|
function formatBalance2(balance) {
|
|
4648
5560
|
const n = parseFloat(balance);
|
|
4649
|
-
return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
5561
|
+
return isNaN(n) ? balance : n.toLocaleString(void 0, { minimumFractionDigits: 7, maximumFractionDigits: 7 });
|
|
4650
5562
|
}
|
|
4651
5563
|
function cropAddress2(address) {
|
|
4652
5564
|
if (address.length <= 16) return address;
|
|
@@ -4655,7 +5567,13 @@ function cropAddress2(address) {
|
|
|
4655
5567
|
function BalanceItem({ record }) {
|
|
4656
5568
|
const balanceDiffers = record.balance !== record.available;
|
|
4657
5569
|
return /* @__PURE__ */ jsxs("div", { className: "pollar-bal-item", children: [
|
|
4658
|
-
/* @__PURE__ */
|
|
5570
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-bal-asset-info", children: [
|
|
5571
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-bal-asset", children: record.code }),
|
|
5572
|
+
record.issuer && /* @__PURE__ */ jsxs("span", { className: "pollar-bal-issuer", children: [
|
|
5573
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-bal-issuer-addr", children: cropAddress2(record.issuer) }),
|
|
5574
|
+
/* @__PURE__ */ jsx(CopyButton, { value: record.issuer, label: "Copy issuer address", className: "pollar-copy-btn-sm" })
|
|
5575
|
+
] })
|
|
5576
|
+
] }),
|
|
4659
5577
|
/* @__PURE__ */ jsxs("div", { className: "pollar-bal-amounts", children: [
|
|
4660
5578
|
/* @__PURE__ */ jsx("span", { className: "pollar-bal-amount", children: formatBalance2(record.balance) }),
|
|
4661
5579
|
balanceDiffers && /* @__PURE__ */ jsxs("span", { className: "pollar-bal-available", children: [
|
|
@@ -4697,29 +5615,49 @@ function WalletBalanceModalTemplate({
|
|
|
4697
5615
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4698
5616
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Wallet Balance" }),
|
|
4699
5617
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
4700
|
-
/* @__PURE__ */
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
5618
|
+
/* @__PURE__ */ jsx(
|
|
5619
|
+
"button",
|
|
5620
|
+
{
|
|
5621
|
+
type: "button",
|
|
5622
|
+
className: "pollar-modal-close",
|
|
5623
|
+
onClick: onRefresh,
|
|
5624
|
+
disabled: isLoading,
|
|
5625
|
+
"aria-label": "Refresh",
|
|
5626
|
+
title: "Refresh",
|
|
5627
|
+
children: /* @__PURE__ */ jsx(
|
|
5628
|
+
"svg",
|
|
5629
|
+
{
|
|
5630
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
5631
|
+
width: "16",
|
|
5632
|
+
height: "16",
|
|
5633
|
+
viewBox: "0 0 16 16",
|
|
5634
|
+
fill: "none",
|
|
5635
|
+
"aria-hidden": true,
|
|
5636
|
+
children: /* @__PURE__ */ jsx(
|
|
5637
|
+
"path",
|
|
5638
|
+
{
|
|
5639
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
5640
|
+
stroke: "currentColor",
|
|
5641
|
+
strokeWidth: "1.6",
|
|
5642
|
+
strokeLinecap: "round",
|
|
5643
|
+
strokeLinejoin: "round"
|
|
5644
|
+
}
|
|
5645
|
+
)
|
|
5646
|
+
}
|
|
5647
|
+
)
|
|
5648
|
+
}
|
|
5649
|
+
),
|
|
4718
5650
|
/* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
4719
5651
|
] })
|
|
4720
5652
|
] }),
|
|
4721
|
-
walletAddress && /* @__PURE__ */
|
|
4722
|
-
|
|
5653
|
+
walletAddress && /* @__PURE__ */ jsxs("div", { className: "pollar-bal-address-row", children: [
|
|
5654
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-bal-address", children: cropAddress2(walletAddress) }),
|
|
5655
|
+
/* @__PURE__ */ jsx(CopyButton, { value: walletAddress, label: "Copy wallet address" })
|
|
5656
|
+
] }),
|
|
5657
|
+
isLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
5658
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
5659
|
+
/* @__PURE__ */ jsx("span", { children: "Loading\u2026" })
|
|
5660
|
+
] }),
|
|
4723
5661
|
walletBalance.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: walletBalance.message }),
|
|
4724
5662
|
data && !data.exists && /* @__PURE__ */ jsxs("div", { className: "pollar-modal-empty", children: [
|
|
4725
5663
|
"Account not found on ",
|
|
@@ -4929,6 +5867,7 @@ function PollarProvider({
|
|
|
4929
5867
|
const [enabledAssetsModalOpen, setEnabledAssetsModalOpen] = useState(false);
|
|
4930
5868
|
const [sendModalOpen, setSendModalOpen] = useState(false);
|
|
4931
5869
|
const [swapModalOpen, setSwapModalOpen] = useState(false);
|
|
5870
|
+
const [earnModalOpen, setEarnModalOpen] = useState(false);
|
|
4932
5871
|
const [receiveModalOpen, setReceiveModalOpen] = useState(false);
|
|
4933
5872
|
const [sessionsModalOpen, setSessionsModalOpen] = useState(false);
|
|
4934
5873
|
const [distributionRulesModalOpen, setDistributionRulesModalOpen] = useState(false);
|
|
@@ -4979,6 +5918,13 @@ function PollarProvider({
|
|
|
4979
5918
|
getSwapQuote: (params) => pollarClient.getSwapQuote(params),
|
|
4980
5919
|
swap: (quote, opts) => pollarClient.swap(quote, opts),
|
|
4981
5920
|
openSwapModal: () => setSwapModalOpen(true),
|
|
5921
|
+
// earn
|
|
5922
|
+
getEarnProviders: () => pollarClient.getEarnProviders(),
|
|
5923
|
+
getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider),
|
|
5924
|
+
getEarnPosition: (params) => pollarClient.getEarnPosition(params),
|
|
5925
|
+
earnDeposit: (params) => pollarClient.earnDeposit(params),
|
|
5926
|
+
earnWithdraw: (params) => pollarClient.earnWithdraw(params),
|
|
5927
|
+
openEarnModal: () => setEarnModalOpen(true),
|
|
4982
5928
|
// sessions
|
|
4983
5929
|
sessions,
|
|
4984
5930
|
openSessionsModal: () => setSessionsModalOpen(true),
|
|
@@ -5034,6 +5980,7 @@ function PollarProvider({
|
|
|
5034
5980
|
enabledAssetsModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setEnabledAssetsModalOpen(false), children: /* @__PURE__ */ jsx(EnabledAssetsModal, { onClose: () => setEnabledAssetsModalOpen(false) }) }),
|
|
5035
5981
|
sendModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
|
|
5036
5982
|
swapModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsx(SwapModal, { onClose: () => setSwapModalOpen(false) }) }),
|
|
5983
|
+
earnModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setEarnModalOpen(false), children: /* @__PURE__ */ jsx(EarnModal, { onClose: () => setEarnModalOpen(false) }) }),
|
|
5037
5984
|
receiveModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) }),
|
|
5038
5985
|
sessionsModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) }),
|
|
5039
5986
|
distributionRulesModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setDistributionRulesModalOpen(false), children: /* @__PURE__ */ jsx(DistributionRulesModal, { onClose: () => setDistributionRulesModalOpen(false) }) })
|
|
@@ -5067,7 +6014,7 @@ function createPollarAdapterHook(key) {
|
|
|
5067
6014
|
};
|
|
5068
6015
|
}
|
|
5069
6016
|
function ButtonLogo() {
|
|
5070
|
-
return /* @__PURE__ */ jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "wallet-btn-logo" });
|
|
6017
|
+
return /* @__PURE__ */ jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "pollar-wallet-btn-logo" });
|
|
5071
6018
|
}
|
|
5072
6019
|
function cropWallet(address) {
|
|
5073
6020
|
if (address.length <= 12) return address;
|
|
@@ -5083,7 +6030,10 @@ function WalletButtonTemplate({
|
|
|
5083
6030
|
itemColor,
|
|
5084
6031
|
wrapperRef,
|
|
5085
6032
|
isInProgress,
|
|
6033
|
+
showCreateAccount,
|
|
6034
|
+
creatingAccount,
|
|
5086
6035
|
onToggleOpen,
|
|
6036
|
+
onCreateAccount,
|
|
5087
6037
|
onCopy,
|
|
5088
6038
|
onWalletBalance,
|
|
5089
6039
|
onTxHistory,
|
|
@@ -5097,23 +6047,23 @@ function WalletButtonTemplate({
|
|
|
5097
6047
|
onLogin
|
|
5098
6048
|
}) {
|
|
5099
6049
|
if (!walletAddress) {
|
|
5100
|
-
return /* @__PURE__ */ jsxs("button", { type: "button", className: "wallet-login-btn", style: { backgroundColor: accentColor }, onClick: onLogin, children: [
|
|
6050
|
+
return /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-wallet-login-btn", style: { backgroundColor: accentColor }, onClick: onLogin, children: [
|
|
5101
6051
|
/* @__PURE__ */ jsx(ButtonLogo, {}),
|
|
5102
6052
|
"Login with Pollar"
|
|
5103
6053
|
] });
|
|
5104
6054
|
}
|
|
5105
|
-
return /* @__PURE__ */ jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
|
|
6055
|
+
return /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-wrapper", ref: wrapperRef, children: [
|
|
5106
6056
|
/* @__PURE__ */ jsxs(
|
|
5107
6057
|
"button",
|
|
5108
6058
|
{
|
|
5109
|
-
className: "wallet-btn",
|
|
6059
|
+
className: "pollar-wallet-btn",
|
|
5110
6060
|
style: { backgroundColor: accentColor },
|
|
5111
6061
|
onClick: isInProgress ? void 0 : onToggleOpen,
|
|
5112
6062
|
disabled: isInProgress,
|
|
5113
6063
|
"aria-busy": isInProgress,
|
|
5114
6064
|
children: [
|
|
5115
|
-
/* @__PURE__ */ jsx("span", { className: "wallet-btn-label", children: cropWallet(walletAddress) }),
|
|
5116
|
-
isInProgress ? /* @__PURE__ */ jsxs("svg", { className: "wallet-btn-spinner", viewBox: "0 0 12 12", width: "12", height: "12", fill: "none", "aria-hidden": true, children: [
|
|
6065
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-wallet-btn-label", children: cropWallet(walletAddress) }),
|
|
6066
|
+
isInProgress ? /* @__PURE__ */ jsxs("svg", { className: "pollar-wallet-btn-spinner", viewBox: "0 0 12 12", width: "12", height: "12", fill: "none", "aria-hidden": true, children: [
|
|
5117
6067
|
/* @__PURE__ */ jsx("circle", { cx: "6", cy: "6", r: "4.5", stroke: "rgba(255,255,255,0.35)", strokeWidth: "1.5" }),
|
|
5118
6068
|
/* @__PURE__ */ jsx(
|
|
5119
6069
|
"circle",
|
|
@@ -5131,7 +6081,7 @@ function WalletButtonTemplate({
|
|
|
5131
6081
|
] }) : /* @__PURE__ */ jsx(
|
|
5132
6082
|
"svg",
|
|
5133
6083
|
{
|
|
5134
|
-
className: `wallet-chevron${open ? " open" : ""}`,
|
|
6084
|
+
className: `pollar-wallet-chevron${open ? " pollar-open" : ""}`,
|
|
5135
6085
|
viewBox: "0 0 12 12",
|
|
5136
6086
|
fill: "none",
|
|
5137
6087
|
stroke: "currentColor",
|
|
@@ -5144,8 +6094,42 @@ function WalletButtonTemplate({
|
|
|
5144
6094
|
]
|
|
5145
6095
|
}
|
|
5146
6096
|
),
|
|
5147
|
-
open && /* @__PURE__ */ jsxs("div", { className: "wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
|
|
5148
|
-
/* @__PURE__ */ jsxs(
|
|
6097
|
+
open && /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
|
|
6098
|
+
showCreateAccount && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6099
|
+
/* @__PURE__ */ jsxs(
|
|
6100
|
+
"button",
|
|
6101
|
+
{
|
|
6102
|
+
className: "pollar-wallet-dropdown-item",
|
|
6103
|
+
style: { color: itemColor },
|
|
6104
|
+
onClick: onCreateAccount,
|
|
6105
|
+
disabled: creatingAccount,
|
|
6106
|
+
children: [
|
|
6107
|
+
/* @__PURE__ */ jsxs(
|
|
6108
|
+
"svg",
|
|
6109
|
+
{
|
|
6110
|
+
width: "14",
|
|
6111
|
+
height: "14",
|
|
6112
|
+
viewBox: "0 0 24 24",
|
|
6113
|
+
fill: "none",
|
|
6114
|
+
stroke: "currentColor",
|
|
6115
|
+
strokeWidth: "2",
|
|
6116
|
+
strokeLinecap: "round",
|
|
6117
|
+
strokeLinejoin: "round",
|
|
6118
|
+
children: [
|
|
6119
|
+
/* @__PURE__ */ jsx("path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" }),
|
|
6120
|
+
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "7", r: "4" }),
|
|
6121
|
+
/* @__PURE__ */ jsx("line", { x1: "19", y1: "8", x2: "19", y2: "14" }),
|
|
6122
|
+
/* @__PURE__ */ jsx("line", { x1: "22", y1: "11", x2: "16", y2: "11" })
|
|
6123
|
+
]
|
|
6124
|
+
}
|
|
6125
|
+
),
|
|
6126
|
+
creatingAccount ? "Creating account\u2026" : "Create account"
|
|
6127
|
+
]
|
|
6128
|
+
}
|
|
6129
|
+
),
|
|
6130
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-wallet-dropdown-divider" })
|
|
6131
|
+
] }),
|
|
6132
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onSend, children: [
|
|
5149
6133
|
/* @__PURE__ */ jsxs(
|
|
5150
6134
|
"svg",
|
|
5151
6135
|
{
|
|
@@ -5165,7 +6149,7 @@ function WalletButtonTemplate({
|
|
|
5165
6149
|
),
|
|
5166
6150
|
"Send"
|
|
5167
6151
|
] }),
|
|
5168
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
|
|
6152
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
|
|
5169
6153
|
/* @__PURE__ */ jsxs(
|
|
5170
6154
|
"svg",
|
|
5171
6155
|
{
|
|
@@ -5186,8 +6170,8 @@ function WalletButtonTemplate({
|
|
|
5186
6170
|
),
|
|
5187
6171
|
"Receive"
|
|
5188
6172
|
] }),
|
|
5189
|
-
/* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
|
|
5190
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
|
|
6173
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-wallet-dropdown-divider" }),
|
|
6174
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
|
|
5191
6175
|
/* @__PURE__ */ jsxs(
|
|
5192
6176
|
"svg",
|
|
5193
6177
|
{
|
|
@@ -5207,7 +6191,7 @@ function WalletButtonTemplate({
|
|
|
5207
6191
|
),
|
|
5208
6192
|
copied ? "Copied!" : "Copy address"
|
|
5209
6193
|
] }),
|
|
5210
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
|
|
6194
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
|
|
5211
6195
|
/* @__PURE__ */ jsxs(
|
|
5212
6196
|
"svg",
|
|
5213
6197
|
{
|
|
@@ -5228,7 +6212,7 @@ function WalletButtonTemplate({
|
|
|
5228
6212
|
),
|
|
5229
6213
|
"Wallet balance"
|
|
5230
6214
|
] }),
|
|
5231
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
|
|
6215
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
|
|
5232
6216
|
/* @__PURE__ */ jsxs(
|
|
5233
6217
|
"svg",
|
|
5234
6218
|
{
|
|
@@ -5251,8 +6235,8 @@ function WalletButtonTemplate({
|
|
|
5251
6235
|
),
|
|
5252
6236
|
"Transaction history"
|
|
5253
6237
|
] }),
|
|
5254
|
-
/* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
|
|
5255
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onRamp, children: [
|
|
6238
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-wallet-dropdown-divider" }),
|
|
6239
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onRamp, children: [
|
|
5256
6240
|
/* @__PURE__ */ jsxs(
|
|
5257
6241
|
"svg",
|
|
5258
6242
|
{
|
|
@@ -5274,7 +6258,7 @@ function WalletButtonTemplate({
|
|
|
5274
6258
|
),
|
|
5275
6259
|
"Buy / Sell"
|
|
5276
6260
|
] }),
|
|
5277
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onKyc, children: [
|
|
6261
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onKyc, children: [
|
|
5278
6262
|
/* @__PURE__ */ jsxs(
|
|
5279
6263
|
"svg",
|
|
5280
6264
|
{
|
|
@@ -5295,7 +6279,7 @@ function WalletButtonTemplate({
|
|
|
5295
6279
|
),
|
|
5296
6280
|
"Identity verification"
|
|
5297
6281
|
] }),
|
|
5298
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onDistributionRules, children: [
|
|
6282
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onDistributionRules, children: [
|
|
5299
6283
|
/* @__PURE__ */ jsxs(
|
|
5300
6284
|
"svg",
|
|
5301
6285
|
{
|
|
@@ -5318,7 +6302,7 @@ function WalletButtonTemplate({
|
|
|
5318
6302
|
),
|
|
5319
6303
|
"Distribution rules"
|
|
5320
6304
|
] }),
|
|
5321
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSessions, children: [
|
|
6305
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onSessions, children: [
|
|
5322
6306
|
/* @__PURE__ */ jsxs(
|
|
5323
6307
|
"svg",
|
|
5324
6308
|
{
|
|
@@ -5339,8 +6323,8 @@ function WalletButtonTemplate({
|
|
|
5339
6323
|
),
|
|
5340
6324
|
"Active sessions"
|
|
5341
6325
|
] }),
|
|
5342
|
-
/* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
|
|
5343
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
|
|
6326
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-wallet-dropdown-divider" }),
|
|
6327
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item pollar-danger", onClick: onLogout, children: [
|
|
5344
6328
|
/* @__PURE__ */ jsxs(
|
|
5345
6329
|
"svg",
|
|
5346
6330
|
{
|
|
@@ -5384,9 +6368,12 @@ function WalletButton() {
|
|
|
5384
6368
|
const walletType = wallet?.custody === "external" ? wallet.provider : null;
|
|
5385
6369
|
const [open, setOpen] = useState(false);
|
|
5386
6370
|
const [copied, setCopied] = useState(false);
|
|
6371
|
+
const [creating, setCreating] = useState(false);
|
|
6372
|
+
const [created, setCreated] = useState(false);
|
|
5387
6373
|
const wrapperRef = useRef(null);
|
|
5388
6374
|
const copyTimerRef = useRef(null);
|
|
5389
6375
|
const isInProgress = transaction.step === "building" || transaction.step === "signing";
|
|
6376
|
+
const canCreateAccount = !created && wallet?.custody === "external" && wallet.existsOnStellar === false && wallet.fundingMode === "IMMEDIATE";
|
|
5390
6377
|
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
5391
6378
|
const isDark = theme === "dark";
|
|
5392
6379
|
const dropdownBg = isDark ? "#18181b" : "#fff";
|
|
@@ -5421,6 +6408,20 @@ function WalletButton() {
|
|
|
5421
6408
|
setOpen(false);
|
|
5422
6409
|
getClient().logout();
|
|
5423
6410
|
}
|
|
6411
|
+
async function handleCreateAccount() {
|
|
6412
|
+
if (creating) return;
|
|
6413
|
+
setCreating(true);
|
|
6414
|
+
try {
|
|
6415
|
+
const res = await getClient().createAccount();
|
|
6416
|
+
if (res.status === "success" || res.status === "pending") {
|
|
6417
|
+
setCreated(true);
|
|
6418
|
+
setOpen(false);
|
|
6419
|
+
await getClient().refreshBalance();
|
|
6420
|
+
}
|
|
6421
|
+
} finally {
|
|
6422
|
+
setCreating(false);
|
|
6423
|
+
}
|
|
6424
|
+
}
|
|
5424
6425
|
function handleWalletBalance() {
|
|
5425
6426
|
setOpen(false);
|
|
5426
6427
|
openWalletBalanceModal();
|
|
@@ -5466,7 +6467,10 @@ function WalletButton() {
|
|
|
5466
6467
|
wrapperRef,
|
|
5467
6468
|
isInProgress,
|
|
5468
6469
|
walletType,
|
|
6470
|
+
showCreateAccount: canCreateAccount,
|
|
6471
|
+
creatingAccount: creating,
|
|
5469
6472
|
onToggleOpen: () => setOpen((v) => !v),
|
|
6473
|
+
onCreateAccount: handleCreateAccount,
|
|
5470
6474
|
onCopy: handleCopy,
|
|
5471
6475
|
onWalletBalance: handleWalletBalance,
|
|
5472
6476
|
onTxHistory: handleTxHistory,
|
|
@@ -5482,6 +6486,6 @@ function WalletButton() {
|
|
|
5482
6486
|
);
|
|
5483
6487
|
}
|
|
5484
6488
|
|
|
5485
|
-
export { DistributionRulesModal, DistributionRulesModalTemplate, EnabledAssetsModal, EnabledAssetsModalTemplate, KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, SwapModal, SwapModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, WalletButtonTemplate, createPollarAdapterHook, usePollar };
|
|
6489
|
+
export { DistributionRulesModal, DistributionRulesModalTemplate, EarnModal, EnabledAssetsModal, EnabledAssetsModalTemplate, KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, SwapModal, SwapModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, WalletButtonTemplate, createPollarAdapterHook, usePollar };
|
|
5486
6490
|
//# sourceMappingURL=index.mjs.map
|
|
5487
6491
|
//# sourceMappingURL=index.mjs.map
|