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