@sats-connect/core 0.5.7-919d21a → 0.5.7-dfae3ce

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/dist/index.mjs CHANGED
@@ -1,25 +1,77 @@
1
- // src/provider/types.ts
1
+ // src/types.ts
2
2
  import * as v from "valibot";
3
+ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
4
+ BitcoinNetworkType2["Mainnet"] = "Mainnet";
5
+ BitcoinNetworkType2["Testnet"] = "Testnet";
6
+ BitcoinNetworkType2["Testnet4"] = "Testnet4";
7
+ BitcoinNetworkType2["Signet"] = "Signet";
8
+ BitcoinNetworkType2["Regtest"] = "Regtest";
9
+ return BitcoinNetworkType2;
10
+ })(BitcoinNetworkType || {});
11
+ var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
12
+ var rpcRequestMessageSchema = v.object({
13
+ jsonrpc: v.literal("2.0"),
14
+ method: v.string(),
15
+ params: v.optional(
16
+ v.union([
17
+ v.array(v.unknown()),
18
+ v.looseObject({}),
19
+ // Note: This is to support current incorrect usage of RPC 2.0. Params need
20
+ // to be either an array or an object when provided. Changing this now would
21
+ // be a breaking change, so accepting null values for now. Tracking in
22
+ // https://linear.app/xverseapp/issue/ENG-4538.
23
+ v.null()
24
+ ])
25
+ ),
26
+ id: v.unwrap(RpcIdSchema)
27
+ });
28
+ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
29
+ RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
30
+ RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
31
+ RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
32
+ RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
33
+ RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
34
+ RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
35
+ RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
36
+ RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
37
+ return RpcErrorCode2;
38
+ })(RpcErrorCode || {});
39
+ var rpcSuccessResponseMessageSchema = v.object({
40
+ jsonrpc: v.literal("2.0"),
41
+ result: v.nonOptional(v.unknown()),
42
+ id: RpcIdSchema
43
+ });
44
+ var rpcErrorResponseMessageSchema = v.object({
45
+ jsonrpc: v.literal("2.0"),
46
+ error: v.nonOptional(v.unknown()),
47
+ id: RpcIdSchema
48
+ });
49
+ var rpcResponseMessageSchema = v.union([
50
+ rpcSuccessResponseMessageSchema,
51
+ rpcErrorResponseMessageSchema
52
+ ]);
53
+
54
+ // src/provider/types.ts
55
+ import * as v2 from "valibot";
3
56
  var accountChangeEventName = "accountChange";
4
- var accountChangeSchema = v.object({
5
- type: v.literal(accountChangeEventName)
57
+ var accountChangeSchema = v2.object({
58
+ type: v2.literal(accountChangeEventName)
6
59
  });
7
60
  var networkChangeEventName = "networkChange";
8
- var networkType = ["Mainnet", "Testnet", "Testnet4", "Signet", "Regtest"];
9
- var networkChangeSchema = v.object({
10
- type: v.literal(networkChangeEventName),
11
- bitcoin: v.object({
12
- name: v.picklist(networkType)
61
+ var networkChangeSchema = v2.object({
62
+ type: v2.literal(networkChangeEventName),
63
+ bitcoin: v2.object({
64
+ name: v2.enum(BitcoinNetworkType)
13
65
  }),
14
- stacks: v.object({
15
- name: v.string()
66
+ stacks: v2.object({
67
+ name: v2.string()
16
68
  })
17
69
  });
18
70
  var disconnectEventName = "disconnect";
19
- var disconnectSchema = v.object({
20
- type: v.literal(disconnectEventName)
71
+ var disconnectSchema = v2.object({
72
+ type: v2.literal(disconnectEventName)
21
73
  });
22
- var walletEventSchema = v.variant("type", [
74
+ var walletEventSchema = v2.variant("type", [
23
75
  accountChangeSchema,
24
76
  networkChangeSchema,
25
77
  disconnectSchema
@@ -64,59 +116,6 @@ function getSupportedWallets() {
64
116
  return wallets;
65
117
  }
66
118
 
67
- // src/types.ts
68
- import * as v2 from "valibot";
69
- var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
70
- BitcoinNetworkType2["Mainnet"] = "Mainnet";
71
- BitcoinNetworkType2["Testnet"] = "Testnet";
72
- BitcoinNetworkType2["Testnet4"] = "Testnet4";
73
- BitcoinNetworkType2["Signet"] = "Signet";
74
- BitcoinNetworkType2["Regtest"] = "Regtest";
75
- return BitcoinNetworkType2;
76
- })(BitcoinNetworkType || {});
77
- var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
78
- var rpcRequestMessageSchema = v2.object({
79
- jsonrpc: v2.literal("2.0"),
80
- method: v2.string(),
81
- params: v2.optional(
82
- v2.union([
83
- v2.array(v2.unknown()),
84
- v2.looseObject({}),
85
- // Note: This is to support current incorrect usage of RPC 2.0. Params need
86
- // to be either an array or an object when provided. Changing this now would
87
- // be a breaking change, so accepting null values for now. Tracking in
88
- // https://linear.app/xverseapp/issue/ENG-4538.
89
- v2.null()
90
- ])
91
- ),
92
- id: v2.unwrap(RpcIdSchema)
93
- });
94
- var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
95
- RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
96
- RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
97
- RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
98
- RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
99
- RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
100
- RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
101
- RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
102
- RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
103
- return RpcErrorCode2;
104
- })(RpcErrorCode || {});
105
- var rpcSuccessResponseMessageSchema = v2.object({
106
- jsonrpc: v2.literal("2.0"),
107
- result: v2.nonOptional(v2.unknown()),
108
- id: RpcIdSchema
109
- });
110
- var rpcErrorResponseMessageSchema = v2.object({
111
- jsonrpc: v2.literal("2.0"),
112
- error: v2.nonOptional(v2.unknown()),
113
- id: RpcIdSchema
114
- });
115
- var rpcResponseMessageSchema = v2.union([
116
- rpcSuccessResponseMessageSchema,
117
- rpcErrorResponseMessageSchema
118
- ]);
119
-
120
119
  // src/request/index.ts
121
120
  import * as v21 from "valibot";
122
121
 
@@ -209,30 +208,15 @@ var stxDeployContractRequestMessageSchema = v4.object({
209
208
  });
210
209
 
211
210
  // src/request/types/stxMethods/getAccounts.ts
211
+ import * as v8 from "valibot";
212
+
213
+ // src/request/types/walletMethods.ts
214
+ import * as v7 from "valibot";
215
+
216
+ // src/request/types/common.ts
212
217
  import * as v5 from "valibot";
213
- var stxGetAccountsMethodName = "stx_getAccounts";
214
- var stxGetAccountsParamsSchema = v5.nullish(v5.null());
215
- var stxGetAccountsResultSchema = v5.object({
216
- /**
217
- * The addresses generated for the given purposes.
218
- */
219
- addresses: v5.array(
220
- v5.object({
221
- address: v5.string(),
222
- publicKey: v5.string(),
223
- gaiaHubUrl: v5.string(),
224
- gaiaAppKey: v5.string()
225
- })
226
- )
227
- });
228
- var stxGetAccountsRequestMessageSchema = v5.object({
229
- ...rpcRequestMessageSchema.entries,
230
- ...v5.object({
231
- method: v5.literal(stxGetAccountsMethodName),
232
- params: stxGetAccountsParamsSchema,
233
- id: v5.string()
234
- }).entries
235
- });
218
+ var walletTypes = ["software", "ledger", "keystone"];
219
+ var walletTypeSchema = v5.picklist(walletTypes);
236
220
 
237
221
  // src/addresses/index.ts
238
222
  import { createUnsecuredToken } from "jsontokens";
@@ -279,185 +263,369 @@ var getAddress = async (options) => {
279
263
  }
280
264
  };
281
265
 
266
+ // src/request/types/walletMethods.ts
267
+ var accountActionsSchema = v7.object({
268
+ read: v7.optional(v7.boolean())
269
+ });
270
+ var walletActionsSchema = v7.object({
271
+ readNetwork: v7.optional(v7.boolean())
272
+ });
273
+ var accountPermissionSchema = v7.object({
274
+ type: v7.literal("account"),
275
+ resourceId: v7.string(),
276
+ clientId: v7.string(),
277
+ actions: accountActionsSchema
278
+ });
279
+ var walletPermissionSchema = v7.object({
280
+ type: v7.literal("wallet"),
281
+ resourceId: v7.string(),
282
+ clientId: v7.string(),
283
+ actions: walletActionsSchema
284
+ });
285
+ var PermissionRequestParams = v7.variant("type", [
286
+ v7.object({
287
+ ...v7.omit(accountPermissionSchema, ["clientId"]).entries
288
+ }),
289
+ v7.object({
290
+ ...v7.omit(walletPermissionSchema, ["clientId"]).entries
291
+ })
292
+ ]);
293
+ var permission = v7.variant("type", [accountPermissionSchema, walletPermissionSchema]);
294
+ var requestPermissionsMethodName = "wallet_requestPermissions";
295
+ var requestPermissionsParamsSchema = v7.nullish(v7.array(PermissionRequestParams));
296
+ var requestPermissionsResultSchema = v7.literal(true);
297
+ var requestPermissionsRequestMessageSchema = v7.object({
298
+ ...rpcRequestMessageSchema.entries,
299
+ ...v7.object({
300
+ method: v7.literal(requestPermissionsMethodName),
301
+ params: requestPermissionsParamsSchema,
302
+ id: v7.string()
303
+ }).entries
304
+ });
305
+ var renouncePermissionsMethodName = "wallet_renouncePermissions";
306
+ var renouncePermissionsParamsSchema = v7.nullish(v7.null());
307
+ var renouncePermissionsResultSchema = v7.nullish(v7.null());
308
+ var renouncePermissionsRequestMessageSchema = v7.object({
309
+ ...rpcRequestMessageSchema.entries,
310
+ ...v7.object({
311
+ method: v7.literal(renouncePermissionsMethodName),
312
+ params: renouncePermissionsParamsSchema,
313
+ id: v7.string()
314
+ }).entries
315
+ });
316
+ var disconnectMethodName = "wallet_disconnect";
317
+ var disconnectParamsSchema = v7.nullish(v7.null());
318
+ var disconnectResultSchema = v7.nullish(v7.null());
319
+ var disconnectRequestMessageSchema = v7.object({
320
+ ...rpcRequestMessageSchema.entries,
321
+ ...v7.object({
322
+ method: v7.literal(disconnectMethodName),
323
+ params: disconnectParamsSchema,
324
+ id: v7.string()
325
+ }).entries
326
+ });
327
+ var getWalletTypeMethodName = "wallet_getWalletType";
328
+ var getWalletTypeParamsSchema = v7.nullish(v7.null());
329
+ var getWalletTypeResultSchema = walletTypeSchema;
330
+ var getWalletTypeRequestMessageSchema = v7.object({
331
+ ...rpcRequestMessageSchema.entries,
332
+ ...v7.object({
333
+ method: v7.literal(getWalletTypeMethodName),
334
+ params: getWalletTypeParamsSchema,
335
+ id: v7.string()
336
+ }).entries
337
+ });
338
+ var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
339
+ var getCurrentPermissionsParamsSchema = v7.nullish(v7.null());
340
+ var getCurrentPermissionsResultSchema = v7.array(permission);
341
+ var getCurrentPermissionsRequestMessageSchema = v7.object({
342
+ ...rpcRequestMessageSchema.entries,
343
+ ...v7.object({
344
+ method: v7.literal(getCurrentPermissionsMethodName),
345
+ params: getCurrentPermissionsParamsSchema,
346
+ id: v7.string()
347
+ }).entries
348
+ });
349
+ var getNetworkMethodName = "wallet_getNetwork";
350
+ var getNetworkParamsSchema = v7.nullish(v7.null());
351
+ var getNetworkResultSchema = v7.object({
352
+ bitcoin: v7.object({
353
+ name: v7.enum(BitcoinNetworkType)
354
+ }),
355
+ stacks: v7.object({
356
+ name: v7.string()
357
+ })
358
+ });
359
+ var getNetworkRequestMessageSchema = v7.object({
360
+ ...rpcRequestMessageSchema.entries,
361
+ ...v7.object({
362
+ method: v7.literal(getNetworkMethodName),
363
+ params: getNetworkParamsSchema,
364
+ id: v7.string()
365
+ }).entries
366
+ });
367
+ var changeNetworkMethodName = "wallet_changeNetwork";
368
+ var changeNetworkParamsSchema = v7.nullish(
369
+ v7.object({
370
+ name: v7.enum(BitcoinNetworkType)
371
+ })
372
+ );
373
+ var changeNetworkResultSchema = v7.nullish(v7.null());
374
+ var changeNetworkRequestMessageSchema = v7.object({
375
+ ...rpcRequestMessageSchema.entries,
376
+ ...v7.object({
377
+ method: v7.literal(changeNetworkMethodName),
378
+ params: changeNetworkParamsSchema,
379
+ id: v7.string()
380
+ }).entries
381
+ });
382
+ var getAccountMethodName = "wallet_getAccount";
383
+ var getAccountParamsSchema = v7.nullish(v7.null());
384
+ var getAccountResultSchema = v7.object({
385
+ id: v7.string(),
386
+ addresses: v7.array(addressSchema),
387
+ walletType: walletTypeSchema,
388
+ network: getNetworkResultSchema
389
+ });
390
+ var getAccountRequestMessageSchema = v7.object({
391
+ ...rpcRequestMessageSchema.entries,
392
+ ...v7.object({
393
+ method: v7.literal(getAccountMethodName),
394
+ params: getAccountParamsSchema,
395
+ id: v7.string()
396
+ }).entries
397
+ });
398
+ var connectMethodName = "wallet_connect";
399
+ var connectParamsSchema = v7.nullish(
400
+ v7.object({
401
+ permissions: v7.optional(v7.array(PermissionRequestParams)),
402
+ addresses: v7.optional(v7.array(v7.enum(AddressPurpose))),
403
+ message: v7.optional(
404
+ v7.pipe(v7.string(), v7.maxLength(80, "The message must not exceed 80 characters."))
405
+ )
406
+ })
407
+ );
408
+ var connectResultSchema = v7.object({
409
+ id: v7.string(),
410
+ addresses: v7.array(addressSchema),
411
+ walletType: walletTypeSchema,
412
+ network: getNetworkResultSchema
413
+ });
414
+ var connectRequestMessageSchema = v7.object({
415
+ ...rpcRequestMessageSchema.entries,
416
+ ...v7.object({
417
+ method: v7.literal(connectMethodName),
418
+ params: connectParamsSchema,
419
+ id: v7.string()
420
+ }).entries
421
+ });
422
+
423
+ // src/request/types/stxMethods/getAccounts.ts
424
+ var stxGetAccountsMethodName = "stx_getAccounts";
425
+ var stxGetAccountsParamsSchema = v8.nullish(v8.null());
426
+ var stxGetAccountsResultSchema = v8.object({
427
+ /**
428
+ * The addresses generated for the given purposes.
429
+ */
430
+ addresses: v8.array(
431
+ v8.object({
432
+ address: v8.string(),
433
+ publicKey: v8.string(),
434
+ gaiaHubUrl: v8.string(),
435
+ gaiaAppKey: v8.string()
436
+ })
437
+ ),
438
+ network: getNetworkResultSchema
439
+ });
440
+ var stxGetAccountsRequestMessageSchema = v8.object({
441
+ ...rpcRequestMessageSchema.entries,
442
+ ...v8.object({
443
+ method: v8.literal(stxGetAccountsMethodName),
444
+ params: stxGetAccountsParamsSchema,
445
+ id: v8.string()
446
+ }).entries
447
+ });
448
+
282
449
  // src/request/types/stxMethods/getAddresses.ts
283
- import * as v7 from "valibot";
450
+ import * as v9 from "valibot";
284
451
  var stxGetAddressesMethodName = "stx_getAddresses";
285
- var stxGetAddressesParamsSchema = v7.nullish(
286
- v7.object({
452
+ var stxGetAddressesParamsSchema = v9.nullish(
453
+ v9.object({
287
454
  /**
288
455
  * A message to be displayed to the user in the request prompt.
289
456
  */
290
- message: v7.optional(v7.string())
457
+ message: v9.optional(v9.string())
291
458
  })
292
459
  );
293
- var stxGetAddressesResultSchema = v7.object({
460
+ var stxGetAddressesResultSchema = v9.object({
294
461
  /**
295
462
  * The addresses generated for the given purposes.
296
463
  */
297
- addresses: v7.array(addressSchema)
464
+ addresses: v9.array(addressSchema),
465
+ network: getNetworkResultSchema
298
466
  });
299
- var stxGetAddressesRequestMessageSchema = v7.object({
467
+ var stxGetAddressesRequestMessageSchema = v9.object({
300
468
  ...rpcRequestMessageSchema.entries,
301
- ...v7.object({
302
- method: v7.literal(stxGetAddressesMethodName),
469
+ ...v9.object({
470
+ method: v9.literal(stxGetAddressesMethodName),
303
471
  params: stxGetAddressesParamsSchema,
304
- id: v7.string()
472
+ id: v9.string()
305
473
  }).entries
306
474
  });
307
475
 
308
476
  // src/request/types/stxMethods/signMessage.ts
309
- import * as v8 from "valibot";
477
+ import * as v10 from "valibot";
310
478
  var stxSignMessageMethodName = "stx_signMessage";
311
- var stxSignMessageParamsSchema = v8.object({
479
+ var stxSignMessageParamsSchema = v10.object({
312
480
  /**
313
481
  * The message to sign.
314
482
  */
315
- message: v8.string(),
483
+ message: v10.string(),
316
484
  /**
317
485
  * The public key to sign the message with.
318
486
  */
319
- publicKey: v8.string(),
487
+ publicKey: v10.string(),
320
488
  /**
321
489
  * The format version of the parameter.
322
490
  */
323
- parameterFormatVersion: v8.optional(v8.number())
491
+ parameterFormatVersion: v10.optional(v10.number())
324
492
  });
325
- var stxSignMessageResultSchema = v8.object({
493
+ var stxSignMessageResultSchema = v10.object({
326
494
  /**
327
495
  * The signature of the message.
328
496
  */
329
- signature: v8.string(),
497
+ signature: v10.string(),
330
498
  /**
331
499
  * The public key used to sign the message.
332
500
  */
333
- publicKey: v8.string()
501
+ publicKey: v10.string()
334
502
  });
335
- var stxSignMessageRequestMessageSchema = v8.object({
503
+ var stxSignMessageRequestMessageSchema = v10.object({
336
504
  ...rpcRequestMessageSchema.entries,
337
- ...v8.object({
338
- method: v8.literal(stxSignMessageMethodName),
505
+ ...v10.object({
506
+ method: v10.literal(stxSignMessageMethodName),
339
507
  params: stxSignMessageParamsSchema,
340
- id: v8.string()
508
+ id: v10.string()
341
509
  }).entries
342
510
  });
343
511
 
344
512
  // src/request/types/stxMethods/signStructuredMessage.ts
345
- import * as v9 from "valibot";
513
+ import * as v11 from "valibot";
346
514
  var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
347
- var stxSignStructuredMessageParamsSchema = v9.object({
515
+ var stxSignStructuredMessageParamsSchema = v11.object({
348
516
  /**
349
517
  * The domain to be signed.
350
518
  */
351
- domain: v9.string(),
519
+ domain: v11.string(),
352
520
  /**
353
521
  * Message payload to be signed.
354
522
  */
355
- message: v9.string(),
523
+ message: v11.string(),
356
524
  /**
357
525
  * The format version of the parameter.
358
526
  */
359
- parameterFormatVersion: v9.optional(v9.number()),
527
+ parameterFormatVersion: v11.optional(v11.number()),
360
528
  /**
361
529
  * The public key to sign the message with.
362
530
  */
363
- publicKey: v9.optional(v9.string())
531
+ publicKey: v11.optional(v11.string())
364
532
  });
365
- var stxSignStructuredMessageResultSchema = v9.object({
533
+ var stxSignStructuredMessageResultSchema = v11.object({
366
534
  /**
367
535
  * Signature of the message.
368
536
  */
369
- signature: v9.string(),
537
+ signature: v11.string(),
370
538
  /**
371
539
  * Public key as hex-encoded string.
372
540
  */
373
- publicKey: v9.string()
541
+ publicKey: v11.string()
374
542
  });
375
- var stxSignStructuredMessageRequestMessageSchema = v9.object({
543
+ var stxSignStructuredMessageRequestMessageSchema = v11.object({
376
544
  ...rpcRequestMessageSchema.entries,
377
- ...v9.object({
378
- method: v9.literal(stxSignStructuredMessageMethodName),
545
+ ...v11.object({
546
+ method: v11.literal(stxSignStructuredMessageMethodName),
379
547
  params: stxSignStructuredMessageParamsSchema,
380
- id: v9.string()
548
+ id: v11.string()
381
549
  }).entries
382
550
  });
383
551
 
384
552
  // src/request/types/stxMethods/signTransaction.ts
385
- import * as v10 from "valibot";
553
+ import * as v12 from "valibot";
386
554
  var stxSignTransactionMethodName = "stx_signTransaction";
387
- var stxSignTransactionParamsSchema = v10.object({
555
+ var stxSignTransactionParamsSchema = v12.object({
388
556
  /**
389
557
  * The transaction to sign as a hex-encoded string.
390
558
  */
391
- transaction: v10.string(),
559
+ transaction: v12.string(),
392
560
  /**
393
561
  * The public key to sign the transaction with. The wallet may use any key
394
562
  * when not provided.
395
563
  */
396
- pubkey: v10.optional(v10.string()),
564
+ pubkey: v12.optional(v12.string()),
397
565
  /**
398
566
  * Whether to broadcast the transaction after signing. Defaults to `true`.
399
567
  */
400
- broadcast: v10.optional(v10.boolean())
568
+ broadcast: v12.optional(v12.boolean())
401
569
  });
402
- var stxSignTransactionResultSchema = v10.object({
570
+ var stxSignTransactionResultSchema = v12.object({
403
571
  /**
404
572
  * The signed transaction as a hex-encoded string.
405
573
  */
406
- transaction: v10.string()
574
+ transaction: v12.string()
407
575
  });
408
- var stxSignTransactionRequestMessageSchema = v10.object({
576
+ var stxSignTransactionRequestMessageSchema = v12.object({
409
577
  ...rpcRequestMessageSchema.entries,
410
- ...v10.object({
411
- method: v10.literal(stxSignTransactionMethodName),
578
+ ...v12.object({
579
+ method: v12.literal(stxSignTransactionMethodName),
412
580
  params: stxSignTransactionParamsSchema,
413
- id: v10.string()
581
+ id: v12.string()
414
582
  }).entries
415
583
  });
416
584
 
417
585
  // src/request/types/stxMethods/signTransactions.ts
418
- import * as v11 from "valibot";
586
+ import * as v13 from "valibot";
419
587
  var stxSignTransactionsMethodName = "stx_signTransactions";
420
- var stxSignTransactionsParamsSchema = v11.object({
588
+ var stxSignTransactionsParamsSchema = v13.object({
421
589
  /**
422
590
  * The transactions to sign as hex-encoded strings.
423
591
  */
424
- transactions: v11.pipe(
425
- v11.array(
426
- v11.pipe(
427
- v11.string(),
428
- v11.check((hex) => {
592
+ transactions: v13.pipe(
593
+ v13.array(
594
+ v13.pipe(
595
+ v13.string(),
596
+ v13.check((hex) => {
429
597
  return true;
430
598
  }, "Invalid hex-encoded Stacks transaction.")
431
599
  )
432
600
  ),
433
- v11.minLength(1)
601
+ v13.minLength(1)
434
602
  ),
435
603
  /**
436
604
  * Whether the signed transactions should be broadcast after signing. Defaults
437
605
  * to `true`.
438
606
  */
439
- broadcast: v11.optional(v11.boolean())
607
+ broadcast: v13.optional(v13.boolean())
440
608
  });
441
- var stxSignTransactionsResultSchema = v11.object({
609
+ var stxSignTransactionsResultSchema = v13.object({
442
610
  /**
443
611
  * The signed transactions as hex-encoded strings, in the same order as in the
444
612
  * sign request.
445
613
  */
446
- transactions: v11.array(v11.string())
614
+ transactions: v13.array(v13.string())
447
615
  });
448
- var stxSignTransactionsRequestMessageSchema = v11.object({
616
+ var stxSignTransactionsRequestMessageSchema = v13.object({
449
617
  ...rpcRequestMessageSchema.entries,
450
- ...v11.object({
451
- method: v11.literal(stxSignTransactionsMethodName),
618
+ ...v13.object({
619
+ method: v13.literal(stxSignTransactionsMethodName),
452
620
  params: stxSignTransactionsParamsSchema,
453
- id: v11.string()
621
+ id: v13.string()
454
622
  }).entries
455
623
  });
456
624
 
457
625
  // src/request/types/stxMethods/transferStx.ts
458
- import * as v12 from "valibot";
626
+ import * as v14 from "valibot";
459
627
  var stxTransferStxMethodName = "stx_transferStx";
460
- var stxTransferStxParamsSchema = v12.object({
628
+ var stxTransferStxParamsSchema = v14.object({
461
629
  /**
462
630
  * Amount of STX tokens to transfer in microstacks as a string. Anything
463
631
  * parseable by `BigInt` is acceptable.
@@ -470,23 +638,23 @@ var stxTransferStxParamsSchema = v12.object({
470
638
  * const amount3 = '1234';
471
639
  * ```
472
640
  */
473
- amount: v12.union([v12.number(), v12.string()]),
641
+ amount: v14.union([v14.number(), v14.string()]),
474
642
  /**
475
643
  * The recipeint's principal.
476
644
  */
477
- recipient: v12.string(),
645
+ recipient: v14.string(),
478
646
  /**
479
647
  * A string representing the memo.
480
648
  */
481
- memo: v12.optional(v12.string()),
649
+ memo: v14.optional(v14.string()),
482
650
  /**
483
651
  * Version of parameter format.
484
652
  */
485
- version: v12.optional(v12.string()),
653
+ version: v14.optional(v14.string()),
486
654
  /**
487
655
  * The mode of the post conditions.
488
656
  */
489
- postConditionMode: v12.optional(v12.number()),
657
+ postConditionMode: v14.optional(v14.number()),
490
658
  /**
491
659
  * A hex-encoded string representing the post conditions.
492
660
  *
@@ -499,89 +667,83 @@ var stxTransferStxParamsSchema = v12.object({
499
667
  * const hexPostCondition = serializePostCondition(postCondition).toString('hex');
500
668
  * ```
501
669
  */
502
- postConditions: v12.optional(v12.array(v12.string())),
670
+ postConditions: v14.optional(v14.array(v14.string())),
503
671
  /**
504
672
  * The public key to sign the transaction with. The wallet may use any key
505
673
  * when not provided.
506
674
  */
507
- pubkey: v12.optional(v12.string())
675
+ pubkey: v14.optional(v14.string())
508
676
  });
509
- var stxTransferStxResultSchema = v12.object({
677
+ var stxTransferStxResultSchema = v14.object({
510
678
  /**
511
679
  * The ID of the transaction.
512
680
  */
513
- txid: v12.string(),
681
+ txid: v14.string(),
514
682
  /**
515
683
  * A Stacks transaction as a hex-encoded string.
516
684
  */
517
- transaction: v12.string()
685
+ transaction: v14.string()
518
686
  });
519
- var stxTransferStxRequestMessageSchema = v12.object({
687
+ var stxTransferStxRequestMessageSchema = v14.object({
520
688
  ...rpcRequestMessageSchema.entries,
521
- ...v12.object({
522
- method: v12.literal(stxTransferStxMethodName),
689
+ ...v14.object({
690
+ method: v14.literal(stxTransferStxMethodName),
523
691
  params: stxTransferStxParamsSchema,
524
- id: v12.string()
692
+ id: v14.string()
525
693
  }).entries
526
694
  });
527
695
 
528
696
  // src/request/types/btcMethods.ts
529
- import * as v14 from "valibot";
530
-
531
- // src/request/types/common.ts
532
- import * as v13 from "valibot";
533
- var walletTypes = ["software", "ledger", "keystone"];
534
- var walletTypeSchema = v13.picklist(walletTypes);
535
-
536
- // src/request/types/btcMethods.ts
697
+ import * as v15 from "valibot";
537
698
  var getInfoMethodName = "getInfo";
538
- var getInfoParamsSchema = v14.nullish(v14.null());
539
- var getInfoResultSchema = v14.object({
699
+ var getInfoParamsSchema = v15.nullish(v15.null());
700
+ var getInfoResultSchema = v15.object({
540
701
  /**
541
702
  * Version of the wallet.
542
703
  */
543
- version: v14.string(),
704
+ version: v15.string(),
544
705
  /**
545
706
  * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
546
707
  */
547
- methods: v14.optional(v14.array(v14.string())),
708
+ methods: v15.optional(v15.array(v15.string())),
548
709
  /**
549
710
  * List of WBIP standards supported by the wallet. Not currently used.
550
711
  */
551
- supports: v14.array(v14.string())
712
+ supports: v15.array(v15.string())
552
713
  });
553
- var getInfoRequestMessageSchema = v14.object({
714
+ var getInfoRequestMessageSchema = v15.object({
554
715
  ...rpcRequestMessageSchema.entries,
555
- ...v14.object({
556
- method: v14.literal(getInfoMethodName),
716
+ ...v15.object({
717
+ method: v15.literal(getInfoMethodName),
557
718
  params: getInfoParamsSchema,
558
- id: v14.string()
719
+ id: v15.string()
559
720
  }).entries
560
721
  });
561
722
  var getAddressesMethodName = "getAddresses";
562
- var getAddressesParamsSchema = v14.object({
723
+ var getAddressesParamsSchema = v15.object({
563
724
  /**
564
725
  * The purposes for which to generate addresses. See
565
726
  * {@linkcode AddressPurpose} for available purposes.
566
727
  */
567
- purposes: v14.array(v14.enum(AddressPurpose)),
728
+ purposes: v15.array(v15.enum(AddressPurpose)),
568
729
  /**
569
730
  * A message to be displayed to the user in the request prompt.
570
731
  */
571
- message: v14.optional(v14.string())
732
+ message: v15.optional(v15.string())
572
733
  });
573
- var getAddressesResultSchema = v14.object({
734
+ var getAddressesResultSchema = v15.object({
574
735
  /**
575
736
  * The addresses generated for the given purposes.
576
737
  */
577
- addresses: v14.array(addressSchema)
738
+ addresses: v15.array(addressSchema),
739
+ network: getNetworkResultSchema
578
740
  });
579
- var getAddressesRequestMessageSchema = v14.object({
741
+ var getAddressesRequestMessageSchema = v15.object({
580
742
  ...rpcRequestMessageSchema.entries,
581
- ...v14.object({
582
- method: v14.literal(getAddressesMethodName),
743
+ ...v15.object({
744
+ method: v15.literal(getAddressesMethodName),
583
745
  params: getAddressesParamsSchema,
584
- id: v14.string()
746
+ id: v15.string()
585
747
  }).entries
586
748
  });
587
749
  var signMessageMethodName = "signMessage";
@@ -590,306 +752,162 @@ var MessageSigningProtocols = /* @__PURE__ */ ((MessageSigningProtocols2) => {
590
752
  MessageSigningProtocols2["BIP322"] = "BIP322";
591
753
  return MessageSigningProtocols2;
592
754
  })(MessageSigningProtocols || {});
593
- var signMessageParamsSchema = v14.object({
755
+ var signMessageParamsSchema = v15.object({
594
756
  /**
595
757
  * The address used for signing.
596
758
  **/
597
- address: v14.string(),
759
+ address: v15.string(),
598
760
  /**
599
761
  * The message to sign.
600
762
  **/
601
- message: v14.string(),
763
+ message: v15.string(),
602
764
  /**
603
765
  * The protocol to use for signing the message.
604
766
  */
605
- protocol: v14.optional(v14.enum(MessageSigningProtocols))
767
+ protocol: v15.optional(v15.enum(MessageSigningProtocols))
606
768
  });
607
- var signMessageResultSchema = v14.object({
769
+ var signMessageResultSchema = v15.object({
608
770
  /**
609
771
  * The signature of the message.
610
772
  */
611
- signature: v14.string(),
773
+ signature: v15.string(),
612
774
  /**
613
775
  * hash of the message.
614
776
  */
615
- messageHash: v14.string(),
777
+ messageHash: v15.string(),
616
778
  /**
617
779
  * The address used for signing.
618
780
  */
619
- address: v14.string(),
781
+ address: v15.string(),
620
782
  /**
621
783
  * The protocol to use for signing the message.
622
784
  */
623
- protocol: v14.enum(MessageSigningProtocols)
785
+ protocol: v15.enum(MessageSigningProtocols)
624
786
  });
625
- var signMessageRequestMessageSchema = v14.object({
787
+ var signMessageRequestMessageSchema = v15.object({
626
788
  ...rpcRequestMessageSchema.entries,
627
- ...v14.object({
628
- method: v14.literal(signMessageMethodName),
789
+ ...v15.object({
790
+ method: v15.literal(signMessageMethodName),
629
791
  params: signMessageParamsSchema,
630
- id: v14.string()
792
+ id: v15.string()
631
793
  }).entries
632
794
  });
633
795
  var sendTransferMethodName = "sendTransfer";
634
- var sendTransferParamsSchema = v14.object({
796
+ var sendTransferParamsSchema = v15.object({
635
797
  /**
636
798
  * Array of recipients to send to.
637
799
  * The amount to send to each recipient is in satoshis.
638
800
  */
639
- recipients: v14.array(
640
- v14.object({
641
- address: v14.string(),
642
- amount: v14.number()
801
+ recipients: v15.array(
802
+ v15.object({
803
+ address: v15.string(),
804
+ amount: v15.number()
643
805
  })
644
806
  )
645
807
  });
646
- var sendTransferResultSchema = v14.object({
808
+ var sendTransferResultSchema = v15.object({
647
809
  /**
648
810
  * The transaction id as a hex-encoded string.
649
811
  */
650
- txid: v14.string()
812
+ txid: v15.string()
651
813
  });
652
- var sendTransferRequestMessageSchema = v14.object({
814
+ var sendTransferRequestMessageSchema = v15.object({
653
815
  ...rpcRequestMessageSchema.entries,
654
- ...v14.object({
655
- method: v14.literal(sendTransferMethodName),
816
+ ...v15.object({
817
+ method: v15.literal(sendTransferMethodName),
656
818
  params: sendTransferParamsSchema,
657
- id: v14.string()
819
+ id: v15.string()
658
820
  }).entries
659
821
  });
660
822
  var signPsbtMethodName = "signPsbt";
661
- var signPsbtParamsSchema = v14.object({
823
+ var signPsbtParamsSchema = v15.object({
662
824
  /**
663
825
  * The base64 encoded PSBT to sign.
664
826
  */
665
- psbt: v14.string(),
827
+ psbt: v15.string(),
666
828
  /**
667
829
  * The inputs to sign.
668
830
  * The key is the address and the value is an array of indexes of the inputs to sign.
669
831
  */
670
- signInputs: v14.record(v14.string(), v14.array(v14.number())),
832
+ signInputs: v15.record(v15.string(), v15.array(v15.number())),
671
833
  /**
672
834
  * Whether to broadcast the transaction after signing.
673
835
  **/
674
- broadcast: v14.optional(v14.boolean())
836
+ broadcast: v15.optional(v15.boolean())
675
837
  });
676
- var signPsbtResultSchema = v14.object({
838
+ var signPsbtResultSchema = v15.object({
677
839
  /**
678
840
  * The base64 encoded PSBT after signing.
679
841
  */
680
- psbt: v14.string(),
842
+ psbt: v15.string(),
681
843
  /**
682
844
  * The transaction id as a hex-encoded string.
683
845
  * This is only returned if the transaction was broadcast.
684
846
  **/
685
- txid: v14.optional(v14.string())
847
+ txid: v15.optional(v15.string())
686
848
  });
687
- var signPsbtRequestMessageSchema = v14.object({
849
+ var signPsbtRequestMessageSchema = v15.object({
688
850
  ...rpcRequestMessageSchema.entries,
689
- ...v14.object({
690
- method: v14.literal(signPsbtMethodName),
851
+ ...v15.object({
852
+ method: v15.literal(signPsbtMethodName),
691
853
  params: signPsbtParamsSchema,
692
- id: v14.string()
854
+ id: v15.string()
693
855
  }).entries
694
856
  });
695
857
  var getAccountsMethodName = "getAccounts";
696
- var getAccountsParamsSchema = v14.object({
858
+ var getAccountsParamsSchema = v15.object({
697
859
  /**
698
860
  * The purposes for which to generate addresses. See
699
861
  * {@linkcode AddressPurpose} for available purposes.
700
862
  */
701
- purposes: v14.array(v14.enum(AddressPurpose)),
863
+ purposes: v15.array(v15.enum(AddressPurpose)),
702
864
  /**
703
865
  * A message to be displayed to the user in the request prompt.
704
866
  */
705
- message: v14.optional(v14.string())
867
+ message: v15.optional(v15.string())
706
868
  });
707
- var getAccountsResultSchema = v14.array(
708
- v14.object({
869
+ var getAccountsResultSchema = v15.array(
870
+ v15.object({
709
871
  ...addressSchema.entries,
710
- ...v14.object({
872
+ ...v15.object({
711
873
  walletType: walletTypeSchema
712
874
  }).entries
713
875
  })
714
876
  );
715
- var getAccountsRequestMessageSchema = v14.object({
877
+ var getAccountsRequestMessageSchema = v15.object({
716
878
  ...rpcRequestMessageSchema.entries,
717
- ...v14.object({
718
- method: v14.literal(getAccountsMethodName),
879
+ ...v15.object({
880
+ method: v15.literal(getAccountsMethodName),
719
881
  params: getAccountsParamsSchema,
720
- id: v14.string()
882
+ id: v15.string()
721
883
  }).entries
722
884
  });
723
885
  var getBalanceMethodName = "getBalance";
724
- var getBalanceParamsSchema = v14.nullish(v14.null());
725
- var getBalanceResultSchema = v14.object({
886
+ var getBalanceParamsSchema = v15.nullish(v15.null());
887
+ var getBalanceResultSchema = v15.object({
726
888
  /**
727
889
  * The confirmed balance of the wallet in sats. Using a string due to chrome
728
890
  * messages not supporting bigint
729
891
  * (https://issues.chromium.org/issues/40116184).
730
892
  */
731
- confirmed: v14.string(),
893
+ confirmed: v15.string(),
732
894
  /**
733
895
  * The unconfirmed balance of the wallet in sats. Using a string due to chrome
734
896
  * messages not supporting bigint
735
897
  * (https://issues.chromium.org/issues/40116184).
736
898
  */
737
- unconfirmed: v14.string(),
899
+ unconfirmed: v15.string(),
738
900
  /**
739
901
  * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
740
902
  * sats. Using a string due to chrome messages not supporting bigint
741
903
  * (https://issues.chromium.org/issues/40116184).
742
904
  */
743
- total: v14.string()
744
- });
745
- var getBalanceRequestMessageSchema = v14.object({
746
- ...rpcRequestMessageSchema.entries,
747
- ...v14.object({
748
- method: v14.literal(getBalanceMethodName),
749
- id: v14.string()
750
- }).entries
751
- });
752
-
753
- // src/request/types/walletMethods.ts
754
- import * as v15 from "valibot";
755
- var accountActionsSchema = v15.object({
756
- read: v15.optional(v15.boolean())
905
+ total: v15.string()
757
906
  });
758
- var walletActionsSchema = v15.object({
759
- readNetwork: v15.optional(v15.boolean())
760
- });
761
- var accountPermissionSchema = v15.object({
762
- type: v15.literal("account"),
763
- resourceId: v15.string(),
764
- clientId: v15.string(),
765
- actions: accountActionsSchema
766
- });
767
- var walletPermissionSchema = v15.object({
768
- type: v15.literal("wallet"),
769
- resourceId: v15.string(),
770
- clientId: v15.string(),
771
- actions: walletActionsSchema
772
- });
773
- var PermissionRequestParams = v15.variant("type", [
774
- v15.object({
775
- ...v15.omit(accountPermissionSchema, ["clientId"]).entries
776
- }),
777
- v15.object({
778
- ...v15.omit(walletPermissionSchema, ["clientId"]).entries
779
- })
780
- ]);
781
- var permission = v15.variant("type", [accountPermissionSchema, walletPermissionSchema]);
782
- var requestPermissionsMethodName = "wallet_requestPermissions";
783
- var requestPermissionsParamsSchema = v15.nullish(v15.array(PermissionRequestParams));
784
- var requestPermissionsResultSchema = v15.literal(true);
785
- var requestPermissionsRequestMessageSchema = v15.object({
786
- ...rpcRequestMessageSchema.entries,
787
- ...v15.object({
788
- method: v15.literal(requestPermissionsMethodName),
789
- params: requestPermissionsParamsSchema,
790
- id: v15.string()
791
- }).entries
792
- });
793
- var renouncePermissionsMethodName = "wallet_renouncePermissions";
794
- var renouncePermissionsParamsSchema = v15.nullish(v15.null());
795
- var renouncePermissionsResultSchema = v15.nullish(v15.null());
796
- var renouncePermissionsRequestMessageSchema = v15.object({
797
- ...rpcRequestMessageSchema.entries,
798
- ...v15.object({
799
- method: v15.literal(renouncePermissionsMethodName),
800
- params: renouncePermissionsParamsSchema,
801
- id: v15.string()
802
- }).entries
803
- });
804
- var disconnectMethodName = "wallet_disconnect";
805
- var disconnectParamsSchema = v15.nullish(v15.null());
806
- var disconnectResultSchema = v15.nullish(v15.null());
807
- var disconnectRequestMessageSchema = v15.object({
808
- ...rpcRequestMessageSchema.entries,
809
- ...v15.object({
810
- method: v15.literal(disconnectMethodName),
811
- params: disconnectParamsSchema,
812
- id: v15.string()
813
- }).entries
814
- });
815
- var getWalletTypeMethodName = "wallet_getWalletType";
816
- var getWalletTypeParamsSchema = v15.nullish(v15.null());
817
- var getWalletTypeResultSchema = walletTypeSchema;
818
- var getWalletTypeRequestMessageSchema = v15.object({
907
+ var getBalanceRequestMessageSchema = v15.object({
819
908
  ...rpcRequestMessageSchema.entries,
820
909
  ...v15.object({
821
- method: v15.literal(getWalletTypeMethodName),
822
- params: getWalletTypeParamsSchema,
823
- id: v15.string()
824
- }).entries
825
- });
826
- var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
827
- var getCurrentPermissionsParamsSchema = v15.nullish(v15.null());
828
- var getCurrentPermissionsResultSchema = v15.array(permission);
829
- var getCurrentPermissionsRequestMessageSchema = v15.object({
830
- ...rpcRequestMessageSchema.entries,
831
- ...v15.object({
832
- method: v15.literal(getCurrentPermissionsMethodName),
833
- params: getCurrentPermissionsParamsSchema,
834
- id: v15.string()
835
- }).entries
836
- });
837
- var getNetworkMethodName = "wallet_getNetwork";
838
- var getNetworkParamsSchema = v15.nullish(v15.null());
839
- var networkType2 = ["Mainnet", "Testnet", "Testnet4", "Signet", "Regtest"];
840
- var getNetworkResultSchema = v15.object({
841
- bitcoin: v15.object({
842
- name: v15.picklist(networkType2)
843
- }),
844
- stacks: v15.object({
845
- name: v15.string()
846
- })
847
- });
848
- var getNetworkRequestMessageSchema = v15.object({
849
- ...rpcRequestMessageSchema.entries,
850
- ...v15.object({
851
- method: v15.literal(getNetworkMethodName),
852
- params: getNetworkParamsSchema,
853
- id: v15.string()
854
- }).entries
855
- });
856
- var getAccountMethodName = "wallet_getAccount";
857
- var getAccountParamsSchema = v15.nullish(v15.null());
858
- var getAccountResultSchema = v15.object({
859
- id: v15.string(),
860
- addresses: v15.array(addressSchema),
861
- walletType: walletTypeSchema,
862
- network: getNetworkResultSchema
863
- });
864
- var getAccountRequestMessageSchema = v15.object({
865
- ...rpcRequestMessageSchema.entries,
866
- ...v15.object({
867
- method: v15.literal(getAccountMethodName),
868
- params: getAccountParamsSchema,
869
- id: v15.string()
870
- }).entries
871
- });
872
- var connectMethodName = "wallet_connect";
873
- var connectParamsSchema = v15.nullish(
874
- v15.object({
875
- permissions: v15.optional(v15.array(PermissionRequestParams)),
876
- addresses: v15.optional(v15.array(v15.enum(AddressPurpose))),
877
- message: v15.optional(
878
- v15.pipe(v15.string(), v15.maxLength(80, "The message must not exceed 80 characters."))
879
- )
880
- })
881
- );
882
- var connectResultSchema = v15.object({
883
- id: v15.string(),
884
- addresses: v15.array(addressSchema),
885
- walletType: walletTypeSchema,
886
- network: getNetworkResultSchema
887
- });
888
- var connectRequestMessageSchema = v15.object({
889
- ...rpcRequestMessageSchema.entries,
890
- ...v15.object({
891
- method: v15.literal(connectMethodName),
892
- params: connectParamsSchema,
910
+ method: v15.literal(getBalanceMethodName),
893
911
  id: v15.string()
894
912
  }).entries
895
913
  });
@@ -2093,6 +2111,10 @@ export {
2093
2111
  accountPermissionSchema,
2094
2112
  addListener,
2095
2113
  addressSchema,
2114
+ changeNetworkMethodName,
2115
+ changeNetworkParamsSchema,
2116
+ changeNetworkRequestMessageSchema,
2117
+ changeNetworkResultSchema,
2096
2118
  connectMethodName,
2097
2119
  connectParamsSchema,
2098
2120
  connectRequestMessageSchema,