@cookill/wallet-adapter 3.1.6 → 3.1.7
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/README.md +36 -26
- package/dist/react.cjs +94 -109
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +94 -109
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,9 +23,38 @@ function App() {
|
|
|
23
23
|
}
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
`WalletProvider` renders a built-in connect modal automatically. On desktop it opens centered; on mobile it slides up as a sheet.
|
|
26
|
+
`WalletProvider` renders a built-in connect modal automatically. On desktop it opens as a centered dialog; on mobile it slides up as a bottom sheet with swipe-to-dismiss.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
## Built-in Modal
|
|
29
|
+
|
|
30
|
+
The built-in modal is rendered inside `WalletProvider` and includes:
|
|
31
|
+
|
|
32
|
+
- **Extension tab** — detects Sheep Wallet, shows install link if not found, triggers `window.rialo.connect()` on click
|
|
33
|
+
- **Scan to Connect tab** — generates a `rialo-wc://` QR code for cross-device pairing
|
|
34
|
+
- **Responsive layout** — centered dialog on desktop, slide-up sheet on mobile
|
|
35
|
+
- **Auto-close** — closes automatically after successful connection
|
|
36
|
+
|
|
37
|
+
Control it programmatically:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
const { openModal, closeModal } = useWallet();
|
|
41
|
+
|
|
42
|
+
// Open the built-in modal
|
|
43
|
+
openModal();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or use `ConnectButton` which handles everything:
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
<ConnectButton
|
|
50
|
+
connectLabel="Connect Wallet"
|
|
51
|
+
disconnectLabel="Disconnect"
|
|
52
|
+
showAddress={true}
|
|
53
|
+
showBalance={false}
|
|
54
|
+
/>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
> When the extension is installed, `ConnectButton` calls `connect()` directly without opening the modal. When not installed, it opens the modal with a download link.
|
|
29
58
|
|
|
30
59
|
## React Hooks
|
|
31
60
|
|
|
@@ -53,7 +82,7 @@ const {
|
|
|
53
82
|
sendTransaction, // (tx) => Promise<TransactionResult>
|
|
54
83
|
signAndSendTransaction, // (tx) => Promise<TransactionResult>
|
|
55
84
|
|
|
56
|
-
//
|
|
85
|
+
// Modal control
|
|
57
86
|
openModal, // () => void
|
|
58
87
|
closeModal, // () => void
|
|
59
88
|
} = useWallet();
|
|
@@ -92,9 +121,9 @@ const { positions, credits, hasCredits, createPosition, sendGasless, refresh } =
|
|
|
92
121
|
const { scanURI, status, generateQR, approveSession, rejectSession } = useScanConnect();
|
|
93
122
|
```
|
|
94
123
|
|
|
95
|
-
## Custom Modal
|
|
124
|
+
## Custom Modal (Optional)
|
|
96
125
|
|
|
97
|
-
|
|
126
|
+
If you need full control over the UI, build your own modal using the hooks:
|
|
98
127
|
|
|
99
128
|
```tsx
|
|
100
129
|
import { useConnectWallet, useScanConnect, isInstalled } from '@cookill/wallet-adapter/react';
|
|
@@ -136,7 +165,7 @@ function MyConnectModal({ open, onClose }) {
|
|
|
136
165
|
```
|
|
137
166
|
|
|
138
167
|
Key points:
|
|
139
|
-
-
|
|
168
|
+
- `connect()` calls `window.rialo.connect()` which triggers the extension's approval popup
|
|
140
169
|
- The `connect()` call has a 20-second timeout to prevent dApp freezes
|
|
141
170
|
- Use `isInstalled()` to check if the extension is present before connecting
|
|
142
171
|
|
|
@@ -163,20 +192,6 @@ await wallet.signAndSendTransaction({
|
|
|
163
192
|
await wallet.disconnect();
|
|
164
193
|
```
|
|
165
194
|
|
|
166
|
-
## ConnectButton
|
|
167
|
-
|
|
168
|
-
```tsx
|
|
169
|
-
<ConnectButton
|
|
170
|
-
connectLabel="Connect Wallet"
|
|
171
|
-
disconnectLabel="Disconnect"
|
|
172
|
-
showAddress={true}
|
|
173
|
-
showBalance={false}
|
|
174
|
-
showFeatures={false}
|
|
175
|
-
/>
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
> **Note:** When the extension is installed, `ConnectButton` calls `connect()` directly (no modal). When not installed, it opens the built-in modal with a download link.
|
|
179
|
-
|
|
180
195
|
## WalletProvider Props
|
|
181
196
|
|
|
182
197
|
| Prop | Type | Default | Description |
|
|
@@ -246,14 +261,9 @@ import {
|
|
|
246
261
|
|
|
247
262
|
- All provider calls have a 20-second timeout to prevent dApp freezes
|
|
248
263
|
- `autoConnect` uses `checkSession()` — never triggers a user-facing popup
|
|
249
|
-
- The built-in modal
|
|
264
|
+
- The built-in modal uses a sibling DOM architecture (backdrop and content are separate elements) to prevent click events from interfering with tab switching or button interactions
|
|
250
265
|
- `ConnectButton` bypasses the modal when the extension is installed
|
|
251
266
|
|
|
252
|
-
## Known Issues
|
|
253
|
-
|
|
254
|
-
1. **Built-in modal tab switching** — Clicking "Scan to Connect" tab may close the modal due to event propagation. Workaround: use a custom modal.
|
|
255
|
-
2. **Built-in modal connect button** — May not trigger the extension popup in some environments. Workaround: use `connect()` directly.
|
|
256
|
-
|
|
257
267
|
## License
|
|
258
268
|
|
|
259
269
|
MIT
|
package/dist/react.cjs
CHANGED
|
@@ -1528,124 +1528,111 @@ function WalletModal({ scanConnectRelay, dispatch }) {
|
|
|
1528
1528
|
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 6 12 12" })
|
|
1529
1529
|
] });
|
|
1530
1530
|
if (isMobile) {
|
|
1531
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1531
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "fixed", inset: 0, zIndex: 9999 }, children: [
|
|
1532
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1533
|
+
"div",
|
|
1534
|
+
{
|
|
1535
|
+
style: {
|
|
1536
|
+
position: "absolute",
|
|
1537
|
+
inset: 0,
|
|
1538
|
+
backgroundColor: "rgba(0,0,0,0.6)",
|
|
1539
|
+
backdropFilter: "blur(8px)",
|
|
1540
|
+
WebkitBackdropFilter: "blur(8px)"
|
|
1541
|
+
},
|
|
1542
|
+
onClick: closeModal
|
|
1543
|
+
}
|
|
1544
|
+
),
|
|
1545
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1546
|
+
"div",
|
|
1547
|
+
{
|
|
1548
|
+
onTouchStart: handleTouchStart,
|
|
1549
|
+
onTouchMove: handleTouchMove,
|
|
1550
|
+
onTouchEnd: handleTouchEnd,
|
|
1551
|
+
style: {
|
|
1552
|
+
position: "fixed",
|
|
1553
|
+
bottom: 0,
|
|
1554
|
+
left: 0,
|
|
1555
|
+
right: 0,
|
|
1556
|
+
backgroundColor: "#011B29",
|
|
1557
|
+
borderTopLeftRadius: "24px",
|
|
1558
|
+
borderTopRightRadius: "24px",
|
|
1559
|
+
padding: "0 20px 28px",
|
|
1560
|
+
maxHeight: "85vh",
|
|
1561
|
+
overflow: "auto",
|
|
1562
|
+
boxShadow: "0 -8px 40px rgba(0,0,0,0.5)",
|
|
1563
|
+
transform: `translateY(${dragY}px)`,
|
|
1564
|
+
transition: isDragging ? "none" : "transform 0.3s cubic-bezier(0.4,0,0.2,1)",
|
|
1565
|
+
animation: isDragging ? "none" : "walletModalSlideUp 0.35s cubic-bezier(0.4,0,0.2,1)"
|
|
1566
|
+
},
|
|
1567
|
+
children: [
|
|
1568
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", justifyContent: "center", padding: "12px 0 16px", cursor: "grab", touchAction: "none" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: "36px", height: "4px", borderRadius: "2px", backgroundColor: "rgba(255,255,255,0.12)" } }) }),
|
|
1569
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "20px" }, children: [
|
|
1570
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { color: "#fff", fontSize: "18px", fontWeight: 600, margin: 0, letterSpacing: "-0.01em" }, children: "Connect Wallet" }),
|
|
1571
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: closeModal, style: closeBtn, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) })
|
|
1572
|
+
] }),
|
|
1573
|
+
renderContent()
|
|
1574
|
+
]
|
|
1575
|
+
}
|
|
1576
|
+
),
|
|
1577
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
1578
|
+
@keyframes walletModalSlideUp {
|
|
1579
|
+
from { transform: translateY(100%); }
|
|
1580
|
+
to { transform: translateY(0); }
|
|
1581
|
+
}
|
|
1582
|
+
@keyframes walletModalPulse {
|
|
1583
|
+
0%, 100% { opacity: 1; }
|
|
1584
|
+
50% { opacity: 0.3; }
|
|
1585
|
+
}
|
|
1586
|
+
` })
|
|
1587
|
+
] });
|
|
1588
|
+
}
|
|
1589
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { position: "fixed", inset: 0, zIndex: 9999 }, children: [
|
|
1590
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1532
1591
|
"div",
|
|
1533
1592
|
{
|
|
1534
1593
|
style: {
|
|
1535
|
-
position: "
|
|
1594
|
+
position: "absolute",
|
|
1536
1595
|
inset: 0,
|
|
1537
|
-
zIndex: 9999,
|
|
1538
1596
|
backgroundColor: "rgba(0,0,0,0.6)",
|
|
1539
1597
|
backdropFilter: "blur(8px)",
|
|
1540
1598
|
WebkitBackdropFilter: "blur(8px)"
|
|
1541
1599
|
},
|
|
1542
|
-
onClick:
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1600
|
+
onClick: closeModal
|
|
1601
|
+
}
|
|
1602
|
+
),
|
|
1603
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1604
|
+
position: "fixed",
|
|
1605
|
+
inset: 0,
|
|
1606
|
+
display: "flex",
|
|
1607
|
+
alignItems: "center",
|
|
1608
|
+
justifyContent: "center",
|
|
1609
|
+
pointerEvents: "none"
|
|
1610
|
+
}, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1611
|
+
"div",
|
|
1612
|
+
{
|
|
1613
|
+
style: {
|
|
1614
|
+
pointerEvents: "auto",
|
|
1615
|
+
backgroundColor: "#011B29",
|
|
1616
|
+
borderRadius: "20px",
|
|
1617
|
+
padding: "24px",
|
|
1618
|
+
width: "100%",
|
|
1619
|
+
maxWidth: "400px",
|
|
1620
|
+
margin: "16px",
|
|
1621
|
+
boxShadow: "0 25px 60px -12px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05)",
|
|
1622
|
+
maxHeight: "90vh",
|
|
1623
|
+
overflow: "auto",
|
|
1624
|
+
animation: "walletModalFadeIn 0.25s cubic-bezier(0.4,0,0.2,1)"
|
|
1547
1625
|
},
|
|
1548
1626
|
children: [
|
|
1549
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1550
|
-
"
|
|
1551
|
-
{
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
onTouchEnd: handleTouchEnd,
|
|
1555
|
-
onClick: stop,
|
|
1556
|
-
style: {
|
|
1557
|
-
position: "fixed",
|
|
1558
|
-
bottom: 0,
|
|
1559
|
-
left: 0,
|
|
1560
|
-
right: 0,
|
|
1561
|
-
backgroundColor: "#011B29",
|
|
1562
|
-
borderTopLeftRadius: "24px",
|
|
1563
|
-
borderTopRightRadius: "24px",
|
|
1564
|
-
padding: "0 20px 28px",
|
|
1565
|
-
maxHeight: "85vh",
|
|
1566
|
-
overflow: "auto",
|
|
1567
|
-
boxShadow: "0 -8px 40px rgba(0,0,0,0.5)",
|
|
1568
|
-
transform: `translateY(${dragY}px)`,
|
|
1569
|
-
transition: isDragging ? "none" : "transform 0.3s cubic-bezier(0.4,0,0.2,1)",
|
|
1570
|
-
animation: isDragging ? "none" : "walletModalSlideUp 0.35s cubic-bezier(0.4,0,0.2,1)"
|
|
1571
|
-
},
|
|
1572
|
-
children: [
|
|
1573
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", justifyContent: "center", padding: "12px 0 16px", cursor: "grab", touchAction: "none" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: "36px", height: "4px", borderRadius: "2px", backgroundColor: "rgba(255,255,255,0.12)" } }) }),
|
|
1574
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "20px" }, children: [
|
|
1575
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { color: "#fff", fontSize: "18px", fontWeight: 600, margin: 0, letterSpacing: "-0.01em" }, children: "Connect Wallet" }),
|
|
1576
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: (e) => {
|
|
1577
|
-
stop(e);
|
|
1578
|
-
closeModal();
|
|
1579
|
-
}, style: closeBtn, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) })
|
|
1580
|
-
] }),
|
|
1581
|
-
renderContent()
|
|
1582
|
-
]
|
|
1583
|
-
}
|
|
1584
|
-
),
|
|
1585
|
-
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
1586
|
-
@keyframes walletModalSlideUp {
|
|
1587
|
-
from { transform: translateY(100%); }
|
|
1588
|
-
to { transform: translateY(0); }
|
|
1589
|
-
}
|
|
1590
|
-
@keyframes walletModalPulse {
|
|
1591
|
-
0%, 100% { opacity: 1; }
|
|
1592
|
-
50% { opacity: 0.3; }
|
|
1593
|
-
}
|
|
1594
|
-
` })
|
|
1627
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "20px" }, children: [
|
|
1628
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { color: "#fff", fontSize: "18px", fontWeight: 600, margin: 0, letterSpacing: "-0.01em" }, children: "Connect Wallet" }),
|
|
1629
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: closeModal, style: closeBtn, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) })
|
|
1630
|
+
] }),
|
|
1631
|
+
renderContent()
|
|
1595
1632
|
]
|
|
1596
1633
|
}
|
|
1597
|
-
)
|
|
1598
|
-
|
|
1599
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1600
|
-
"div",
|
|
1601
|
-
{
|
|
1602
|
-
style: {
|
|
1603
|
-
position: "fixed",
|
|
1604
|
-
inset: 0,
|
|
1605
|
-
zIndex: 9999,
|
|
1606
|
-
display: "flex",
|
|
1607
|
-
alignItems: "center",
|
|
1608
|
-
justifyContent: "center",
|
|
1609
|
-
backgroundColor: "rgba(0,0,0,0.6)",
|
|
1610
|
-
backdropFilter: "blur(8px)",
|
|
1611
|
-
WebkitBackdropFilter: "blur(8px)"
|
|
1612
|
-
},
|
|
1613
|
-
onClick: (e) => {
|
|
1614
|
-
if (e.target === e.currentTarget) closeModal();
|
|
1615
|
-
},
|
|
1616
|
-
onPointerDown: (e) => {
|
|
1617
|
-
if (e.target !== e.currentTarget) e.stopPropagation();
|
|
1618
|
-
},
|
|
1619
|
-
children: [
|
|
1620
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1621
|
-
"div",
|
|
1622
|
-
{
|
|
1623
|
-
onClick: stop,
|
|
1624
|
-
style: {
|
|
1625
|
-
backgroundColor: "#011B29",
|
|
1626
|
-
borderRadius: "20px",
|
|
1627
|
-
padding: "24px",
|
|
1628
|
-
width: "100%",
|
|
1629
|
-
maxWidth: "400px",
|
|
1630
|
-
margin: "16px",
|
|
1631
|
-
boxShadow: "0 25px 60px -12px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05)",
|
|
1632
|
-
maxHeight: "90vh",
|
|
1633
|
-
overflow: "auto",
|
|
1634
|
-
animation: "walletModalFadeIn 0.25s cubic-bezier(0.4,0,0.2,1)"
|
|
1635
|
-
},
|
|
1636
|
-
children: [
|
|
1637
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "20px" }, children: [
|
|
1638
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { color: "#fff", fontSize: "18px", fontWeight: 600, margin: 0, letterSpacing: "-0.01em" }, children: "Connect Wallet" }),
|
|
1639
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: (e) => {
|
|
1640
|
-
stop(e);
|
|
1641
|
-
closeModal();
|
|
1642
|
-
}, style: closeBtn, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon, {}) })
|
|
1643
|
-
] }),
|
|
1644
|
-
renderContent()
|
|
1645
|
-
]
|
|
1646
|
-
}
|
|
1647
|
-
),
|
|
1648
|
-
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
1634
|
+
) }),
|
|
1635
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
1649
1636
|
@keyframes walletModalFadeIn {
|
|
1650
1637
|
from { opacity: 0; transform: scale(0.97) translateY(8px); }
|
|
1651
1638
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
@@ -1655,9 +1642,7 @@ function WalletModal({ scanConnectRelay, dispatch }) {
|
|
|
1655
1642
|
50% { opacity: 0.3; }
|
|
1656
1643
|
}
|
|
1657
1644
|
` })
|
|
1658
|
-
|
|
1659
|
-
}
|
|
1660
|
-
);
|
|
1645
|
+
] });
|
|
1661
1646
|
}
|
|
1662
1647
|
function ConnectButton({
|
|
1663
1648
|
connectLabel = "Connect Wallet",
|