@reclack/walletkit 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +392 -2
- package/assets/backpack.webp +0 -0
- package/assets/berasig.webp +0 -0
- package/assets/bestwallet.webp +0 -0
- package/assets/bifrostwallet.webp +0 -0
- package/assets/binance.webp +0 -0
- package/assets/bitcoincom.webp +0 -0
- package/assets/bitget.webp +0 -0
- package/assets/bitpay.webp +0 -0
- package/assets/bitski.webp +0 -0
- package/assets/bitverse.webp +0 -0
- package/assets/blockchaincom.webp +0 -0
- package/assets/brave.webp +0 -0
- package/assets/bybit.webp +0 -0
- package/assets/clv.webp +0 -0
- package/assets/coin98.webp +0 -0
- package/assets/coinbase.webp +0 -0
- package/assets/compass.webp +0 -0
- package/assets/core.webp +0 -0
- package/assets/crypto_com.webp +0 -0
- package/assets/ctrl.webp +0 -0
- package/assets/dawn.webp +0 -0
- package/assets/desig.webp +0 -0
- package/assets/enkrypt.webp +0 -0
- package/assets/exodus.webp +0 -0
- package/assets/foxwallet.webp +0 -0
- package/assets/frame.webp +0 -0
- package/assets/frontier.webp +0 -0
- package/assets/gate.webp +0 -0
- package/assets/gemini.webp +0 -0
- package/assets/imtoken.webp +0 -0
- package/assets/iopay.webp +0 -0
- package/assets/kaia.webp +0 -0
- package/assets/kaikas.webp +0 -0
- package/assets/kraken.webp +0 -0
- package/assets/kresuswallet.webp +0 -0
- package/assets/ledger.webp +0 -0
- package/assets/magiceden.webp +0 -0
- package/assets/meco.webp +0 -0
- package/assets/metamask.webp +0 -0
- package/assets/mew.webp +0 -0
- package/assets/nest.webp +0 -0
- package/assets/nova.webp +0 -0
- package/assets/okto.webp +0 -0
- package/assets/okx.webp +0 -0
- package/assets/oneinch.webp +0 -0
- package/assets/onekey.webp +0 -0
- package/assets/phantom.webp +0 -0
- package/assets/rabby.webp +0 -0
- package/assets/rainbow.webp +0 -0
- package/assets/ramper.webp +0 -0
- package/assets/ready.webp +0 -0
- package/assets/ronin.webp +0 -0
- package/assets/safe.webp +0 -0
- package/assets/safepal.webp +0 -0
- package/assets/solflare.webp +0 -0
- package/assets/subwallet.webp +0 -0
- package/assets/taho.webp +0 -0
- package/assets/talisman.webp +0 -0
- package/assets/tokenary.webp +0 -0
- package/assets/tokenpocket.webp +0 -0
- package/assets/trust-wallet.webp +0 -0
- package/assets/uniswap.webp +0 -0
- package/assets/universalprofiles.webp +0 -0
- package/assets/valora.webp +0 -0
- package/assets/wigwam.webp +0 -0
- package/assets/xportal.webp +0 -0
- package/assets/zeal.webp +0 -0
- package/assets/zerion.webp +0 -0
- package/custom-elements.json +207 -0
- package/dist/abi.d.ts +21 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +50 -0
- package/dist/abi.js.map +1 -0
- package/dist/address.d.ts +15 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.js +25 -0
- package/dist/address.js.map +1 -0
- package/dist/balance.d.ts +78 -0
- package/dist/balance.d.ts.map +1 -0
- package/dist/balance.js +146 -0
- package/dist/balance.js.map +1 -0
- package/dist/base58.d.ts +15 -0
- package/dist/base58.d.ts.map +1 -0
- package/dist/base58.js +52 -0
- package/dist/base58.js.map +1 -0
- package/dist/catalog-fetch.d.ts +18 -0
- package/dist/catalog-fetch.d.ts.map +1 -0
- package/dist/catalog-fetch.js +85 -0
- package/dist/catalog-fetch.js.map +1 -0
- package/dist/catalog.d.ts +57 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +80 -0
- package/dist/catalog.js.map +1 -0
- package/dist/chains.d.ts +32 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +103 -0
- package/dist/chains.js.map +1 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +44 -0
- package/dist/config.js.map +1 -0
- package/dist/deep-links.d.ts +22 -0
- package/dist/deep-links.d.ts.map +1 -0
- package/dist/deep-links.js +201 -0
- package/dist/deep-links.js.map +1 -0
- package/dist/device.d.ts +23 -0
- package/dist/device.d.ts.map +1 -0
- package/dist/device.js +59 -0
- package/dist/device.js.map +1 -0
- package/dist/element/attributes.d.ts +48 -0
- package/dist/element/element.d.ts +92 -0
- package/dist/element/index.d.ts +4 -0
- package/dist/element/props.d.ts +67 -0
- package/dist/element/ui/app.d.ts +22 -0
- package/dist/element/ui/assets.d.ts +7 -0
- package/dist/element/ui/qr.d.ts +16 -0
- package/dist/element/ui/use-handheld.d.ts +8 -0
- package/dist/element/ui/wallet-connect-panel.d.ts +26 -0
- package/dist/element/ui/wallet-dialog.d.ts +37 -0
- package/dist/element/ui/wallet-list.d.ts +26 -0
- package/dist/element/ui/wallet-mark.d.ts +15 -0
- package/dist/element.js +2079 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +64 -0
- package/dist/errors.js.map +1 -0
- package/dist/evm.d.ts +49 -0
- package/dist/evm.d.ts.map +1 -0
- package/dist/evm.js +217 -0
- package/dist/evm.js.map +1 -0
- package/dist/icons.d.ts +22 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +98 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/intent.d.ts +60 -0
- package/dist/intent.d.ts.map +1 -0
- package/dist/intent.js +2 -0
- package/dist/intent.js.map +1 -0
- package/dist/kit.d.ts +124 -0
- package/dist/kit.d.ts.map +1 -0
- package/dist/kit.js +362 -0
- package/dist/kit.js.map +1 -0
- package/dist/svm.d.ts +45 -0
- package/dist/svm.d.ts.map +1 -0
- package/dist/svm.js +201 -0
- package/dist/svm.js.map +1 -0
- package/dist/theme.d.ts +101 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +217 -0
- package/dist/theme.js.map +1 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/wallet-standard.d.ts +77 -0
- package/dist/wallet-standard.d.ts.map +1 -0
- package/dist/wallet-standard.js +89 -0
- package/dist/wallet-standard.js.map +1 -0
- package/dist/walletconnect.d.ts +74 -0
- package/dist/walletconnect.d.ts.map +1 -0
- package/dist/walletconnect.js +133 -0
- package/dist/walletconnect.js.map +1 -0
- package/package.json +71 -3
- package/vscode.html-custom-data.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Reclack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,393 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @reclack/walletkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A wallet picker and connection layer for the web. Connect a wallet, read an
|
|
4
|
+
address, read a balance, on EVM chains and on Solana.
|
|
5
|
+
|
|
6
|
+
- **Works with any framework.** The picker is a custom element, and the
|
|
7
|
+
connection layer is a plain object with `getState` and `subscribe`.
|
|
8
|
+
- **One dependency**, loaded only when someone picks a wallet that needs it.
|
|
9
|
+
- **Nothing to configure.** Endpoints, the wallet catalogue and relay pairing
|
|
10
|
+
all ship with sensible defaults.
|
|
11
|
+
- **Typed**, and safe to import in a server render.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @reclack/walletkit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<script type="module">
|
|
21
|
+
import '@reclack/walletkit/element'
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<reclack-connect variant="modal" family="evm"></reclack-connect>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Importing `@reclack/walletkit/element` defines the tag. With no bundler, point
|
|
28
|
+
a module script at a CDN instead:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<script type="module" src="https://esm.sh/@reclack/walletkit/element"></script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
document.querySelector('reclack-connect')
|
|
36
|
+
.addEventListener('connect', (event) => {
|
|
37
|
+
console.log(event.detail.address)
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or, if you only need a value and not a component:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { connectWallet } from '@reclack/walletkit/element'
|
|
45
|
+
|
|
46
|
+
const { address } = await connectWallet({ intent: ['address'], family: 'evm' })
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Your framework
|
|
50
|
+
|
|
51
|
+
### React, Next.js, Remix, React Router
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm install @reclack/walletkit @reclack/walletkit-react
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { ReclackConnect } from '@reclack/walletkit-react'
|
|
59
|
+
|
|
60
|
+
<ReclackConnect
|
|
61
|
+
variant="modal"
|
|
62
|
+
family="evm"
|
|
63
|
+
chainId={8453}
|
|
64
|
+
intent={['address']}
|
|
65
|
+
onConnect={({ address }) => setAddress(address)}
|
|
66
|
+
onCancel={() => setOpen(false)}
|
|
67
|
+
/>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
In Next.js, add `'use client'` to the file that renders it. Importing
|
|
71
|
+
`@reclack/walletkit` itself on the server is fine.
|
|
72
|
+
|
|
73
|
+
### Preact
|
|
74
|
+
|
|
75
|
+
The React package, unchanged. `preact/compat` handles the rest.
|
|
76
|
+
|
|
77
|
+
### Vue
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
npm install @reclack/walletkit @reclack/walletkit-vue
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```vue
|
|
84
|
+
<script setup>
|
|
85
|
+
import { ReclackConnect } from '@reclack/walletkit-vue'
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<template>
|
|
89
|
+
<ReclackConnect variant="modal" family="evm" :chain-id="8453" @connect="onConnect" />
|
|
90
|
+
</template>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Angular, Svelte, SolidJS, plain HTML
|
|
94
|
+
|
|
95
|
+
No wrapper needed. Each binds properties and listens for events on a custom
|
|
96
|
+
element natively.
|
|
97
|
+
|
|
98
|
+
```html
|
|
99
|
+
<!-- Angular, with CUSTOM_ELEMENTS_SCHEMA on the component or module -->
|
|
100
|
+
<reclack-connect family="evm" (connect)="onConnect($event)"></reclack-connect>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```svelte
|
|
104
|
+
<!-- Svelte -->
|
|
105
|
+
<reclack-connect family="evm" on:connect={(e) => take(e.detail)} />
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```jsx
|
|
109
|
+
/* SolidJS */
|
|
110
|
+
<reclack-connect family="evm" on:connect={(e) => take(e.detail)} />
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Editors and Vue's language server read the `custom-elements.json` shipped in
|
|
114
|
+
this package, so the tag and its attributes autocomplete without a wrapper.
|
|
115
|
+
`vscode.html-custom-data.json` does the same for plain HTML.
|
|
116
|
+
|
|
117
|
+
## The element
|
|
118
|
+
|
|
119
|
+
### Attributes
|
|
120
|
+
|
|
121
|
+
| Attribute | Values | Default | What it does |
|
|
122
|
+
| --- | --- | --- | --- |
|
|
123
|
+
| `variant` | `inline`, `modal` | `inline` | A list on the page, or the picker over it |
|
|
124
|
+
| `family` | `evm`, `svm` | `evm` | Which wallets to offer |
|
|
125
|
+
| `chain-id` | number | none | Require this chain, switching the wallet if needed |
|
|
126
|
+
| `intent` | `address`, `balance`, comma separated | `address` | What to return |
|
|
127
|
+
| `keep-alive` | present or absent | absent | Stay connected after resolving |
|
|
128
|
+
| `theme-mode` | `light`, `dark`, `system` | `system` | Which palette to wear |
|
|
129
|
+
| `brand` | `#rrggbb` | Reclack's | Your colour, worn by the primary action |
|
|
130
|
+
| `radius` | CSS length | `10px` | Corner radius |
|
|
131
|
+
| `font` | CSS font stack | inherited | Type |
|
|
132
|
+
| `asset-base` | URL path | `/images/` | Where the wallet logos are served from |
|
|
133
|
+
| `api-url` | URL | Reclack's | A different deployment, such as a sandbox |
|
|
134
|
+
|
|
135
|
+
### Properties
|
|
136
|
+
|
|
137
|
+
For anything an attribute cannot carry, set a property instead.
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
element.kit = sharedKit // share one kit, see below
|
|
141
|
+
element.theme = { mode: 'dark', brand: '#f60' }
|
|
142
|
+
element.request = { // an intent carrying assets
|
|
143
|
+
intent: ['address', 'balance'],
|
|
144
|
+
assets: [{ family: 'evm', chainId: 8453, token: USDC, decimals: 6 }],
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Events
|
|
149
|
+
|
|
150
|
+
| Event | Detail |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `connect` | `{ address, chainId, walletId, name, family, balances }` |
|
|
153
|
+
| `cancel` | none, the person closed the picker |
|
|
154
|
+
| `connect-error` | `{ message }` |
|
|
155
|
+
|
|
156
|
+
All three are composed, so a listener on an ancestor hears them through the
|
|
157
|
+
shadow boundary. It is `connect-error` rather than `error` because `error`
|
|
158
|
+
already means a resource failed to load.
|
|
159
|
+
|
|
160
|
+
The markup lives in a shadow root, so the picker cannot restyle your page and
|
|
161
|
+
your stylesheet cannot reach into it. Theme it with the attributes above, or
|
|
162
|
+
by setting any `--rkw-` token on the element.
|
|
163
|
+
|
|
164
|
+
`variant="modal"` is a native `<dialog>`, so focus trapping, Esc to close, an
|
|
165
|
+
inert background and a backdrop all come from the browser.
|
|
166
|
+
|
|
167
|
+
## The kit
|
|
168
|
+
|
|
169
|
+
The element makes its own kit, and you never have to touch one. Reach for the
|
|
170
|
+
kit directly when you want the wallet state without the picker, or when
|
|
171
|
+
several pickers should share one.
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { createWalletKit } from '@reclack/walletkit'
|
|
175
|
+
|
|
176
|
+
const kit = createWalletKit()
|
|
177
|
+
const stop = kit.subscribe(() => render(kit.getState()))
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
const { evm, svm, catalog, scheme, variables, handheld } = kit.getState()
|
|
182
|
+
evm.available // the wallets this browser has
|
|
183
|
+
evm.connected // { address, chainId, walletId, name } once one is
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
| Method | What it does |
|
|
187
|
+
| --- | --- |
|
|
188
|
+
| `getState()` | The whole state, as one object |
|
|
189
|
+
| `subscribe(fn)` | Calls `fn` on every change, returns an unsubscribe |
|
|
190
|
+
| `connectEvm(wallet)` / `connectSvm(wallet)` | Connect one from `available` |
|
|
191
|
+
| `connectRemote(wallet, chainId, onUri)` | Pair by QR code |
|
|
192
|
+
| `resolveIntent(family, request)` | Connect and return what you asked for |
|
|
193
|
+
| `readBalances(family, assets)` | Balances for a connected address |
|
|
194
|
+
| `ensureChain(chainId)` | Switch the wallet's chain, true if it is there |
|
|
195
|
+
| `setTheme(theme)` | Replace the theme, such as when branding loads |
|
|
196
|
+
| `disconnect(family?)` | Drop the session |
|
|
197
|
+
| `destroy()` | Release listeners |
|
|
198
|
+
|
|
199
|
+
`getState` and `subscribe` are all any framework needs:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
// React
|
|
203
|
+
const state = useSyncExternalStore(kit.subscribe, kit.getState, kit.getState)
|
|
204
|
+
|
|
205
|
+
// Vue
|
|
206
|
+
const state = shallowRef(kit.getState())
|
|
207
|
+
onMounted(() => kit.subscribe(() => { state.value = kit.getState() }))
|
|
208
|
+
|
|
209
|
+
// Svelte
|
|
210
|
+
const state = {
|
|
211
|
+
subscribe: (run) => (run(kit.getState()), kit.subscribe(() => run(kit.getState()))),
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Angular
|
|
215
|
+
readonly state = toSignal(
|
|
216
|
+
new Observable((s) => kit.subscribe(() => s.next(kit.getState()))),
|
|
217
|
+
)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Sharing one kit
|
|
221
|
+
|
|
222
|
+
Discovering wallets means a window listener and a catalogue fetch. A page with
|
|
223
|
+
several pickers should share a kit rather than run both twice.
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
element.kit = myKit
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Themes stay per element, so one kit can serve a light picker in a panel and a
|
|
230
|
+
dark one in a drawer.
|
|
231
|
+
|
|
232
|
+
### Options
|
|
233
|
+
|
|
234
|
+
Every one of these is an override. The defaults are what most integrations
|
|
235
|
+
want.
|
|
236
|
+
|
|
237
|
+
```ts
|
|
238
|
+
createWalletKit({
|
|
239
|
+
theme: { mode: 'system', brand: '#ff6600' },
|
|
240
|
+
assetBase: '/wallets/',
|
|
241
|
+
rpcUrls: { 8453: 'https://your-node.example' }, // worth setting, see Balances
|
|
242
|
+
svmRpcUrl: 'https://your-solana-node.example',
|
|
243
|
+
walletConnect: { projectId: 'your-project-id' },
|
|
244
|
+
apiUrl: 'https://api.reclack.com',
|
|
245
|
+
catalog: [], // supply the wallet list yourself instead of fetching it
|
|
246
|
+
})
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Intent
|
|
250
|
+
|
|
251
|
+
What you want back from connecting, as a list rather than a mode, because
|
|
252
|
+
these are not alternatives.
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
await kit.connectEvm(wallet)
|
|
256
|
+
|
|
257
|
+
const result = await kit.resolveIntent('evm', {
|
|
258
|
+
intent: ['address', 'balance'],
|
|
259
|
+
assets: [{ family: 'evm', chainId: 8453, token: USDC, decimals: 6 }],
|
|
260
|
+
keepAlive: false,
|
|
261
|
+
})
|
|
262
|
+
// { address, chainId, walletId, name, family, balances }
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
- `address` always comes back. Listing it says you want it handed to you.
|
|
266
|
+
- `balance` needs an asset to be a balance of. Asking without one throws.
|
|
267
|
+
- `keepAlive` holds the connection open and keeps following account and chain
|
|
268
|
+
changes. True for a checkout that signs later, false for a form that wanted
|
|
269
|
+
a value and is done.
|
|
270
|
+
|
|
271
|
+
A chain is enforced only when you pass `chainId`. Leave it out when collecting
|
|
272
|
+
a settlement address: the same address receives on every EVM chain, so asking
|
|
273
|
+
someone to switch networks to read it back serves no purpose.
|
|
274
|
+
|
|
275
|
+
## Theming
|
|
276
|
+
|
|
277
|
+
Twelve tokens, light or dark.
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
createWalletKit({
|
|
281
|
+
theme: {
|
|
282
|
+
mode: 'system', // 'light' | 'dark' | 'system'
|
|
283
|
+
brand: '#ff6600', // worn by the primary action
|
|
284
|
+
radius: '14px',
|
|
285
|
+
fontFamily: 'Inter, sans-serif',
|
|
286
|
+
dark: { surface: '#000000' }, // applied on top, in dark only
|
|
287
|
+
},
|
|
288
|
+
})
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
The resolved mode and the tokens are part of the state you are already
|
|
292
|
+
subscribed to, so the picker follows the reader's system without a second
|
|
293
|
+
listener:
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
const { scheme, variables } = kit.getState()
|
|
297
|
+
// scheme: 'dark'
|
|
298
|
+
// variables: { '--rkw-surface': '#16161a', '--rkw-brand': '#ff6600', ... }
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Three things worth knowing:
|
|
302
|
+
|
|
303
|
+
- **Text on your brand colour is computed** from its relative luminance, so a
|
|
304
|
+
pale brand gets dark text rather than unreadable white.
|
|
305
|
+
- **Dark is its own palette, not an inversion.** A brand colour you set is
|
|
306
|
+
kept in both modes.
|
|
307
|
+
- **Colours must be `#rrggbb`.** Anything else is ignored and the default
|
|
308
|
+
stands, so a value from an API response can never end up inside a style.
|
|
309
|
+
|
|
310
|
+
Tokens are prefixed `--rkw-` so they cannot collide with your own.
|
|
311
|
+
|
|
312
|
+
## Balances
|
|
313
|
+
|
|
314
|
+
Amounts are `bigint`, in the asset's smallest unit. `formatUnits` places the
|
|
315
|
+
decimal point with string arithmetic, because money does not survive a float.
|
|
316
|
+
|
|
317
|
+
```ts
|
|
318
|
+
import { formatUnits } from '@reclack/walletkit'
|
|
319
|
+
|
|
320
|
+
const [usdc] = await kit.readBalances('evm', [
|
|
321
|
+
{ family: 'evm', chainId: 8453, token: USDC, decimals: 6 },
|
|
322
|
+
])
|
|
323
|
+
formatUnits(usdc.amount, 6) // "125.40"
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Balances are read through an endpoint by default, which can cover several
|
|
327
|
+
chains at once and does not move the wallet onto another network. Reading
|
|
328
|
+
through the connected wallet instead requires it to already be on that chain,
|
|
329
|
+
which suits a check immediately before signing.
|
|
330
|
+
|
|
331
|
+
Public endpoints are used unless you pass `rpcUrls`. Set your own for anything
|
|
332
|
+
heavier than a balance or two. Solana balances are endpoint-only.
|
|
333
|
+
|
|
334
|
+
## Wallet artwork
|
|
335
|
+
|
|
336
|
+
Logos ship in `assets/` as `.webp`. Copy them into whatever your app serves
|
|
337
|
+
static files from, then say where that is:
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
createWalletKit({ assetBase: '/wallets/' })
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
```html
|
|
344
|
+
<reclack-connect asset-base="/wallets/"></reclack-connect>
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
The default is `/images/`. Serving them yourself means your checkout makes no
|
|
348
|
+
third-party image request. A wallet that supplies its own icon through
|
|
349
|
+
EIP-6963 uses that instead, so getting the path wrong costs you the logos of
|
|
350
|
+
wallets that are not installed, not the ability to connect.
|
|
351
|
+
|
|
352
|
+
## Pairing by QR code
|
|
353
|
+
|
|
354
|
+
Some wallets connect over a relay rather than through the browser. That works
|
|
355
|
+
out of the box, with nothing to install or configure, and the relay provider
|
|
356
|
+
is fetched only if someone picks one of those wallets.
|
|
357
|
+
|
|
358
|
+
To pair under your own WalletConnect project instead:
|
|
359
|
+
|
|
360
|
+
```ts
|
|
361
|
+
createWalletKit({
|
|
362
|
+
walletConnect: {
|
|
363
|
+
projectId: 'your-project-id',
|
|
364
|
+
metadata: { name: 'Your app', url: 'https://your-app.example' },
|
|
365
|
+
},
|
|
366
|
+
})
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## Server rendering
|
|
370
|
+
|
|
371
|
+
Nothing touches `window` until something subscribes, so importing the kit in a
|
|
372
|
+
server render is safe and needs no guards. Registering the element is skipped
|
|
373
|
+
where there is no `customElements`.
|
|
374
|
+
|
|
375
|
+
## TypeScript
|
|
376
|
+
|
|
377
|
+
Types ship with the package. The ones you are most likely to name:
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
import type {
|
|
381
|
+
WalletKit,
|
|
382
|
+
WalletKitState,
|
|
383
|
+
WalletKitTheme,
|
|
384
|
+
ConnectRequest,
|
|
385
|
+
ConnectResult,
|
|
386
|
+
Asset,
|
|
387
|
+
Balance,
|
|
388
|
+
} from '@reclack/walletkit'
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## Licence
|
|
392
|
+
|
|
393
|
+
MIT.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/clv.webp
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/core.webp
ADDED
|
Binary file
|
|
Binary file
|
package/assets/ctrl.webp
ADDED
|
Binary file
|
package/assets/dawn.webp
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/gate.webp
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/kaia.webp
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/meco.webp
ADDED
|
Binary file
|
|
Binary file
|
package/assets/mew.webp
ADDED
|
Binary file
|
package/assets/nest.webp
ADDED
|
Binary file
|
package/assets/nova.webp
ADDED
|
Binary file
|
package/assets/okto.webp
ADDED
|
Binary file
|
package/assets/okx.webp
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/safe.webp
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/taho.webp
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/zeal.webp
ADDED
|
Binary file
|
|
Binary file
|