stellar-wallet-kit 2.0.0
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 +588 -0
- package/dist/index.d.mts +172 -0
- package/dist/index.d.ts +172 -0
- package/dist/index.js +840 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +821 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tushar Pamnani
|
|
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
ADDED
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
# π Stellar Wallet Kit
|
|
2
|
+
|
|
3
|
+
A comprehensive, production-ready wallet connection library for Stellar dApps. Built with TypeScript, React, and inspired by RainbowKit.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/stellar-wallet-kit)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
|
|
9
|
+
## β¨ Features
|
|
10
|
+
|
|
11
|
+
- π **Multiple Wallet Support** - Freighter (more coming soon)
|
|
12
|
+
- π¨ **Fully Customizable** - Complete theme control to match your brand
|
|
13
|
+
- β‘ **TypeScript First** - Full type safety and IntelliSense support
|
|
14
|
+
- π― **React Hooks** - Simple, intuitive API with `useWallet()`
|
|
15
|
+
- π° **Built-in Balance Checking** - Automatic balance fetching and refresh
|
|
16
|
+
- πΎ **Auto-reconnect** - Persists connection across sessions
|
|
17
|
+
- π **Dark Mode** - Built-in light/dark/auto theme support
|
|
18
|
+
- π **Auto-refresh Balances** - Updates every 30 seconds
|
|
19
|
+
- π **Zero Dependencies** - Only requires React and Stellar SDK
|
|
20
|
+
- π± **Next.js Ready** - Full App Router and SSR support
|
|
21
|
+
- πͺ **Modal UI** - Beautiful, accessible wallet selection modal
|
|
22
|
+
|
|
23
|
+
## π¦ Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install stellar-wallet-kit
|
|
27
|
+
# or
|
|
28
|
+
yarn add stellar-wallet-kit
|
|
29
|
+
# or
|
|
30
|
+
pnpm add stellar-wallet-kit
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## π Quick Start
|
|
34
|
+
|
|
35
|
+
### 1. Wrap your app with `WalletProvider`
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { WalletProvider, NetworkType } from 'stellar-wallet-kit';
|
|
39
|
+
|
|
40
|
+
function App() {
|
|
41
|
+
return (
|
|
42
|
+
<WalletProvider
|
|
43
|
+
config={{
|
|
44
|
+
network: NetworkType.TESTNET,
|
|
45
|
+
autoConnect: true,
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<YourApp />
|
|
49
|
+
</WalletProvider>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Add the `ConnectButton`
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { ConnectButton } from 'stellar-wallet-kit';
|
|
58
|
+
|
|
59
|
+
function Header() {
|
|
60
|
+
return (
|
|
61
|
+
<header>
|
|
62
|
+
<h1>My Stellar dApp</h1>
|
|
63
|
+
<ConnectButton showBalance />
|
|
64
|
+
</header>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Use the `useWallet` hook
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { useWallet } from 'stellar-wallet-kit';
|
|
73
|
+
|
|
74
|
+
function Dashboard() {
|
|
75
|
+
const { account, isConnected, signTransaction } = useWallet();
|
|
76
|
+
|
|
77
|
+
if (!isConnected) {
|
|
78
|
+
return <p>Please connect your wallet</p>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div>
|
|
83
|
+
<p>Connected: {account.address}</p>
|
|
84
|
+
<button onClick={() => signTransaction(xdr)}>
|
|
85
|
+
Sign Transaction
|
|
86
|
+
</button>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## π¨ Customization
|
|
93
|
+
|
|
94
|
+
### Theme Configuration
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
<WalletProvider
|
|
98
|
+
config={{
|
|
99
|
+
network: NetworkType.TESTNET,
|
|
100
|
+
appName: "My Stellar dApp",
|
|
101
|
+
appIcon: "https://myapp.com/icon.png",
|
|
102
|
+
theme: {
|
|
103
|
+
mode: 'dark', // 'light' | 'dark' | 'auto'
|
|
104
|
+
primaryColor: '#8b5cf6',
|
|
105
|
+
backgroundColor: '#1a1a1a',
|
|
106
|
+
borderRadius: '16px',
|
|
107
|
+
fontFamily: 'Inter, sans-serif',
|
|
108
|
+
overlayBackground: 'rgba(0, 0, 0, 0.8)',
|
|
109
|
+
modalBackground: '#1a1a1a',
|
|
110
|
+
textColor: '#ffffff',
|
|
111
|
+
buttonHoverColor: '#252525',
|
|
112
|
+
},
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
<App />
|
|
116
|
+
</WalletProvider>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Custom Connect Button
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
<ConnectButton
|
|
123
|
+
label="Connect Wallet"
|
|
124
|
+
showBalance={true}
|
|
125
|
+
theme={customTheme}
|
|
126
|
+
onConnect={() => console.log('Connected!')}
|
|
127
|
+
onDisconnect={() => console.log('Disconnected!')}
|
|
128
|
+
/>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## π° Balance Checking
|
|
132
|
+
|
|
133
|
+
### Automatic Balance Updates
|
|
134
|
+
|
|
135
|
+
Balances are fetched automatically:
|
|
136
|
+
- β
When wallet connects
|
|
137
|
+
- β
Every 30 seconds while connected
|
|
138
|
+
- β
When network switches
|
|
139
|
+
- β
When manually triggered
|
|
140
|
+
|
|
141
|
+
### Using Balances
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { useWallet, getNativeBalance, formatBalance } from 'stellar-wallet-kit';
|
|
145
|
+
|
|
146
|
+
function BalanceDisplay() {
|
|
147
|
+
const { account, isLoadingBalances, refreshBalances } = useWallet();
|
|
148
|
+
|
|
149
|
+
if (!account?.balances) return null;
|
|
150
|
+
|
|
151
|
+
const xlmBalance = getNativeBalance(account.balances);
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div>
|
|
155
|
+
<h3>{formatBalance(xlmBalance, 2)} XLM</h3>
|
|
156
|
+
<button onClick={refreshBalances} disabled={isLoadingBalances}>
|
|
157
|
+
{isLoadingBalances ? 'Loading...' : 'Refresh'}
|
|
158
|
+
</button>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Balance Utility Functions
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import {
|
|
168
|
+
getNativeBalance, // Get XLM balance
|
|
169
|
+
formatBalance, // Format for display
|
|
170
|
+
getAssetBalance, // Get specific asset balance
|
|
171
|
+
hasSufficientBalance, // Check if enough funds
|
|
172
|
+
groupBalancesByType, // Group balances by type
|
|
173
|
+
} from 'stellar-wallet-kit';
|
|
174
|
+
|
|
175
|
+
// Get XLM balance
|
|
176
|
+
const xlm = getNativeBalance(account.balances);
|
|
177
|
+
|
|
178
|
+
// Get custom asset balance
|
|
179
|
+
const usdc = getAssetBalance(account.balances, 'USDC', issuerAddress);
|
|
180
|
+
|
|
181
|
+
// Format for display
|
|
182
|
+
const formatted = formatBalance("1234.5678900", 2); // "1234.56"
|
|
183
|
+
|
|
184
|
+
// Check sufficient balance
|
|
185
|
+
const canPay = hasSufficientBalance(account.balances, '100', 'USDC');
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## π― API Reference
|
|
189
|
+
|
|
190
|
+
### `useWallet()` Hook
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
const {
|
|
194
|
+
// State
|
|
195
|
+
account, // Connected account with balances
|
|
196
|
+
isConnected, // Connection status
|
|
197
|
+
isConnecting, // Loading state
|
|
198
|
+
isLoadingBalances, // Balance loading state
|
|
199
|
+
error, // Error if any
|
|
200
|
+
network, // Current network
|
|
201
|
+
selectedWallet, // Selected wallet type
|
|
202
|
+
availableWallets, // List of available wallets
|
|
203
|
+
|
|
204
|
+
// Methods
|
|
205
|
+
connect, // Connect to a wallet
|
|
206
|
+
disconnect, // Disconnect wallet
|
|
207
|
+
signTransaction, // Sign a transaction
|
|
208
|
+
signAuthEntry, // Sign authorization entry
|
|
209
|
+
switchNetwork, // Switch networks
|
|
210
|
+
refreshBalances, // Manually refresh balances
|
|
211
|
+
} = useWallet();
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Connect to Wallet
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
// Connect to default/auto-detected wallet
|
|
218
|
+
await connect();
|
|
219
|
+
|
|
220
|
+
// Connect to specific wallet
|
|
221
|
+
await connect(WalletType.FREIGHTER);
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Sign Transaction
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
const response = await signTransaction(xdr, {
|
|
228
|
+
network: 'TESTNET',
|
|
229
|
+
networkPassphrase: 'Test SDF Network ; September 2015',
|
|
230
|
+
accountToSign: 'GXXXXXX...',
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
console.log(response.signedTxXdr);
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Sign Authorization Entry
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
const response = await signAuthEntry(entryXdr, {
|
|
240
|
+
accountToSign: 'GXXXXXX...',
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
console.log(response.signedAuthEntry);
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## π§ Configuration Options
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
interface StellarWalletKitConfig {
|
|
250
|
+
network?: NetworkType; // 'PUBLIC' | 'TESTNET' | 'FUTURENET' | 'STANDALONE'
|
|
251
|
+
defaultWallet?: WalletType; // Default wallet to connect
|
|
252
|
+
autoConnect?: boolean; // Auto-reconnect on page load
|
|
253
|
+
theme?: WalletTheme; // Custom theme
|
|
254
|
+
appName?: string; // Your app name
|
|
255
|
+
appIcon?: string; // Your app icon URL
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## π± Next.js App Router Setup
|
|
260
|
+
|
|
261
|
+
The kit works seamlessly with Next.js 13+ App Router:
|
|
262
|
+
|
|
263
|
+
### 1. Create a Client Component wrapper
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
// app/providers.tsx
|
|
267
|
+
'use client';
|
|
268
|
+
|
|
269
|
+
import { WalletProvider, NetworkType } from 'stellar-wallet-kit';
|
|
270
|
+
|
|
271
|
+
export function Providers({ children }: { children: React.ReactNode }) {
|
|
272
|
+
return (
|
|
273
|
+
<WalletProvider config={{ network: NetworkType.TESTNET }}>
|
|
274
|
+
{children}
|
|
275
|
+
</WalletProvider>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### 2. Use in your layout
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
// app/layout.tsx
|
|
284
|
+
import { Providers } from './providers';
|
|
285
|
+
|
|
286
|
+
export default function RootLayout({ children }) {
|
|
287
|
+
return (
|
|
288
|
+
<html lang="en">
|
|
289
|
+
<body>
|
|
290
|
+
<Providers>{children}</Providers>
|
|
291
|
+
</body>
|
|
292
|
+
</html>
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### 3. Mark pages using the wallet as Client Components
|
|
298
|
+
|
|
299
|
+
```tsx
|
|
300
|
+
// app/page.tsx
|
|
301
|
+
'use client';
|
|
302
|
+
|
|
303
|
+
import { useWallet, ConnectButton } from 'stellar-wallet-kit';
|
|
304
|
+
|
|
305
|
+
export default function Home() {
|
|
306
|
+
const { isConnected } = useWallet();
|
|
307
|
+
return <ConnectButton />;
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## π Network Support
|
|
312
|
+
|
|
313
|
+
Supports all Stellar networks:
|
|
314
|
+
|
|
315
|
+
```tsx
|
|
316
|
+
import { NetworkType } from 'stellar-wallet-kit';
|
|
317
|
+
|
|
318
|
+
NetworkType.PUBLIC // Mainnet
|
|
319
|
+
NetworkType.TESTNET // Testnet
|
|
320
|
+
NetworkType.FUTURENET // Futurenet
|
|
321
|
+
NetworkType.STANDALONE // Local network
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## π Supported Wallets
|
|
325
|
+
|
|
326
|
+
Currently supported:
|
|
327
|
+
- β
**Freighter** - Browser extension wallet
|
|
328
|
+
|
|
329
|
+
Coming soon:
|
|
330
|
+
- π xBull
|
|
331
|
+
- π Albedo
|
|
332
|
+
- π Rabet
|
|
333
|
+
- π WalletConnect
|
|
334
|
+
|
|
335
|
+
## π οΈ Advanced Usage
|
|
336
|
+
|
|
337
|
+
### Custom Wallet Modal
|
|
338
|
+
|
|
339
|
+
```tsx
|
|
340
|
+
import { useState } from 'react';
|
|
341
|
+
import { useWallet, WalletModal } from 'stellar-wallet-kit';
|
|
342
|
+
|
|
343
|
+
function CustomConnect() {
|
|
344
|
+
const [showModal, setShowModal] = useState(false);
|
|
345
|
+
const { availableWallets, connect } = useWallet();
|
|
346
|
+
|
|
347
|
+
return (
|
|
348
|
+
<>
|
|
349
|
+
<button onClick={() => setShowModal(true)}>
|
|
350
|
+
Connect Wallet
|
|
351
|
+
</button>
|
|
352
|
+
|
|
353
|
+
<WalletModal
|
|
354
|
+
isOpen={showModal}
|
|
355
|
+
onClose={() => setShowModal(false)}
|
|
356
|
+
wallets={availableWallets}
|
|
357
|
+
onSelectWallet={connect}
|
|
358
|
+
/>
|
|
359
|
+
</>
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Payment with Balance Check
|
|
365
|
+
|
|
366
|
+
```tsx
|
|
367
|
+
import { useWallet, hasSufficientBalance } from 'stellar-wallet-kit';
|
|
368
|
+
|
|
369
|
+
function PaymentForm() {
|
|
370
|
+
const { account, signTransaction } = useWallet();
|
|
371
|
+
const [amount, setAmount] = useState('');
|
|
372
|
+
|
|
373
|
+
const handlePay = async () => {
|
|
374
|
+
// Check balance before signing
|
|
375
|
+
if (!hasSufficientBalance(account.balances, amount)) {
|
|
376
|
+
alert('Insufficient balance!');
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Build and sign transaction
|
|
381
|
+
const signed = await signTransaction(transactionXDR);
|
|
382
|
+
// Submit to network...
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<form onSubmit={handlePay}>
|
|
387
|
+
<input value={amount} onChange={e => setAmount(e.target.value)} />
|
|
388
|
+
<button type="submit">Pay</button>
|
|
389
|
+
</form>
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Error Handling
|
|
395
|
+
|
|
396
|
+
```tsx
|
|
397
|
+
function MyComponent() {
|
|
398
|
+
const { connect, error } = useWallet();
|
|
399
|
+
const [txError, setTxError] = useState<string | null>(null);
|
|
400
|
+
|
|
401
|
+
const handleConnect = async () => {
|
|
402
|
+
try {
|
|
403
|
+
await connect();
|
|
404
|
+
} catch (err) {
|
|
405
|
+
console.error('Failed to connect:', err);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
return (
|
|
410
|
+
<div>
|
|
411
|
+
{error && <p className="error">{error.message}</p>}
|
|
412
|
+
{txError && <p className="error">{txError}</p>}
|
|
413
|
+
<button onClick={handleConnect}>Connect</button>
|
|
414
|
+
</div>
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
## π TypeScript Support
|
|
420
|
+
|
|
421
|
+
Full TypeScript support with comprehensive types:
|
|
422
|
+
|
|
423
|
+
```tsx
|
|
424
|
+
import type {
|
|
425
|
+
WalletAccount,
|
|
426
|
+
WalletContextValue,
|
|
427
|
+
AccountBalance,
|
|
428
|
+
SignTransactionResponse,
|
|
429
|
+
WalletTheme,
|
|
430
|
+
NetworkType,
|
|
431
|
+
} from 'stellar-wallet-kit';
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## π¨ Styling
|
|
435
|
+
|
|
436
|
+
The package provides unstyled components that you can customize:
|
|
437
|
+
|
|
438
|
+
### Using Tailwind CSS
|
|
439
|
+
|
|
440
|
+
```tsx
|
|
441
|
+
<ConnectButton
|
|
442
|
+
className="px-6 py-3 bg-purple-600 text-white rounded-lg hover:bg-purple-700"
|
|
443
|
+
/>
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### Using Custom Styles
|
|
447
|
+
|
|
448
|
+
```tsx
|
|
449
|
+
<ConnectButton
|
|
450
|
+
style={{
|
|
451
|
+
backgroundColor: '#8b5cf6',
|
|
452
|
+
color: 'white',
|
|
453
|
+
padding: '12px 24px',
|
|
454
|
+
borderRadius: '12px',
|
|
455
|
+
}}
|
|
456
|
+
/>
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
## π§ͺ Testing Transaction Signing
|
|
460
|
+
|
|
461
|
+
Generate safe test transactions:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
npm install @stellar/stellar-sdk
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
```tsx
|
|
468
|
+
import * as StellarSdk from '@stellar/stellar-sdk';
|
|
469
|
+
|
|
470
|
+
async function generateTestTx(publicKey: string) {
|
|
471
|
+
const server = new StellarSdk.Horizon.Server(
|
|
472
|
+
'https://horizon-testnet.stellar.org'
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
const account = await server.loadAccount(publicKey);
|
|
476
|
+
|
|
477
|
+
const transaction = new StellarSdk.TransactionBuilder(account, {
|
|
478
|
+
fee: StellarSdk.BASE_FEE,
|
|
479
|
+
networkPassphrase: StellarSdk.Networks.TESTNET,
|
|
480
|
+
})
|
|
481
|
+
.addMemo(StellarSdk.Memo.text('Test transaction'))
|
|
482
|
+
.setTimeout(300)
|
|
483
|
+
.build();
|
|
484
|
+
|
|
485
|
+
return transaction.toXDR();
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
## π€ Contributing
|
|
490
|
+
|
|
491
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
492
|
+
|
|
493
|
+
### Development Setup
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
# Clone the repository
|
|
497
|
+
git clone https://github.com/tusharpamnani/stellar-wallet-kit
|
|
498
|
+
cd stellar-wallet-kit
|
|
499
|
+
|
|
500
|
+
# Install dependencies
|
|
501
|
+
npm install
|
|
502
|
+
|
|
503
|
+
# Build the package
|
|
504
|
+
npm run build
|
|
505
|
+
|
|
506
|
+
# Run in development mode
|
|
507
|
+
npm run dev
|
|
508
|
+
|
|
509
|
+
# Link for local testing
|
|
510
|
+
npm link
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Adding a New Wallet
|
|
514
|
+
|
|
515
|
+
1. Create a new adapter in `src/adapters/`
|
|
516
|
+
2. Implement the `WalletAdapter` interface
|
|
517
|
+
3. Register it in `WalletContext.tsx`
|
|
518
|
+
4. Add metadata and icon
|
|
519
|
+
5. Submit a PR!
|
|
520
|
+
|
|
521
|
+
## π Examples
|
|
522
|
+
|
|
523
|
+
Check out the `/example` directory for complete working examples:
|
|
524
|
+
|
|
525
|
+
- Basic wallet connection
|
|
526
|
+
- Balance display
|
|
527
|
+
- Transaction signing
|
|
528
|
+
- Payment forms
|
|
529
|
+
- Next.js integration
|
|
530
|
+
|
|
531
|
+
## π Troubleshooting
|
|
532
|
+
|
|
533
|
+
### Next.js: "You're importing a component that needs useState"
|
|
534
|
+
**Solution:** Add `'use client'` directive to the top of your file.
|
|
535
|
+
|
|
536
|
+
### TypeScript: Type conflicts between React versions
|
|
537
|
+
**Solution:** Add `"skipLibCheck": true` to your `tsconfig.json`.
|
|
538
|
+
|
|
539
|
+
### Freighter not detected
|
|
540
|
+
**Solution:** Make sure Freighter extension is installed and enabled in your browser.
|
|
541
|
+
|
|
542
|
+
### Balances not loading
|
|
543
|
+
**Solution:** Ensure your account is funded on the selected network. Use the [Stellar Laboratory](https://laboratory.stellar.org/#account-creator) to fund testnet accounts.
|
|
544
|
+
|
|
545
|
+
## π Documentation
|
|
546
|
+
|
|
547
|
+
- [Freighter API Docs](https://docs.freighter.app/)
|
|
548
|
+
- [Stellar Docs](https://developers.stellar.org/)
|
|
549
|
+
- [Stellar SDK](https://stellar.github.io/js-stellar-sdk/)
|
|
550
|
+
|
|
551
|
+
## πΊοΈ Roadmap
|
|
552
|
+
|
|
553
|
+
- [x] Freighter wallet support
|
|
554
|
+
- [x] Balance checking
|
|
555
|
+
- [x] Auto-reconnect
|
|
556
|
+
- [x] Next.js App Router support
|
|
557
|
+
- [ ] xBull wallet support
|
|
558
|
+
- [ ] Albedo wallet support
|
|
559
|
+
- [ ] Rabet wallet support
|
|
560
|
+
- [ ] WalletConnect integration
|
|
561
|
+
- [ ] Transaction history
|
|
562
|
+
- [ ] Multi-account support
|
|
563
|
+
- [ ] Mobile wallet support
|
|
564
|
+
- [ ] Hardware wallet support
|
|
565
|
+
|
|
566
|
+
## π License
|
|
567
|
+
|
|
568
|
+
MIT Β© TusharPamnani
|
|
569
|
+
|
|
570
|
+
## π Acknowledgments
|
|
571
|
+
|
|
572
|
+
- Inspired by [RainbowKit](https://www.rainbowkit.com/)
|
|
573
|
+
- Built for the [Stellar](https://stellar.org/) ecosystem
|
|
574
|
+
- Thanks to the Stellar Developer Foundation
|
|
575
|
+
|
|
576
|
+
## π¬ Community & Support
|
|
577
|
+
|
|
578
|
+
- [GitHub Issues](https://github.com/yourusername/stellar-wallet-kit/issues)
|
|
579
|
+
- [Stellar Discord](https://discord.gg/stellardev)
|
|
580
|
+
- [Stack Exchange](https://stellar.stackexchange.com/)
|
|
581
|
+
|
|
582
|
+
## π Show Your Support
|
|
583
|
+
|
|
584
|
+
If this project helped you, please give it a βοΈ on GitHub!
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
**Made with β€οΈ for the Stellar community**
|