@supanovaapp/sdk 0.2.1 → 0.2.4
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 +115 -6
- package/dist/index.cjs.js +521 -519
- package/dist/index.d.ts +211 -13
- package/dist/index.esm.js +58741 -53214
- package/package.json +14 -3
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ For a quick overview of the code, check out the demo application in the `/demo`
|
|
|
9
9
|
## Key Features
|
|
10
10
|
|
|
11
11
|
- **Privy.io Authentication** - Email, wallet, and social login methods
|
|
12
|
+
- **EVM Smart Wallets** - Support for Privy Smart Wallets with gas sponsorship
|
|
12
13
|
- **Built-in Confirmation Modals** - User-friendly signing confirmations
|
|
13
14
|
- **Theme Support** - Light/dark mode with customizable appearance
|
|
14
15
|
- **Automatic Polling** - Transaction completion tracking
|
|
@@ -27,6 +28,12 @@ yarn add @supa/sdk
|
|
|
27
28
|
pnpm add @supa/sdk
|
|
28
29
|
```
|
|
29
30
|
|
|
31
|
+
#### Optional: For Smart Wallets support
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install permissionless viem
|
|
35
|
+
```
|
|
36
|
+
|
|
30
37
|
### From local repository
|
|
31
38
|
|
|
32
39
|
If the package is not yet published to npm, you can install it locally:
|
|
@@ -152,7 +159,7 @@ function App() {
|
|
|
152
159
|
**Configuration options:**
|
|
153
160
|
- `privyAppId` - Your Privy App ID (required)
|
|
154
161
|
- `apiBaseUrl` - Backend API URL (default: `https://stage_api.supa.fyi`)
|
|
155
|
-
- `nodeIdentifier` - Canton node identifier
|
|
162
|
+
- `nodeIdentifier` - Canton node identifier
|
|
156
163
|
- `appearance` - Theme and styling options
|
|
157
164
|
- `loginMethods` - Array of enabled authentication methods
|
|
158
165
|
|
|
@@ -234,17 +241,81 @@ const filteredContracts = await getActiveContracts([
|
|
|
234
241
|
]);
|
|
235
242
|
```
|
|
236
243
|
|
|
244
|
+
#### Get Canton Balances
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
const { getBalances, cantonBalances } = useCanton();
|
|
248
|
+
|
|
249
|
+
// Fetch balances
|
|
250
|
+
try {
|
|
251
|
+
const balances = await getBalances();
|
|
252
|
+
|
|
253
|
+
// Find Canton Coin token
|
|
254
|
+
const cantonCoin = balances.tokens.find(
|
|
255
|
+
token => token.instrumentId.id === 'Amulet'
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
if (cantonCoin) {
|
|
259
|
+
console.log('Unlocked balance:', cantonCoin.totalUnlockedBalance);
|
|
260
|
+
console.log('Locked balance:', cantonCoin.totalLockedBalance);
|
|
261
|
+
console.log('Total balance:', cantonCoin.totalBalance);
|
|
262
|
+
|
|
263
|
+
// Access locked UTXOs for details
|
|
264
|
+
cantonCoin.lockedUtxos.forEach(utxo => {
|
|
265
|
+
console.log('Locked amount:', utxo.amount);
|
|
266
|
+
console.log('Expires at:', utxo.lock.expiresAt);
|
|
267
|
+
console.log('Context:', utxo.lock.context);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
} catch (error) {
|
|
271
|
+
console.error('Failed to load balances:', error);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Or use the cached state
|
|
275
|
+
if (cantonBalances) {
|
|
276
|
+
console.log('Cached balances:', cantonBalances);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### Send Canton Coin
|
|
281
|
+
|
|
282
|
+
```tsx
|
|
283
|
+
const { sendCantonCoin } = useCanton();
|
|
284
|
+
|
|
285
|
+
try {
|
|
286
|
+
const result = await sendCantonCoin(
|
|
287
|
+
'receiver-party::1220abc123...', // Receiver Party ID
|
|
288
|
+
'100.5', // Amount (max 10 decimal places)
|
|
289
|
+
'Payment for services', // Optional memo
|
|
290
|
+
{
|
|
291
|
+
timeout: 30000, // completion timeout (ms)
|
|
292
|
+
pollInterval: 1000, // polling interval (ms)
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
console.log('Canton Coin sent successfully:', result);
|
|
296
|
+
} catch (error) {
|
|
297
|
+
// Special handling for preapproval errors
|
|
298
|
+
if (error.message.includes('preapproval')) {
|
|
299
|
+
console.error('Receiver must have transfer preapproval enabled');
|
|
300
|
+
} else {
|
|
301
|
+
console.error('Transfer failed:', error);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Note**: The amount cannot have more than 10 decimal places. Transfers are only supported to wallets with preapproved transfers enabled.
|
|
307
|
+
|
|
237
308
|
#### Submit a Transaction
|
|
238
309
|
|
|
239
310
|
```tsx
|
|
240
311
|
const { sendTransaction } = useCanton();
|
|
241
312
|
|
|
242
|
-
const
|
|
243
|
-
// Your Canton command
|
|
313
|
+
const commands = {
|
|
314
|
+
// Your Canton command(s)
|
|
244
315
|
};
|
|
245
316
|
|
|
246
317
|
try {
|
|
247
|
-
const result = await sendTransaction(
|
|
318
|
+
const result = await sendTransaction(commands, disclosedContracts, {
|
|
248
319
|
timeout: 30000, // completion timeout (ms)
|
|
249
320
|
pollInterval: 1000, // polling interval (ms)
|
|
250
321
|
});
|
|
@@ -336,7 +407,7 @@ await sendTransaction(command, contracts, {
|
|
|
336
407
|
| Hook | Purpose | Key Methods |
|
|
337
408
|
|------|---------|-------------|
|
|
338
409
|
| `useAuth` | Authentication | `login`, `logout`, `authenticated`, `user` |
|
|
339
|
-
| `useCanton` | Canton Network | `registerCanton`, `signMessage`, `sendTransaction`, `getActiveContracts`, `tapDevnet` |
|
|
410
|
+
| `useCanton` | Canton Network | `registerCanton`, `getBalances`, `sendCantonCoin`, `signMessage`, `sendTransaction`, `getActiveContracts`, `tapDevnet` |
|
|
340
411
|
| `useSignMessage` | Enhanced message signing | `signMessage` with custom modals |
|
|
341
412
|
| `useSendTransaction` | Enhanced transactions | `sendTransaction` with custom modals |
|
|
342
413
|
| `useConfirmModal` | Generic modals | `confirm`, `signMessageConfirm`, `signTransactionConfirm` |
|
|
@@ -358,11 +429,18 @@ import type {
|
|
|
358
429
|
CantonMeResponseDto,
|
|
359
430
|
CantonActiveContractsResponseDto,
|
|
360
431
|
CantonQueryCompletionResponseDto,
|
|
432
|
+
CantonWalletBalancesResponseDto,
|
|
433
|
+
CantonTokenBalanceDto,
|
|
434
|
+
CantonInstrumentIdDto,
|
|
435
|
+
CantonLockedUtxoDto,
|
|
436
|
+
CantonUnlockedUtxoDto,
|
|
437
|
+
CantonPrepareAmuletTransferRequestDto,
|
|
361
438
|
|
|
362
439
|
// Option Types
|
|
363
440
|
SignMessageOptions,
|
|
364
441
|
SendTransactionOptions,
|
|
365
442
|
ConfirmModalOptions,
|
|
443
|
+
CantonSubmitPreparedOptions,
|
|
366
444
|
} from '@supa/sdk';
|
|
367
445
|
```
|
|
368
446
|
|
|
@@ -395,7 +473,9 @@ Visit http://localhost:6969 to see the demo.
|
|
|
395
473
|
|
|
396
474
|
The demo application includes:
|
|
397
475
|
- Complete authentication flow
|
|
398
|
-
- Canton wallet registration
|
|
476
|
+
- Canton wallet registration with automatic transfer preapproval
|
|
477
|
+
- Canton balance display with locked/unlocked UTXO details
|
|
478
|
+
- Canton Coin sending with validation
|
|
399
479
|
- Message signing with modals
|
|
400
480
|
- Transaction sending with modals
|
|
401
481
|
- Contract querying
|
|
@@ -455,9 +535,38 @@ npm publish
|
|
|
455
535
|
## Support
|
|
456
536
|
|
|
457
537
|
- **Demo**: Full working example in `/demo` folder
|
|
538
|
+
- **Documentation**:
|
|
539
|
+
- [Smart Wallets Guide](./doc/smart-wallets.md)
|
|
540
|
+
- [Usage Guide](./doc/usage.md)
|
|
458
541
|
- **Issues**: Report bugs on GitHub
|
|
459
542
|
- **Examples**: Check out the demo application for complete implementation examples
|
|
460
543
|
|
|
544
|
+
## Advanced Features
|
|
545
|
+
|
|
546
|
+
### EVM Smart Wallets
|
|
547
|
+
|
|
548
|
+
Supa SDK supports Privy Smart Wallets for EVM chains with gas sponsorship capabilities.
|
|
549
|
+
|
|
550
|
+
```tsx
|
|
551
|
+
<SupaProvider
|
|
552
|
+
config={{
|
|
553
|
+
privyAppId: 'your-app-id',
|
|
554
|
+
nodeIdentifier: 'node',
|
|
555
|
+
smartWallets: {
|
|
556
|
+
enabled: true,
|
|
557
|
+
paymasterContext: {
|
|
558
|
+
mode: 'SPONSORED',
|
|
559
|
+
// ... paymaster configuration
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}}
|
|
563
|
+
>
|
|
564
|
+
<YourApp />
|
|
565
|
+
</SupaProvider>
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
See [Smart Wallets documentation](./doc/smart-wallets.md) for detailed setup and usage.
|
|
569
|
+
|
|
461
570
|
---
|
|
462
571
|
|
|
463
572
|
**Version:** 0.1.0
|