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