@swype-org/react-sdk 0.1.21 → 0.1.22
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.cjs +411 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +413 -332
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -583,24 +583,39 @@ function resolveRootDomainFromHostname(hostname) {
|
|
|
583
583
|
}
|
|
584
584
|
return parts.slice(-2).join(".");
|
|
585
585
|
}
|
|
586
|
-
|
|
587
|
-
// src/signature.ts
|
|
586
|
+
var ERC_6492_MAGIC_SUFFIX = "6492649264926492649264926492649264926492649264926492649264926492";
|
|
588
587
|
function normalizeSignature(sig) {
|
|
589
|
-
const
|
|
590
|
-
if (
|
|
591
|
-
return `0x${
|
|
588
|
+
const hex = sig.startsWith("0x") ? sig.slice(2) : sig;
|
|
589
|
+
if (hex.length === 130) {
|
|
590
|
+
return `0x${hex}`;
|
|
592
591
|
}
|
|
593
|
-
if (
|
|
594
|
-
const r =
|
|
595
|
-
const yParityAndS =
|
|
592
|
+
if (hex.length === 128) {
|
|
593
|
+
const r = hex.slice(0, 64);
|
|
594
|
+
const yParityAndS = hex.slice(64, 128);
|
|
596
595
|
const highByte = parseInt(yParityAndS.slice(0, 2), 16);
|
|
597
596
|
const v = (highByte & 128) !== 0 ? 28 : 27;
|
|
598
597
|
const sFirstByte = (highByte & 127).toString(16).padStart(2, "0");
|
|
599
598
|
const s = sFirstByte + yParityAndS.slice(2);
|
|
600
599
|
return `0x${r}${s}${v.toString(16)}`;
|
|
601
600
|
}
|
|
601
|
+
if (hex.length > 64 && hex.endsWith(ERC_6492_MAGIC_SUFFIX)) {
|
|
602
|
+
const { signature: inner } = utils.parseErc6492Signature(
|
|
603
|
+
`0x${hex}`
|
|
604
|
+
);
|
|
605
|
+
return normalizeSignature(inner);
|
|
606
|
+
}
|
|
607
|
+
if (hex.length > 130) {
|
|
608
|
+
try {
|
|
609
|
+
const [, innerBytes] = viem.decodeAbiParameters(
|
|
610
|
+
[{ type: "uint256" }, { type: "bytes" }],
|
|
611
|
+
`0x${hex}`
|
|
612
|
+
);
|
|
613
|
+
return normalizeSignature(innerBytes);
|
|
614
|
+
} catch {
|
|
615
|
+
}
|
|
616
|
+
}
|
|
602
617
|
throw new Error(
|
|
603
|
-
`Invalid signature
|
|
618
|
+
`Invalid signature: unable to normalize. Length=${hex.length / 2} bytes. Expected 65, 64, ERC-6492 wrapped, or ABI-encoded SignatureWrapper.`
|
|
604
619
|
);
|
|
605
620
|
}
|
|
606
621
|
|
|
@@ -1414,19 +1429,15 @@ function ProviderCard({ provider, selected, onClick }) {
|
|
|
1414
1429
|
}
|
|
1415
1430
|
);
|
|
1416
1431
|
}
|
|
1417
|
-
function
|
|
1432
|
+
function AccountDropdown({
|
|
1418
1433
|
accounts,
|
|
1419
|
-
providers,
|
|
1420
1434
|
selectedAccountId,
|
|
1435
|
+
onSelect,
|
|
1421
1436
|
selectedWalletId,
|
|
1422
|
-
|
|
1423
|
-
onSelectAccount,
|
|
1424
|
-
onSelectWallet,
|
|
1425
|
-
onConnectNewAccount
|
|
1437
|
+
onWalletSelect
|
|
1426
1438
|
}) {
|
|
1427
1439
|
const { tokens } = useSwypeConfig();
|
|
1428
1440
|
const [open, setOpen] = react.useState(false);
|
|
1429
|
-
const [showProviders, setShowProviders] = react.useState(false);
|
|
1430
1441
|
const containerRef = react.useRef(null);
|
|
1431
1442
|
const selected = accounts.find((a) => a.id === selectedAccountId);
|
|
1432
1443
|
const selectedWallet = selected?.wallets.find(
|
|
@@ -1437,15 +1448,41 @@ function FundingSourceDropdown({
|
|
|
1437
1448
|
const handleClick = (e) => {
|
|
1438
1449
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
1439
1450
|
setOpen(false);
|
|
1440
|
-
setShowProviders(false);
|
|
1441
1451
|
}
|
|
1442
1452
|
};
|
|
1443
1453
|
document.addEventListener("mousedown", handleClick);
|
|
1444
1454
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
1445
1455
|
}, [open]);
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1456
|
+
if (accounts.length === 0) return null;
|
|
1457
|
+
const hasMultipleChoices = accounts.length > 1 || accounts.length === 1 && onWalletSelect && accounts[0].wallets.filter((w) => w.balance.available.amount > 0).length > 1;
|
|
1458
|
+
if (!hasMultipleChoices) {
|
|
1459
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1460
|
+
"div",
|
|
1461
|
+
{
|
|
1462
|
+
style: {
|
|
1463
|
+
display: "flex",
|
|
1464
|
+
alignItems: "center",
|
|
1465
|
+
gap: "6px",
|
|
1466
|
+
fontSize: "0.85rem",
|
|
1467
|
+
color: tokens.textSecondary
|
|
1468
|
+
},
|
|
1469
|
+
children: [
|
|
1470
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500 }, children: accounts[0].name }),
|
|
1471
|
+
(selectedWallet ?? accounts[0].wallets[0]) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1472
|
+
"span",
|
|
1473
|
+
{
|
|
1474
|
+
style: {
|
|
1475
|
+
fontSize: "0.75rem",
|
|
1476
|
+
color: tokens.textMuted,
|
|
1477
|
+
fontFamily: '"SF Mono", "Fira Code", monospace'
|
|
1478
|
+
},
|
|
1479
|
+
children: selectedWallet ? `${selectedWallet.chain.name} \xB7 ${selectedWallet.name}` : accounts[0].wallets[0]?.name
|
|
1480
|
+
}
|
|
1481
|
+
)
|
|
1482
|
+
]
|
|
1483
|
+
}
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1449
1486
|
const getAccountBalance = (account) => {
|
|
1450
1487
|
let total = 0;
|
|
1451
1488
|
for (const w of account.wallets) {
|
|
@@ -1454,27 +1491,6 @@ function FundingSourceDropdown({
|
|
|
1454
1491
|
return total > 0 ? `$${total.toFixed(2)}` : "";
|
|
1455
1492
|
};
|
|
1456
1493
|
const hasActiveWallet = (account) => account.wallets.some((w) => w.status === "ACTIVE");
|
|
1457
|
-
let triggerLabel;
|
|
1458
|
-
if (connectingNewAccount) {
|
|
1459
|
-
triggerLabel = /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500, color: tokens.textMuted, fontSize: "0.85rem" }, children: "Connecting\u2026" });
|
|
1460
|
-
} else if (selected) {
|
|
1461
|
-
triggerLabel = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1462
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500, color: tokens.text }, children: selected.name }),
|
|
1463
|
-
(selectedWallet ?? selected.wallets[0]) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1464
|
-
"span",
|
|
1465
|
-
{
|
|
1466
|
-
style: {
|
|
1467
|
-
fontSize: "0.75rem",
|
|
1468
|
-
color: tokens.textMuted,
|
|
1469
|
-
fontFamily: '"SF Mono", "Fira Code", monospace'
|
|
1470
|
-
},
|
|
1471
|
-
children: selectedWallet ? `${selectedWallet.chain.name} \xB7 ${selectedWallet.name}` : selected.wallets[0].name
|
|
1472
|
-
}
|
|
1473
|
-
)
|
|
1474
|
-
] });
|
|
1475
|
-
} else {
|
|
1476
|
-
triggerLabel = /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500, color: tokens.textMuted }, children: "Select a source" });
|
|
1477
|
-
}
|
|
1478
1494
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, style: { position: "relative" }, children: [
|
|
1479
1495
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1480
1496
|
"button",
|
|
@@ -1495,7 +1511,18 @@ function FundingSourceDropdown({
|
|
|
1495
1511
|
outline: "none"
|
|
1496
1512
|
},
|
|
1497
1513
|
children: [
|
|
1498
|
-
|
|
1514
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500, color: tokens.text }, children: selected?.name ?? "Select account" }),
|
|
1515
|
+
(selectedWallet ?? selected?.wallets?.[0]) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1516
|
+
"span",
|
|
1517
|
+
{
|
|
1518
|
+
style: {
|
|
1519
|
+
fontSize: "0.75rem",
|
|
1520
|
+
color: tokens.textMuted,
|
|
1521
|
+
fontFamily: '"SF Mono", "Fira Code", monospace'
|
|
1522
|
+
},
|
|
1523
|
+
children: selectedWallet ? `${selectedWallet.chain.name} \xB7 ${selectedWallet.name}` : selected.wallets[0].name
|
|
1524
|
+
}
|
|
1525
|
+
),
|
|
1499
1526
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1500
1527
|
"svg",
|
|
1501
1528
|
{
|
|
@@ -1523,12 +1550,13 @@ function FundingSourceDropdown({
|
|
|
1523
1550
|
]
|
|
1524
1551
|
}
|
|
1525
1552
|
),
|
|
1526
|
-
open && /* @__PURE__ */ jsxRuntime.
|
|
1553
|
+
open && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1527
1554
|
"div",
|
|
1528
1555
|
{
|
|
1529
1556
|
style: {
|
|
1530
1557
|
position: "absolute",
|
|
1531
1558
|
top: "100%",
|
|
1559
|
+
left: 0,
|
|
1532
1560
|
right: 0,
|
|
1533
1561
|
marginTop: "4px",
|
|
1534
1562
|
background: tokens.bgCard,
|
|
@@ -1537,93 +1565,190 @@ function FundingSourceDropdown({
|
|
|
1537
1565
|
boxShadow: tokens.shadowLg,
|
|
1538
1566
|
zIndex: 50,
|
|
1539
1567
|
overflow: "hidden",
|
|
1540
|
-
minWidth: "
|
|
1568
|
+
minWidth: "220px"
|
|
1541
1569
|
},
|
|
1542
|
-
children:
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1570
|
+
children: accounts.map((account) => {
|
|
1571
|
+
const isAcctSelected = account.id === selectedAccountId;
|
|
1572
|
+
const balance = getAccountBalance(account);
|
|
1573
|
+
const active = hasActiveWallet(account);
|
|
1574
|
+
const walletsWithBalance = account.wallets.filter(
|
|
1575
|
+
(w) => w.balance.available.amount > 0
|
|
1576
|
+
);
|
|
1577
|
+
const showWallets = onWalletSelect && walletsWithBalance.length > 0;
|
|
1578
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1579
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1580
|
+
"button",
|
|
1581
|
+
{
|
|
1582
|
+
onClick: () => {
|
|
1583
|
+
onSelect(account.id);
|
|
1584
|
+
if (!showWallets) setOpen(false);
|
|
1585
|
+
},
|
|
1586
|
+
style: {
|
|
1587
|
+
display: "flex",
|
|
1588
|
+
alignItems: "center",
|
|
1589
|
+
justifyContent: "space-between",
|
|
1590
|
+
width: "100%",
|
|
1591
|
+
padding: "10px 14px",
|
|
1592
|
+
background: isAcctSelected && !selectedWalletId ? tokens.accent + "12" : "transparent",
|
|
1593
|
+
border: "none",
|
|
1594
|
+
borderBottom: showWallets ? "none" : `1px solid ${tokens.border}`,
|
|
1595
|
+
cursor: "pointer",
|
|
1596
|
+
color: tokens.text,
|
|
1597
|
+
fontFamily: "inherit",
|
|
1598
|
+
fontSize: "0.85rem",
|
|
1599
|
+
textAlign: "left",
|
|
1600
|
+
outline: "none",
|
|
1601
|
+
transition: "background 0.1s ease"
|
|
1602
|
+
},
|
|
1603
|
+
children: [
|
|
1604
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { minWidth: 0, flex: 1 }, children: [
|
|
1605
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1606
|
+
"div",
|
|
1607
|
+
{
|
|
1608
|
+
style: {
|
|
1609
|
+
display: "flex",
|
|
1610
|
+
alignItems: "center",
|
|
1611
|
+
gap: "6px"
|
|
1612
|
+
},
|
|
1613
|
+
children: [
|
|
1614
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500 }, children: account.name }),
|
|
1615
|
+
active && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1616
|
+
"span",
|
|
1617
|
+
{
|
|
1618
|
+
style: {
|
|
1619
|
+
fontSize: "0.6rem",
|
|
1620
|
+
fontWeight: 600,
|
|
1621
|
+
color: tokens.success,
|
|
1622
|
+
background: tokens.successBg,
|
|
1623
|
+
padding: "2px 7px",
|
|
1624
|
+
borderRadius: "999px",
|
|
1625
|
+
textTransform: "uppercase",
|
|
1626
|
+
letterSpacing: "0.03em"
|
|
1627
|
+
},
|
|
1628
|
+
children: "Active"
|
|
1629
|
+
}
|
|
1630
|
+
)
|
|
1631
|
+
]
|
|
1632
|
+
}
|
|
1633
|
+
),
|
|
1634
|
+
balance && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1635
|
+
"div",
|
|
1636
|
+
{
|
|
1637
|
+
style: {
|
|
1638
|
+
fontSize: "0.75rem",
|
|
1639
|
+
color: tokens.textMuted,
|
|
1640
|
+
marginTop: "2px"
|
|
1641
|
+
},
|
|
1642
|
+
children: balance
|
|
1643
|
+
}
|
|
1644
|
+
)
|
|
1645
|
+
] }),
|
|
1646
|
+
isAcctSelected && !selectedWalletId && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1647
|
+
"svg",
|
|
1648
|
+
{
|
|
1649
|
+
width: "14",
|
|
1650
|
+
height: "14",
|
|
1651
|
+
viewBox: "0 0 24 24",
|
|
1652
|
+
fill: "none",
|
|
1653
|
+
style: { flexShrink: 0, marginLeft: "8px" },
|
|
1654
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1655
|
+
"path",
|
|
1656
|
+
{
|
|
1657
|
+
d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z",
|
|
1658
|
+
fill: tokens.accent
|
|
1659
|
+
}
|
|
1660
|
+
)
|
|
1661
|
+
}
|
|
1662
|
+
)
|
|
1663
|
+
]
|
|
1664
|
+
}
|
|
1665
|
+
),
|
|
1666
|
+
showWallets && walletsWithBalance.map((wallet, wIdx) => {
|
|
1667
|
+
const isWalletSelected = isAcctSelected && wallet.id === selectedWalletId;
|
|
1668
|
+
const walletBal = wallet.balance.available.amount > 0 ? `$${wallet.balance.available.amount.toFixed(2)}` : "";
|
|
1669
|
+
const isLastWallet = wIdx === walletsWithBalance.length - 1;
|
|
1670
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1553
1671
|
"button",
|
|
1554
1672
|
{
|
|
1555
1673
|
onClick: () => {
|
|
1556
|
-
|
|
1557
|
-
|
|
1674
|
+
onWalletSelect(account.id, wallet.id);
|
|
1675
|
+
setOpen(false);
|
|
1558
1676
|
},
|
|
1559
1677
|
style: {
|
|
1560
1678
|
display: "flex",
|
|
1561
1679
|
alignItems: "center",
|
|
1562
1680
|
justifyContent: "space-between",
|
|
1563
1681
|
width: "100%",
|
|
1564
|
-
padding: "
|
|
1565
|
-
background:
|
|
1682
|
+
padding: "8px 14px 8px 28px",
|
|
1683
|
+
background: isWalletSelected ? tokens.accent + "12" : "transparent",
|
|
1566
1684
|
border: "none",
|
|
1567
|
-
borderBottom:
|
|
1685
|
+
borderBottom: isLastWallet ? `1px solid ${tokens.border}` : "none",
|
|
1568
1686
|
cursor: "pointer",
|
|
1569
1687
|
color: tokens.text,
|
|
1570
1688
|
fontFamily: "inherit",
|
|
1571
|
-
fontSize: "0.
|
|
1689
|
+
fontSize: "0.8rem",
|
|
1572
1690
|
textAlign: "left",
|
|
1573
1691
|
outline: "none",
|
|
1574
1692
|
transition: "background 0.1s ease"
|
|
1575
1693
|
},
|
|
1576
1694
|
children: [
|
|
1577
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
{
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1695
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1696
|
+
"div",
|
|
1697
|
+
{
|
|
1698
|
+
style: {
|
|
1699
|
+
display: "flex",
|
|
1700
|
+
alignItems: "center",
|
|
1701
|
+
gap: "6px",
|
|
1702
|
+
minWidth: 0,
|
|
1703
|
+
flex: 1
|
|
1704
|
+
},
|
|
1705
|
+
children: [
|
|
1706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1707
|
+
"span",
|
|
1708
|
+
{
|
|
1709
|
+
style: {
|
|
1710
|
+
fontWeight: 500,
|
|
1711
|
+
fontSize: "0.8rem"
|
|
1712
|
+
},
|
|
1713
|
+
children: wallet.chain.name
|
|
1714
|
+
}
|
|
1715
|
+
),
|
|
1716
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1717
|
+
"span",
|
|
1718
|
+
{
|
|
1719
|
+
style: {
|
|
1720
|
+
fontSize: "0.7rem",
|
|
1721
|
+
color: tokens.textMuted,
|
|
1722
|
+
fontFamily: '"SF Mono", "Fira Code", monospace'
|
|
1723
|
+
},
|
|
1724
|
+
children: wallet.name
|
|
1725
|
+
}
|
|
1726
|
+
),
|
|
1727
|
+
walletBal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1728
|
+
"span",
|
|
1729
|
+
{
|
|
1730
|
+
style: {
|
|
1731
|
+
fontSize: "0.7rem",
|
|
1732
|
+
color: tokens.textMuted,
|
|
1733
|
+
marginLeft: "auto"
|
|
1734
|
+
},
|
|
1735
|
+
children: walletBal
|
|
1736
|
+
}
|
|
1737
|
+
)
|
|
1738
|
+
]
|
|
1739
|
+
}
|
|
1740
|
+
),
|
|
1741
|
+
isWalletSelected && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1620
1742
|
"svg",
|
|
1621
1743
|
{
|
|
1622
|
-
width: "
|
|
1623
|
-
height: "
|
|
1744
|
+
width: "12",
|
|
1745
|
+
height: "12",
|
|
1624
1746
|
viewBox: "0 0 24 24",
|
|
1625
1747
|
fill: "none",
|
|
1626
|
-
style: {
|
|
1748
|
+
style: {
|
|
1749
|
+
flexShrink: 0,
|
|
1750
|
+
marginLeft: "8px"
|
|
1751
|
+
},
|
|
1627
1752
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1628
1753
|
"path",
|
|
1629
1754
|
{
|
|
@@ -1634,214 +1759,12 @@ function FundingSourceDropdown({
|
|
|
1634
1759
|
}
|
|
1635
1760
|
)
|
|
1636
1761
|
]
|
|
1637
|
-
}
|
|
1638
|
-
),
|
|
1639
|
-
showWallets && walletsWithBalance.map((wallet, wIdx) => {
|
|
1640
|
-
const isWalletSelected = isAcctSelected && wallet.id === selectedWalletId;
|
|
1641
|
-
const walletBal = wallet.balance.available.amount > 0 ? `$${wallet.balance.available.amount.toFixed(2)}` : "";
|
|
1642
|
-
const isLastWallet = wIdx === walletsWithBalance.length - 1;
|
|
1643
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1644
|
-
"button",
|
|
1645
|
-
{
|
|
1646
|
-
onClick: () => {
|
|
1647
|
-
onSelectWallet(account.id, wallet.id);
|
|
1648
|
-
setOpen(false);
|
|
1649
|
-
},
|
|
1650
|
-
style: {
|
|
1651
|
-
display: "flex",
|
|
1652
|
-
alignItems: "center",
|
|
1653
|
-
justifyContent: "space-between",
|
|
1654
|
-
width: "100%",
|
|
1655
|
-
padding: "8px 14px 8px 28px",
|
|
1656
|
-
background: isWalletSelected ? tokens.accent + "12" : "transparent",
|
|
1657
|
-
border: "none",
|
|
1658
|
-
borderBottom: isLastWallet ? `1px solid ${tokens.border}` : "none",
|
|
1659
|
-
cursor: "pointer",
|
|
1660
|
-
color: tokens.text,
|
|
1661
|
-
fontFamily: "inherit",
|
|
1662
|
-
fontSize: "0.8rem",
|
|
1663
|
-
textAlign: "left",
|
|
1664
|
-
outline: "none",
|
|
1665
|
-
transition: "background 0.1s ease"
|
|
1666
|
-
},
|
|
1667
|
-
children: [
|
|
1668
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1669
|
-
"div",
|
|
1670
|
-
{
|
|
1671
|
-
style: {
|
|
1672
|
-
display: "flex",
|
|
1673
|
-
alignItems: "center",
|
|
1674
|
-
gap: "6px",
|
|
1675
|
-
minWidth: 0,
|
|
1676
|
-
flex: 1
|
|
1677
|
-
},
|
|
1678
|
-
children: [
|
|
1679
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500, fontSize: "0.8rem" }, children: wallet.chain.name }),
|
|
1680
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1681
|
-
"span",
|
|
1682
|
-
{
|
|
1683
|
-
style: {
|
|
1684
|
-
fontSize: "0.7rem",
|
|
1685
|
-
color: tokens.textMuted,
|
|
1686
|
-
fontFamily: '"SF Mono", "Fira Code", monospace'
|
|
1687
|
-
},
|
|
1688
|
-
children: wallet.name
|
|
1689
|
-
}
|
|
1690
|
-
),
|
|
1691
|
-
walletBal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1692
|
-
"span",
|
|
1693
|
-
{
|
|
1694
|
-
style: {
|
|
1695
|
-
fontSize: "0.7rem",
|
|
1696
|
-
color: tokens.textMuted,
|
|
1697
|
-
marginLeft: "auto"
|
|
1698
|
-
},
|
|
1699
|
-
children: walletBal
|
|
1700
|
-
}
|
|
1701
|
-
)
|
|
1702
|
-
]
|
|
1703
|
-
}
|
|
1704
|
-
),
|
|
1705
|
-
isWalletSelected && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1706
|
-
"svg",
|
|
1707
|
-
{
|
|
1708
|
-
width: "12",
|
|
1709
|
-
height: "12",
|
|
1710
|
-
viewBox: "0 0 24 24",
|
|
1711
|
-
fill: "none",
|
|
1712
|
-
style: { flexShrink: 0, marginLeft: "8px" },
|
|
1713
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1714
|
-
"path",
|
|
1715
|
-
{
|
|
1716
|
-
d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z",
|
|
1717
|
-
fill: tokens.accent
|
|
1718
|
-
}
|
|
1719
|
-
)
|
|
1720
|
-
}
|
|
1721
|
-
)
|
|
1722
|
-
]
|
|
1723
|
-
},
|
|
1724
|
-
wallet.id
|
|
1725
|
-
);
|
|
1726
|
-
})
|
|
1727
|
-
] }, account.id);
|
|
1728
|
-
}),
|
|
1729
|
-
accounts.length > 0 && !showProviders && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1730
|
-
"div",
|
|
1731
|
-
{
|
|
1732
|
-
style: {
|
|
1733
|
-
height: "1px",
|
|
1734
|
-
background: tokens.border,
|
|
1735
|
-
margin: "0"
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
),
|
|
1739
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "8px" }, children: !showProviders ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1740
|
-
"button",
|
|
1741
|
-
{
|
|
1742
|
-
onClick: () => setShowProviders(true),
|
|
1743
|
-
disabled: connectingNewAccount,
|
|
1744
|
-
style: {
|
|
1745
|
-
display: "flex",
|
|
1746
|
-
alignItems: "center",
|
|
1747
|
-
gap: "8px",
|
|
1748
|
-
background: "transparent",
|
|
1749
|
-
border: `1px dashed ${tokens.border}`,
|
|
1750
|
-
borderRadius: tokens.radius,
|
|
1751
|
-
padding: "10px 12px",
|
|
1752
|
-
width: "100%",
|
|
1753
|
-
cursor: connectingNewAccount ? "not-allowed" : "pointer",
|
|
1754
|
-
color: tokens.textSecondary,
|
|
1755
|
-
fontFamily: "inherit",
|
|
1756
|
-
fontSize: "0.825rem",
|
|
1757
|
-
fontWeight: 500,
|
|
1758
|
-
outline: "none",
|
|
1759
|
-
opacity: connectingNewAccount ? 0.5 : 1,
|
|
1760
|
-
transition: "opacity 0.15s ease"
|
|
1761
|
-
},
|
|
1762
|
-
children: [
|
|
1763
|
-
/* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1764
|
-
"path",
|
|
1765
|
-
{
|
|
1766
|
-
d: "M12 5v14M5 12h14",
|
|
1767
|
-
stroke: tokens.textMuted,
|
|
1768
|
-
strokeWidth: "2",
|
|
1769
|
-
strokeLinecap: "round"
|
|
1770
|
-
}
|
|
1771
|
-
) }),
|
|
1772
|
-
"Add a source"
|
|
1773
|
-
]
|
|
1774
|
-
}
|
|
1775
|
-
) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1776
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1777
|
-
"div",
|
|
1778
|
-
{
|
|
1779
|
-
style: {
|
|
1780
|
-
display: "flex",
|
|
1781
|
-
alignItems: "center",
|
|
1782
|
-
justifyContent: "space-between",
|
|
1783
|
-
marginBottom: "8px",
|
|
1784
|
-
padding: "0 4px"
|
|
1785
|
-
},
|
|
1786
|
-
children: [
|
|
1787
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1788
|
-
"label",
|
|
1789
|
-
{
|
|
1790
|
-
style: {
|
|
1791
|
-
fontSize: "0.7rem",
|
|
1792
|
-
fontWeight: 600,
|
|
1793
|
-
color: tokens.textMuted,
|
|
1794
|
-
textTransform: "uppercase",
|
|
1795
|
-
letterSpacing: "0.05em"
|
|
1796
|
-
},
|
|
1797
|
-
children: "Select provider"
|
|
1798
|
-
}
|
|
1799
|
-
),
|
|
1800
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1801
|
-
"button",
|
|
1802
|
-
{
|
|
1803
|
-
onClick: () => setShowProviders(false),
|
|
1804
|
-
style: {
|
|
1805
|
-
background: "transparent",
|
|
1806
|
-
border: "none",
|
|
1807
|
-
cursor: "pointer",
|
|
1808
|
-
color: tokens.textMuted,
|
|
1809
|
-
fontSize: "0.75rem",
|
|
1810
|
-
fontFamily: "inherit",
|
|
1811
|
-
outline: "none",
|
|
1812
|
-
padding: "2px 4px"
|
|
1813
|
-
},
|
|
1814
|
-
children: "Cancel"
|
|
1815
|
-
}
|
|
1816
|
-
)
|
|
1817
|
-
]
|
|
1818
|
-
}
|
|
1819
|
-
),
|
|
1820
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1821
|
-
"div",
|
|
1822
|
-
{
|
|
1823
|
-
style: {
|
|
1824
|
-
display: "flex",
|
|
1825
|
-
flexDirection: "column",
|
|
1826
|
-
gap: "6px"
|
|
1827
1762
|
},
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
onClick: () => {
|
|
1834
|
-
onConnectNewAccount(p.id);
|
|
1835
|
-
setOpen(false);
|
|
1836
|
-
setShowProviders(false);
|
|
1837
|
-
}
|
|
1838
|
-
},
|
|
1839
|
-
p.id
|
|
1840
|
-
))
|
|
1841
|
-
}
|
|
1842
|
-
)
|
|
1843
|
-
] }) })
|
|
1844
|
-
]
|
|
1763
|
+
wallet.id
|
|
1764
|
+
);
|
|
1765
|
+
})
|
|
1766
|
+
] }, account.id);
|
|
1767
|
+
})
|
|
1845
1768
|
}
|
|
1846
1769
|
)
|
|
1847
1770
|
] });
|
|
@@ -1850,10 +1773,14 @@ var ASSETS = ["USDC", "USDT"];
|
|
|
1850
1773
|
function AdvancedSettings({
|
|
1851
1774
|
settings,
|
|
1852
1775
|
onChange,
|
|
1853
|
-
chains
|
|
1776
|
+
chains,
|
|
1777
|
+
providers,
|
|
1778
|
+
onConnectNewAccount,
|
|
1779
|
+
connectingNewAccount
|
|
1854
1780
|
}) {
|
|
1855
1781
|
const { tokens } = useSwypeConfig();
|
|
1856
1782
|
const [open, setOpen] = react.useState(false);
|
|
1783
|
+
const [showProviders, setShowProviders] = react.useState(false);
|
|
1857
1784
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "12px" }, children: [
|
|
1858
1785
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1859
1786
|
"button",
|
|
@@ -1957,7 +1884,7 @@ function AdvancedSettings({
|
|
|
1957
1884
|
);
|
|
1958
1885
|
}) })
|
|
1959
1886
|
] }),
|
|
1960
|
-
chains.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1887
|
+
chains.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "14px" }, children: [
|
|
1961
1888
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1962
1889
|
"label",
|
|
1963
1890
|
{
|
|
@@ -2000,7 +1927,119 @@ function AdvancedSettings({
|
|
|
2000
1927
|
chain.id
|
|
2001
1928
|
);
|
|
2002
1929
|
}) })
|
|
2003
|
-
] })
|
|
1930
|
+
] }),
|
|
1931
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: !showProviders ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1932
|
+
"button",
|
|
1933
|
+
{
|
|
1934
|
+
onClick: () => setShowProviders(true),
|
|
1935
|
+
disabled: connectingNewAccount,
|
|
1936
|
+
style: {
|
|
1937
|
+
display: "flex",
|
|
1938
|
+
alignItems: "center",
|
|
1939
|
+
gap: "6px",
|
|
1940
|
+
background: tokens.bgCard,
|
|
1941
|
+
border: `1px dashed ${tokens.border}`,
|
|
1942
|
+
borderRadius: "999px",
|
|
1943
|
+
padding: "10px 14px",
|
|
1944
|
+
width: "100%",
|
|
1945
|
+
cursor: connectingNewAccount ? "not-allowed" : "pointer",
|
|
1946
|
+
color: tokens.textSecondary,
|
|
1947
|
+
fontFamily: "inherit",
|
|
1948
|
+
fontSize: "0.825rem",
|
|
1949
|
+
fontWeight: 500,
|
|
1950
|
+
outline: "none",
|
|
1951
|
+
opacity: connectingNewAccount ? 0.5 : 1,
|
|
1952
|
+
transition: "opacity 0.1s ease"
|
|
1953
|
+
},
|
|
1954
|
+
children: [
|
|
1955
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1956
|
+
"svg",
|
|
1957
|
+
{
|
|
1958
|
+
width: "14",
|
|
1959
|
+
height: "14",
|
|
1960
|
+
viewBox: "0 0 24 24",
|
|
1961
|
+
fill: "none",
|
|
1962
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1963
|
+
"path",
|
|
1964
|
+
{
|
|
1965
|
+
d: "M12 5v14M5 12h14",
|
|
1966
|
+
stroke: tokens.textMuted,
|
|
1967
|
+
strokeWidth: "2",
|
|
1968
|
+
strokeLinecap: "round"
|
|
1969
|
+
}
|
|
1970
|
+
)
|
|
1971
|
+
}
|
|
1972
|
+
),
|
|
1973
|
+
"Connect new account"
|
|
1974
|
+
]
|
|
1975
|
+
}
|
|
1976
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1977
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1978
|
+
"div",
|
|
1979
|
+
{
|
|
1980
|
+
style: {
|
|
1981
|
+
display: "flex",
|
|
1982
|
+
alignItems: "center",
|
|
1983
|
+
justifyContent: "space-between",
|
|
1984
|
+
marginBottom: "8px"
|
|
1985
|
+
},
|
|
1986
|
+
children: [
|
|
1987
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1988
|
+
"label",
|
|
1989
|
+
{
|
|
1990
|
+
style: {
|
|
1991
|
+
fontSize: "0.7rem",
|
|
1992
|
+
fontWeight: 600,
|
|
1993
|
+
color: tokens.textMuted,
|
|
1994
|
+
textTransform: "uppercase",
|
|
1995
|
+
letterSpacing: "0.05em"
|
|
1996
|
+
},
|
|
1997
|
+
children: "Select provider"
|
|
1998
|
+
}
|
|
1999
|
+
),
|
|
2000
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2001
|
+
"button",
|
|
2002
|
+
{
|
|
2003
|
+
onClick: () => setShowProviders(false),
|
|
2004
|
+
style: {
|
|
2005
|
+
background: "transparent",
|
|
2006
|
+
border: "none",
|
|
2007
|
+
cursor: "pointer",
|
|
2008
|
+
color: tokens.textMuted,
|
|
2009
|
+
fontSize: "0.75rem",
|
|
2010
|
+
fontFamily: "inherit",
|
|
2011
|
+
outline: "none",
|
|
2012
|
+
padding: "2px 4px"
|
|
2013
|
+
},
|
|
2014
|
+
children: "Cancel"
|
|
2015
|
+
}
|
|
2016
|
+
)
|
|
2017
|
+
]
|
|
2018
|
+
}
|
|
2019
|
+
),
|
|
2020
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2021
|
+
"div",
|
|
2022
|
+
{
|
|
2023
|
+
style: {
|
|
2024
|
+
display: "flex",
|
|
2025
|
+
flexDirection: "column",
|
|
2026
|
+
gap: "6px"
|
|
2027
|
+
},
|
|
2028
|
+
children: providers.map((p) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2029
|
+
ProviderCard,
|
|
2030
|
+
{
|
|
2031
|
+
provider: p,
|
|
2032
|
+
selected: false,
|
|
2033
|
+
onClick: () => {
|
|
2034
|
+
onConnectNewAccount(p.id);
|
|
2035
|
+
setShowProviders(false);
|
|
2036
|
+
}
|
|
2037
|
+
},
|
|
2038
|
+
p.id
|
|
2039
|
+
))
|
|
2040
|
+
}
|
|
2041
|
+
)
|
|
2042
|
+
] }) })
|
|
2004
2043
|
]
|
|
2005
2044
|
}
|
|
2006
2045
|
)
|
|
@@ -2519,6 +2558,11 @@ function SwypePayment({
|
|
|
2519
2558
|
pollingTransferIdRef.current = null;
|
|
2520
2559
|
mobileSigningTransferIdRef.current = null;
|
|
2521
2560
|
}, [logout, polling, depositAmount]);
|
|
2561
|
+
const handleConnectNewAccount = (providerId) => {
|
|
2562
|
+
setSelectedProviderId(providerId);
|
|
2563
|
+
setSelectedAccountId(null);
|
|
2564
|
+
setConnectingNewAccount(true);
|
|
2565
|
+
};
|
|
2522
2566
|
const cardStyle = {
|
|
2523
2567
|
background: tokens.bgCard,
|
|
2524
2568
|
borderRadius: tokens.radiusLg,
|
|
@@ -2890,6 +2934,7 @@ function SwypePayment({
|
|
|
2890
2934
|
if (step === "ready") {
|
|
2891
2935
|
const parsedAmount = parseFloat(amount);
|
|
2892
2936
|
const canPay = !isNaN(parsedAmount) && parsedAmount >= MIN_SEND_AMOUNT_USD && !!sourceId && !loadingData;
|
|
2937
|
+
const noAccounts = !loadingData && accounts.length === 0;
|
|
2893
2938
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: cardStyle, children: [
|
|
2894
2939
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "relative" }, children: [
|
|
2895
2940
|
stepBadge("Review & pay"),
|
|
@@ -3020,30 +3065,23 @@ function SwypePayment({
|
|
|
3020
3065
|
},
|
|
3021
3066
|
children: [
|
|
3022
3067
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "From" }),
|
|
3023
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3024
|
-
|
|
3068
|
+
noAccounts ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontWeight: 500, color: tokens.textMuted }, children: "New account" }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3069
|
+
AccountDropdown,
|
|
3025
3070
|
{
|
|
3026
3071
|
accounts,
|
|
3027
|
-
providers,
|
|
3028
3072
|
selectedAccountId,
|
|
3029
3073
|
selectedWalletId,
|
|
3030
|
-
|
|
3031
|
-
onSelectAccount: (id) => {
|
|
3074
|
+
onSelect: (id) => {
|
|
3032
3075
|
setSelectedAccountId(id);
|
|
3033
3076
|
setSelectedWalletId(null);
|
|
3034
3077
|
setConnectingNewAccount(false);
|
|
3035
3078
|
setSelectedProviderId(null);
|
|
3036
3079
|
},
|
|
3037
|
-
|
|
3080
|
+
onWalletSelect: (accountId, walletId) => {
|
|
3038
3081
|
setSelectedAccountId(accountId);
|
|
3039
3082
|
setSelectedWalletId(walletId);
|
|
3040
3083
|
setConnectingNewAccount(false);
|
|
3041
3084
|
setSelectedProviderId(null);
|
|
3042
|
-
},
|
|
3043
|
-
onConnectNewAccount: (providerId) => {
|
|
3044
|
-
setSelectedProviderId(providerId);
|
|
3045
|
-
setSelectedAccountId(null);
|
|
3046
|
-
setConnectingNewAccount(true);
|
|
3047
3085
|
}
|
|
3048
3086
|
}
|
|
3049
3087
|
)
|
|
@@ -3053,6 +3091,46 @@ function SwypePayment({
|
|
|
3053
3091
|
]
|
|
3054
3092
|
}
|
|
3055
3093
|
),
|
|
3094
|
+
noAccounts && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
3095
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3096
|
+
"label",
|
|
3097
|
+
{
|
|
3098
|
+
style: {
|
|
3099
|
+
display: "block",
|
|
3100
|
+
fontSize: "0.8rem",
|
|
3101
|
+
color: tokens.textMuted,
|
|
3102
|
+
marginBottom: "8px",
|
|
3103
|
+
fontWeight: 500,
|
|
3104
|
+
textTransform: "uppercase",
|
|
3105
|
+
letterSpacing: "0.05em"
|
|
3106
|
+
},
|
|
3107
|
+
children: "Connect a wallet"
|
|
3108
|
+
}
|
|
3109
|
+
),
|
|
3110
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3111
|
+
"div",
|
|
3112
|
+
{
|
|
3113
|
+
style: {
|
|
3114
|
+
display: "flex",
|
|
3115
|
+
flexDirection: "column",
|
|
3116
|
+
gap: "8px"
|
|
3117
|
+
},
|
|
3118
|
+
children: providers.map((p) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3119
|
+
ProviderCard,
|
|
3120
|
+
{
|
|
3121
|
+
provider: p,
|
|
3122
|
+
selected: selectedProviderId === p.id,
|
|
3123
|
+
onClick: () => {
|
|
3124
|
+
setSelectedProviderId(p.id);
|
|
3125
|
+
setSelectedAccountId(null);
|
|
3126
|
+
setConnectingNewAccount(false);
|
|
3127
|
+
}
|
|
3128
|
+
},
|
|
3129
|
+
p.id
|
|
3130
|
+
))
|
|
3131
|
+
}
|
|
3132
|
+
)
|
|
3133
|
+
] }),
|
|
3056
3134
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3057
3135
|
"button",
|
|
3058
3136
|
{
|
|
@@ -3065,12 +3143,15 @@ function SwypePayment({
|
|
|
3065
3143
|
]
|
|
3066
3144
|
}
|
|
3067
3145
|
),
|
|
3068
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3146
|
+
!noAccounts && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3069
3147
|
AdvancedSettings,
|
|
3070
3148
|
{
|
|
3071
3149
|
settings: advancedSettings,
|
|
3072
3150
|
onChange: setAdvancedSettings,
|
|
3073
|
-
chains
|
|
3151
|
+
chains,
|
|
3152
|
+
providers,
|
|
3153
|
+
onConnectNewAccount: handleConnectNewAccount,
|
|
3154
|
+
connectingNewAccount
|
|
3074
3155
|
}
|
|
3075
3156
|
)
|
|
3076
3157
|
] })
|