@pollar/react 0.10.1-rc.1 → 0.10.1-rc.11
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 +251 -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 +1520 -463
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1520 -464
- 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.11"
|
|
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,47 @@ 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
|
+
loadingLabel,
|
|
3431
|
+
disabled = false,
|
|
3432
|
+
appGroupLabel = "App assets",
|
|
3433
|
+
otherGroupLabel = "Other assets",
|
|
3434
|
+
children
|
|
3435
|
+
}) {
|
|
3436
|
+
const appAssets = options.filter((o) => o.enabledInApp);
|
|
3437
|
+
const otherAssets = options.filter((o) => !o.enabledInApp);
|
|
3438
|
+
return /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
3439
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: label }),
|
|
3440
|
+
loading ? loadingLabel ? /* @__PURE__ */ jsxs("div", { className: "pollar-input pollar-select-loading", children: [
|
|
3441
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
3442
|
+
/* @__PURE__ */ jsx("span", { children: loadingLabel })
|
|
3443
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxs(
|
|
3444
|
+
"select",
|
|
3445
|
+
{
|
|
3446
|
+
className: "pollar-input pollar-send-select",
|
|
3447
|
+
value,
|
|
3448
|
+
disabled,
|
|
3449
|
+
onChange: (e) => onChange(e.target.value),
|
|
3450
|
+
children: [
|
|
3451
|
+
value === "" && /* @__PURE__ */ jsx("option", { value: "", disabled: true, hidden: true }),
|
|
3452
|
+
appAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: appGroupLabel, children: appAssets.map((o) => /* @__PURE__ */ jsx("option", { value: o.key, children: optionLabel(o) }, o.key)) }),
|
|
3453
|
+
otherAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: otherGroupLabel, children: otherAssets.map((o) => /* @__PURE__ */ jsx("option", { value: o.key, children: optionLabel(o) }, o.key)) })
|
|
3454
|
+
]
|
|
3455
|
+
}
|
|
3456
|
+
),
|
|
3457
|
+
!loading && children
|
|
3458
|
+
] });
|
|
3459
|
+
}
|
|
3066
3460
|
var STATUS_MESSAGES = {
|
|
3067
3461
|
idle: "",
|
|
3068
3462
|
building: "Building transaction\u2026",
|
|
@@ -3287,6 +3681,7 @@ function SendModalTemplate({
|
|
|
3287
3681
|
isInProgress,
|
|
3288
3682
|
onClose,
|
|
3289
3683
|
onBack,
|
|
3684
|
+
onRefresh,
|
|
3290
3685
|
onSelectAsset,
|
|
3291
3686
|
onAmountChange,
|
|
3292
3687
|
onDestinationChange,
|
|
@@ -3315,8 +3710,6 @@ function SendModalTemplate({
|
|
|
3315
3710
|
"--pollar-input-border-radius": "0.5rem",
|
|
3316
3711
|
"--pollar-card-border-radius": "10px"
|
|
3317
3712
|
};
|
|
3318
|
-
const enabledAssets = assets.filter((a) => a.enabledInApp);
|
|
3319
|
-
const otherAssets = assets.filter((a) => !a.enabledInApp);
|
|
3320
3713
|
const selectedKey = selectedAsset ? assetKey3(selectedAsset) : "";
|
|
3321
3714
|
const canSubmit = !!selectedAsset && !!amount && !!destination.trim() && !isLoadingBalance;
|
|
3322
3715
|
const title = step === "form" ? "Send" : txTitle;
|
|
@@ -3333,39 +3726,61 @@ function SendModalTemplate({
|
|
|
3333
3726
|
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
3727
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: title })
|
|
3335
3728
|
] }),
|
|
3336
|
-
!isInProgress && /* @__PURE__ */
|
|
3729
|
+
!isInProgress && /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
3730
|
+
step === "form" && /* @__PURE__ */ jsx(
|
|
3731
|
+
"button",
|
|
3732
|
+
{
|
|
3733
|
+
type: "button",
|
|
3734
|
+
className: "pollar-modal-close",
|
|
3735
|
+
onClick: onRefresh,
|
|
3736
|
+
disabled: isLoadingBalance,
|
|
3737
|
+
"aria-label": "Refresh",
|
|
3738
|
+
title: "Refresh balances",
|
|
3739
|
+
children: /* @__PURE__ */ jsx(
|
|
3740
|
+
"svg",
|
|
3741
|
+
{
|
|
3742
|
+
className: isLoadingBalance ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
3743
|
+
width: "16",
|
|
3744
|
+
height: "16",
|
|
3745
|
+
viewBox: "0 0 16 16",
|
|
3746
|
+
fill: "none",
|
|
3747
|
+
"aria-hidden": true,
|
|
3748
|
+
children: /* @__PURE__ */ jsx(
|
|
3749
|
+
"path",
|
|
3750
|
+
{
|
|
3751
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
3752
|
+
stroke: "currentColor",
|
|
3753
|
+
strokeWidth: "1.6",
|
|
3754
|
+
strokeLinecap: "round",
|
|
3755
|
+
strokeLinejoin: "round"
|
|
3756
|
+
}
|
|
3757
|
+
)
|
|
3758
|
+
}
|
|
3759
|
+
)
|
|
3760
|
+
}
|
|
3761
|
+
),
|
|
3762
|
+
/* @__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" }) }) })
|
|
3763
|
+
] })
|
|
3337
3764
|
] }),
|
|
3338
3765
|
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
|
-
]
|
|
3766
|
+
/* @__PURE__ */ jsx(
|
|
3767
|
+
AssetSelect,
|
|
3768
|
+
{
|
|
3769
|
+
label: "Asset",
|
|
3770
|
+
value: selectedKey,
|
|
3771
|
+
loading: isLoadingBalance,
|
|
3772
|
+
options: assets.map((a) => ({
|
|
3773
|
+
key: assetKey3(a),
|
|
3774
|
+
code: a.code,
|
|
3775
|
+
available: a.available,
|
|
3776
|
+
enabledInApp: a.enabledInApp
|
|
3777
|
+
})),
|
|
3778
|
+
onChange: (key) => {
|
|
3779
|
+
const found = assets.find((a) => assetKey3(a) === key);
|
|
3780
|
+
if (found) onSelectAsset(found);
|
|
3366
3781
|
}
|
|
3367
|
-
|
|
3368
|
-
|
|
3782
|
+
}
|
|
3783
|
+
),
|
|
3369
3784
|
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
3370
3785
|
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
3371
3786
|
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Amount" }),
|
|
@@ -3465,13 +3880,16 @@ function SendModal({ onClose }) {
|
|
|
3465
3880
|
const allAssets = balanceData?.balances ?? [];
|
|
3466
3881
|
const sortedAssets = [
|
|
3467
3882
|
...allAssets.filter((b) => b.enabledInApp),
|
|
3468
|
-
...allAssets.filter((b) => !b.enabledInApp && parseFloat(b.balance) > 0)
|
|
3883
|
+
...allAssets.filter((b) => !b.enabledInApp && (b.type === "native" || parseFloat(b.balance) > 0))
|
|
3469
3884
|
];
|
|
3885
|
+
useEffect(() => {
|
|
3886
|
+
if (!selectedAsset && sortedAssets.length > 0) setSelectedAsset(sortedAssets[0]);
|
|
3887
|
+
}, [sortedAssets, selectedAsset]);
|
|
3470
3888
|
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
3471
3889
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
3472
3890
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
3473
3891
|
const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
|
|
3474
|
-
const
|
|
3892
|
+
const IN_FLIGHT_STEPS3 = [
|
|
3475
3893
|
"building",
|
|
3476
3894
|
"signing",
|
|
3477
3895
|
"submitting",
|
|
@@ -3479,7 +3897,7 @@ function SendModal({ onClose }) {
|
|
|
3479
3897
|
"signing-submitting",
|
|
3480
3898
|
"building-signing-submitting"
|
|
3481
3899
|
];
|
|
3482
|
-
const isInProgress =
|
|
3900
|
+
const isInProgress = IN_FLIGHT_STEPS3.includes(transaction.step);
|
|
3483
3901
|
const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
|
|
3484
3902
|
const txTitle = isInProgress ? "Sending\u2026" : transaction.step === "success" ? "Sent!" : transaction.step === "error" ? "Send failed" : "Confirm Send";
|
|
3485
3903
|
async function handleSubmit() {
|
|
@@ -3552,6 +3970,7 @@ function SendModal({ onClose }) {
|
|
|
3552
3970
|
isInProgress,
|
|
3553
3971
|
onClose,
|
|
3554
3972
|
onBack: handleBack,
|
|
3973
|
+
onRefresh: () => void refreshWalletBalance(),
|
|
3555
3974
|
onSelectAsset: setSelectedAsset,
|
|
3556
3975
|
onAmountChange: setAmount,
|
|
3557
3976
|
onDestinationChange: setDestination,
|
|
@@ -3573,7 +3992,7 @@ var PROVIDER_LABELS = {
|
|
|
3573
3992
|
soroswap: "Soroswap",
|
|
3574
3993
|
sdex: "Stellar DEX"
|
|
3575
3994
|
};
|
|
3576
|
-
function
|
|
3995
|
+
function formatAmount3(value) {
|
|
3577
3996
|
const n = parseFloat(value);
|
|
3578
3997
|
return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
3579
3998
|
}
|
|
@@ -3656,214 +4075,233 @@ function SwapModalTemplate({
|
|
|
3656
4075
|
const buyKey = selectedBuy ? assetOptionKey(selectedBuy) : "";
|
|
3657
4076
|
const canSwap = !smartUnsupported && !!selectedSell && !!selectedBuy && !!amount && !!quote && !quoteLoading && !isLoadingData;
|
|
3658
4077
|
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",
|
|
4078
|
+
return /* @__PURE__ */ jsxs(
|
|
4079
|
+
"div",
|
|
4080
|
+
{
|
|
4081
|
+
className: "pollar-modal-card pollar-send-modal",
|
|
4082
|
+
"data-theme": theme,
|
|
4083
|
+
style: cssVars,
|
|
4084
|
+
onClick: (e) => e.stopPropagation(),
|
|
4085
|
+
children: [
|
|
4086
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4087
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-header-left", children: [
|
|
4088
|
+
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" }) }) }),
|
|
4089
|
+
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: title })
|
|
4090
|
+
] }),
|
|
4091
|
+
!isInProgress && /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
4092
|
+
step === "form" && /* @__PURE__ */ jsx(
|
|
4093
|
+
"button",
|
|
3677
4094
|
{
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
4095
|
+
type: "button",
|
|
4096
|
+
className: "pollar-modal-close",
|
|
4097
|
+
onClick: onRefresh,
|
|
4098
|
+
disabled: configLoading || isLoadingData,
|
|
4099
|
+
"aria-label": "Refresh",
|
|
4100
|
+
title: "Refresh balances and options",
|
|
4101
|
+
children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
4102
|
+
"path",
|
|
4103
|
+
{
|
|
4104
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3",
|
|
4105
|
+
stroke: "currentColor",
|
|
4106
|
+
strokeWidth: "1.6",
|
|
4107
|
+
strokeLinecap: "round",
|
|
4108
|
+
strokeLinejoin: "round"
|
|
4109
|
+
}
|
|
4110
|
+
) })
|
|
3683
4111
|
}
|
|
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
|
|
4112
|
+
),
|
|
4113
|
+
/* @__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
4114
|
] })
|
|
3724
4115
|
] }),
|
|
3725
|
-
/* @__PURE__ */ jsx(
|
|
3726
|
-
|
|
3727
|
-
{
|
|
3728
|
-
className: "pollar-input",
|
|
3729
|
-
type: "text",
|
|
3730
|
-
inputMode: "decimal",
|
|
3731
|
-
placeholder: "0.00",
|
|
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: [
|
|
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 || configLoading,
|
|
4125
|
+
loadingLabel: "Loading assets\u2026",
|
|
4126
|
+
disabled: configLoading,
|
|
4127
|
+
options: sellOptions.map((o) => ({
|
|
4128
|
+
key: assetOptionKey(o),
|
|
4129
|
+
code: o.code,
|
|
4130
|
+
available: o.available,
|
|
4131
|
+
enabledInApp: o.enabledInApp
|
|
4132
|
+
})),
|
|
4133
|
+
onChange: (key) => {
|
|
4134
|
+
const found = sellOptions.find((o) => assetOptionKey(o) === key);
|
|
4135
|
+
if (found) onSelectSell(found);
|
|
4136
|
+
}
|
|
3766
4137
|
}
|
|
3767
4138
|
),
|
|
4139
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4140
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
4141
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Amount" }),
|
|
4142
|
+
selectedSell?.available !== void 0 && /* @__PURE__ */ jsxs("span", { className: "pollar-send-hint", children: [
|
|
4143
|
+
"Available: ",
|
|
4144
|
+
formatAmount3(selectedSell.available),
|
|
4145
|
+
" ",
|
|
4146
|
+
selectedSell.code
|
|
4147
|
+
] })
|
|
4148
|
+
] }),
|
|
4149
|
+
/* @__PURE__ */ jsx(
|
|
4150
|
+
"input",
|
|
4151
|
+
{
|
|
4152
|
+
className: "pollar-input",
|
|
4153
|
+
type: "text",
|
|
4154
|
+
inputMode: "decimal",
|
|
4155
|
+
placeholder: "0.00",
|
|
4156
|
+
value: amount,
|
|
4157
|
+
disabled: configLoading,
|
|
4158
|
+
onChange: (e) => onAmountChange(e.target.value)
|
|
4159
|
+
}
|
|
4160
|
+
)
|
|
4161
|
+
] }),
|
|
3768
4162
|
/* @__PURE__ */ jsx(
|
|
3769
|
-
|
|
4163
|
+
AssetSelect,
|
|
3770
4164
|
{
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
4165
|
+
label: "You receive",
|
|
4166
|
+
value: buyKey,
|
|
4167
|
+
loading: isLoadingData || configLoading,
|
|
4168
|
+
loadingLabel: "Loading assets\u2026",
|
|
4169
|
+
disabled: configLoading,
|
|
4170
|
+
options: buyOptions.map((o) => ({
|
|
4171
|
+
key: assetOptionKey(o),
|
|
4172
|
+
code: o.code,
|
|
4173
|
+
enabledInApp: o.enabledInApp
|
|
4174
|
+
})),
|
|
4175
|
+
onChange: (key) => {
|
|
4176
|
+
const found = buyOptions.find((o) => assetOptionKey(o) === key);
|
|
4177
|
+
if (found) onSelectBuy(found);
|
|
4178
|
+
},
|
|
4179
|
+
children: customOpen ? /* @__PURE__ */ jsxs("div", { className: "pollar-swap-custom", children: [
|
|
4180
|
+
/* @__PURE__ */ jsx(
|
|
4181
|
+
"input",
|
|
4182
|
+
{
|
|
4183
|
+
className: "pollar-input",
|
|
4184
|
+
type: "text",
|
|
4185
|
+
placeholder: "Code (e.g. USDC)",
|
|
4186
|
+
value: customCode,
|
|
4187
|
+
onChange: (e) => setCustomCode(e.target.value)
|
|
4188
|
+
}
|
|
4189
|
+
),
|
|
4190
|
+
/* @__PURE__ */ jsx(
|
|
4191
|
+
"input",
|
|
4192
|
+
{
|
|
4193
|
+
className: "pollar-input",
|
|
4194
|
+
type: "text",
|
|
4195
|
+
placeholder: "Issuer (G...)",
|
|
4196
|
+
value: customIssuer,
|
|
4197
|
+
onChange: (e) => setCustomIssuer(e.target.value)
|
|
4198
|
+
}
|
|
4199
|
+
),
|
|
4200
|
+
customError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: customError }),
|
|
4201
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-custom-actions", children: [
|
|
4202
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submitCustomToken, children: "Add token" }),
|
|
4203
|
+
/* @__PURE__ */ jsx(
|
|
4204
|
+
"button",
|
|
4205
|
+
{
|
|
4206
|
+
type: "button",
|
|
4207
|
+
className: "pollar-swap-custom-cancel",
|
|
4208
|
+
onClick: () => {
|
|
4209
|
+
setCustomOpen(false);
|
|
4210
|
+
setCustomError("");
|
|
4211
|
+
},
|
|
4212
|
+
children: "Cancel"
|
|
4213
|
+
}
|
|
4214
|
+
)
|
|
4215
|
+
] })
|
|
4216
|
+
] }) : /* @__PURE__ */ jsx(
|
|
4217
|
+
"button",
|
|
4218
|
+
{
|
|
4219
|
+
type: "button",
|
|
4220
|
+
className: "pollar-swap-custom-toggle",
|
|
4221
|
+
disabled: configLoading,
|
|
4222
|
+
onClick: () => setCustomOpen(true),
|
|
4223
|
+
children: "+ Add a token by code / issuer"
|
|
4224
|
+
}
|
|
4225
|
+
)
|
|
3776
4226
|
}
|
|
3777
4227
|
),
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-primary", onClick: submitCustomToken, children: "Add token" }),
|
|
4228
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4229
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Route" }),
|
|
3781
4230
|
/* @__PURE__ */ jsx(
|
|
3782
|
-
"
|
|
4231
|
+
"select",
|
|
3783
4232
|
{
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
},
|
|
3790
|
-
children: "Cancel"
|
|
4233
|
+
className: "pollar-input pollar-send-select",
|
|
4234
|
+
value: provider,
|
|
4235
|
+
disabled: configLoading || providers.length === 0,
|
|
4236
|
+
onChange: (e) => onProviderChange(e.target.value),
|
|
4237
|
+
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
4238
|
}
|
|
3792
4239
|
)
|
|
3793
|
-
] })
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
"
|
|
4240
|
+
] }),
|
|
4241
|
+
quoteLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-send-hint pollar-inline-loading", children: [
|
|
4242
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm" }),
|
|
4243
|
+
"Fetching best price\u2026"
|
|
4244
|
+
] }),
|
|
4245
|
+
!quoteLoading && quoteError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: quoteError }),
|
|
4246
|
+
!quoteLoading && !quoteError && quote && selectedBuy && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote", children: [
|
|
4247
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4248
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "You receive" }),
|
|
4249
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4250
|
+
"~ ",
|
|
4251
|
+
formatAmount3(quote.amountOut),
|
|
4252
|
+
" ",
|
|
4253
|
+
selectedBuy.code
|
|
4254
|
+
] })
|
|
4255
|
+
] }),
|
|
4256
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4257
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Minimum received" }),
|
|
4258
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4259
|
+
formatAmount3(quote.minReceived),
|
|
4260
|
+
" ",
|
|
4261
|
+
selectedBuy.code
|
|
4262
|
+
] })
|
|
4263
|
+
] }),
|
|
4264
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4265
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Price impact" }),
|
|
4266
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4267
|
+
quote.priceImpactPct,
|
|
4268
|
+
"%"
|
|
4269
|
+
] })
|
|
4270
|
+
] }),
|
|
4271
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4272
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Route" }),
|
|
4273
|
+
/* @__PURE__ */ jsx("span", { children: PROVIDER_LABELS[quote.provider] })
|
|
4274
|
+
] })
|
|
4275
|
+
] }),
|
|
4276
|
+
!quoteLoading && !quoteError && !quote && selectedSell && selectedBuy && !!amount && /* @__PURE__ */ jsx("div", { className: "pollar-send-hint", children: "No route found for this pair." }),
|
|
4277
|
+
buyNeedsTrustline && selectedBuy && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-trustline-notice", children: [
|
|
4278
|
+
"To receive ",
|
|
4279
|
+
selectedBuy.code,
|
|
4280
|
+
" your wallet needs a trustline. Swapping will create it first (~0.5 XLM reserve, refundable if you later remove it)."
|
|
4281
|
+
] }),
|
|
4282
|
+
formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
|
|
4283
|
+
/* @__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" }) })
|
|
4284
|
+
] }),
|
|
4285
|
+
step === "tx" && /* @__PURE__ */ jsx(
|
|
4286
|
+
TxStatusView,
|
|
3800
4287
|
{
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
4288
|
+
transaction,
|
|
4289
|
+
showXdr,
|
|
4290
|
+
copied,
|
|
4291
|
+
explorerUrl,
|
|
4292
|
+
walletType,
|
|
4293
|
+
onSignAndSend: () => {
|
|
4294
|
+
},
|
|
4295
|
+
onToggleXdr,
|
|
4296
|
+
onCopyHash,
|
|
4297
|
+
onRetry,
|
|
4298
|
+
onDone
|
|
3805
4299
|
}
|
|
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
|
-
] });
|
|
4300
|
+
),
|
|
4301
|
+
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
4302
|
+
]
|
|
4303
|
+
}
|
|
4304
|
+
);
|
|
3867
4305
|
}
|
|
3868
4306
|
var QUOTE_DEBOUNCE_MS = 400;
|
|
3869
4307
|
function toRef(a) {
|
|
@@ -3941,7 +4379,7 @@ function SwapModal({ onClose }) {
|
|
|
3941
4379
|
const balances = walletBalance.step === "loaded" ? walletBalance.data.balances : [];
|
|
3942
4380
|
const assetRecords = enabledAssets.step === "loaded" ? enabledAssets.data.assets : [];
|
|
3943
4381
|
const isLoadingData = walletBalance.step === "loading" || enabledAssets.step === "loading";
|
|
3944
|
-
const sellOptions = balances.filter((b) =>
|
|
4382
|
+
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
4383
|
const buyKeyOfSell = selectedSell ? `${selectedSell.code}:${selectedSell.issuer ?? "native"}` : "";
|
|
3946
4384
|
const optKey = (o) => `${o.code}:${o.issuer ?? "native"}`;
|
|
3947
4385
|
const enabledBuy = assetRecords.map((a) => ({
|
|
@@ -3959,9 +4397,19 @@ function SwapModal({ onClose }) {
|
|
|
3959
4397
|
})).filter((o) => !enabledKeys.has(optKey(o)));
|
|
3960
4398
|
const knownKeys = /* @__PURE__ */ new Set([...enabledKeys, ...catalogBuy.map(optKey)]);
|
|
3961
4399
|
const customBuy = customTokens.filter((o) => !knownKeys.has(optKey(o)));
|
|
3962
|
-
const buyOptions = [...enabledBuy, ...catalogBuy, ...customBuy].filter(
|
|
3963
|
-
|
|
3964
|
-
|
|
4400
|
+
const buyOptions = [...enabledBuy, ...catalogBuy, ...customBuy].filter((o) => optKey(o) !== buyKeyOfSell);
|
|
4401
|
+
useEffect(() => {
|
|
4402
|
+
if (sellOptions.length === 0) return;
|
|
4403
|
+
if (!selectedSell || !sellOptions.some((o) => optKey(o) === optKey(selectedSell))) {
|
|
4404
|
+
setSelectedSell(sellOptions[0]);
|
|
4405
|
+
}
|
|
4406
|
+
}, [sellOptions, selectedSell]);
|
|
4407
|
+
useEffect(() => {
|
|
4408
|
+
if (buyOptions.length === 0) return;
|
|
4409
|
+
if (!selectedBuy || !buyOptions.some((o) => optKey(o) === optKey(selectedBuy))) {
|
|
4410
|
+
setSelectedBuy(buyOptions[0]);
|
|
4411
|
+
}
|
|
4412
|
+
}, [buyOptions, selectedBuy]);
|
|
3965
4413
|
function addCustomToken(code, issuer) {
|
|
3966
4414
|
const c = code.trim().toUpperCase();
|
|
3967
4415
|
const i = issuer.trim();
|
|
@@ -4020,7 +4468,7 @@ function SwapModal({ onClose }) {
|
|
|
4020
4468
|
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
4021
4469
|
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
4022
4470
|
const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
|
|
4023
|
-
const
|
|
4471
|
+
const IN_FLIGHT_STEPS3 = [
|
|
4024
4472
|
"building",
|
|
4025
4473
|
"signing",
|
|
4026
4474
|
"submitting",
|
|
@@ -4028,7 +4476,7 @@ function SwapModal({ onClose }) {
|
|
|
4028
4476
|
"signing-submitting",
|
|
4029
4477
|
"building-signing-submitting"
|
|
4030
4478
|
];
|
|
4031
|
-
const isInProgress =
|
|
4479
|
+
const isInProgress = IN_FLIGHT_STEPS3.includes(transaction.step);
|
|
4032
4480
|
const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
|
|
4033
4481
|
const txTitle = isInProgress ? "Swapping\u2026" : transaction.step === "success" ? "Swapped!" : transaction.step === "error" ? "Swap failed" : "Confirm Swap";
|
|
4034
4482
|
async function handleSwap() {
|
|
@@ -4122,6 +4570,412 @@ function SwapModal({ onClose }) {
|
|
|
4122
4570
|
}
|
|
4123
4571
|
) });
|
|
4124
4572
|
}
|
|
4573
|
+
var POSITION_POLL_MS = 1e4;
|
|
4574
|
+
var PROVIDER_LABELS2 = {
|
|
4575
|
+
blend: "Blend",
|
|
4576
|
+
defindex: "DeFindex"
|
|
4577
|
+
};
|
|
4578
|
+
var IN_FLIGHT_STEPS2 = [
|
|
4579
|
+
"building",
|
|
4580
|
+
"signing",
|
|
4581
|
+
"submitting",
|
|
4582
|
+
"submitted",
|
|
4583
|
+
"signing-submitting",
|
|
4584
|
+
"building-signing-submitting"
|
|
4585
|
+
];
|
|
4586
|
+
function formatAmount4(value) {
|
|
4587
|
+
const n = parseFloat(value);
|
|
4588
|
+
return isNaN(n) ? value : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
4589
|
+
}
|
|
4590
|
+
function EarnModal({ onClose }) {
|
|
4591
|
+
const {
|
|
4592
|
+
getEarnProviders,
|
|
4593
|
+
getEarnOpportunities,
|
|
4594
|
+
getEarnPosition,
|
|
4595
|
+
earnDeposit,
|
|
4596
|
+
earnWithdraw,
|
|
4597
|
+
tx: transaction,
|
|
4598
|
+
wallet,
|
|
4599
|
+
walletBalance,
|
|
4600
|
+
refreshWalletBalance,
|
|
4601
|
+
network,
|
|
4602
|
+
styles
|
|
4603
|
+
} = usePollar();
|
|
4604
|
+
const walletType = wallet?.custody === "external" ? wallet.provider : null;
|
|
4605
|
+
const smartUnsupported = wallet?.custody === "smart";
|
|
4606
|
+
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
4607
|
+
const isDark = theme === "dark";
|
|
4608
|
+
const [step, setStep] = useState("form");
|
|
4609
|
+
const [tab, setTab] = useState("deposit");
|
|
4610
|
+
const [providers, setProviders] = useState(null);
|
|
4611
|
+
const [provider, setProvider] = useState(null);
|
|
4612
|
+
const [opportunities, setOpportunities] = useState([]);
|
|
4613
|
+
const [opportunityId, setOpportunityId] = useState("");
|
|
4614
|
+
const [position, setPosition] = useState(null);
|
|
4615
|
+
const [amount, setAmount] = useState("");
|
|
4616
|
+
const [loadingOpps, setLoadingOpps] = useState(false);
|
|
4617
|
+
const [formError, setFormError] = useState("");
|
|
4618
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
4619
|
+
const [showXdr, setShowXdr] = useState(false);
|
|
4620
|
+
const [copied, setCopied] = useState(false);
|
|
4621
|
+
const copyTimerRef = useRef(null);
|
|
4622
|
+
const loadProviders = useCallback(() => {
|
|
4623
|
+
setProviders(null);
|
|
4624
|
+
return getEarnProviders().then((ps) => {
|
|
4625
|
+
setProviders(ps);
|
|
4626
|
+
setProvider((cur) => cur ?? ps[0] ?? null);
|
|
4627
|
+
}).catch(() => setProviders([]));
|
|
4628
|
+
}, [getEarnProviders]);
|
|
4629
|
+
useEffect(() => {
|
|
4630
|
+
void loadProviders();
|
|
4631
|
+
}, [loadProviders]);
|
|
4632
|
+
useEffect(() => {
|
|
4633
|
+
void refreshWalletBalance();
|
|
4634
|
+
}, [refreshWalletBalance]);
|
|
4635
|
+
useEffect(() => {
|
|
4636
|
+
if (!provider) return;
|
|
4637
|
+
let cancelled = false;
|
|
4638
|
+
setLoadingOpps(true);
|
|
4639
|
+
getEarnOpportunities(provider).then((opps) => {
|
|
4640
|
+
if (cancelled) return;
|
|
4641
|
+
setOpportunities(opps);
|
|
4642
|
+
setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
|
|
4643
|
+
}).catch(() => {
|
|
4644
|
+
if (!cancelled) setOpportunities([]);
|
|
4645
|
+
}).finally(() => {
|
|
4646
|
+
if (!cancelled) setLoadingOpps(false);
|
|
4647
|
+
});
|
|
4648
|
+
return () => {
|
|
4649
|
+
cancelled = true;
|
|
4650
|
+
};
|
|
4651
|
+
}, [provider, getEarnOpportunities]);
|
|
4652
|
+
const selectedOpportunity = opportunities.find((o) => o.id === opportunityId) ?? null;
|
|
4653
|
+
const refreshPosition = useCallback(() => {
|
|
4654
|
+
if (!provider || !opportunityId || !wallet) return;
|
|
4655
|
+
getEarnPosition({ provider, opportunity: opportunityId }).then(setPosition).catch(() => {
|
|
4656
|
+
});
|
|
4657
|
+
}, [provider, opportunityId, wallet, getEarnPosition]);
|
|
4658
|
+
useEffect(() => {
|
|
4659
|
+
setPosition(null);
|
|
4660
|
+
refreshPosition();
|
|
4661
|
+
}, [refreshPosition]);
|
|
4662
|
+
useEffect(() => {
|
|
4663
|
+
if (step !== "form" || !provider || !opportunityId) return;
|
|
4664
|
+
const id = setInterval(refreshPosition, POSITION_POLL_MS);
|
|
4665
|
+
return () => clearInterval(id);
|
|
4666
|
+
}, [step, provider, opportunityId, refreshPosition]);
|
|
4667
|
+
useEffect(
|
|
4668
|
+
() => () => {
|
|
4669
|
+
if (copyTimerRef.current !== null) clearTimeout(copyTimerRef.current);
|
|
4670
|
+
},
|
|
4671
|
+
[]
|
|
4672
|
+
);
|
|
4673
|
+
const providersLoading = providers === null;
|
|
4674
|
+
const earnUnavailable = providers !== null && providers.length === 0;
|
|
4675
|
+
const withdrawUnit = position?.withdrawUnit ?? "asset";
|
|
4676
|
+
const assetCode = selectedOpportunity?.asset.code ?? "";
|
|
4677
|
+
const amountUnitLabel = tab === "deposit" ? assetCode : withdrawUnit === "shares" ? "shares" : assetCode;
|
|
4678
|
+
const walletAvailable = (() => {
|
|
4679
|
+
if (!selectedOpportunity) return null;
|
|
4680
|
+
const balances = walletBalance.step === "loaded" ? walletBalance.data.balances : [];
|
|
4681
|
+
const issuer = selectedOpportunity.asset.issuer;
|
|
4682
|
+
const rec = balances.find(
|
|
4683
|
+
(b) => issuer === null ? b.type === "native" : b.code === assetCode && b.issuer === issuer
|
|
4684
|
+
);
|
|
4685
|
+
return rec ? rec.available : null;
|
|
4686
|
+
})();
|
|
4687
|
+
const hash = transaction.step === "success" ? transaction.hash : null;
|
|
4688
|
+
const buildData = "buildData" in transaction ? transaction.buildData : null;
|
|
4689
|
+
const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
|
|
4690
|
+
const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
|
|
4691
|
+
const isInProgress = IN_FLIGHT_STEPS2.includes(transaction.step);
|
|
4692
|
+
const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
|
|
4693
|
+
const txTitle = isInProgress ? tab === "deposit" ? "Depositing\u2026" : "Withdrawing\u2026" : transaction.step === "success" ? "Done!" : transaction.step === "error" ? tab === "deposit" ? "Deposit failed" : "Withdraw failed" : "Confirm";
|
|
4694
|
+
const parsedAmount = parseFloat(amount);
|
|
4695
|
+
const exceedsAvailable = tab === "deposit" ? walletAvailable != null && parsedAmount > parseFloat(walletAvailable) : position != null && parsedAmount > parseFloat(position.withdrawable);
|
|
4696
|
+
const canSubmit = !smartUnsupported && !!provider && !!opportunityId && !!amount && parsedAmount > 0 && !exceedsAvailable && !providersLoading && !loadingOpps;
|
|
4697
|
+
const cssVars = {
|
|
4698
|
+
"--pollar-accent": accentColor,
|
|
4699
|
+
"--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
|
|
4700
|
+
"--pollar-border": isDark ? "#374151" : "#e5e7eb",
|
|
4701
|
+
"--pollar-text": isDark ? "#ffffff" : "#111827",
|
|
4702
|
+
"--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
|
|
4703
|
+
"--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
|
|
4704
|
+
"--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
|
|
4705
|
+
"--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
|
|
4706
|
+
"--pollar-error-text": isDark ? "#f87171" : "#dc2626",
|
|
4707
|
+
"--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
|
|
4708
|
+
"--pollar-buttons-border-radius": "6px",
|
|
4709
|
+
"--pollar-buttons-height": "44px",
|
|
4710
|
+
"--pollar-input-height": "44px",
|
|
4711
|
+
"--pollar-input-border-radius": "0.5rem",
|
|
4712
|
+
"--pollar-card-border-radius": "10px"
|
|
4713
|
+
};
|
|
4714
|
+
async function handleSubmit() {
|
|
4715
|
+
setFormError("");
|
|
4716
|
+
if (smartUnsupported) {
|
|
4717
|
+
setFormError("Earn is not yet supported for smart (passkey) wallets");
|
|
4718
|
+
return;
|
|
4719
|
+
}
|
|
4720
|
+
if (!provider || !opportunityId) {
|
|
4721
|
+
setFormError("Select a vault or pool");
|
|
4722
|
+
return;
|
|
4723
|
+
}
|
|
4724
|
+
const parsed = parseFloat(amount);
|
|
4725
|
+
if (!amount || isNaN(parsed) || parsed <= 0) {
|
|
4726
|
+
setFormError("Enter a valid amount");
|
|
4727
|
+
return;
|
|
4728
|
+
}
|
|
4729
|
+
if (tab === "deposit" && walletAvailable != null && parsed > parseFloat(walletAvailable)) {
|
|
4730
|
+
setFormError("Amount exceeds your wallet balance");
|
|
4731
|
+
return;
|
|
4732
|
+
}
|
|
4733
|
+
if (tab === "withdraw" && position && parsed > parseFloat(position.withdrawable)) {
|
|
4734
|
+
setFormError("Amount exceeds your position");
|
|
4735
|
+
return;
|
|
4736
|
+
}
|
|
4737
|
+
setStep("tx");
|
|
4738
|
+
const params = { provider, opportunity: opportunityId, amount };
|
|
4739
|
+
const outcome = tab === "deposit" ? await earnDeposit(params) : await earnWithdraw(params);
|
|
4740
|
+
if (outcome.status === "success" || outcome.status === "pending") {
|
|
4741
|
+
setAmount("");
|
|
4742
|
+
refreshPosition();
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4745
|
+
async function handleRetry() {
|
|
4746
|
+
if (transaction.step !== "error" || !provider || !opportunityId) return;
|
|
4747
|
+
const params = { provider, opportunity: opportunityId, amount };
|
|
4748
|
+
if (tab === "deposit") await earnDeposit(params);
|
|
4749
|
+
else await earnWithdraw(params);
|
|
4750
|
+
}
|
|
4751
|
+
function handleCopyHash() {
|
|
4752
|
+
if (!hash) return;
|
|
4753
|
+
navigator.clipboard.writeText(hash).then(() => {
|
|
4754
|
+
setCopied(true);
|
|
4755
|
+
if (copyTimerRef.current !== null) clearTimeout(copyTimerRef.current);
|
|
4756
|
+
copyTimerRef.current = setTimeout(() => {
|
|
4757
|
+
copyTimerRef.current = null;
|
|
4758
|
+
setCopied(false);
|
|
4759
|
+
}, 2e3);
|
|
4760
|
+
});
|
|
4761
|
+
}
|
|
4762
|
+
function handleBack() {
|
|
4763
|
+
setStep("form");
|
|
4764
|
+
setShowXdr(false);
|
|
4765
|
+
setCopied(false);
|
|
4766
|
+
refreshPosition();
|
|
4767
|
+
}
|
|
4768
|
+
async function handleRefresh() {
|
|
4769
|
+
if (refreshing || !provider) return;
|
|
4770
|
+
setRefreshing(true);
|
|
4771
|
+
try {
|
|
4772
|
+
void refreshWalletBalance();
|
|
4773
|
+
const opps = await getEarnOpportunities(provider);
|
|
4774
|
+
setOpportunities(opps);
|
|
4775
|
+
setOpportunityId((cur) => opps.some((o) => o.id === cur) ? cur : opps[0]?.id ?? "");
|
|
4776
|
+
refreshPosition();
|
|
4777
|
+
} catch {
|
|
4778
|
+
} finally {
|
|
4779
|
+
setRefreshing(false);
|
|
4780
|
+
}
|
|
4781
|
+
}
|
|
4782
|
+
const title = step === "form" ? "Earn" : txTitle;
|
|
4783
|
+
return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxs(
|
|
4784
|
+
"div",
|
|
4785
|
+
{
|
|
4786
|
+
className: "pollar-modal-card pollar-send-modal",
|
|
4787
|
+
"data-theme": theme,
|
|
4788
|
+
style: cssVars,
|
|
4789
|
+
onClick: (e) => e.stopPropagation(),
|
|
4790
|
+
children: [
|
|
4791
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4792
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-header-left", children: [
|
|
4793
|
+
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" }) }) }),
|
|
4794
|
+
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: title })
|
|
4795
|
+
] }),
|
|
4796
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
4797
|
+
step === "form" && !earnUnavailable && !smartUnsupported && /* @__PURE__ */ jsx(
|
|
4798
|
+
"button",
|
|
4799
|
+
{
|
|
4800
|
+
type: "button",
|
|
4801
|
+
className: "pollar-modal-close",
|
|
4802
|
+
onClick: () => void handleRefresh(),
|
|
4803
|
+
disabled: refreshing || providersLoading,
|
|
4804
|
+
"aria-label": "Refresh",
|
|
4805
|
+
children: /* @__PURE__ */ jsx(
|
|
4806
|
+
"svg",
|
|
4807
|
+
{
|
|
4808
|
+
className: refreshing ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
4809
|
+
width: "16",
|
|
4810
|
+
height: "16",
|
|
4811
|
+
viewBox: "0 0 16 16",
|
|
4812
|
+
fill: "none",
|
|
4813
|
+
"aria-hidden": true,
|
|
4814
|
+
children: /* @__PURE__ */ jsx(
|
|
4815
|
+
"path",
|
|
4816
|
+
{
|
|
4817
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
4818
|
+
stroke: "currentColor",
|
|
4819
|
+
strokeWidth: "1.6",
|
|
4820
|
+
strokeLinecap: "round",
|
|
4821
|
+
strokeLinejoin: "round"
|
|
4822
|
+
}
|
|
4823
|
+
)
|
|
4824
|
+
}
|
|
4825
|
+
)
|
|
4826
|
+
}
|
|
4827
|
+
),
|
|
4828
|
+
!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" }) }) })
|
|
4829
|
+
] })
|
|
4830
|
+
] }),
|
|
4831
|
+
step === "form" && providersLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
4832
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
4833
|
+
/* @__PURE__ */ jsx("span", { children: "Loading Earn options\u2026" })
|
|
4834
|
+
] }),
|
|
4835
|
+
step === "form" && earnUnavailable && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "Earn is not available for this app." }),
|
|
4836
|
+
step === "form" && !earnUnavailable && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4837
|
+
smartUnsupported && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: "Earn is not yet available for smart (passkey) wallets." }),
|
|
4838
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-tabs", children: [
|
|
4839
|
+
/* @__PURE__ */ jsx(
|
|
4840
|
+
"button",
|
|
4841
|
+
{
|
|
4842
|
+
type: "button",
|
|
4843
|
+
className: "pollar-tab",
|
|
4844
|
+
"data-active": tab === "deposit",
|
|
4845
|
+
onClick: () => {
|
|
4846
|
+
setTab("deposit");
|
|
4847
|
+
setFormError("");
|
|
4848
|
+
},
|
|
4849
|
+
children: "Deposit"
|
|
4850
|
+
}
|
|
4851
|
+
),
|
|
4852
|
+
/* @__PURE__ */ jsx(
|
|
4853
|
+
"button",
|
|
4854
|
+
{
|
|
4855
|
+
type: "button",
|
|
4856
|
+
className: "pollar-tab",
|
|
4857
|
+
"data-active": tab === "withdraw",
|
|
4858
|
+
onClick: () => {
|
|
4859
|
+
setTab("withdraw");
|
|
4860
|
+
setFormError("");
|
|
4861
|
+
},
|
|
4862
|
+
children: "Withdraw"
|
|
4863
|
+
}
|
|
4864
|
+
)
|
|
4865
|
+
] }),
|
|
4866
|
+
providers && providers.length > 1 && /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4867
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Provider" }),
|
|
4868
|
+
/* @__PURE__ */ jsx(
|
|
4869
|
+
"select",
|
|
4870
|
+
{
|
|
4871
|
+
className: "pollar-input pollar-send-select",
|
|
4872
|
+
value: provider ?? "",
|
|
4873
|
+
onChange: (e) => setProvider(e.target.value),
|
|
4874
|
+
children: providers.map((p) => /* @__PURE__ */ jsx("option", { value: p, children: PROVIDER_LABELS2[p] }, p))
|
|
4875
|
+
}
|
|
4876
|
+
)
|
|
4877
|
+
] }),
|
|
4878
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4879
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
4880
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: provider === "defindex" ? "Vault" : "Pool" }),
|
|
4881
|
+
loadingOpps && /* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm", "aria-label": "Loading options" })
|
|
4882
|
+
] }),
|
|
4883
|
+
/* @__PURE__ */ jsx(
|
|
4884
|
+
"select",
|
|
4885
|
+
{
|
|
4886
|
+
className: "pollar-input pollar-send-select",
|
|
4887
|
+
value: opportunityId,
|
|
4888
|
+
disabled: loadingOpps || opportunities.length === 0,
|
|
4889
|
+
onChange: (e) => setOpportunityId(e.target.value),
|
|
4890
|
+
children: opportunities.length === 0 ? /* @__PURE__ */ jsx("option", { value: "", children: loadingOpps ? "Loading\u2026" : "None available" }) : opportunities.map((o) => /* @__PURE__ */ jsxs("option", { value: o.id, children: [
|
|
4891
|
+
o.name,
|
|
4892
|
+
" \xB7 ",
|
|
4893
|
+
o.apy.toFixed(2),
|
|
4894
|
+
"% APY"
|
|
4895
|
+
] }, o.id))
|
|
4896
|
+
}
|
|
4897
|
+
)
|
|
4898
|
+
] }),
|
|
4899
|
+
selectedOpportunity && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote", children: [
|
|
4900
|
+
tab === "deposit" && /* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4901
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "In your wallet" }),
|
|
4902
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4903
|
+
walletAvailable != null ? formatAmount4(walletAvailable) : "\u2026",
|
|
4904
|
+
" ",
|
|
4905
|
+
assetCode
|
|
4906
|
+
] })
|
|
4907
|
+
] }),
|
|
4908
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4909
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "Your position" }),
|
|
4910
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
4911
|
+
position ? formatAmount4(position.balance) : "\u2026",
|
|
4912
|
+
" ",
|
|
4913
|
+
assetCode
|
|
4914
|
+
] })
|
|
4915
|
+
] }),
|
|
4916
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-swap-quote-row", children: [
|
|
4917
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-send-hint", children: "APY" }),
|
|
4918
|
+
/* @__PURE__ */ jsxs("span", { className: "pollar-earn-live", children: [
|
|
4919
|
+
selectedOpportunity.apy.toFixed(2),
|
|
4920
|
+
"%"
|
|
4921
|
+
] })
|
|
4922
|
+
] })
|
|
4923
|
+
] }),
|
|
4924
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
|
|
4925
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
|
|
4926
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: tab === "deposit" ? "Amount" : "Withdraw amount" }),
|
|
4927
|
+
tab === "deposit" && walletAvailable != null && /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-swap-custom-toggle", onClick: () => setAmount(walletAvailable), children: [
|
|
4928
|
+
"Max: ",
|
|
4929
|
+
formatAmount4(walletAvailable),
|
|
4930
|
+
" ",
|
|
4931
|
+
amountUnitLabel
|
|
4932
|
+
] }),
|
|
4933
|
+
tab === "withdraw" && position && /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-swap-custom-toggle", onClick: () => setAmount(position.withdrawable), children: [
|
|
4934
|
+
"Max: ",
|
|
4935
|
+
formatAmount4(position.withdrawable),
|
|
4936
|
+
" ",
|
|
4937
|
+
amountUnitLabel
|
|
4938
|
+
] })
|
|
4939
|
+
] }),
|
|
4940
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-earn-amount", children: [
|
|
4941
|
+
/* @__PURE__ */ jsx(
|
|
4942
|
+
"input",
|
|
4943
|
+
{
|
|
4944
|
+
className: "pollar-input",
|
|
4945
|
+
type: "text",
|
|
4946
|
+
inputMode: "decimal",
|
|
4947
|
+
placeholder: "0.00",
|
|
4948
|
+
value: amount,
|
|
4949
|
+
onChange: (e) => setAmount(e.target.value)
|
|
4950
|
+
}
|
|
4951
|
+
),
|
|
4952
|
+
amountUnitLabel && /* @__PURE__ */ jsx("span", { className: "pollar-earn-amount-unit", children: amountUnitLabel })
|
|
4953
|
+
] })
|
|
4954
|
+
] }),
|
|
4955
|
+
formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
|
|
4956
|
+
/* @__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" }) })
|
|
4957
|
+
] }),
|
|
4958
|
+
step === "tx" && /* @__PURE__ */ jsx(
|
|
4959
|
+
TxStatusView,
|
|
4960
|
+
{
|
|
4961
|
+
transaction,
|
|
4962
|
+
showXdr,
|
|
4963
|
+
copied,
|
|
4964
|
+
explorerUrl,
|
|
4965
|
+
walletType,
|
|
4966
|
+
onSignAndSend: () => {
|
|
4967
|
+
},
|
|
4968
|
+
onToggleXdr: () => setShowXdr((v) => !v),
|
|
4969
|
+
onCopyHash: handleCopyHash,
|
|
4970
|
+
onRetry: () => void handleRetry(),
|
|
4971
|
+
onDone: onClose
|
|
4972
|
+
}
|
|
4973
|
+
),
|
|
4974
|
+
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
4975
|
+
]
|
|
4976
|
+
}
|
|
4977
|
+
) });
|
|
4978
|
+
}
|
|
4125
4979
|
function describeDevice(s) {
|
|
4126
4980
|
if (s.deviceLabel) return s.deviceLabel;
|
|
4127
4981
|
if (!s.userAgent) return "Unknown device";
|
|
@@ -4213,30 +5067,46 @@ function SessionsModalTemplate({
|
|
|
4213
5067
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4214
5068
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Active sessions" }),
|
|
4215
5069
|
/* @__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
|
-
|
|
5070
|
+
/* @__PURE__ */ jsx(
|
|
5071
|
+
"button",
|
|
5072
|
+
{
|
|
5073
|
+
type: "button",
|
|
5074
|
+
className: "pollar-modal-close",
|
|
5075
|
+
onClick: onRefresh,
|
|
5076
|
+
disabled: isLoading,
|
|
5077
|
+
"aria-label": "Refresh",
|
|
5078
|
+
title: "Refresh",
|
|
5079
|
+
children: /* @__PURE__ */ jsx(
|
|
5080
|
+
"svg",
|
|
5081
|
+
{
|
|
5082
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
5083
|
+
width: "16",
|
|
5084
|
+
height: "16",
|
|
5085
|
+
viewBox: "0 0 16 16",
|
|
5086
|
+
fill: "none",
|
|
5087
|
+
"aria-hidden": true,
|
|
5088
|
+
children: /* @__PURE__ */ jsx(
|
|
5089
|
+
"path",
|
|
5090
|
+
{
|
|
5091
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
5092
|
+
stroke: "currentColor",
|
|
5093
|
+
strokeWidth: "1.6",
|
|
5094
|
+
strokeLinecap: "round",
|
|
5095
|
+
strokeLinejoin: "round"
|
|
5096
|
+
}
|
|
5097
|
+
)
|
|
5098
|
+
}
|
|
5099
|
+
)
|
|
5100
|
+
}
|
|
5101
|
+
),
|
|
4234
5102
|
/* @__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
5103
|
] })
|
|
4236
5104
|
] }),
|
|
4237
5105
|
/* @__PURE__ */ jsxs("div", { className: "pollar-sessions-list", children: [
|
|
4238
|
-
state.step === "idle" && /* @__PURE__ */
|
|
4239
|
-
|
|
5106
|
+
(state.step === "idle" || isLoading) && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
5107
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
5108
|
+
/* @__PURE__ */ jsx("span", { children: "Loading\u2026" })
|
|
5109
|
+
] }),
|
|
4240
5110
|
state.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: state.message }),
|
|
4241
5111
|
state.step === "loaded" && sessions.length === 0 && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No active sessions." }),
|
|
4242
5112
|
sessions.map((s) => {
|
|
@@ -4265,7 +5135,10 @@ function SessionsModalTemplate({
|
|
|
4265
5135
|
className: "pollar-sessions-item-revoke",
|
|
4266
5136
|
onClick: () => onRevoke(s.familyId),
|
|
4267
5137
|
disabled: isRevoking || signingOutEverywhere,
|
|
4268
|
-
children: isRevoking ?
|
|
5138
|
+
children: isRevoking ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5139
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }),
|
|
5140
|
+
"Revoking\u2026"
|
|
5141
|
+
] }) : "Revoke"
|
|
4269
5142
|
}
|
|
4270
5143
|
)
|
|
4271
5144
|
] }, s.familyId);
|
|
@@ -4278,7 +5151,10 @@ function SessionsModalTemplate({
|
|
|
4278
5151
|
onClick: onLogoutEverywhere,
|
|
4279
5152
|
disabled: signingOutEverywhere || otherCount === 0,
|
|
4280
5153
|
title: otherCount === 0 ? "No other devices to sign out" : void 0,
|
|
4281
|
-
children: signingOutEverywhere ?
|
|
5154
|
+
children: signingOutEverywhere ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5155
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-spinner pollar-spinner-sm pollar-spinner-current" }),
|
|
5156
|
+
"Signing out\u2026"
|
|
5157
|
+
] }) : "Sign out everywhere"
|
|
4282
5158
|
}
|
|
4283
5159
|
) }),
|
|
4284
5160
|
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
@@ -4471,6 +5347,33 @@ function StatusBadge({ status }) {
|
|
|
4471
5347
|
function formatDate(iso) {
|
|
4472
5348
|
return new Date(iso).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
|
|
4473
5349
|
}
|
|
5350
|
+
function truncateMiddle(value, head = 4, tail = 4) {
|
|
5351
|
+
return value.length <= head + tail + 1 ? value : `${value.slice(0, head)}\u2026${value.slice(-tail)}`;
|
|
5352
|
+
}
|
|
5353
|
+
var STELLAR_ADDRESS = /\b[GC][A-Z2-7]{55}\b/g;
|
|
5354
|
+
function AddressChip({ value, label }) {
|
|
5355
|
+
return /* @__PURE__ */ jsxs("span", { className: "pollar-hist-item-issuer", children: [
|
|
5356
|
+
truncateMiddle(value),
|
|
5357
|
+
/* @__PURE__ */ jsx(CopyButton, { value, label, className: "pollar-copy-btn-sm" })
|
|
5358
|
+
] });
|
|
5359
|
+
}
|
|
5360
|
+
function renderSummary(summary) {
|
|
5361
|
+
const parts = [];
|
|
5362
|
+
let last = 0;
|
|
5363
|
+
let key = 0;
|
|
5364
|
+
STELLAR_ADDRESS.lastIndex = 0;
|
|
5365
|
+
for (let m = STELLAR_ADDRESS.exec(summary); m !== null; m = STELLAR_ADDRESS.exec(summary)) {
|
|
5366
|
+
if (m.index > last) parts.push(/* @__PURE__ */ jsx("span", { children: summary.slice(last, m.index) }, key++));
|
|
5367
|
+
const address = m[0];
|
|
5368
|
+
parts.push(
|
|
5369
|
+
/* @__PURE__ */ jsx(AddressChip, { value: address, label: address[0] === "C" ? "Copy contract address" : "Copy wallet address" }, key++)
|
|
5370
|
+
);
|
|
5371
|
+
last = m.index + address.length;
|
|
5372
|
+
}
|
|
5373
|
+
if (parts.length === 0) return /* @__PURE__ */ jsx("span", { className: "pollar-hist-item-title", children: summary });
|
|
5374
|
+
if (last < summary.length) parts.push(/* @__PURE__ */ jsx("span", { children: summary.slice(last) }, key));
|
|
5375
|
+
return parts;
|
|
5376
|
+
}
|
|
4474
5377
|
function TxHistoryModalTemplate({
|
|
4475
5378
|
theme,
|
|
4476
5379
|
accentColor,
|
|
@@ -4516,59 +5419,106 @@ function TxHistoryModalTemplate({
|
|
|
4516
5419
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4517
5420
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Transaction History" }),
|
|
4518
5421
|
/* @__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
|
-
|
|
5422
|
+
/* @__PURE__ */ jsx(
|
|
5423
|
+
"button",
|
|
5424
|
+
{
|
|
5425
|
+
type: "button",
|
|
5426
|
+
className: "pollar-modal-close",
|
|
5427
|
+
onClick: onRefresh,
|
|
5428
|
+
disabled: isLoading,
|
|
5429
|
+
"aria-label": "Refresh",
|
|
5430
|
+
title: "Refresh",
|
|
5431
|
+
children: /* @__PURE__ */ jsx(
|
|
5432
|
+
"svg",
|
|
5433
|
+
{
|
|
5434
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
5435
|
+
width: "16",
|
|
5436
|
+
height: "16",
|
|
5437
|
+
viewBox: "0 0 16 16",
|
|
5438
|
+
fill: "none",
|
|
5439
|
+
"aria-hidden": true,
|
|
5440
|
+
children: /* @__PURE__ */ jsx(
|
|
5441
|
+
"path",
|
|
5442
|
+
{
|
|
5443
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
5444
|
+
stroke: "currentColor",
|
|
5445
|
+
strokeWidth: "1.6",
|
|
5446
|
+
strokeLinecap: "round",
|
|
5447
|
+
strokeLinejoin: "round"
|
|
5448
|
+
}
|
|
5449
|
+
)
|
|
5450
|
+
}
|
|
5451
|
+
)
|
|
5452
|
+
}
|
|
5453
|
+
),
|
|
4537
5454
|
/* @__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
5455
|
] })
|
|
4539
5456
|
] }),
|
|
4540
5457
|
/* @__PURE__ */ jsxs("div", { className: "pollar-hist-list", children: [
|
|
4541
5458
|
txHistory.step === "idle" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "Click Refresh to load transactions." }),
|
|
4542
|
-
isLoading && /* @__PURE__ */
|
|
5459
|
+
isLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
5460
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
5461
|
+
/* @__PURE__ */ jsx("span", { children: "Loading\u2026" })
|
|
5462
|
+
] }),
|
|
4543
5463
|
txHistory.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: txHistory.message }),
|
|
4544
5464
|
txHistory.step === "loaded" && records.length === 0 && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No transactions yet." }),
|
|
4545
5465
|
records.map((record) => {
|
|
4546
|
-
const
|
|
5466
|
+
const hash = typeof record.hash === "string" && record.hash.length > 0 ? record.hash : void 0;
|
|
5467
|
+
const explorerUrl = hash ? `https://stellar.expert/explorer/${record.network === "testnet" ? "testnet" : "public"}/tx/${hash}` : void 0;
|
|
5468
|
+
const asset = typeof record.details?.asset === "string" ? record.details.asset : void 0;
|
|
5469
|
+
const colon = asset ? asset.indexOf(":") : -1;
|
|
5470
|
+
const trustline = record.operation === "change_trust" && asset && colon > 0 ? {
|
|
5471
|
+
prefix: record.summary.split(":")[0],
|
|
5472
|
+
code: asset.slice(0, colon),
|
|
5473
|
+
issuer: asset.slice(colon + 1)
|
|
5474
|
+
} : void 0;
|
|
5475
|
+
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
5476
|
return /* @__PURE__ */ jsxs("div", { className: "pollar-hist-item", children: [
|
|
4548
|
-
/* @__PURE__ */
|
|
4549
|
-
|
|
5477
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-hist-item-top", children: [
|
|
5478
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-hist-item-summary", children: trustline ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5479
|
+
/* @__PURE__ */ jsxs("span", { className: "pollar-hist-item-title", children: [
|
|
5480
|
+
trustline.prefix,
|
|
5481
|
+
": ",
|
|
5482
|
+
trustline.code
|
|
5483
|
+
] }),
|
|
5484
|
+
/* @__PURE__ */ jsx(AddressChip, { value: trustline.issuer, label: "Copy issuer" })
|
|
5485
|
+
] }) : contract ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5486
|
+
/* @__PURE__ */ jsxs("span", { className: "pollar-hist-item-title", children: [
|
|
5487
|
+
"Invoke ",
|
|
5488
|
+
contract.method,
|
|
5489
|
+
"() on"
|
|
5490
|
+
] }),
|
|
5491
|
+
/* @__PURE__ */ jsx(AddressChip, { value: contract.contractId, label: "Copy contract address" })
|
|
5492
|
+
] }) : renderSummary(record.summary) }),
|
|
5493
|
+
/* @__PURE__ */ jsx(StatusBadge, { status: record.status })
|
|
5494
|
+
] }),
|
|
4550
5495
|
/* @__PURE__ */ jsxs("span", { className: "pollar-hist-item-meta", children: [
|
|
4551
5496
|
/* @__PURE__ */ jsx("span", { children: record.operation }),
|
|
5497
|
+
typeof record.details?.sponsored === "boolean" && /* @__PURE__ */ jsxs("span", { children: [
|
|
5498
|
+
"\xB7 ",
|
|
5499
|
+
record.details.sponsored ? "Sponsored" : "Self-paid"
|
|
5500
|
+
] }),
|
|
4552
5501
|
record.feeXlm && /* @__PURE__ */ jsxs("span", { children: [
|
|
4553
5502
|
"\xB7 ",
|
|
4554
5503
|
record.feeXlm,
|
|
4555
5504
|
" XLM"
|
|
4556
|
-
] })
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
"
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
5505
|
+
] })
|
|
5506
|
+
] }),
|
|
5507
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-hist-item-footer", children: [
|
|
5508
|
+
/* @__PURE__ */ jsx("span", { children: formatDate(record.createdAt) }),
|
|
5509
|
+
hash && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5510
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-hist-item-dot", children: "\xB7" }),
|
|
5511
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-hist-item-hash", children: truncateMiddle(hash, 6, 6) }),
|
|
5512
|
+
/* @__PURE__ */ jsx(CopyButton, { value: hash, label: "Copy transaction hash", className: "pollar-copy-btn-sm" }),
|
|
5513
|
+
/* @__PURE__ */ jsx(
|
|
5514
|
+
"a",
|
|
5515
|
+
{
|
|
5516
|
+
className: "pollar-hist-item-explorer",
|
|
5517
|
+
href: explorerUrl,
|
|
5518
|
+
target: "_blank",
|
|
5519
|
+
rel: "noopener noreferrer",
|
|
5520
|
+
"aria-label": "View on Stellar Explorer",
|
|
5521
|
+
children: /* @__PURE__ */ jsxs("svg", { width: "12", height: "12", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
4572
5522
|
/* @__PURE__ */ jsx(
|
|
4573
5523
|
"path",
|
|
4574
5524
|
{
|
|
@@ -4588,11 +5538,10 @@ function TxHistoryModalTemplate({
|
|
|
4588
5538
|
strokeLinejoin: "round"
|
|
4589
5539
|
}
|
|
4590
5540
|
)
|
|
4591
|
-
] })
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
)
|
|
5541
|
+
] })
|
|
5542
|
+
}
|
|
5543
|
+
)
|
|
5544
|
+
] })
|
|
4596
5545
|
] })
|
|
4597
5546
|
] }, record.id);
|
|
4598
5547
|
})
|
|
@@ -4646,7 +5595,7 @@ function TxHistoryModal({ onClose }) {
|
|
|
4646
5595
|
}
|
|
4647
5596
|
function formatBalance2(balance) {
|
|
4648
5597
|
const n = parseFloat(balance);
|
|
4649
|
-
return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
5598
|
+
return isNaN(n) ? balance : n.toLocaleString(void 0, { minimumFractionDigits: 7, maximumFractionDigits: 7 });
|
|
4650
5599
|
}
|
|
4651
5600
|
function cropAddress2(address) {
|
|
4652
5601
|
if (address.length <= 16) return address;
|
|
@@ -4655,7 +5604,13 @@ function cropAddress2(address) {
|
|
|
4655
5604
|
function BalanceItem({ record }) {
|
|
4656
5605
|
const balanceDiffers = record.balance !== record.available;
|
|
4657
5606
|
return /* @__PURE__ */ jsxs("div", { className: "pollar-bal-item", children: [
|
|
4658
|
-
/* @__PURE__ */
|
|
5607
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-bal-asset-info", children: [
|
|
5608
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-bal-asset", children: record.code }),
|
|
5609
|
+
record.issuer && /* @__PURE__ */ jsxs("span", { className: "pollar-bal-issuer", children: [
|
|
5610
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-bal-issuer-addr", children: cropAddress2(record.issuer) }),
|
|
5611
|
+
/* @__PURE__ */ jsx(CopyButton, { value: record.issuer, label: "Copy issuer address", className: "pollar-copy-btn-sm" })
|
|
5612
|
+
] })
|
|
5613
|
+
] }),
|
|
4659
5614
|
/* @__PURE__ */ jsxs("div", { className: "pollar-bal-amounts", children: [
|
|
4660
5615
|
/* @__PURE__ */ jsx("span", { className: "pollar-bal-amount", children: formatBalance2(record.balance) }),
|
|
4661
5616
|
balanceDiffers && /* @__PURE__ */ jsxs("span", { className: "pollar-bal-available", children: [
|
|
@@ -4697,29 +5652,49 @@ function WalletBalanceModalTemplate({
|
|
|
4697
5652
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
4698
5653
|
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Wallet Balance" }),
|
|
4699
5654
|
/* @__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
|
-
|
|
5655
|
+
/* @__PURE__ */ jsx(
|
|
5656
|
+
"button",
|
|
5657
|
+
{
|
|
5658
|
+
type: "button",
|
|
5659
|
+
className: "pollar-modal-close",
|
|
5660
|
+
onClick: onRefresh,
|
|
5661
|
+
disabled: isLoading,
|
|
5662
|
+
"aria-label": "Refresh",
|
|
5663
|
+
title: "Refresh",
|
|
5664
|
+
children: /* @__PURE__ */ jsx(
|
|
5665
|
+
"svg",
|
|
5666
|
+
{
|
|
5667
|
+
className: isLoading ? "pollar-modal-refresh-icon pollar-spinning" : "pollar-modal-refresh-icon",
|
|
5668
|
+
width: "16",
|
|
5669
|
+
height: "16",
|
|
5670
|
+
viewBox: "0 0 16 16",
|
|
5671
|
+
fill: "none",
|
|
5672
|
+
"aria-hidden": true,
|
|
5673
|
+
children: /* @__PURE__ */ jsx(
|
|
5674
|
+
"path",
|
|
5675
|
+
{
|
|
5676
|
+
d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2v3h-3",
|
|
5677
|
+
stroke: "currentColor",
|
|
5678
|
+
strokeWidth: "1.6",
|
|
5679
|
+
strokeLinecap: "round",
|
|
5680
|
+
strokeLinejoin: "round"
|
|
5681
|
+
}
|
|
5682
|
+
)
|
|
5683
|
+
}
|
|
5684
|
+
)
|
|
5685
|
+
}
|
|
5686
|
+
),
|
|
4718
5687
|
/* @__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
5688
|
] })
|
|
4720
5689
|
] }),
|
|
4721
|
-
walletAddress && /* @__PURE__ */
|
|
4722
|
-
|
|
5690
|
+
walletAddress && /* @__PURE__ */ jsxs("div", { className: "pollar-bal-address-row", children: [
|
|
5691
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-bal-address", children: cropAddress2(walletAddress) }),
|
|
5692
|
+
/* @__PURE__ */ jsx(CopyButton, { value: walletAddress, label: "Copy wallet address" })
|
|
5693
|
+
] }),
|
|
5694
|
+
isLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
|
|
5695
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-spinner" }),
|
|
5696
|
+
/* @__PURE__ */ jsx("span", { children: "Loading\u2026" })
|
|
5697
|
+
] }),
|
|
4723
5698
|
walletBalance.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: walletBalance.message }),
|
|
4724
5699
|
data && !data.exists && /* @__PURE__ */ jsxs("div", { className: "pollar-modal-empty", children: [
|
|
4725
5700
|
"Account not found on ",
|
|
@@ -4929,6 +5904,10 @@ function PollarProvider({
|
|
|
4929
5904
|
const [enabledAssetsModalOpen, setEnabledAssetsModalOpen] = useState(false);
|
|
4930
5905
|
const [sendModalOpen, setSendModalOpen] = useState(false);
|
|
4931
5906
|
const [swapModalOpen, setSwapModalOpen] = useState(false);
|
|
5907
|
+
const [earnModalOpen, setEarnModalOpen] = useState(false);
|
|
5908
|
+
const [sendModalKey, setSendModalKey] = useState(0);
|
|
5909
|
+
const [swapModalKey, setSwapModalKey] = useState(0);
|
|
5910
|
+
const [earnModalKey, setEarnModalKey] = useState(0);
|
|
4932
5911
|
const [receiveModalOpen, setReceiveModalOpen] = useState(false);
|
|
4933
5912
|
const [sessionsModalOpen, setSessionsModalOpen] = useState(false);
|
|
4934
5913
|
const [distributionRulesModalOpen, setDistributionRulesModalOpen] = useState(false);
|
|
@@ -4971,14 +5950,33 @@ function PollarProvider({
|
|
|
4971
5950
|
setTrustline: (asset, opts) => pollarClient.setTrustline(asset, opts),
|
|
4972
5951
|
openEnabledAssetsModal: () => setEnabledAssetsModalOpen(true),
|
|
4973
5952
|
// send / receive
|
|
4974
|
-
openSendModal: () =>
|
|
5953
|
+
openSendModal: () => {
|
|
5954
|
+
pollarClient.resetTransactionState();
|
|
5955
|
+
setSendModalKey((k) => k + 1);
|
|
5956
|
+
setSendModalOpen(true);
|
|
5957
|
+
},
|
|
4975
5958
|
openReceiveModal: () => setReceiveModalOpen(true),
|
|
4976
5959
|
// swap
|
|
4977
5960
|
getSwapConfig: () => pollarClient.getSwapConfig(),
|
|
4978
5961
|
getSwapTokens: () => pollarClient.getSwapTokens(),
|
|
4979
5962
|
getSwapQuote: (params) => pollarClient.getSwapQuote(params),
|
|
4980
5963
|
swap: (quote, opts) => pollarClient.swap(quote, opts),
|
|
4981
|
-
openSwapModal: () =>
|
|
5964
|
+
openSwapModal: () => {
|
|
5965
|
+
pollarClient.resetTransactionState();
|
|
5966
|
+
setSwapModalKey((k) => k + 1);
|
|
5967
|
+
setSwapModalOpen(true);
|
|
5968
|
+
},
|
|
5969
|
+
// earn
|
|
5970
|
+
getEarnProviders: () => pollarClient.getEarnProviders(),
|
|
5971
|
+
getEarnOpportunities: (provider) => pollarClient.getEarnOpportunities(provider),
|
|
5972
|
+
getEarnPosition: (params) => pollarClient.getEarnPosition(params),
|
|
5973
|
+
earnDeposit: (params) => pollarClient.earnDeposit(params),
|
|
5974
|
+
earnWithdraw: (params) => pollarClient.earnWithdraw(params),
|
|
5975
|
+
openEarnModal: () => {
|
|
5976
|
+
pollarClient.resetTransactionState();
|
|
5977
|
+
setEarnModalKey((k) => k + 1);
|
|
5978
|
+
setEarnModalOpen(true);
|
|
5979
|
+
},
|
|
4982
5980
|
// sessions
|
|
4983
5981
|
sessions,
|
|
4984
5982
|
openSessionsModal: () => setSessionsModalOpen(true),
|
|
@@ -5032,8 +6030,9 @@ function PollarProvider({
|
|
|
5032
6030
|
txHistoryModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false) }) }),
|
|
5033
6031
|
walletBalanceModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
|
|
5034
6032
|
enabledAssetsModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setEnabledAssetsModalOpen(false), children: /* @__PURE__ */ jsx(EnabledAssetsModal, { onClose: () => setEnabledAssetsModalOpen(false) }) }),
|
|
5035
|
-
sendModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
|
|
5036
|
-
swapModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsx(SwapModal, { onClose: () => setSwapModalOpen(false) }) }),
|
|
6033
|
+
sendModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }, sendModalKey),
|
|
6034
|
+
swapModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSwapModalOpen(false), children: /* @__PURE__ */ jsx(SwapModal, { onClose: () => setSwapModalOpen(false) }) }, swapModalKey),
|
|
6035
|
+
earnModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setEarnModalOpen(false), children: /* @__PURE__ */ jsx(EarnModal, { onClose: () => setEarnModalOpen(false) }) }, earnModalKey),
|
|
5037
6036
|
receiveModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) }),
|
|
5038
6037
|
sessionsModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) }),
|
|
5039
6038
|
distributionRulesModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setDistributionRulesModalOpen(false), children: /* @__PURE__ */ jsx(DistributionRulesModal, { onClose: () => setDistributionRulesModalOpen(false) }) })
|
|
@@ -5067,7 +6066,7 @@ function createPollarAdapterHook(key) {
|
|
|
5067
6066
|
};
|
|
5068
6067
|
}
|
|
5069
6068
|
function ButtonLogo() {
|
|
5070
|
-
return /* @__PURE__ */ jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "wallet-btn-logo" });
|
|
6069
|
+
return /* @__PURE__ */ jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "pollar-wallet-btn-logo" });
|
|
5071
6070
|
}
|
|
5072
6071
|
function cropWallet(address) {
|
|
5073
6072
|
if (address.length <= 12) return address;
|
|
@@ -5083,7 +6082,10 @@ function WalletButtonTemplate({
|
|
|
5083
6082
|
itemColor,
|
|
5084
6083
|
wrapperRef,
|
|
5085
6084
|
isInProgress,
|
|
6085
|
+
showCreateAccount,
|
|
6086
|
+
creatingAccount,
|
|
5086
6087
|
onToggleOpen,
|
|
6088
|
+
onCreateAccount,
|
|
5087
6089
|
onCopy,
|
|
5088
6090
|
onWalletBalance,
|
|
5089
6091
|
onTxHistory,
|
|
@@ -5097,23 +6099,23 @@ function WalletButtonTemplate({
|
|
|
5097
6099
|
onLogin
|
|
5098
6100
|
}) {
|
|
5099
6101
|
if (!walletAddress) {
|
|
5100
|
-
return /* @__PURE__ */ jsxs("button", { type: "button", className: "wallet-login-btn", style: { backgroundColor: accentColor }, onClick: onLogin, children: [
|
|
6102
|
+
return /* @__PURE__ */ jsxs("button", { type: "button", className: "pollar-wallet-login-btn", style: { backgroundColor: accentColor }, onClick: onLogin, children: [
|
|
5101
6103
|
/* @__PURE__ */ jsx(ButtonLogo, {}),
|
|
5102
6104
|
"Login with Pollar"
|
|
5103
6105
|
] });
|
|
5104
6106
|
}
|
|
5105
|
-
return /* @__PURE__ */ jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
|
|
6107
|
+
return /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-wrapper", ref: wrapperRef, children: [
|
|
5106
6108
|
/* @__PURE__ */ jsxs(
|
|
5107
6109
|
"button",
|
|
5108
6110
|
{
|
|
5109
|
-
className: "wallet-btn",
|
|
6111
|
+
className: "pollar-wallet-btn",
|
|
5110
6112
|
style: { backgroundColor: accentColor },
|
|
5111
6113
|
onClick: isInProgress ? void 0 : onToggleOpen,
|
|
5112
6114
|
disabled: isInProgress,
|
|
5113
6115
|
"aria-busy": isInProgress,
|
|
5114
6116
|
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: [
|
|
6117
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-wallet-btn-label", children: cropWallet(walletAddress) }),
|
|
6118
|
+
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
6119
|
/* @__PURE__ */ jsx("circle", { cx: "6", cy: "6", r: "4.5", stroke: "rgba(255,255,255,0.35)", strokeWidth: "1.5" }),
|
|
5118
6120
|
/* @__PURE__ */ jsx(
|
|
5119
6121
|
"circle",
|
|
@@ -5131,7 +6133,7 @@ function WalletButtonTemplate({
|
|
|
5131
6133
|
] }) : /* @__PURE__ */ jsx(
|
|
5132
6134
|
"svg",
|
|
5133
6135
|
{
|
|
5134
|
-
className: `wallet-chevron${open ? " open" : ""}`,
|
|
6136
|
+
className: `pollar-wallet-chevron${open ? " pollar-open" : ""}`,
|
|
5135
6137
|
viewBox: "0 0 12 12",
|
|
5136
6138
|
fill: "none",
|
|
5137
6139
|
stroke: "currentColor",
|
|
@@ -5144,8 +6146,42 @@ function WalletButtonTemplate({
|
|
|
5144
6146
|
]
|
|
5145
6147
|
}
|
|
5146
6148
|
),
|
|
5147
|
-
open && /* @__PURE__ */ jsxs("div", { className: "wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
|
|
5148
|
-
/* @__PURE__ */ jsxs(
|
|
6149
|
+
open && /* @__PURE__ */ jsxs("div", { className: "pollar-wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
|
|
6150
|
+
showCreateAccount && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6151
|
+
/* @__PURE__ */ jsxs(
|
|
6152
|
+
"button",
|
|
6153
|
+
{
|
|
6154
|
+
className: "pollar-wallet-dropdown-item",
|
|
6155
|
+
style: { color: itemColor },
|
|
6156
|
+
onClick: onCreateAccount,
|
|
6157
|
+
disabled: creatingAccount,
|
|
6158
|
+
children: [
|
|
6159
|
+
/* @__PURE__ */ jsxs(
|
|
6160
|
+
"svg",
|
|
6161
|
+
{
|
|
6162
|
+
width: "14",
|
|
6163
|
+
height: "14",
|
|
6164
|
+
viewBox: "0 0 24 24",
|
|
6165
|
+
fill: "none",
|
|
6166
|
+
stroke: "currentColor",
|
|
6167
|
+
strokeWidth: "2",
|
|
6168
|
+
strokeLinecap: "round",
|
|
6169
|
+
strokeLinejoin: "round",
|
|
6170
|
+
children: [
|
|
6171
|
+
/* @__PURE__ */ jsx("path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" }),
|
|
6172
|
+
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "7", r: "4" }),
|
|
6173
|
+
/* @__PURE__ */ jsx("line", { x1: "19", y1: "8", x2: "19", y2: "14" }),
|
|
6174
|
+
/* @__PURE__ */ jsx("line", { x1: "22", y1: "11", x2: "16", y2: "11" })
|
|
6175
|
+
]
|
|
6176
|
+
}
|
|
6177
|
+
),
|
|
6178
|
+
creatingAccount ? "Creating account\u2026" : "Create account"
|
|
6179
|
+
]
|
|
6180
|
+
}
|
|
6181
|
+
),
|
|
6182
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-wallet-dropdown-divider" })
|
|
6183
|
+
] }),
|
|
6184
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onSend, children: [
|
|
5149
6185
|
/* @__PURE__ */ jsxs(
|
|
5150
6186
|
"svg",
|
|
5151
6187
|
{
|
|
@@ -5165,7 +6201,7 @@ function WalletButtonTemplate({
|
|
|
5165
6201
|
),
|
|
5166
6202
|
"Send"
|
|
5167
6203
|
] }),
|
|
5168
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
|
|
6204
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
|
|
5169
6205
|
/* @__PURE__ */ jsxs(
|
|
5170
6206
|
"svg",
|
|
5171
6207
|
{
|
|
@@ -5186,8 +6222,8 @@ function WalletButtonTemplate({
|
|
|
5186
6222
|
),
|
|
5187
6223
|
"Receive"
|
|
5188
6224
|
] }),
|
|
5189
|
-
/* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
|
|
5190
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
|
|
6225
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-wallet-dropdown-divider" }),
|
|
6226
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
|
|
5191
6227
|
/* @__PURE__ */ jsxs(
|
|
5192
6228
|
"svg",
|
|
5193
6229
|
{
|
|
@@ -5207,7 +6243,7 @@ function WalletButtonTemplate({
|
|
|
5207
6243
|
),
|
|
5208
6244
|
copied ? "Copied!" : "Copy address"
|
|
5209
6245
|
] }),
|
|
5210
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
|
|
6246
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
|
|
5211
6247
|
/* @__PURE__ */ jsxs(
|
|
5212
6248
|
"svg",
|
|
5213
6249
|
{
|
|
@@ -5228,7 +6264,7 @@ function WalletButtonTemplate({
|
|
|
5228
6264
|
),
|
|
5229
6265
|
"Wallet balance"
|
|
5230
6266
|
] }),
|
|
5231
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
|
|
6267
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
|
|
5232
6268
|
/* @__PURE__ */ jsxs(
|
|
5233
6269
|
"svg",
|
|
5234
6270
|
{
|
|
@@ -5251,8 +6287,8 @@ function WalletButtonTemplate({
|
|
|
5251
6287
|
),
|
|
5252
6288
|
"Transaction history"
|
|
5253
6289
|
] }),
|
|
5254
|
-
/* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
|
|
5255
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onRamp, children: [
|
|
6290
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-wallet-dropdown-divider" }),
|
|
6291
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onRamp, children: [
|
|
5256
6292
|
/* @__PURE__ */ jsxs(
|
|
5257
6293
|
"svg",
|
|
5258
6294
|
{
|
|
@@ -5274,7 +6310,7 @@ function WalletButtonTemplate({
|
|
|
5274
6310
|
),
|
|
5275
6311
|
"Buy / Sell"
|
|
5276
6312
|
] }),
|
|
5277
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onKyc, children: [
|
|
6313
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onKyc, children: [
|
|
5278
6314
|
/* @__PURE__ */ jsxs(
|
|
5279
6315
|
"svg",
|
|
5280
6316
|
{
|
|
@@ -5295,7 +6331,7 @@ function WalletButtonTemplate({
|
|
|
5295
6331
|
),
|
|
5296
6332
|
"Identity verification"
|
|
5297
6333
|
] }),
|
|
5298
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onDistributionRules, children: [
|
|
6334
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onDistributionRules, children: [
|
|
5299
6335
|
/* @__PURE__ */ jsxs(
|
|
5300
6336
|
"svg",
|
|
5301
6337
|
{
|
|
@@ -5318,7 +6354,7 @@ function WalletButtonTemplate({
|
|
|
5318
6354
|
),
|
|
5319
6355
|
"Distribution rules"
|
|
5320
6356
|
] }),
|
|
5321
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSessions, children: [
|
|
6357
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item", style: { color: itemColor }, onClick: onSessions, children: [
|
|
5322
6358
|
/* @__PURE__ */ jsxs(
|
|
5323
6359
|
"svg",
|
|
5324
6360
|
{
|
|
@@ -5339,8 +6375,8 @@ function WalletButtonTemplate({
|
|
|
5339
6375
|
),
|
|
5340
6376
|
"Active sessions"
|
|
5341
6377
|
] }),
|
|
5342
|
-
/* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
|
|
5343
|
-
/* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
|
|
6378
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-wallet-dropdown-divider" }),
|
|
6379
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-wallet-dropdown-item pollar-danger", onClick: onLogout, children: [
|
|
5344
6380
|
/* @__PURE__ */ jsxs(
|
|
5345
6381
|
"svg",
|
|
5346
6382
|
{
|
|
@@ -5384,9 +6420,12 @@ function WalletButton() {
|
|
|
5384
6420
|
const walletType = wallet?.custody === "external" ? wallet.provider : null;
|
|
5385
6421
|
const [open, setOpen] = useState(false);
|
|
5386
6422
|
const [copied, setCopied] = useState(false);
|
|
6423
|
+
const [creating, setCreating] = useState(false);
|
|
6424
|
+
const [created, setCreated] = useState(false);
|
|
5387
6425
|
const wrapperRef = useRef(null);
|
|
5388
6426
|
const copyTimerRef = useRef(null);
|
|
5389
6427
|
const isInProgress = transaction.step === "building" || transaction.step === "signing";
|
|
6428
|
+
const canCreateAccount = !created && wallet?.custody === "external" && wallet.existsOnStellar === false && wallet.fundingMode === "IMMEDIATE";
|
|
5390
6429
|
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
5391
6430
|
const isDark = theme === "dark";
|
|
5392
6431
|
const dropdownBg = isDark ? "#18181b" : "#fff";
|
|
@@ -5421,6 +6460,20 @@ function WalletButton() {
|
|
|
5421
6460
|
setOpen(false);
|
|
5422
6461
|
getClient().logout();
|
|
5423
6462
|
}
|
|
6463
|
+
async function handleCreateAccount() {
|
|
6464
|
+
if (creating) return;
|
|
6465
|
+
setCreating(true);
|
|
6466
|
+
try {
|
|
6467
|
+
const res = await getClient().createAccount();
|
|
6468
|
+
if (res.status === "success" || res.status === "pending") {
|
|
6469
|
+
setCreated(true);
|
|
6470
|
+
setOpen(false);
|
|
6471
|
+
await getClient().refreshBalance();
|
|
6472
|
+
}
|
|
6473
|
+
} finally {
|
|
6474
|
+
setCreating(false);
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
5424
6477
|
function handleWalletBalance() {
|
|
5425
6478
|
setOpen(false);
|
|
5426
6479
|
openWalletBalanceModal();
|
|
@@ -5466,7 +6519,10 @@ function WalletButton() {
|
|
|
5466
6519
|
wrapperRef,
|
|
5467
6520
|
isInProgress,
|
|
5468
6521
|
walletType,
|
|
6522
|
+
showCreateAccount: canCreateAccount,
|
|
6523
|
+
creatingAccount: creating,
|
|
5469
6524
|
onToggleOpen: () => setOpen((v) => !v),
|
|
6525
|
+
onCreateAccount: handleCreateAccount,
|
|
5470
6526
|
onCopy: handleCopy,
|
|
5471
6527
|
onWalletBalance: handleWalletBalance,
|
|
5472
6528
|
onTxHistory: handleTxHistory,
|
|
@@ -5482,6 +6538,6 @@ function WalletButton() {
|
|
|
5482
6538
|
);
|
|
5483
6539
|
}
|
|
5484
6540
|
|
|
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 };
|
|
6541
|
+
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
6542
|
//# sourceMappingURL=index.mjs.map
|
|
5487
6543
|
//# sourceMappingURL=index.mjs.map
|