stellar-wallet-kit 2.0.2 β†’ 2.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # 🌟 Stellar Wallet Kit
2
2
 
3
- A comprehensive, production-ready wallet connection SDK for Stellar dApps.
4
- Built with TypeScript and React, inspired by RainbowKit.
3
+ A **production-ready wallet connection SDK** for Stellar dApps.
4
+ Built with **TypeScript + React**, inspired by RainbowKit β€” but designed for the **realities of Stellar wallets**.
5
5
 
6
6
  [![npm version](https://img.shields.io/npm/v/stellar-wallet-kit.svg)](https://www.npmjs.com/package/stellar-wallet-kit)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -11,17 +11,21 @@ Built with TypeScript and React, inspired by RainbowKit.
11
11
 
12
12
  ## ✨ Features
13
13
 
14
- - πŸ”Œ **Multiple Wallet Support** – Freighter & Albedo
15
- - 🎨 **Fully Customizable UI** – Theme control to match your brand
16
- - ⚑ **TypeScript First** – Full type safety & IntelliSense
17
- - 🎯 **React Hooks API** – Simple `useWallet()` hook
18
- - πŸ’° **Built-in Balance Fetching**
19
- - πŸ’Ύ **Auto-reconnect** (extension wallets)
20
- - πŸŒ“ **Light / Dark / Auto theme**
21
- - πŸ”„ **Auto-refresh balances**
22
- - πŸš€ **Framework-agnostic SDK**
23
- - πŸ“± **Next.js compatible**
24
- - πŸŽͺ **Beautiful Wallet Modal**
14
+ * πŸ”Œ **Multiple Wallets**
15
+
16
+ * Freighter (extension)
17
+ * Albedo (web popup)
18
+ * WalletConnect (mobile wallets)
19
+ * LOBSTR (via WalletConnect)
20
+ * 🎨 **Customizable Wallet Modal**
21
+ * ⚑ **TypeScript-first**
22
+ * 🎯 **React Hooks API**
23
+ * πŸ’° **Built-in balance fetching**
24
+ * πŸ’Ύ **Session persistence**
25
+ * πŸŒ“ **Light / Dark / Auto theme**
26
+ * πŸ”„ **Auto-refresh balances**
27
+ * πŸ“± **Next.js (App Router & Pages) compatible**
28
+ * πŸš€ **Framework-agnostic core**
25
29
 
26
30
  ---
27
31
 
@@ -33,7 +37,7 @@ npm install stellar-wallet-kit
33
37
  yarn add stellar-wallet-kit
34
38
  # or
35
39
  pnpm add stellar-wallet-kit
36
- ````
40
+ ```
37
41
 
38
42
  ---
39
43
 
@@ -66,7 +70,7 @@ export function App() {
66
70
  import { ConnectButton } from 'stellar-wallet-kit';
67
71
 
68
72
  export function Header() {
69
- return <ConnectButton showBalance />;
73
+ return <ConnectButton />;
70
74
  }
71
75
  ```
72
76
 
@@ -80,9 +84,7 @@ import { useWallet } from 'stellar-wallet-kit';
80
84
  function Dashboard() {
81
85
  const { account, isConnected, signTransaction } = useWallet();
82
86
 
83
- if (!isConnected) {
84
- return <p>Please connect your wallet</p>;
85
- }
87
+ if (!isConnected) return <p>Please connect your wallet</p>;
86
88
 
87
89
  return (
88
90
  <div>
@@ -99,72 +101,70 @@ function Dashboard() {
99
101
 
100
102
  ## πŸ”Œ Supported Wallets
101
103
 
102
- | Wallet | Type | Auto-Reconnect |
103
- | ------------- | ----------------- | -------------- |
104
- | **Freighter** | Browser extension | βœ… |
105
- | **Albedo** | Web-based (popup) | ❌ |
104
+ | Wallet | Type | Connection Model | Auto-Reconnect |
105
+ | ----------------- | ----------------- | ---------------------- | -------------- |
106
+ | **Freighter** | Browser extension | Injected API | βœ… |
107
+ | **Albedo** | Web wallet | Popup + callback | ❌ |
108
+ | **WalletConnect** | Mobile wallets | QR / deep-link session | βœ… |
109
+ | **LOBSTR** | Mobile wallet | WalletConnect | βœ… |
110
+
111
+ > **LOBSTR is exposed separately in the UI** but internally uses WalletConnect.
106
112
 
107
113
  ---
108
114
 
109
- ## 🌐 Albedo Wallet Integration (Important)
115
+ ## πŸ”— WalletConnect & LOBSTR (Important)
110
116
 
111
- Albedo is a **web-based wallet**, not a browser extension.
117
+ WalletConnect **does not block the UI** like extensions.
112
118
 
113
- Because of this, it **cannot inject APIs** into your app and **requires a callback route** to return results.
119
+ * QR modal stays visible
120
+ * SDK tracks `connectingWallet`
121
+ * Global loaders **do not cover** WalletConnect
114
122
 
115
- This is **intentional and secure by design**.
123
+ This avoids the β€œQR hidden behind loader” problem by design.
116
124
 
117
125
  ---
118
126
 
119
- ### 🧠 How Albedo Works
127
+ ### Connecting explicitly
128
+
129
+ ```tsx
130
+ import { WalletType, useWallet } from 'stellar-wallet-kit';
120
131
 
121
- 1. Your app opens Albedo in a popup
122
- 2. User approves the action in Albedo
123
- 3. Albedo redirects the popup to a callback URL
124
- 4. The callback sends data back to your app
125
- 5. The popup closes and the wallet is connected
132
+ const { connect } = useWallet();
126
133
 
127
- If the callback route is missing, **Albedo will open but never connect**.
134
+ await connect(WalletType.WALLETCONNECT);
135
+ await connect(WalletType.LOBSTR);
136
+ ```
128
137
 
129
138
  ---
130
139
 
131
- ## ⚠️ Required: Add an Albedo Callback Route (App-side)
140
+ ## 🌐 Albedo Wallet Integration (Required)
132
141
 
133
- Because this SDK is **framework-agnostic**, it **cannot create routes for you**.
142
+ Albedo is a **web-based wallet** and **requires a callback route**.
134
143
 
135
- Your app **must define** a callback route.
144
+ If the callback is missing:
136
145
 
137
- ---
146
+ * Albedo opens
147
+ * User approves
148
+ * **Connection never completes**
138
149
 
139
- ### Example: Next.js (Pages Router)
150
+ This is expected behavior.
140
151
 
141
- ```tsx
142
- // pages/albedo-callback.tsx
143
- import { useEffect } from 'react';
144
-
145
- export default function AlbedoCallback() {
146
- useEffect(() => {
147
- const params = Object.fromEntries(
148
- new URLSearchParams(window.location.search)
149
- );
150
-
151
- if (window.opener) {
152
- window.opener.postMessage(
153
- { type: 'ALBEDO_RESULT', payload: params },
154
- window.location.origin
155
- );
156
- }
152
+ ---
157
153
 
158
- window.close();
159
- }, []);
154
+ ### How Albedo Works
160
155
 
161
- return <p>Connecting wallet…</p>;
162
- }
163
- ```
156
+ 1. App opens Albedo popup
157
+ 2. User approves
158
+ 3. Albedo redirects to callback URL
159
+ 4. Callback posts message to opener
160
+ 5. Popup closes
161
+ 6. Wallet connects
164
162
 
165
163
  ---
166
164
 
167
- ### Example: Next.js (App Router)
165
+ ### Required: Add a Callback Route
166
+
167
+ #### Next.js (App Router)
168
168
 
169
169
  ```tsx
170
170
  // app/albedo-callback/page.tsx
@@ -194,43 +194,6 @@ export default function AlbedoCallback() {
194
194
 
195
195
  ---
196
196
 
197
- ### Example: React Router
198
-
199
- ```tsx
200
- function AlbedoCallback() {
201
- useEffect(() => {
202
- const params = Object.fromEntries(
203
- new URLSearchParams(window.location.search)
204
- );
205
-
206
- if (window.opener) {
207
- window.opener.postMessage(
208
- { type: 'ALBEDO_RESULT', payload: params },
209
- window.location.origin
210
- );
211
- }
212
-
213
- window.close();
214
- }, []);
215
-
216
- return <p>Connecting wallet…</p>;
217
- }
218
- ```
219
-
220
- ---
221
-
222
- ## πŸ”— Connecting Explicitly to Albedo
223
-
224
- ```tsx
225
- import { WalletType, useWallet } from 'stellar-wallet-kit';
226
-
227
- const { connect } = useWallet();
228
-
229
- await connect(WalletType.ALBEDO);
230
- ```
231
-
232
- ---
233
-
234
197
  ## πŸ’° Balance Utilities
235
198
 
236
199
  ```tsx
@@ -267,11 +230,12 @@ const usdc = getAssetBalance(account.balances, 'USDC', issuer);
267
230
 
268
231
  ## 🎯 `useWallet()` API
269
232
 
270
- ```tsx
233
+ ```ts
271
234
  const {
272
235
  account,
273
236
  isConnected,
274
237
  isConnecting,
238
+ connectingWallet,
275
239
  error,
276
240
  network,
277
241
  selectedWallet,
@@ -300,27 +264,27 @@ supports = {
300
264
  }
301
265
  ```
302
266
 
303
- Useful for conditional UI and safer flows.
267
+ Use this to:
268
+
269
+ * Disable unsupported actions
270
+ * Adjust UX per wallet
304
271
 
305
272
  ---
306
273
 
307
- ## πŸ“± Next.js App Router Setup
274
+ ## πŸ› Troubleshooting
308
275
 
309
- ```tsx
310
- 'use client';
276
+ ### WalletConnect QR stuck on β€œConnecting…”
311
277
 
312
- import { WalletProvider } from 'stellar-wallet-kit';
278
+ βœ” Mobile wallet not approved
279
+ βœ” App not foregrounded on phone
280
+ βœ” Session rejected in wallet
313
281
 
314
- export function Providers({ children }) {
315
- return <WalletProvider>{children}</WalletProvider>;
316
- }
317
- ```
318
-
319
- ---
282
+ ### QR hidden behind loader
320
283
 
321
- ## πŸ› Troubleshooting
284
+ βœ” **Handled automatically**
285
+ WalletConnect never blocks UI
322
286
 
323
- ### Albedo popup opens but doesn’t connect
287
+ ### Albedo opens but doesn’t connect
324
288
 
325
289
  βœ” Missing callback route
326
290
  βœ” Callback URL mismatch
@@ -328,31 +292,31 @@ export function Providers({ children }) {
328
292
 
329
293
  ### Freighter not detected
330
294
 
331
- βœ” Ensure extension is installed & enabled
295
+ βœ” Extension not installed / disabled
332
296
 
333
297
  ---
334
298
 
335
299
  ## πŸ—ΊοΈ Roadmap
336
300
 
337
- * [x] Freighter support
338
- * [x] Albedo support
339
- * [x] Balance utilities
301
+ * [x] Freighter
302
+ * [x] Albedo
303
+ * [x] WalletConnect
304
+ * [x] LOBSTR
340
305
  * [ ] xBull
341
306
  * [ ] Rabet
342
- * [ ] WalletConnect
343
- * [ ] Mobile deep-link wallets
307
+ * [ ] Multi-account support
344
308
  * [ ] Hardware wallets
345
309
 
346
310
  ---
347
311
 
348
312
  ## πŸ“„ License
349
313
 
350
- MIT Β© Tushar Pamnani
314
+ MIT Β© **Tushar Pamnani**
351
315
 
352
316
  ---
353
317
 
354
318
  ## 🌟 Show Your Support
355
319
 
356
- If this project helps you, please ⭐️ it on GitHub.
320
+ If this SDK saved you pain β€” ⭐️ it on GitHub.
357
321
 
358
322
  Built with ❀️ for the Stellar ecosystem.
package/dist/index.d.mts CHANGED
@@ -2,7 +2,9 @@ import React, { PropsWithChildren } from 'react';
2
2
 
3
3
  declare enum WalletType {
4
4
  FREIGHTER = "freighter",
5
- ALBEDO = "albedo"
5
+ ALBEDO = "albedo",
6
+ WALLETCONNECT = "walletconnect",
7
+ LOBSTR = "lobstr"
6
8
  }
7
9
  declare enum NetworkType {
8
10
  PUBLIC = "PUBLIC",
@@ -82,6 +84,7 @@ interface StellarWalletKitConfig {
82
84
  theme?: WalletTheme;
83
85
  appName?: string;
84
86
  appIcon?: string;
87
+ adapters?: Partial<Record<WalletType, WalletAdapter>>;
85
88
  }
86
89
  interface WalletTheme {
87
90
  mode?: "light" | "dark" | "auto";
@@ -123,8 +126,14 @@ interface WalletContextValue {
123
126
  networkDetection: boolean;
124
127
  authEntrySigning: boolean;
125
128
  };
129
+ connectingWallet: WalletType | null;
126
130
  }
127
131
  type WalletKind = "extension" | "web";
132
+ interface WalletCapabilities {
133
+ silentReconnect: boolean;
134
+ networkDetection: boolean;
135
+ authEntrySigning: boolean;
136
+ }
128
137
 
129
138
  type WalletProviderProps = PropsWithChildren<{
130
139
  config?: StellarWalletKitConfig;
@@ -175,6 +184,10 @@ declare function getTotalValueXLM(balances: AccountBalance[]): string;
175
184
  */
176
185
  declare function groupBalancesByType(balances: AccountBalance[]): Record<string, AccountBalance[]>;
177
186
 
187
+ declare function createWalletAdapters(config: {
188
+ walletConnectProjectId?: string;
189
+ }): Partial<Record<WalletType, WalletAdapter>>;
190
+
178
191
  declare class FreighterAdapter implements WalletAdapter {
179
192
  readonly type = WalletType.FREIGHTER;
180
193
  isAvailable(): Promise<boolean>;
@@ -186,4 +199,20 @@ declare class FreighterAdapter implements WalletAdapter {
186
199
  signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
187
200
  }
188
201
 
189
- export { type AccountBalance, ConnectButton, type ConnectWalletResponse, FreighterAdapter, type ModalProps, NetworkType, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarWalletKitConfig, type WalletAccount, type WalletAdapter, type WalletContextValue, type WalletInfo, WalletModal, WalletProvider, type WalletTheme, WalletType, fetchAccountBalances, formatBalance, getAssetBalance, getNativeBalance, getTotalValueXLM, groupBalancesByType, hasSufficientBalance, useWallet };
202
+ declare class WalletConnectAdapter implements WalletAdapter {
203
+ readonly type = WalletType.WALLETCONNECT;
204
+ private projectId;
205
+ private connector;
206
+ private session;
207
+ constructor(projectId: string);
208
+ isAvailable(): Promise<boolean>;
209
+ private getConnector;
210
+ connect(): Promise<ConnectWalletResponse>;
211
+ disconnect(): Promise<void>;
212
+ getPublicKey(): Promise<string | null>;
213
+ getNetwork(): Promise<string>;
214
+ signTransaction(xdr: string, _options?: SignTransactionOptions): Promise<SignTransactionResponse>;
215
+ signAuthEntry(_entryXdr: string, _options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
216
+ }
217
+
218
+ export { type AccountBalance, ConnectButton, type ConnectWalletResponse, FreighterAdapter, type ModalProps, NetworkType, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarWalletKitConfig, type WalletAccount, type WalletAdapter, type WalletCapabilities, WalletConnectAdapter, type WalletContextValue, type WalletInfo, type WalletKind, WalletModal, WalletProvider, type WalletTheme, WalletType, createWalletAdapters, fetchAccountBalances, formatBalance, getAssetBalance, getNativeBalance, getTotalValueXLM, groupBalancesByType, hasSufficientBalance, useWallet };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,9 @@ import React, { PropsWithChildren } from 'react';
2
2
 
3
3
  declare enum WalletType {
4
4
  FREIGHTER = "freighter",
5
- ALBEDO = "albedo"
5
+ ALBEDO = "albedo",
6
+ WALLETCONNECT = "walletconnect",
7
+ LOBSTR = "lobstr"
6
8
  }
7
9
  declare enum NetworkType {
8
10
  PUBLIC = "PUBLIC",
@@ -82,6 +84,7 @@ interface StellarWalletKitConfig {
82
84
  theme?: WalletTheme;
83
85
  appName?: string;
84
86
  appIcon?: string;
87
+ adapters?: Partial<Record<WalletType, WalletAdapter>>;
85
88
  }
86
89
  interface WalletTheme {
87
90
  mode?: "light" | "dark" | "auto";
@@ -123,8 +126,14 @@ interface WalletContextValue {
123
126
  networkDetection: boolean;
124
127
  authEntrySigning: boolean;
125
128
  };
129
+ connectingWallet: WalletType | null;
126
130
  }
127
131
  type WalletKind = "extension" | "web";
132
+ interface WalletCapabilities {
133
+ silentReconnect: boolean;
134
+ networkDetection: boolean;
135
+ authEntrySigning: boolean;
136
+ }
128
137
 
129
138
  type WalletProviderProps = PropsWithChildren<{
130
139
  config?: StellarWalletKitConfig;
@@ -175,6 +184,10 @@ declare function getTotalValueXLM(balances: AccountBalance[]): string;
175
184
  */
176
185
  declare function groupBalancesByType(balances: AccountBalance[]): Record<string, AccountBalance[]>;
177
186
 
187
+ declare function createWalletAdapters(config: {
188
+ walletConnectProjectId?: string;
189
+ }): Partial<Record<WalletType, WalletAdapter>>;
190
+
178
191
  declare class FreighterAdapter implements WalletAdapter {
179
192
  readonly type = WalletType.FREIGHTER;
180
193
  isAvailable(): Promise<boolean>;
@@ -186,4 +199,20 @@ declare class FreighterAdapter implements WalletAdapter {
186
199
  signAuthEntry(entryXdr: string, options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
187
200
  }
188
201
 
189
- export { type AccountBalance, ConnectButton, type ConnectWalletResponse, FreighterAdapter, type ModalProps, NetworkType, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarWalletKitConfig, type WalletAccount, type WalletAdapter, type WalletContextValue, type WalletInfo, WalletModal, WalletProvider, type WalletTheme, WalletType, fetchAccountBalances, formatBalance, getAssetBalance, getNativeBalance, getTotalValueXLM, groupBalancesByType, hasSufficientBalance, useWallet };
202
+ declare class WalletConnectAdapter implements WalletAdapter {
203
+ readonly type = WalletType.WALLETCONNECT;
204
+ private projectId;
205
+ private connector;
206
+ private session;
207
+ constructor(projectId: string);
208
+ isAvailable(): Promise<boolean>;
209
+ private getConnector;
210
+ connect(): Promise<ConnectWalletResponse>;
211
+ disconnect(): Promise<void>;
212
+ getPublicKey(): Promise<string | null>;
213
+ getNetwork(): Promise<string>;
214
+ signTransaction(xdr: string, _options?: SignTransactionOptions): Promise<SignTransactionResponse>;
215
+ signAuthEntry(_entryXdr: string, _options?: SignAuthEntryOptions): Promise<SignAuthEntryResponse>;
216
+ }
217
+
218
+ export { type AccountBalance, ConnectButton, type ConnectWalletResponse, FreighterAdapter, type ModalProps, NetworkType, type SignAuthEntryOptions, type SignAuthEntryResponse, type SignTransactionOptions, type SignTransactionResponse, type StellarWalletKitConfig, type WalletAccount, type WalletAdapter, type WalletCapabilities, WalletConnectAdapter, type WalletContextValue, type WalletInfo, type WalletKind, WalletModal, WalletProvider, type WalletTheme, WalletType, createWalletAdapters, fetchAccountBalances, formatBalance, getAssetBalance, getNativeBalance, getTotalValueXLM, groupBalancesByType, hasSufficientBalance, useWallet };