@pollar/react 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +150 -59
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +395 -163
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +395 -165
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { AUTH_ERROR_CODES, WalletType, PollarClient } from '@pollar/core';
|
|
3
|
-
import { forwardRef, createContext, useState, useEffect, useRef,
|
|
3
|
+
import { forwardRef, createContext, useState, useCallback, useEffect, useRef, useMemo, useContext, Component } from 'react';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
var __create = Object.create;
|
|
@@ -1028,7 +1028,7 @@ var PollarModalFooter = () => {
|
|
|
1028
1028
|
/* @__PURE__ */ jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
|
|
1029
1029
|
/* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
|
|
1030
1030
|
"v",
|
|
1031
|
-
"0.7.
|
|
1031
|
+
"0.7.1"
|
|
1032
1032
|
] })
|
|
1033
1033
|
] })
|
|
1034
1034
|
] });
|
|
@@ -1052,6 +1052,221 @@ function ModalStatusBanner({ message, status, onCancel, onRetry }) {
|
|
|
1052
1052
|
status === "ERROR" && onRetry && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-status-cancel", onClick: onRetry, children: "Retry" })
|
|
1053
1053
|
] });
|
|
1054
1054
|
}
|
|
1055
|
+
var PERIOD_LABEL = {
|
|
1056
|
+
DAY: "every 24h",
|
|
1057
|
+
DAY_CALENDAR: "daily",
|
|
1058
|
+
WEEK: "every 7 days",
|
|
1059
|
+
MONTH: "every 30 days",
|
|
1060
|
+
MONTH_CALENDAR: "monthly",
|
|
1061
|
+
LIFETIME: "one-time"
|
|
1062
|
+
};
|
|
1063
|
+
var REASON_LABEL = {
|
|
1064
|
+
DISTRIBUTION_RULE_DISABLED: "Disabled",
|
|
1065
|
+
DISTRIBUTION_RULE_NOT_STARTED: "Not started yet",
|
|
1066
|
+
DISTRIBUTION_RULE_EXPIRED: "Expired",
|
|
1067
|
+
DISTRIBUTION_RULE_EXHAUSTED: "Fully claimed",
|
|
1068
|
+
DISTRIBUTION_RATE_LIMIT_EXCEEDED: "Already claimed"
|
|
1069
|
+
};
|
|
1070
|
+
function reasonLabel(reason) {
|
|
1071
|
+
if (!reason) return "Not available";
|
|
1072
|
+
return REASON_LABEL[reason] ?? "Not available";
|
|
1073
|
+
}
|
|
1074
|
+
function formatAmount(amount) {
|
|
1075
|
+
const n = parseFloat(amount);
|
|
1076
|
+
return isNaN(n) ? amount : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
|
|
1077
|
+
}
|
|
1078
|
+
function formatValidity(rule) {
|
|
1079
|
+
const from = rule.validFrom ? new Date(rule.validFrom) : null;
|
|
1080
|
+
const until = rule.validUntil ? new Date(rule.validUntil) : null;
|
|
1081
|
+
if (!from && !until) return null;
|
|
1082
|
+
const fmt = (d) => d.toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
|
|
1083
|
+
if (from && until) return `${fmt(from)} \u2192 ${fmt(until)}`;
|
|
1084
|
+
if (until) return `Until ${fmt(until)}`;
|
|
1085
|
+
if (from) return `From ${fmt(from)}`;
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
function RuleCard({
|
|
1089
|
+
rule,
|
|
1090
|
+
isClaiming,
|
|
1091
|
+
isClaimed,
|
|
1092
|
+
errorMessage,
|
|
1093
|
+
onClaim
|
|
1094
|
+
}) {
|
|
1095
|
+
const validity = formatValidity(rule);
|
|
1096
|
+
const effectivelyClaimable = rule.claimable && !isClaimed;
|
|
1097
|
+
return /* @__PURE__ */ jsxs("div", { className: "pollar-dist-item", "data-claimable": effectivelyClaimable ? "true" : "false", children: [
|
|
1098
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-dist-item-row", children: [
|
|
1099
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-dist-item-name", children: rule.name }),
|
|
1100
|
+
/* @__PURE__ */ jsxs("span", { className: "pollar-dist-item-amount", children: [
|
|
1101
|
+
formatAmount(rule.amount),
|
|
1102
|
+
" ",
|
|
1103
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-dist-item-asset", children: rule.assetCode })
|
|
1104
|
+
] })
|
|
1105
|
+
] }),
|
|
1106
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-dist-item-meta", children: [
|
|
1107
|
+
/* @__PURE__ */ jsx("span", { children: PERIOD_LABEL[rule.period] }),
|
|
1108
|
+
validity && /* @__PURE__ */ jsxs("span", { children: [
|
|
1109
|
+
"\xB7 ",
|
|
1110
|
+
validity
|
|
1111
|
+
] })
|
|
1112
|
+
] }),
|
|
1113
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-dist-item-action", children: isClaimed ? /* @__PURE__ */ jsx("span", { className: "pollar-dist-item-status", "data-kind": "claimed", children: "Claimed" }) : effectivelyClaimable ? /* @__PURE__ */ jsx(
|
|
1114
|
+
"button",
|
|
1115
|
+
{
|
|
1116
|
+
type: "button",
|
|
1117
|
+
className: "pollar-btn-primary pollar-dist-claim-btn",
|
|
1118
|
+
onClick: onClaim,
|
|
1119
|
+
disabled: isClaiming,
|
|
1120
|
+
children: isClaiming ? "Claiming\u2026" : "Claim"
|
|
1121
|
+
}
|
|
1122
|
+
) : /* @__PURE__ */ jsx("span", { className: "pollar-dist-item-status", "data-kind": "unavailable", children: reasonLabel(rule.reason) }) }),
|
|
1123
|
+
errorMessage && /* @__PURE__ */ jsx("div", { className: "pollar-dist-item-error", children: errorMessage })
|
|
1124
|
+
] });
|
|
1125
|
+
}
|
|
1126
|
+
function DistributionRulesModalTemplate({
|
|
1127
|
+
theme,
|
|
1128
|
+
accentColor,
|
|
1129
|
+
state,
|
|
1130
|
+
claimingId,
|
|
1131
|
+
claimErrors,
|
|
1132
|
+
claimedIds,
|
|
1133
|
+
onRefresh,
|
|
1134
|
+
onClaim,
|
|
1135
|
+
onClose
|
|
1136
|
+
}) {
|
|
1137
|
+
const isDark = theme === "dark";
|
|
1138
|
+
const cssVars = {
|
|
1139
|
+
"--pollar-accent": accentColor,
|
|
1140
|
+
"--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
|
|
1141
|
+
"--pollar-border": isDark ? "#374151" : "#e5e7eb",
|
|
1142
|
+
"--pollar-text": isDark ? "#ffffff" : "#111827",
|
|
1143
|
+
"--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
|
|
1144
|
+
"--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
|
|
1145
|
+
"--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
|
|
1146
|
+
"--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
|
|
1147
|
+
"--pollar-error-text": isDark ? "#f87171" : "#dc2626",
|
|
1148
|
+
"--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
|
|
1149
|
+
"--pollar-buttons-border-radius": "6px",
|
|
1150
|
+
"--pollar-buttons-height": "44px",
|
|
1151
|
+
"--pollar-input-height": "44px",
|
|
1152
|
+
"--pollar-input-border-radius": "0.5rem",
|
|
1153
|
+
"--pollar-card-border-radius": "10px"
|
|
1154
|
+
};
|
|
1155
|
+
const isLoading = state.step === "loading";
|
|
1156
|
+
const rules = state.step === "loaded" ? state.rules : [];
|
|
1157
|
+
return /* @__PURE__ */ jsxs(
|
|
1158
|
+
"div",
|
|
1159
|
+
{
|
|
1160
|
+
className: "pollar-modal-card pollar-dist-modal",
|
|
1161
|
+
"data-theme": theme,
|
|
1162
|
+
style: cssVars,
|
|
1163
|
+
onClick: (e) => e.stopPropagation(),
|
|
1164
|
+
children: [
|
|
1165
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
1166
|
+
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Distribution Rules" }),
|
|
1167
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
|
|
1168
|
+
/* @__PURE__ */ jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
|
|
1169
|
+
/* @__PURE__ */ jsxs(
|
|
1170
|
+
"svg",
|
|
1171
|
+
{
|
|
1172
|
+
className: `pollar-modal-refresh-icon${isLoading ? " spinning" : ""}`,
|
|
1173
|
+
width: "13",
|
|
1174
|
+
height: "13",
|
|
1175
|
+
viewBox: "0 0 13 13",
|
|
1176
|
+
fill: "none",
|
|
1177
|
+
"aria-hidden": true,
|
|
1178
|
+
children: [
|
|
1179
|
+
/* @__PURE__ */ jsx("path", { d: "M11.5 6.5a5 5 0 11-1.5-3.536", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
|
|
1180
|
+
/* @__PURE__ */ jsx("path", { d: "M10 1v3h-3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
1181
|
+
]
|
|
1182
|
+
}
|
|
1183
|
+
),
|
|
1184
|
+
"Refresh"
|
|
1185
|
+
] }),
|
|
1186
|
+
/* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
|
|
1187
|
+
] })
|
|
1188
|
+
] }),
|
|
1189
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-dist-list", children: [
|
|
1190
|
+
isLoading && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
|
|
1191
|
+
state.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: state.message }),
|
|
1192
|
+
state.step === "loaded" && rules.length === 0 && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No distribution rules available." }),
|
|
1193
|
+
rules.map((rule) => /* @__PURE__ */ jsx(
|
|
1194
|
+
RuleCard,
|
|
1195
|
+
{
|
|
1196
|
+
rule,
|
|
1197
|
+
isClaiming: claimingId === rule.id,
|
|
1198
|
+
isClaimed: claimedIds.has(rule.id),
|
|
1199
|
+
...claimErrors[rule.id] && { errorMessage: claimErrors[rule.id] },
|
|
1200
|
+
onClaim: () => onClaim(rule)
|
|
1201
|
+
},
|
|
1202
|
+
rule.id
|
|
1203
|
+
))
|
|
1204
|
+
] }),
|
|
1205
|
+
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
1206
|
+
]
|
|
1207
|
+
}
|
|
1208
|
+
);
|
|
1209
|
+
}
|
|
1210
|
+
function DistributionRulesModal({ onClose }) {
|
|
1211
|
+
const { getClient, styles } = usePollar();
|
|
1212
|
+
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
1213
|
+
const [state, setState] = useState({ step: "idle" });
|
|
1214
|
+
const [claimingId, setClaimingId] = useState(null);
|
|
1215
|
+
const [claimErrors, setClaimErrors] = useState({});
|
|
1216
|
+
const [claimedIds, setClaimedIds] = useState(() => /* @__PURE__ */ new Set());
|
|
1217
|
+
const load = useCallback(async () => {
|
|
1218
|
+
setState({ step: "loading" });
|
|
1219
|
+
try {
|
|
1220
|
+
const rules = await getClient().listDistributionRules();
|
|
1221
|
+
setState({ step: "loaded", rules });
|
|
1222
|
+
} catch (err) {
|
|
1223
|
+
const message = err instanceof Error ? err.message : "Failed to load distribution rules";
|
|
1224
|
+
setState({ step: "error", message });
|
|
1225
|
+
}
|
|
1226
|
+
}, [getClient]);
|
|
1227
|
+
useEffect(() => {
|
|
1228
|
+
void load();
|
|
1229
|
+
}, [load]);
|
|
1230
|
+
const handleClaim = useCallback(
|
|
1231
|
+
async (rule) => {
|
|
1232
|
+
setClaimingId(rule.id);
|
|
1233
|
+
setClaimErrors((prev) => {
|
|
1234
|
+
if (!prev[rule.id]) return prev;
|
|
1235
|
+
const next = { ...prev };
|
|
1236
|
+
delete next[rule.id];
|
|
1237
|
+
return next;
|
|
1238
|
+
});
|
|
1239
|
+
try {
|
|
1240
|
+
await getClient().claimDistributionRule({ ruleId: rule.id });
|
|
1241
|
+
setClaimedIds((prev) => {
|
|
1242
|
+
const next = new Set(prev);
|
|
1243
|
+
next.add(rule.id);
|
|
1244
|
+
return next;
|
|
1245
|
+
});
|
|
1246
|
+
} catch (err) {
|
|
1247
|
+
const message = err instanceof Error ? err.message : "Claim failed";
|
|
1248
|
+
setClaimErrors((prev) => ({ ...prev, [rule.id]: message }));
|
|
1249
|
+
} finally {
|
|
1250
|
+
setClaimingId(null);
|
|
1251
|
+
}
|
|
1252
|
+
},
|
|
1253
|
+
[getClient]
|
|
1254
|
+
);
|
|
1255
|
+
return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
|
|
1256
|
+
DistributionRulesModalTemplate,
|
|
1257
|
+
{
|
|
1258
|
+
theme,
|
|
1259
|
+
accentColor,
|
|
1260
|
+
state,
|
|
1261
|
+
claimingId,
|
|
1262
|
+
claimErrors,
|
|
1263
|
+
claimedIds,
|
|
1264
|
+
onRefresh: () => void load(),
|
|
1265
|
+
onClaim: handleClaim,
|
|
1266
|
+
onClose
|
|
1267
|
+
}
|
|
1268
|
+
) });
|
|
1269
|
+
}
|
|
1055
1270
|
var STATUS_CONFIG = {
|
|
1056
1271
|
none: { label: "Not started", color: "#6b7280", dot: false },
|
|
1057
1272
|
pending: { label: "Pending review", color: "#f59e0b", dot: true },
|
|
@@ -1575,166 +1790,6 @@ function LoginModal({ onClose }) {
|
|
|
1575
1790
|
}
|
|
1576
1791
|
) });
|
|
1577
1792
|
}
|
|
1578
|
-
|
|
1579
|
-
// src/lib/qr-code/index.tsx
|
|
1580
|
-
var import_ErrorCorrectLevel = __toESM(require_ErrorCorrectLevel());
|
|
1581
|
-
var import_QRCode = __toESM(require_QRCode());
|
|
1582
|
-
var QRCodeSvg = forwardRef(function QRCodeSvg2({
|
|
1583
|
-
bgColor,
|
|
1584
|
-
bgD,
|
|
1585
|
-
fgD,
|
|
1586
|
-
fgColor,
|
|
1587
|
-
size,
|
|
1588
|
-
title,
|
|
1589
|
-
viewBoxSize,
|
|
1590
|
-
xmlns = "http://www.w3.org/2000/svg",
|
|
1591
|
-
...props
|
|
1592
|
-
}, ref) {
|
|
1593
|
-
return /* @__PURE__ */ jsxs("svg", { ...props, height: size, ref, viewBox: `0 0 ${viewBoxSize} ${viewBoxSize}`, width: size, xmlns, children: [
|
|
1594
|
-
title ? /* @__PURE__ */ jsx("title", { children: title }) : null,
|
|
1595
|
-
/* @__PURE__ */ jsx("path", { d: bgD, fill: bgColor }),
|
|
1596
|
-
/* @__PURE__ */ jsx("path", { d: fgD, fill: fgColor })
|
|
1597
|
-
] });
|
|
1598
|
-
});
|
|
1599
|
-
QRCodeSvg.displayName = "QRCodeSvg";
|
|
1600
|
-
function bytesToBinaryString(bytes) {
|
|
1601
|
-
return bytes.map((b) => String.fromCharCode(b & 255)).join("");
|
|
1602
|
-
}
|
|
1603
|
-
function encodeStringToUtf8Bytes(input) {
|
|
1604
|
-
return Array.from(new TextEncoder().encode(input));
|
|
1605
|
-
}
|
|
1606
|
-
var QRCode = forwardRef(function QRCode2({ bgColor = "#FFFFFF", fgColor = "#000000", level = "L", size = 256, value, ...props }, ref) {
|
|
1607
|
-
const qrcode = new import_QRCode.default(-1, import_ErrorCorrectLevel.default[level]);
|
|
1608
|
-
const utf8Bytes = encodeStringToUtf8Bytes(value);
|
|
1609
|
-
const binaryString = bytesToBinaryString(utf8Bytes);
|
|
1610
|
-
qrcode.addData(binaryString, "Byte");
|
|
1611
|
-
qrcode.make();
|
|
1612
|
-
const cells = qrcode.modules;
|
|
1613
|
-
return /* @__PURE__ */ jsx(
|
|
1614
|
-
QRCodeSvg,
|
|
1615
|
-
{
|
|
1616
|
-
...props,
|
|
1617
|
-
bgColor,
|
|
1618
|
-
bgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => !cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
|
|
1619
|
-
fgColor,
|
|
1620
|
-
fgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
|
|
1621
|
-
ref,
|
|
1622
|
-
size,
|
|
1623
|
-
viewBoxSize: cells.length
|
|
1624
|
-
}
|
|
1625
|
-
);
|
|
1626
|
-
});
|
|
1627
|
-
function ReceiveModalTemplate({
|
|
1628
|
-
theme,
|
|
1629
|
-
accentColor,
|
|
1630
|
-
walletAddress,
|
|
1631
|
-
copied,
|
|
1632
|
-
onCopy,
|
|
1633
|
-
onClose
|
|
1634
|
-
}) {
|
|
1635
|
-
const isDark = theme === "dark";
|
|
1636
|
-
const cssVars = {
|
|
1637
|
-
"--pollar-accent": accentColor,
|
|
1638
|
-
"--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
|
|
1639
|
-
"--pollar-border": isDark ? "#374151" : "#e5e7eb",
|
|
1640
|
-
"--pollar-text": isDark ? "#ffffff" : "#111827",
|
|
1641
|
-
"--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
|
|
1642
|
-
"--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
|
|
1643
|
-
"--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
|
|
1644
|
-
"--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
|
|
1645
|
-
"--pollar-error-text": isDark ? "#f87171" : "#dc2626",
|
|
1646
|
-
"--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
|
|
1647
|
-
"--pollar-buttons-border-radius": "6px",
|
|
1648
|
-
"--pollar-buttons-height": "44px",
|
|
1649
|
-
"--pollar-input-height": "44px",
|
|
1650
|
-
"--pollar-input-border-radius": "0.5rem",
|
|
1651
|
-
"--pollar-card-border-radius": "10px"
|
|
1652
|
-
};
|
|
1653
|
-
return /* @__PURE__ */ jsxs(
|
|
1654
|
-
"div",
|
|
1655
|
-
{
|
|
1656
|
-
className: "pollar-modal-card pollar-receive-modal",
|
|
1657
|
-
"data-theme": theme,
|
|
1658
|
-
style: cssVars,
|
|
1659
|
-
onClick: (e) => e.stopPropagation(),
|
|
1660
|
-
children: [
|
|
1661
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
1662
|
-
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Receive" }),
|
|
1663
|
-
/* @__PURE__ */ jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
|
|
1664
|
-
] }),
|
|
1665
|
-
walletAddress ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1666
|
-
/* @__PURE__ */ jsx("div", { className: "pollar-receive-qr", children: /* @__PURE__ */ jsx(
|
|
1667
|
-
QRCode,
|
|
1668
|
-
{
|
|
1669
|
-
value: walletAddress,
|
|
1670
|
-
size: 180,
|
|
1671
|
-
fgColor: isDark ? "#ffffff" : "#111827",
|
|
1672
|
-
bgColor: "transparent"
|
|
1673
|
-
}
|
|
1674
|
-
) }),
|
|
1675
|
-
/* @__PURE__ */ jsx("p", { className: "pollar-receive-instructions", children: "Share your Stellar address to receive any asset. Only send Stellar assets to this address." }),
|
|
1676
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-receive-address-row", children: [
|
|
1677
|
-
/* @__PURE__ */ jsx("span", { className: "pollar-receive-address", children: walletAddress }),
|
|
1678
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-receive-copy-btn", onClick: onCopy, "aria-label": "Copy address", children: copied ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1679
|
-
/* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
|
|
1680
|
-
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
|
|
1681
|
-
/* @__PURE__ */ jsx(
|
|
1682
|
-
"path",
|
|
1683
|
-
{
|
|
1684
|
-
d: "M3.5 7l2.5 2.5 4.5-5",
|
|
1685
|
-
stroke: "white",
|
|
1686
|
-
strokeWidth: "1.5",
|
|
1687
|
-
strokeLinecap: "round",
|
|
1688
|
-
strokeLinejoin: "round"
|
|
1689
|
-
}
|
|
1690
|
-
)
|
|
1691
|
-
] }),
|
|
1692
|
-
"Copied!"
|
|
1693
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1694
|
-
/* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
1695
|
-
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
1696
|
-
/* @__PURE__ */ jsx(
|
|
1697
|
-
"path",
|
|
1698
|
-
{
|
|
1699
|
-
d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
|
|
1700
|
-
stroke: "currentColor",
|
|
1701
|
-
strokeWidth: "1.5",
|
|
1702
|
-
strokeLinecap: "round"
|
|
1703
|
-
}
|
|
1704
|
-
)
|
|
1705
|
-
] }),
|
|
1706
|
-
"Copy address"
|
|
1707
|
-
] }) })
|
|
1708
|
-
] })
|
|
1709
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No wallet connected." }),
|
|
1710
|
-
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
1711
|
-
]
|
|
1712
|
-
}
|
|
1713
|
-
);
|
|
1714
|
-
}
|
|
1715
|
-
function ReceiveModal({ onClose }) {
|
|
1716
|
-
const { walletAddress, styles } = usePollar();
|
|
1717
|
-
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
1718
|
-
const [copied, setCopied] = useState(false);
|
|
1719
|
-
function handleCopy() {
|
|
1720
|
-
if (!walletAddress) return;
|
|
1721
|
-
navigator.clipboard.writeText(walletAddress).then(() => {
|
|
1722
|
-
setCopied(true);
|
|
1723
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
1724
|
-
});
|
|
1725
|
-
}
|
|
1726
|
-
return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
|
|
1727
|
-
ReceiveModalTemplate,
|
|
1728
|
-
{
|
|
1729
|
-
theme,
|
|
1730
|
-
accentColor,
|
|
1731
|
-
walletAddress,
|
|
1732
|
-
copied,
|
|
1733
|
-
onCopy: handleCopy,
|
|
1734
|
-
onClose
|
|
1735
|
-
}
|
|
1736
|
-
) });
|
|
1737
|
-
}
|
|
1738
1793
|
var RAIL_LABELS = {
|
|
1739
1794
|
SPEI: "SPEI (Mexico)",
|
|
1740
1795
|
PIX: "PIX (Brazil)",
|
|
@@ -2049,6 +2104,166 @@ function RampWidget({ onClose }) {
|
|
|
2049
2104
|
}
|
|
2050
2105
|
) });
|
|
2051
2106
|
}
|
|
2107
|
+
|
|
2108
|
+
// src/lib/qr-code/index.tsx
|
|
2109
|
+
var import_ErrorCorrectLevel = __toESM(require_ErrorCorrectLevel());
|
|
2110
|
+
var import_QRCode = __toESM(require_QRCode());
|
|
2111
|
+
var QRCodeSvg = forwardRef(function QRCodeSvg2({
|
|
2112
|
+
bgColor,
|
|
2113
|
+
bgD,
|
|
2114
|
+
fgD,
|
|
2115
|
+
fgColor,
|
|
2116
|
+
size,
|
|
2117
|
+
title,
|
|
2118
|
+
viewBoxSize,
|
|
2119
|
+
xmlns = "http://www.w3.org/2000/svg",
|
|
2120
|
+
...props
|
|
2121
|
+
}, ref) {
|
|
2122
|
+
return /* @__PURE__ */ jsxs("svg", { ...props, height: size, ref, viewBox: `0 0 ${viewBoxSize} ${viewBoxSize}`, width: size, xmlns, children: [
|
|
2123
|
+
title ? /* @__PURE__ */ jsx("title", { children: title }) : null,
|
|
2124
|
+
/* @__PURE__ */ jsx("path", { d: bgD, fill: bgColor }),
|
|
2125
|
+
/* @__PURE__ */ jsx("path", { d: fgD, fill: fgColor })
|
|
2126
|
+
] });
|
|
2127
|
+
});
|
|
2128
|
+
QRCodeSvg.displayName = "QRCodeSvg";
|
|
2129
|
+
function bytesToBinaryString(bytes) {
|
|
2130
|
+
return bytes.map((b) => String.fromCharCode(b & 255)).join("");
|
|
2131
|
+
}
|
|
2132
|
+
function encodeStringToUtf8Bytes(input) {
|
|
2133
|
+
return Array.from(new TextEncoder().encode(input));
|
|
2134
|
+
}
|
|
2135
|
+
var QRCode = forwardRef(function QRCode2({ bgColor = "#FFFFFF", fgColor = "#000000", level = "L", size = 256, value, ...props }, ref) {
|
|
2136
|
+
const qrcode = new import_QRCode.default(-1, import_ErrorCorrectLevel.default[level]);
|
|
2137
|
+
const utf8Bytes = encodeStringToUtf8Bytes(value);
|
|
2138
|
+
const binaryString = bytesToBinaryString(utf8Bytes);
|
|
2139
|
+
qrcode.addData(binaryString, "Byte");
|
|
2140
|
+
qrcode.make();
|
|
2141
|
+
const cells = qrcode.modules;
|
|
2142
|
+
return /* @__PURE__ */ jsx(
|
|
2143
|
+
QRCodeSvg,
|
|
2144
|
+
{
|
|
2145
|
+
...props,
|
|
2146
|
+
bgColor,
|
|
2147
|
+
bgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => !cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
|
|
2148
|
+
fgColor,
|
|
2149
|
+
fgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
|
|
2150
|
+
ref,
|
|
2151
|
+
size,
|
|
2152
|
+
viewBoxSize: cells.length
|
|
2153
|
+
}
|
|
2154
|
+
);
|
|
2155
|
+
});
|
|
2156
|
+
function ReceiveModalTemplate({
|
|
2157
|
+
theme,
|
|
2158
|
+
accentColor,
|
|
2159
|
+
walletAddress,
|
|
2160
|
+
copied,
|
|
2161
|
+
onCopy,
|
|
2162
|
+
onClose
|
|
2163
|
+
}) {
|
|
2164
|
+
const isDark = theme === "dark";
|
|
2165
|
+
const cssVars = {
|
|
2166
|
+
"--pollar-accent": accentColor,
|
|
2167
|
+
"--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
|
|
2168
|
+
"--pollar-border": isDark ? "#374151" : "#e5e7eb",
|
|
2169
|
+
"--pollar-text": isDark ? "#ffffff" : "#111827",
|
|
2170
|
+
"--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
|
|
2171
|
+
"--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
|
|
2172
|
+
"--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
|
|
2173
|
+
"--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
|
|
2174
|
+
"--pollar-error-text": isDark ? "#f87171" : "#dc2626",
|
|
2175
|
+
"--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
|
|
2176
|
+
"--pollar-buttons-border-radius": "6px",
|
|
2177
|
+
"--pollar-buttons-height": "44px",
|
|
2178
|
+
"--pollar-input-height": "44px",
|
|
2179
|
+
"--pollar-input-border-radius": "0.5rem",
|
|
2180
|
+
"--pollar-card-border-radius": "10px"
|
|
2181
|
+
};
|
|
2182
|
+
return /* @__PURE__ */ jsxs(
|
|
2183
|
+
"div",
|
|
2184
|
+
{
|
|
2185
|
+
className: "pollar-modal-card pollar-receive-modal",
|
|
2186
|
+
"data-theme": theme,
|
|
2187
|
+
style: cssVars,
|
|
2188
|
+
onClick: (e) => e.stopPropagation(),
|
|
2189
|
+
children: [
|
|
2190
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
|
|
2191
|
+
/* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Receive" }),
|
|
2192
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
|
|
2193
|
+
] }),
|
|
2194
|
+
walletAddress ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2195
|
+
/* @__PURE__ */ jsx("div", { className: "pollar-receive-qr", children: /* @__PURE__ */ jsx(
|
|
2196
|
+
QRCode,
|
|
2197
|
+
{
|
|
2198
|
+
value: walletAddress,
|
|
2199
|
+
size: 180,
|
|
2200
|
+
fgColor: isDark ? "#ffffff" : "#111827",
|
|
2201
|
+
bgColor: "transparent"
|
|
2202
|
+
}
|
|
2203
|
+
) }),
|
|
2204
|
+
/* @__PURE__ */ jsx("p", { className: "pollar-receive-instructions", children: "Share your Stellar address to receive any asset. Only send Stellar assets to this address." }),
|
|
2205
|
+
/* @__PURE__ */ jsxs("div", { className: "pollar-receive-address-row", children: [
|
|
2206
|
+
/* @__PURE__ */ jsx("span", { className: "pollar-receive-address", children: walletAddress }),
|
|
2207
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-receive-copy-btn", onClick: onCopy, "aria-label": "Copy address", children: copied ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2208
|
+
/* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
|
|
2209
|
+
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
|
|
2210
|
+
/* @__PURE__ */ jsx(
|
|
2211
|
+
"path",
|
|
2212
|
+
{
|
|
2213
|
+
d: "M3.5 7l2.5 2.5 4.5-5",
|
|
2214
|
+
stroke: "white",
|
|
2215
|
+
strokeWidth: "1.5",
|
|
2216
|
+
strokeLinecap: "round",
|
|
2217
|
+
strokeLinejoin: "round"
|
|
2218
|
+
}
|
|
2219
|
+
)
|
|
2220
|
+
] }),
|
|
2221
|
+
"Copied!"
|
|
2222
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2223
|
+
/* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
|
|
2224
|
+
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
2225
|
+
/* @__PURE__ */ jsx(
|
|
2226
|
+
"path",
|
|
2227
|
+
{
|
|
2228
|
+
d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
|
|
2229
|
+
stroke: "currentColor",
|
|
2230
|
+
strokeWidth: "1.5",
|
|
2231
|
+
strokeLinecap: "round"
|
|
2232
|
+
}
|
|
2233
|
+
)
|
|
2234
|
+
] }),
|
|
2235
|
+
"Copy address"
|
|
2236
|
+
] }) })
|
|
2237
|
+
] })
|
|
2238
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No wallet connected." }),
|
|
2239
|
+
/* @__PURE__ */ jsx(PollarModalFooter, {})
|
|
2240
|
+
]
|
|
2241
|
+
}
|
|
2242
|
+
);
|
|
2243
|
+
}
|
|
2244
|
+
function ReceiveModal({ onClose }) {
|
|
2245
|
+
const { walletAddress, styles } = usePollar();
|
|
2246
|
+
const { theme = "light", accentColor = "#005DB4" } = styles;
|
|
2247
|
+
const [copied, setCopied] = useState(false);
|
|
2248
|
+
function handleCopy() {
|
|
2249
|
+
if (!walletAddress) return;
|
|
2250
|
+
navigator.clipboard.writeText(walletAddress).then(() => {
|
|
2251
|
+
setCopied(true);
|
|
2252
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
2253
|
+
});
|
|
2254
|
+
}
|
|
2255
|
+
return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
|
|
2256
|
+
ReceiveModalTemplate,
|
|
2257
|
+
{
|
|
2258
|
+
theme,
|
|
2259
|
+
accentColor,
|
|
2260
|
+
walletAddress,
|
|
2261
|
+
copied,
|
|
2262
|
+
onCopy: handleCopy,
|
|
2263
|
+
onClose
|
|
2264
|
+
}
|
|
2265
|
+
) });
|
|
2266
|
+
}
|
|
2052
2267
|
var STATUS_MESSAGES = {
|
|
2053
2268
|
idle: "",
|
|
2054
2269
|
building: "Building transaction\u2026",
|
|
@@ -3189,6 +3404,7 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
|
|
|
3189
3404
|
const [sendModalOpen, setSendModalOpen] = useState(false);
|
|
3190
3405
|
const [receiveModalOpen, setReceiveModalOpen] = useState(false);
|
|
3191
3406
|
const [sessionsModalOpen, setSessionsModalOpen] = useState(false);
|
|
3407
|
+
const [distributionRulesModalOpen, setDistributionRulesModalOpen] = useState(false);
|
|
3192
3408
|
const adaptersRef = useRef(adapters);
|
|
3193
3409
|
adaptersRef.current = adapters;
|
|
3194
3410
|
const walletAddress = sessionState?.wallet?.publicKey || "";
|
|
@@ -3223,6 +3439,8 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
|
|
|
3223
3439
|
openReceiveModal: () => setReceiveModalOpen(true),
|
|
3224
3440
|
// sessions
|
|
3225
3441
|
openSessionsModal: () => setSessionsModalOpen(true),
|
|
3442
|
+
// distribution
|
|
3443
|
+
openDistributionRulesModal: () => setDistributionRulesModalOpen(true),
|
|
3226
3444
|
// network
|
|
3227
3445
|
network: networkState.step === "connected" ? networkState.network : "testnet",
|
|
3228
3446
|
setNetwork: (network) => pollarClient.setNetwork(network),
|
|
@@ -3238,7 +3456,18 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
|
|
|
3238
3456
|
styles,
|
|
3239
3457
|
adapters: adaptersRef.current
|
|
3240
3458
|
}),
|
|
3241
|
-
[
|
|
3459
|
+
[
|
|
3460
|
+
walletAddress,
|
|
3461
|
+
pollarClient,
|
|
3462
|
+
getClient,
|
|
3463
|
+
transaction,
|
|
3464
|
+
txHistory,
|
|
3465
|
+
walletBalance,
|
|
3466
|
+
refreshWalletBalance,
|
|
3467
|
+
networkState,
|
|
3468
|
+
remoteConfig,
|
|
3469
|
+
styles
|
|
3470
|
+
]
|
|
3242
3471
|
);
|
|
3243
3472
|
return /* @__PURE__ */ jsxs(PollarContext.Provider, { value: contextValue, children: [
|
|
3244
3473
|
children,
|
|
@@ -3258,7 +3487,8 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
|
|
|
3258
3487
|
walletBalanceModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
|
|
3259
3488
|
sendModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
|
|
3260
3489
|
receiveModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) }),
|
|
3261
|
-
sessionsModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) })
|
|
3490
|
+
sessionsModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) }),
|
|
3491
|
+
distributionRulesModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setDistributionRulesModalOpen(false), children: /* @__PURE__ */ jsx(DistributionRulesModal, { onClose: () => setDistributionRulesModalOpen(false) }) })
|
|
3262
3492
|
] });
|
|
3263
3493
|
}
|
|
3264
3494
|
function usePollar() {
|
|
@@ -3509,6 +3739,6 @@ function WalletButton() {
|
|
|
3509
3739
|
);
|
|
3510
3740
|
}
|
|
3511
3741
|
|
|
3512
|
-
export { KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, createPollarAdapterHook, usePollar };
|
|
3742
|
+
export { DistributionRulesModal, DistributionRulesModalTemplate, KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, createPollarAdapterHook, usePollar };
|
|
3513
3743
|
//# sourceMappingURL=index.mjs.map
|
|
3514
3744
|
//# sourceMappingURL=index.mjs.map
|