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