@swype-org/react-sdk 0.1.21 → 0.1.23

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,50 @@ 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
+ try {
613
+ const [wrapper] = decodeAbiParameters(
614
+ [{
615
+ type: "tuple",
616
+ components: [{ type: "uint8" }, { type: "bytes" }]
617
+ }],
618
+ `0x${hex}`
619
+ );
620
+ return normalizeSignature(wrapper[1]);
621
+ } catch {
622
+ }
623
+ }
624
+ }
599
625
  throw new Error(
600
- `Invalid signature length: expected 65 or 64 bytes, got ${stripped.length / 2}`
626
+ `Invalid signature: unable to normalize. Length=${hex.length / 2} bytes. Expected 65, 64, ERC-6492 wrapped, or ABI-encoded SignatureWrapper.`
601
627
  );
602
628
  }
603
629
 
@@ -1411,19 +1437,15 @@ function ProviderCard({ provider, selected, onClick }) {
1411
1437
  }
1412
1438
  );
1413
1439
  }
1414
- function FundingSourceDropdown({
1440
+ function AccountDropdown({
1415
1441
  accounts,
1416
- providers,
1417
1442
  selectedAccountId,
1443
+ onSelect,
1418
1444
  selectedWalletId,
1419
- connectingNewAccount,
1420
- onSelectAccount,
1421
- onSelectWallet,
1422
- onConnectNewAccount
1445
+ onWalletSelect
1423
1446
  }) {
1424
1447
  const { tokens } = useSwypeConfig();
1425
1448
  const [open, setOpen] = useState(false);
1426
- const [showProviders, setShowProviders] = useState(false);
1427
1449
  const containerRef = useRef(null);
1428
1450
  const selected = accounts.find((a) => a.id === selectedAccountId);
1429
1451
  const selectedWallet = selected?.wallets.find(
@@ -1434,15 +1456,41 @@ function FundingSourceDropdown({
1434
1456
  const handleClick = (e) => {
1435
1457
  if (containerRef.current && !containerRef.current.contains(e.target)) {
1436
1458
  setOpen(false);
1437
- setShowProviders(false);
1438
1459
  }
1439
1460
  };
1440
1461
  document.addEventListener("mousedown", handleClick);
1441
1462
  return () => document.removeEventListener("mousedown", handleClick);
1442
1463
  }, [open]);
1443
- useEffect(() => {
1444
- if (!open) setShowProviders(false);
1445
- }, [open]);
1464
+ if (accounts.length === 0) return null;
1465
+ const hasMultipleChoices = accounts.length > 1 || accounts.length === 1 && onWalletSelect && accounts[0].wallets.filter((w) => w.balance.available.amount > 0).length > 1;
1466
+ if (!hasMultipleChoices) {
1467
+ return /* @__PURE__ */ jsxs(
1468
+ "div",
1469
+ {
1470
+ style: {
1471
+ display: "flex",
1472
+ alignItems: "center",
1473
+ gap: "6px",
1474
+ fontSize: "0.85rem",
1475
+ color: tokens.textSecondary
1476
+ },
1477
+ children: [
1478
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 500 }, children: accounts[0].name }),
1479
+ (selectedWallet ?? accounts[0].wallets[0]) && /* @__PURE__ */ jsx(
1480
+ "span",
1481
+ {
1482
+ style: {
1483
+ fontSize: "0.75rem",
1484
+ color: tokens.textMuted,
1485
+ fontFamily: '"SF Mono", "Fira Code", monospace'
1486
+ },
1487
+ children: selectedWallet ? `${selectedWallet.chain.name} \xB7 ${selectedWallet.name}` : accounts[0].wallets[0]?.name
1488
+ }
1489
+ )
1490
+ ]
1491
+ }
1492
+ );
1493
+ }
1446
1494
  const getAccountBalance = (account) => {
1447
1495
  let total = 0;
1448
1496
  for (const w of account.wallets) {
@@ -1451,27 +1499,6 @@ function FundingSourceDropdown({
1451
1499
  return total > 0 ? `$${total.toFixed(2)}` : "";
1452
1500
  };
1453
1501
  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
1502
  return /* @__PURE__ */ jsxs("div", { ref: containerRef, style: { position: "relative" }, children: [
1476
1503
  /* @__PURE__ */ jsxs(
1477
1504
  "button",
@@ -1492,7 +1519,18 @@ function FundingSourceDropdown({
1492
1519
  outline: "none"
1493
1520
  },
1494
1521
  children: [
1495
- triggerLabel,
1522
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 500, color: tokens.text }, children: selected?.name ?? "Select account" }),
1523
+ (selectedWallet ?? selected?.wallets?.[0]) && /* @__PURE__ */ jsx(
1524
+ "span",
1525
+ {
1526
+ style: {
1527
+ fontSize: "0.75rem",
1528
+ color: tokens.textMuted,
1529
+ fontFamily: '"SF Mono", "Fira Code", monospace'
1530
+ },
1531
+ children: selectedWallet ? `${selectedWallet.chain.name} \xB7 ${selectedWallet.name}` : selected.wallets[0].name
1532
+ }
1533
+ ),
1496
1534
  /* @__PURE__ */ jsx(
1497
1535
  "svg",
1498
1536
  {
@@ -1520,12 +1558,13 @@ function FundingSourceDropdown({
1520
1558
  ]
1521
1559
  }
1522
1560
  ),
1523
- open && /* @__PURE__ */ jsxs(
1561
+ open && /* @__PURE__ */ jsx(
1524
1562
  "div",
1525
1563
  {
1526
1564
  style: {
1527
1565
  position: "absolute",
1528
1566
  top: "100%",
1567
+ left: 0,
1529
1568
  right: 0,
1530
1569
  marginTop: "4px",
1531
1570
  background: tokens.bgCard,
@@ -1534,93 +1573,190 @@ function FundingSourceDropdown({
1534
1573
  boxShadow: tokens.shadowLg,
1535
1574
  zIndex: 50,
1536
1575
  overflow: "hidden",
1537
- minWidth: "260px"
1576
+ minWidth: "220px"
1538
1577
  },
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(
1578
+ children: accounts.map((account) => {
1579
+ const isAcctSelected = account.id === selectedAccountId;
1580
+ const balance = getAccountBalance(account);
1581
+ const active = hasActiveWallet(account);
1582
+ const walletsWithBalance = account.wallets.filter(
1583
+ (w) => w.balance.available.amount > 0
1584
+ );
1585
+ const showWallets = onWalletSelect && walletsWithBalance.length > 0;
1586
+ return /* @__PURE__ */ jsxs("div", { children: [
1587
+ /* @__PURE__ */ jsxs(
1588
+ "button",
1589
+ {
1590
+ onClick: () => {
1591
+ onSelect(account.id);
1592
+ if (!showWallets) setOpen(false);
1593
+ },
1594
+ style: {
1595
+ display: "flex",
1596
+ alignItems: "center",
1597
+ justifyContent: "space-between",
1598
+ width: "100%",
1599
+ padding: "10px 14px",
1600
+ background: isAcctSelected && !selectedWalletId ? tokens.accent + "12" : "transparent",
1601
+ border: "none",
1602
+ borderBottom: showWallets ? "none" : `1px solid ${tokens.border}`,
1603
+ cursor: "pointer",
1604
+ color: tokens.text,
1605
+ fontFamily: "inherit",
1606
+ fontSize: "0.85rem",
1607
+ textAlign: "left",
1608
+ outline: "none",
1609
+ transition: "background 0.1s ease"
1610
+ },
1611
+ children: [
1612
+ /* @__PURE__ */ jsxs("div", { style: { minWidth: 0, flex: 1 }, children: [
1613
+ /* @__PURE__ */ jsxs(
1614
+ "div",
1615
+ {
1616
+ style: {
1617
+ display: "flex",
1618
+ alignItems: "center",
1619
+ gap: "6px"
1620
+ },
1621
+ children: [
1622
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 500 }, children: account.name }),
1623
+ active && /* @__PURE__ */ jsx(
1624
+ "span",
1625
+ {
1626
+ style: {
1627
+ fontSize: "0.6rem",
1628
+ fontWeight: 600,
1629
+ color: tokens.success,
1630
+ background: tokens.successBg,
1631
+ padding: "2px 7px",
1632
+ borderRadius: "999px",
1633
+ textTransform: "uppercase",
1634
+ letterSpacing: "0.03em"
1635
+ },
1636
+ children: "Active"
1637
+ }
1638
+ )
1639
+ ]
1640
+ }
1641
+ ),
1642
+ balance && /* @__PURE__ */ jsx(
1643
+ "div",
1644
+ {
1645
+ style: {
1646
+ fontSize: "0.75rem",
1647
+ color: tokens.textMuted,
1648
+ marginTop: "2px"
1649
+ },
1650
+ children: balance
1651
+ }
1652
+ )
1653
+ ] }),
1654
+ isAcctSelected && !selectedWalletId && /* @__PURE__ */ jsx(
1655
+ "svg",
1656
+ {
1657
+ width: "14",
1658
+ height: "14",
1659
+ viewBox: "0 0 24 24",
1660
+ fill: "none",
1661
+ style: { flexShrink: 0, marginLeft: "8px" },
1662
+ children: /* @__PURE__ */ jsx(
1663
+ "path",
1664
+ {
1665
+ d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z",
1666
+ fill: tokens.accent
1667
+ }
1668
+ )
1669
+ }
1670
+ )
1671
+ ]
1672
+ }
1673
+ ),
1674
+ showWallets && walletsWithBalance.map((wallet, wIdx) => {
1675
+ const isWalletSelected = isAcctSelected && wallet.id === selectedWalletId;
1676
+ const walletBal = wallet.balance.available.amount > 0 ? `$${wallet.balance.available.amount.toFixed(2)}` : "";
1677
+ const isLastWallet = wIdx === walletsWithBalance.length - 1;
1678
+ return /* @__PURE__ */ jsxs(
1550
1679
  "button",
1551
1680
  {
1552
1681
  onClick: () => {
1553
- onSelectAccount(account.id);
1554
- if (!showWallets) setOpen(false);
1682
+ onWalletSelect(account.id, wallet.id);
1683
+ setOpen(false);
1555
1684
  },
1556
1685
  style: {
1557
1686
  display: "flex",
1558
1687
  alignItems: "center",
1559
1688
  justifyContent: "space-between",
1560
1689
  width: "100%",
1561
- padding: "10px 14px",
1562
- background: isAcctSelected && !selectedWalletId ? tokens.accent + "12" : "transparent",
1690
+ padding: "8px 14px 8px 28px",
1691
+ background: isWalletSelected ? tokens.accent + "12" : "transparent",
1563
1692
  border: "none",
1564
- borderBottom: showWallets ? "none" : `1px solid ${tokens.border}`,
1693
+ borderBottom: isLastWallet ? `1px solid ${tokens.border}` : "none",
1565
1694
  cursor: "pointer",
1566
1695
  color: tokens.text,
1567
1696
  fontFamily: "inherit",
1568
- fontSize: "0.85rem",
1697
+ fontSize: "0.8rem",
1569
1698
  textAlign: "left",
1570
1699
  outline: "none",
1571
1700
  transition: "background 0.1s ease"
1572
1701
  },
1573
1702
  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(
1703
+ /* @__PURE__ */ jsxs(
1704
+ "div",
1705
+ {
1706
+ style: {
1707
+ display: "flex",
1708
+ alignItems: "center",
1709
+ gap: "6px",
1710
+ minWidth: 0,
1711
+ flex: 1
1712
+ },
1713
+ children: [
1714
+ /* @__PURE__ */ jsx(
1715
+ "span",
1716
+ {
1717
+ style: {
1718
+ fontWeight: 500,
1719
+ fontSize: "0.8rem"
1720
+ },
1721
+ children: wallet.chain.name
1722
+ }
1723
+ ),
1724
+ /* @__PURE__ */ jsx(
1725
+ "span",
1726
+ {
1727
+ style: {
1728
+ fontSize: "0.7rem",
1729
+ color: tokens.textMuted,
1730
+ fontFamily: '"SF Mono", "Fira Code", monospace'
1731
+ },
1732
+ children: wallet.name
1733
+ }
1734
+ ),
1735
+ walletBal && /* @__PURE__ */ jsx(
1736
+ "span",
1737
+ {
1738
+ style: {
1739
+ fontSize: "0.7rem",
1740
+ color: tokens.textMuted,
1741
+ marginLeft: "auto"
1742
+ },
1743
+ children: walletBal
1744
+ }
1745
+ )
1746
+ ]
1747
+ }
1748
+ ),
1749
+ isWalletSelected && /* @__PURE__ */ jsx(
1617
1750
  "svg",
1618
1751
  {
1619
- width: "14",
1620
- height: "14",
1752
+ width: "12",
1753
+ height: "12",
1621
1754
  viewBox: "0 0 24 24",
1622
1755
  fill: "none",
1623
- style: { flexShrink: 0, marginLeft: "8px" },
1756
+ style: {
1757
+ flexShrink: 0,
1758
+ marginLeft: "8px"
1759
+ },
1624
1760
  children: /* @__PURE__ */ jsx(
1625
1761
  "path",
1626
1762
  {
@@ -1631,214 +1767,12 @@ function FundingSourceDropdown({
1631
1767
  }
1632
1768
  )
1633
1769
  ]
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
1770
  },
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
- ]
1771
+ wallet.id
1772
+ );
1773
+ })
1774
+ ] }, account.id);
1775
+ })
1842
1776
  }
1843
1777
  )
1844
1778
  ] });
@@ -1847,10 +1781,14 @@ var ASSETS = ["USDC", "USDT"];
1847
1781
  function AdvancedSettings({
1848
1782
  settings,
1849
1783
  onChange,
1850
- chains
1784
+ chains,
1785
+ providers,
1786
+ onConnectNewAccount,
1787
+ connectingNewAccount
1851
1788
  }) {
1852
1789
  const { tokens } = useSwypeConfig();
1853
1790
  const [open, setOpen] = useState(false);
1791
+ const [showProviders, setShowProviders] = useState(false);
1854
1792
  return /* @__PURE__ */ jsxs("div", { style: { marginTop: "12px" }, children: [
1855
1793
  /* @__PURE__ */ jsxs(
1856
1794
  "button",
@@ -1954,7 +1892,7 @@ function AdvancedSettings({
1954
1892
  );
1955
1893
  }) })
1956
1894
  ] }),
1957
- chains.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
1895
+ chains.length > 0 && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "14px" }, children: [
1958
1896
  /* @__PURE__ */ jsx(
1959
1897
  "label",
1960
1898
  {
@@ -1997,7 +1935,119 @@ function AdvancedSettings({
1997
1935
  chain.id
1998
1936
  );
1999
1937
  }) })
2000
- ] })
1938
+ ] }),
1939
+ /* @__PURE__ */ jsx("div", { children: !showProviders ? /* @__PURE__ */ jsxs(
1940
+ "button",
1941
+ {
1942
+ onClick: () => setShowProviders(true),
1943
+ disabled: connectingNewAccount,
1944
+ style: {
1945
+ display: "flex",
1946
+ alignItems: "center",
1947
+ gap: "6px",
1948
+ background: tokens.bgCard,
1949
+ border: `1px dashed ${tokens.border}`,
1950
+ borderRadius: "999px",
1951
+ padding: "10px 14px",
1952
+ width: "100%",
1953
+ cursor: connectingNewAccount ? "not-allowed" : "pointer",
1954
+ color: tokens.textSecondary,
1955
+ fontFamily: "inherit",
1956
+ fontSize: "0.825rem",
1957
+ fontWeight: 500,
1958
+ outline: "none",
1959
+ opacity: connectingNewAccount ? 0.5 : 1,
1960
+ transition: "opacity 0.1s ease"
1961
+ },
1962
+ children: [
1963
+ /* @__PURE__ */ jsx(
1964
+ "svg",
1965
+ {
1966
+ width: "14",
1967
+ height: "14",
1968
+ viewBox: "0 0 24 24",
1969
+ fill: "none",
1970
+ children: /* @__PURE__ */ jsx(
1971
+ "path",
1972
+ {
1973
+ d: "M12 5v14M5 12h14",
1974
+ stroke: tokens.textMuted,
1975
+ strokeWidth: "2",
1976
+ strokeLinecap: "round"
1977
+ }
1978
+ )
1979
+ }
1980
+ ),
1981
+ "Connect new account"
1982
+ ]
1983
+ }
1984
+ ) : /* @__PURE__ */ jsxs("div", { children: [
1985
+ /* @__PURE__ */ jsxs(
1986
+ "div",
1987
+ {
1988
+ style: {
1989
+ display: "flex",
1990
+ alignItems: "center",
1991
+ justifyContent: "space-between",
1992
+ marginBottom: "8px"
1993
+ },
1994
+ children: [
1995
+ /* @__PURE__ */ jsx(
1996
+ "label",
1997
+ {
1998
+ style: {
1999
+ fontSize: "0.7rem",
2000
+ fontWeight: 600,
2001
+ color: tokens.textMuted,
2002
+ textTransform: "uppercase",
2003
+ letterSpacing: "0.05em"
2004
+ },
2005
+ children: "Select provider"
2006
+ }
2007
+ ),
2008
+ /* @__PURE__ */ jsx(
2009
+ "button",
2010
+ {
2011
+ onClick: () => setShowProviders(false),
2012
+ style: {
2013
+ background: "transparent",
2014
+ border: "none",
2015
+ cursor: "pointer",
2016
+ color: tokens.textMuted,
2017
+ fontSize: "0.75rem",
2018
+ fontFamily: "inherit",
2019
+ outline: "none",
2020
+ padding: "2px 4px"
2021
+ },
2022
+ children: "Cancel"
2023
+ }
2024
+ )
2025
+ ]
2026
+ }
2027
+ ),
2028
+ /* @__PURE__ */ jsx(
2029
+ "div",
2030
+ {
2031
+ style: {
2032
+ display: "flex",
2033
+ flexDirection: "column",
2034
+ gap: "6px"
2035
+ },
2036
+ children: providers.map((p) => /* @__PURE__ */ jsx(
2037
+ ProviderCard,
2038
+ {
2039
+ provider: p,
2040
+ selected: false,
2041
+ onClick: () => {
2042
+ onConnectNewAccount(p.id);
2043
+ setShowProviders(false);
2044
+ }
2045
+ },
2046
+ p.id
2047
+ ))
2048
+ }
2049
+ )
2050
+ ] }) })
2001
2051
  ]
2002
2052
  }
2003
2053
  )
@@ -2516,6 +2566,11 @@ function SwypePayment({
2516
2566
  pollingTransferIdRef.current = null;
2517
2567
  mobileSigningTransferIdRef.current = null;
2518
2568
  }, [logout, polling, depositAmount]);
2569
+ const handleConnectNewAccount = (providerId) => {
2570
+ setSelectedProviderId(providerId);
2571
+ setSelectedAccountId(null);
2572
+ setConnectingNewAccount(true);
2573
+ };
2519
2574
  const cardStyle = {
2520
2575
  background: tokens.bgCard,
2521
2576
  borderRadius: tokens.radiusLg,
@@ -2887,6 +2942,7 @@ function SwypePayment({
2887
2942
  if (step === "ready") {
2888
2943
  const parsedAmount = parseFloat(amount);
2889
2944
  const canPay = !isNaN(parsedAmount) && parsedAmount >= MIN_SEND_AMOUNT_USD && !!sourceId && !loadingData;
2945
+ const noAccounts = !loadingData && accounts.length === 0;
2890
2946
  return /* @__PURE__ */ jsxs("div", { style: cardStyle, children: [
2891
2947
  /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
2892
2948
  stepBadge("Review & pay"),
@@ -3017,30 +3073,23 @@ function SwypePayment({
3017
3073
  },
3018
3074
  children: [
3019
3075
  /* @__PURE__ */ jsx("span", { children: "From" }),
3020
- /* @__PURE__ */ jsx(
3021
- FundingSourceDropdown,
3076
+ noAccounts ? /* @__PURE__ */ jsx("span", { style: { fontWeight: 500, color: tokens.textMuted }, children: "New account" }) : /* @__PURE__ */ jsx(
3077
+ AccountDropdown,
3022
3078
  {
3023
3079
  accounts,
3024
- providers,
3025
3080
  selectedAccountId,
3026
3081
  selectedWalletId,
3027
- connectingNewAccount,
3028
- onSelectAccount: (id) => {
3082
+ onSelect: (id) => {
3029
3083
  setSelectedAccountId(id);
3030
3084
  setSelectedWalletId(null);
3031
3085
  setConnectingNewAccount(false);
3032
3086
  setSelectedProviderId(null);
3033
3087
  },
3034
- onSelectWallet: (accountId, walletId) => {
3088
+ onWalletSelect: (accountId, walletId) => {
3035
3089
  setSelectedAccountId(accountId);
3036
3090
  setSelectedWalletId(walletId);
3037
3091
  setConnectingNewAccount(false);
3038
3092
  setSelectedProviderId(null);
3039
- },
3040
- onConnectNewAccount: (providerId) => {
3041
- setSelectedProviderId(providerId);
3042
- setSelectedAccountId(null);
3043
- setConnectingNewAccount(true);
3044
3093
  }
3045
3094
  }
3046
3095
  )
@@ -3050,6 +3099,46 @@ function SwypePayment({
3050
3099
  ]
3051
3100
  }
3052
3101
  ),
3102
+ noAccounts && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
3103
+ /* @__PURE__ */ jsx(
3104
+ "label",
3105
+ {
3106
+ style: {
3107
+ display: "block",
3108
+ fontSize: "0.8rem",
3109
+ color: tokens.textMuted,
3110
+ marginBottom: "8px",
3111
+ fontWeight: 500,
3112
+ textTransform: "uppercase",
3113
+ letterSpacing: "0.05em"
3114
+ },
3115
+ children: "Connect a wallet"
3116
+ }
3117
+ ),
3118
+ /* @__PURE__ */ jsx(
3119
+ "div",
3120
+ {
3121
+ style: {
3122
+ display: "flex",
3123
+ flexDirection: "column",
3124
+ gap: "8px"
3125
+ },
3126
+ children: providers.map((p) => /* @__PURE__ */ jsx(
3127
+ ProviderCard,
3128
+ {
3129
+ provider: p,
3130
+ selected: selectedProviderId === p.id,
3131
+ onClick: () => {
3132
+ setSelectedProviderId(p.id);
3133
+ setSelectedAccountId(null);
3134
+ setConnectingNewAccount(false);
3135
+ }
3136
+ },
3137
+ p.id
3138
+ ))
3139
+ }
3140
+ )
3141
+ ] }),
3053
3142
  /* @__PURE__ */ jsxs(
3054
3143
  "button",
3055
3144
  {
@@ -3062,12 +3151,15 @@ function SwypePayment({
3062
3151
  ]
3063
3152
  }
3064
3153
  ),
3065
- /* @__PURE__ */ jsx(
3154
+ !noAccounts && /* @__PURE__ */ jsx(
3066
3155
  AdvancedSettings,
3067
3156
  {
3068
3157
  settings: advancedSettings,
3069
3158
  onChange: setAdvancedSettings,
3070
- chains
3159
+ chains,
3160
+ providers,
3161
+ onConnectNewAccount: handleConnectNewAccount,
3162
+ connectingNewAccount
3071
3163
  }
3072
3164
  )
3073
3165
  ] })