@sats-connect/core 0.4.0-32c4027 → 0.4.0-68f1213

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,6 +1,3 @@
1
- // src/provider/index.ts
2
- import omit from "lodash.omit";
3
-
4
1
  // src/provider/types.ts
5
2
  import * as v from "valibot";
6
3
  var accountChangeEventName = "accountChange";
@@ -50,11 +47,9 @@ function removeDefaultProvider() {
50
47
  localStorage.removeItem("sats-connect_defaultProvider");
51
48
  }
52
49
  function getSupportedWallets() {
53
- const btc_providers = getProviders();
54
- const allProviders = [...btc_providers];
55
- for (const key in omit(DefaultAdaptersInfo, ["xverse"])) {
56
- allProviders.push(DefaultAdaptersInfo[key]);
57
- }
50
+ const ambientProviders = getProviders();
51
+ const { xverse, ...defaultProviders } = DefaultAdaptersInfo;
52
+ const allProviders = [...ambientProviders, ...Object.values(defaultProviders)];
58
53
  const wallets = allProviders.map((provider) => {
59
54
  {
60
55
  return {
@@ -118,13 +113,127 @@ var rpcResponseMessageSchema = v2.union([
118
113
  ]);
119
114
 
120
115
  // src/request/index.ts
121
- import * as v10 from "valibot";
116
+ import * as v17 from "valibot";
117
+
118
+ // src/request/types/stxMethods/callContract.ts
119
+ import * as v3 from "valibot";
120
+ var stxCallContractMethodName = "stx_callContract";
121
+ var stxCallContractParamsSchema = v3.object({
122
+ /**
123
+ * The contract principal.
124
+ *
125
+ * E.g. `"SPKE...GD5C.my-contract"`
126
+ */
127
+ contract: v3.string(),
128
+ /**
129
+ * The name of the function to call.
130
+ *
131
+ * Note: spec changes ongoing,
132
+ * https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
133
+ */
134
+ functionName: v3.string(),
135
+ /**
136
+ * The function's arguments. The arguments are expected to be hex-encoded
137
+ * strings of Clarity values.
138
+ *
139
+ * To convert Clarity values to their hex representation, the `cvToString`
140
+ * helper from the `@stacks/transactions` package may be helpful.
141
+ *
142
+ * ```js
143
+ * import { cvToString } from '@stacks/transactions';
144
+ *
145
+ * const functionArgs = [someClarityValue1, someClarityValue2];
146
+ * const hexArgs = functionArgs.map(cvToString);
147
+ * ```
148
+ */
149
+ arguments: v3.optional(v3.array(v3.string()))
150
+ });
151
+ var stxCallContractResultSchema = v3.object({
152
+ /**
153
+ * The ID of the transaction.
154
+ */
155
+ txid: v3.string(),
156
+ /**
157
+ * A Stacks transaction as a hex-encoded string.
158
+ */
159
+ transaction: v3.string()
160
+ });
161
+ var stxCallContractRequestMessageSchema = v3.object({
162
+ ...rpcRequestMessageSchema.entries,
163
+ ...v3.object({
164
+ method: v3.literal(stxCallContractMethodName),
165
+ params: stxCallContractParamsSchema,
166
+ id: v3.string()
167
+ }).entries
168
+ });
169
+
170
+ // src/request/types/stxMethods/deployContract.ts
171
+ import * as v4 from "valibot";
172
+ var stxDeployContractMethodName = "stx_deployContract";
173
+ var stxDeployContractParamsSchema = v4.object({
174
+ /**
175
+ * Name of the contract.
176
+ */
177
+ name: v4.string(),
178
+ /**
179
+ * The code of the Clarity contract.
180
+ */
181
+ codeBody: v4.string(),
182
+ /**
183
+ * The version of the Clarity contract.
184
+ */
185
+ version: v4.optional(v4.string())
186
+ });
187
+ var stxDeployContractResultSchema = v4.object({
188
+ /**
189
+ * The ID of the transaction.
190
+ */
191
+ txid: v4.string(),
192
+ /**
193
+ * A Stacks transaction as a hex-encoded string.
194
+ */
195
+ transaction: v4.string()
196
+ });
197
+ var stxDeployContractRequestMessageSchema = v4.object({
198
+ ...rpcRequestMessageSchema.entries,
199
+ ...v4.object({
200
+ method: v4.literal(stxDeployContractMethodName),
201
+ params: stxDeployContractParamsSchema,
202
+ id: v4.string()
203
+ }).entries
204
+ });
205
+
206
+ // src/request/types/stxMethods/getAccounts.ts
207
+ import * as v5 from "valibot";
208
+ var stxGetAccountsMethodName = "stx_getAccounts";
209
+ var stxGetAccountsParamsSchema = v5.nullish(v5.null());
210
+ var stxGetAccountsResultSchema = v5.object({
211
+ /**
212
+ * The addresses generated for the given purposes.
213
+ */
214
+ addresses: v5.array(
215
+ v5.object({
216
+ address: v5.string(),
217
+ publicKey: v5.string(),
218
+ gaiaHubUrl: v5.string(),
219
+ gaiaAppKey: v5.string()
220
+ })
221
+ )
222
+ });
223
+ var stxGetAccountsRequestMessageSchema = v5.object({
224
+ ...rpcRequestMessageSchema.entries,
225
+ ...v5.object({
226
+ method: v5.literal(stxGetAccountsMethodName),
227
+ params: stxGetAccountsParamsSchema,
228
+ id: v5.string()
229
+ }).entries
230
+ });
122
231
 
123
232
  // src/addresses/index.ts
124
233
  import { createUnsecuredToken } from "jsontokens";
125
234
 
126
235
  // src/addresses/types.ts
127
- import * as v3 from "valibot";
236
+ import * as v6 from "valibot";
128
237
  var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
129
238
  AddressPurpose2["Ordinals"] = "ordinals";
130
239
  AddressPurpose2["Payment"] = "payment";
@@ -140,11 +249,11 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
140
249
  AddressType3["stacks"] = "stacks";
141
250
  return AddressType3;
142
251
  })(AddressType || {});
143
- var addressSchema = v3.object({
144
- address: v3.string(),
145
- publicKey: v3.string(),
146
- purpose: v3.enum(AddressPurpose),
147
- addressType: v3.enum(AddressType)
252
+ var addressSchema = v6.object({
253
+ address: v6.string(),
254
+ publicKey: v6.string(),
255
+ purpose: v6.enum(AddressPurpose),
256
+ addressType: v6.enum(AddressType)
148
257
  });
149
258
 
150
259
  // src/addresses/index.ts
@@ -164,119 +273,269 @@ var getAddress = async (options) => {
164
273
  }
165
274
  };
166
275
 
167
- // src/request/types/stxMethods.ts
168
- import * as v4 from "valibot";
276
+ // src/request/types/stxMethods/getAddresses.ts
277
+ import * as v7 from "valibot";
169
278
  var stxGetAddressesMethodName = "stx_getAddresses";
170
- var stxGetAddressesParamsSchema = v4.nullish(
171
- v4.object({
279
+ var stxGetAddressesParamsSchema = v7.nullish(
280
+ v7.object({
172
281
  /**
173
282
  * A message to be displayed to the user in the request prompt.
174
283
  */
175
- message: v4.optional(v4.string())
284
+ message: v7.optional(v7.string())
176
285
  })
177
286
  );
178
- var stxGetAddressesResultSchema = v4.object({
287
+ var stxGetAddressesResultSchema = v7.object({
179
288
  /**
180
289
  * The addresses generated for the given purposes.
181
290
  */
182
- addresses: v4.array(addressSchema)
291
+ addresses: v7.array(addressSchema)
183
292
  });
184
- var stxGetAddressesRequestMessageSchema = v4.object({
293
+ var stxGetAddressesRequestMessageSchema = v7.object({
185
294
  ...rpcRequestMessageSchema.entries,
186
- ...v4.object({
187
- method: v4.literal(stxGetAddressesMethodName),
295
+ ...v7.object({
296
+ method: v7.literal(stxGetAddressesMethodName),
188
297
  params: stxGetAddressesParamsSchema,
189
- id: v4.string()
298
+ id: v7.string()
299
+ }).entries
300
+ });
301
+
302
+ // src/request/types/stxMethods/signMessage.ts
303
+ import * as v8 from "valibot";
304
+ var stxSignMessageMethodName = "stx_signMessage";
305
+ var stxSignMessageParamsSchema = v8.object({
306
+ /**
307
+ * The message to sign.
308
+ */
309
+ message: v8.string(),
310
+ /**
311
+ * The public key to sign the message with.
312
+ */
313
+ publicKey: v8.string(),
314
+ /**
315
+ * The format version of the parameter.
316
+ */
317
+ parameterFormatVersion: v8.optional(v8.number())
318
+ });
319
+ var stxSignMessageResultSchema = v8.object({
320
+ /**
321
+ * The signature of the message.
322
+ */
323
+ signature: v8.string(),
324
+ /**
325
+ * The public key used to sign the message.
326
+ */
327
+ publicKey: v8.string()
328
+ });
329
+ var stxSignMessageRequestMessageSchema = v8.object({
330
+ ...rpcRequestMessageSchema.entries,
331
+ ...v8.object({
332
+ method: v8.literal(stxSignMessageMethodName),
333
+ params: stxSignMessageParamsSchema,
334
+ id: v8.string()
190
335
  }).entries
191
336
  });
337
+
338
+ // src/request/types/stxMethods/signStructuredMessage.ts
339
+ import * as v9 from "valibot";
340
+ var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
341
+ var stxSignStructuredMessageParamsSchema = v9.object({
342
+ /**
343
+ * The domain to be signed.
344
+ */
345
+ domain: v9.string(),
346
+ /**
347
+ * Message payload to be signed.
348
+ */
349
+ message: v9.string(),
350
+ /**
351
+ * The format version of the parameter.
352
+ */
353
+ parameterFormatVersion: v9.optional(v9.number()),
354
+ /**
355
+ * The public key to sign the message with.
356
+ */
357
+ publicKey: v9.optional(v9.string())
358
+ });
359
+ var stxSignStructuredMessageResultSchema = v9.object({
360
+ /**
361
+ * Signature of the message.
362
+ */
363
+ signature: v9.string(),
364
+ /**
365
+ * Public key as hex-encoded string.
366
+ */
367
+ publicKey: v9.string()
368
+ });
369
+ var stxSignStructuredMessageRequestMessageSchema = v9.object({
370
+ ...rpcRequestMessageSchema.entries,
371
+ ...v9.object({
372
+ method: v9.literal(stxSignStructuredMessageMethodName),
373
+ params: stxSignStructuredMessageParamsSchema,
374
+ id: v9.string()
375
+ }).entries
376
+ });
377
+
378
+ // src/request/types/stxMethods/signTransaction.ts
379
+ import * as v10 from "valibot";
192
380
  var stxSignTransactionMethodName = "stx_signTransaction";
193
- var stxSignTransactionParamsSchema = v4.object({
381
+ var stxSignTransactionParamsSchema = v10.object({
194
382
  /**
195
383
  * The transaction to sign as a hex-encoded string.
196
384
  */
197
- transaction: v4.string(),
385
+ transaction: v10.string(),
198
386
  /**
199
387
  * The public key to sign the transaction with. The wallet may use any key
200
388
  * when not provided.
201
389
  */
202
- pubkey: v4.optional(v4.string()),
390
+ pubkey: v10.optional(v10.string()),
203
391
  /**
204
392
  * Whether to broadcast the transaction after signing. Defaults to `true`.
205
393
  */
206
- broadcast: v4.optional(v4.boolean())
394
+ broadcast: v10.optional(v10.boolean())
207
395
  });
208
- var stxSignTransactionResultSchema = v4.object({
396
+ var stxSignTransactionResultSchema = v10.object({
209
397
  /**
210
398
  * The signed transaction as a hex-encoded string.
211
399
  */
212
- transaction: v4.string()
400
+ transaction: v10.string()
213
401
  });
214
- var stxSignTransactionRequestMessageSchema = v4.object({
402
+ var stxSignTransactionRequestMessageSchema = v10.object({
215
403
  ...rpcRequestMessageSchema.entries,
216
- ...v4.object({
217
- method: v4.literal(stxSignTransactionMethodName),
404
+ ...v10.object({
405
+ method: v10.literal(stxSignTransactionMethodName),
218
406
  params: stxSignTransactionParamsSchema,
219
- id: v4.string()
407
+ id: v10.string()
408
+ }).entries
409
+ });
410
+
411
+ // src/request/types/stxMethods/transferStx.ts
412
+ import * as v11 from "valibot";
413
+ var stxTransferStxMethodName = "stx_transferStx";
414
+ var stxTransferStxParamsSchema = v11.object({
415
+ /**
416
+ * Amount of STX tokens to transfer in microstacks as a string. Anything
417
+ * parseable by `BigInt` is acceptable.
418
+ *
419
+ * Example,
420
+ *
421
+ * ```js
422
+ * const amount1 = 1234;
423
+ * const amount2 = 1234n;
424
+ * const amount3 = '1234';
425
+ * ```
426
+ */
427
+ amount: v11.union([v11.number(), v11.string()]),
428
+ /**
429
+ * The recipeint's principal.
430
+ */
431
+ recipient: v11.string(),
432
+ /**
433
+ * A string representing the memo.
434
+ */
435
+ memo: v11.optional(v11.string()),
436
+ /**
437
+ * Version of parameter format.
438
+ */
439
+ version: v11.optional(v11.string()),
440
+ /**
441
+ * The mode of the post conditions.
442
+ */
443
+ postConditionMode: v11.optional(v11.number()),
444
+ /**
445
+ * A hex-encoded string representing the post conditions.
446
+ *
447
+ * A post condition may be converted to it's hex representation using the `serializePostCondition` helper from the `@stacks/transactions` package,
448
+ *
449
+ * ```js
450
+ * import { serializePostCondition } from '@stacks/transactions';
451
+ *
452
+ * const postCondition = somePostCondition;
453
+ * const hexPostCondition = serializePostCondition(postCondition).toString('hex');
454
+ * ```
455
+ */
456
+ postConditions: v11.optional(v11.array(v11.string())),
457
+ /**
458
+ * The public key to sign the transaction with. The wallet may use any key
459
+ * when not provided.
460
+ */
461
+ pubkey: v11.optional(v11.string())
462
+ });
463
+ var stxTransferStxResultSchema = v11.object({
464
+ /**
465
+ * The ID of the transaction.
466
+ */
467
+ txid: v11.string(),
468
+ /**
469
+ * A Stacks transaction as a hex-encoded string.
470
+ */
471
+ transaction: v11.string()
472
+ });
473
+ var stxTransferStxRequestMessageSchema = v11.object({
474
+ ...rpcRequestMessageSchema.entries,
475
+ ...v11.object({
476
+ method: v11.literal(stxTransferStxMethodName),
477
+ params: stxTransferStxParamsSchema,
478
+ id: v11.string()
220
479
  }).entries
221
480
  });
222
481
 
223
482
  // src/request/types/btcMethods.ts
224
- import * as v6 from "valibot";
483
+ import * as v13 from "valibot";
225
484
 
226
485
  // src/request/types/common.ts
227
- import * as v5 from "valibot";
486
+ import * as v12 from "valibot";
228
487
  var walletTypes = ["software", "ledger"];
229
- var walletTypeSchema = v5.picklist(walletTypes);
488
+ var walletTypeSchema = v12.picklist(walletTypes);
230
489
 
231
490
  // src/request/types/btcMethods.ts
232
491
  var getInfoMethodName = "getInfo";
233
- var getInfoParamsSchema = v6.nullish(v6.null());
234
- var getInfoResultSchema = v6.object({
492
+ var getInfoParamsSchema = v13.nullish(v13.null());
493
+ var getInfoResultSchema = v13.object({
235
494
  /**
236
495
  * Version of the wallet.
237
496
  */
238
- version: v6.string(),
497
+ version: v13.string(),
239
498
  /**
240
499
  * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
241
500
  */
242
- methods: v6.optional(v6.array(v6.string())),
501
+ methods: v13.optional(v13.array(v13.string())),
243
502
  /**
244
503
  * List of WBIP standards supported by the wallet. Not currently used.
245
504
  */
246
- supports: v6.array(v6.string())
505
+ supports: v13.array(v13.string())
247
506
  });
248
- var getInfoRequestMessageSchema = v6.object({
507
+ var getInfoRequestMessageSchema = v13.object({
249
508
  ...rpcRequestMessageSchema.entries,
250
- ...v6.object({
251
- method: v6.literal(getInfoMethodName),
509
+ ...v13.object({
510
+ method: v13.literal(getInfoMethodName),
252
511
  params: getInfoParamsSchema,
253
- id: v6.string()
512
+ id: v13.string()
254
513
  }).entries
255
514
  });
256
515
  var getAddressesMethodName = "getAddresses";
257
- var getAddressesParamsSchema = v6.object({
516
+ var getAddressesParamsSchema = v13.object({
258
517
  /**
259
518
  * The purposes for which to generate addresses. See
260
519
  * {@linkcode AddressPurpose} for available purposes.
261
520
  */
262
- purposes: v6.array(v6.enum(AddressPurpose)),
521
+ purposes: v13.array(v13.enum(AddressPurpose)),
263
522
  /**
264
523
  * A message to be displayed to the user in the request prompt.
265
524
  */
266
- message: v6.optional(v6.string())
525
+ message: v13.optional(v13.string())
267
526
  });
268
- var getAddressesResultSchema = v6.object({
527
+ var getAddressesResultSchema = v13.object({
269
528
  /**
270
529
  * The addresses generated for the given purposes.
271
530
  */
272
- addresses: v6.array(addressSchema)
531
+ addresses: v13.array(addressSchema)
273
532
  });
274
- var getAddressesRequestMessageSchema = v6.object({
533
+ var getAddressesRequestMessageSchema = v13.object({
275
534
  ...rpcRequestMessageSchema.entries,
276
- ...v6.object({
277
- method: v6.literal(getAddressesMethodName),
535
+ ...v13.object({
536
+ method: v13.literal(getAddressesMethodName),
278
537
  params: getAddressesParamsSchema,
279
- id: v6.string()
538
+ id: v13.string()
280
539
  }).entries
281
540
  });
282
541
  var signMessageMethodName = "signMessage";
@@ -285,314 +544,364 @@ var MessageSigningProtocols = /* @__PURE__ */ ((MessageSigningProtocols2) => {
285
544
  MessageSigningProtocols2["BIP322"] = "BIP322";
286
545
  return MessageSigningProtocols2;
287
546
  })(MessageSigningProtocols || {});
288
- var signMessageParamsSchema = v6.object({
547
+ var signMessageParamsSchema = v13.object({
289
548
  /**
290
549
  * The address used for signing.
291
550
  **/
292
- address: v6.string(),
551
+ address: v13.string(),
293
552
  /**
294
553
  * The message to sign.
295
554
  **/
296
- message: v6.string(),
555
+ message: v13.string(),
297
556
  /**
298
557
  * The protocol to use for signing the message.
299
558
  */
300
- protocol: v6.optional(v6.enum(MessageSigningProtocols))
559
+ protocol: v13.optional(v13.enum(MessageSigningProtocols))
301
560
  });
302
- var signMessageResultSchema = v6.object({
561
+ var signMessageResultSchema = v13.object({
303
562
  /**
304
563
  * The signature of the message.
305
564
  */
306
- signature: v6.string(),
565
+ signature: v13.string(),
307
566
  /**
308
567
  * hash of the message.
309
568
  */
310
- messageHash: v6.string(),
569
+ messageHash: v13.string(),
311
570
  /**
312
571
  * The address used for signing.
313
572
  */
314
- address: v6.string(),
573
+ address: v13.string(),
315
574
  /**
316
575
  * The protocol to use for signing the message.
317
576
  */
318
- protocol: v6.enum(MessageSigningProtocols)
577
+ protocol: v13.enum(MessageSigningProtocols)
319
578
  });
320
- var signMessageRequestMessageSchema = v6.object({
579
+ var signMessageRequestMessageSchema = v13.object({
321
580
  ...rpcRequestMessageSchema.entries,
322
- ...v6.object({
323
- method: v6.literal(signMessageMethodName),
581
+ ...v13.object({
582
+ method: v13.literal(signMessageMethodName),
324
583
  params: signMessageParamsSchema,
325
- id: v6.string()
584
+ id: v13.string()
585
+ }).entries
586
+ });
587
+ var sendTransferMethodName = "sendTransfer";
588
+ var sendTransferParamsSchema = v13.object({
589
+ /**
590
+ * Array of recipients to send to.
591
+ * The amount to send to each recipient is in satoshis.
592
+ */
593
+ recipients: v13.array(
594
+ v13.object({
595
+ address: v13.string(),
596
+ amount: v13.number()
597
+ })
598
+ )
599
+ });
600
+ var sendTransferResultSchema = v13.object({
601
+ /**
602
+ * The transaction id as a hex-encoded string.
603
+ */
604
+ txid: v13.string()
605
+ });
606
+ var sendTransferRequestMessageSchema = v13.object({
607
+ ...rpcRequestMessageSchema.entries,
608
+ ...v13.object({
609
+ method: v13.literal(sendTransferMethodName),
610
+ params: sendTransferParamsSchema,
611
+ id: v13.string()
612
+ }).entries
613
+ });
614
+ var signPsbtMethodName = "signPsbt";
615
+ var signPsbtParamsSchema = v13.object({
616
+ /**
617
+ * The base64 encoded PSBT to sign.
618
+ */
619
+ psbt: v13.string(),
620
+ /**
621
+ * The inputs to sign.
622
+ * The key is the address and the value is an array of indexes of the inputs to sign.
623
+ */
624
+ signInputs: v13.record(v13.string(), v13.array(v13.number())),
625
+ allowedSignHash: v13.optional(v13.number()),
626
+ /**
627
+ * Whether to broadcast the transaction after signing.
628
+ **/
629
+ broadcast: v13.optional(v13.boolean())
630
+ });
631
+ var signPsbtResultSchema = v13.object({
632
+ /**
633
+ * The base64 encoded PSBT after signing.
634
+ */
635
+ psbt: v13.string(),
636
+ /**
637
+ * The transaction id as a hex-encoded string.
638
+ * This is only returned if the transaction was broadcast.
639
+ **/
640
+ txid: v13.optional(v13.string())
641
+ });
642
+ var signPsbtRequestMessageSchema = v13.object({
643
+ ...rpcRequestMessageSchema.entries,
644
+ ...v13.object({
645
+ method: v13.literal(signPsbtMethodName),
646
+ params: signPsbtParamsSchema,
647
+ id: v13.string()
326
648
  }).entries
327
649
  });
328
650
  var getAccountsMethodName = "getAccounts";
329
- var getAccountsParamsSchema = v6.object({
651
+ var getAccountsParamsSchema = v13.object({
330
652
  /**
331
653
  * The purposes for which to generate addresses. See
332
654
  * {@linkcode AddressPurpose} for available purposes.
333
655
  */
334
- purposes: v6.array(v6.enum(AddressPurpose)),
656
+ purposes: v13.array(v13.enum(AddressPurpose)),
335
657
  /**
336
658
  * A message to be displayed to the user in the request prompt.
337
659
  */
338
- message: v6.optional(v6.string())
660
+ message: v13.optional(v13.string())
339
661
  });
340
- var getAccountsResultSchema = v6.array(
341
- v6.object({
662
+ var getAccountsResultSchema = v13.array(
663
+ v13.object({
342
664
  ...addressSchema.entries,
343
- ...v6.object({
665
+ ...v13.object({
344
666
  walletType: walletTypeSchema
345
667
  }).entries
346
668
  })
347
669
  );
348
- var getAccountsRequestMessageSchema = v6.object({
670
+ var getAccountsRequestMessageSchema = v13.object({
349
671
  ...rpcRequestMessageSchema.entries,
350
- ...v6.object({
351
- method: v6.literal(getAccountsMethodName),
672
+ ...v13.object({
673
+ method: v13.literal(getAccountsMethodName),
352
674
  params: getAccountsParamsSchema,
353
- id: v6.string()
675
+ id: v13.string()
354
676
  }).entries
355
677
  });
356
678
  var getBalanceMethodName = "getBalance";
357
- var getBalanceParamsSchema = v6.nullish(v6.null());
358
- var getBalanceResultSchema = v6.object({
679
+ var getBalanceParamsSchema = v13.nullish(v13.null());
680
+ var getBalanceResultSchema = v13.object({
359
681
  /**
360
682
  * The confirmed balance of the wallet in sats. Using a string due to chrome
361
683
  * messages not supporting bigint
362
684
  * (https://issues.chromium.org/issues/40116184).
363
685
  */
364
- confirmed: v6.string(),
686
+ confirmed: v13.string(),
365
687
  /**
366
688
  * The unconfirmed balance of the wallet in sats. Using a string due to chrome
367
689
  * messages not supporting bigint
368
690
  * (https://issues.chromium.org/issues/40116184).
369
691
  */
370
- unconfirmed: v6.string(),
692
+ unconfirmed: v13.string(),
371
693
  /**
372
694
  * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
373
695
  * sats. Using a string due to chrome messages not supporting bigint
374
696
  * (https://issues.chromium.org/issues/40116184).
375
697
  */
376
- total: v6.string()
698
+ total: v13.string()
377
699
  });
378
- var getBalanceRequestMessageSchema = v6.object({
700
+ var getBalanceRequestMessageSchema = v13.object({
379
701
  ...rpcRequestMessageSchema.entries,
380
- ...v6.object({
381
- method: v6.literal(getBalanceMethodName),
382
- id: v6.string()
702
+ ...v13.object({
703
+ method: v13.literal(getBalanceMethodName),
704
+ id: v13.string()
383
705
  }).entries
384
706
  });
385
707
 
386
708
  // src/request/types/walletMethods.ts
387
- import * as v7 from "valibot";
709
+ import * as v14 from "valibot";
388
710
  import { permissions } from "@secretkeylabs/xverse-core";
389
- var permissionsWithoutClientId = v7.array(
390
- v7.variant("type", [
391
- v7.omit(permissions.resources.account.accountPermissionSchema, ["clientId"]),
392
- v7.omit(permissions.resources.wallet.walletPermissionSchema, ["clientId"])
393
- ])
394
- );
711
+ var permissionTemplate = v14.variant("type", [
712
+ v14.object({
713
+ ...v14.omit(permissions.resources.account.accountPermissionSchema, ["clientId", "actions"]).entries,
714
+ actions: v14.partial(permissions.resources.account.accountActionsSchema)
715
+ }),
716
+ v14.object({
717
+ ...v14.omit(permissions.resources.wallet.walletPermissionSchema, ["clientId"]).entries,
718
+ actions: v14.partial(permissions.resources.wallet.walletActionsSchema)
719
+ })
720
+ ]);
395
721
  var requestPermissionsMethodName = "wallet_requestPermissions";
396
- var requestPermissionsParamsSchema = v7.nullish(permissionsWithoutClientId);
397
- var requestPermissionsResultSchema = v7.literal(true);
398
- var requestPermissionsRequestMessageSchema = v7.object({
722
+ var requestPermissionsParamsSchema = v14.nullish(v14.array(permissionTemplate));
723
+ var requestPermissionsResultSchema = v14.literal(true);
724
+ var requestPermissionsRequestMessageSchema = v14.object({
399
725
  ...rpcRequestMessageSchema.entries,
400
- ...v7.object({
401
- method: v7.literal(requestPermissionsMethodName),
726
+ ...v14.object({
727
+ method: v14.literal(requestPermissionsMethodName),
402
728
  params: requestPermissionsParamsSchema,
403
- id: v7.string()
729
+ id: v14.string()
404
730
  }).entries
405
731
  });
406
732
  var renouncePermissionsMethodName = "wallet_renouncePermissions";
407
- var renouncePermissionsParamsSchema = v7.nullish(v7.null());
408
- var renouncePermissionsResultSchema = v7.nullish(v7.null());
409
- var renouncePermissionsRequestMessageSchema = v7.object({
733
+ var renouncePermissionsParamsSchema = v14.nullish(v14.null());
734
+ var renouncePermissionsResultSchema = v14.nullish(v14.null());
735
+ var renouncePermissionsRequestMessageSchema = v14.object({
410
736
  ...rpcRequestMessageSchema.entries,
411
- ...v7.object({
412
- method: v7.literal(renouncePermissionsMethodName),
737
+ ...v14.object({
738
+ method: v14.literal(renouncePermissionsMethodName),
413
739
  params: renouncePermissionsParamsSchema,
414
- id: v7.string()
740
+ id: v14.string()
415
741
  }).entries
416
742
  });
417
743
  var disconnectMethodName = "wallet_disconnect";
418
- var disconnectParamsSchema = v7.nullish(v7.null());
419
- var disconnectResultSchema = v7.nullish(v7.null());
420
- var disconnectRequestMessageSchema = v7.object({
744
+ var disconnectParamsSchema = v14.nullish(v14.null());
745
+ var disconnectResultSchema = v14.nullish(v14.null());
746
+ var disconnectRequestMessageSchema = v14.object({
421
747
  ...rpcRequestMessageSchema.entries,
422
- ...v7.object({
423
- method: v7.literal(disconnectMethodName),
748
+ ...v14.object({
749
+ method: v14.literal(disconnectMethodName),
424
750
  params: disconnectParamsSchema,
425
- id: v7.string()
751
+ id: v14.string()
426
752
  }).entries
427
753
  });
428
754
  var getWalletTypeMethodName = "wallet_getWalletType";
429
- var getWalletTypeParamsSchema = v7.nullish(v7.null());
755
+ var getWalletTypeParamsSchema = v14.nullish(v14.null());
430
756
  var getWalletTypeResultSchema = walletTypeSchema;
431
- var getWalletTypeRequestMessageSchema = v7.object({
757
+ var getWalletTypeRequestMessageSchema = v14.object({
432
758
  ...rpcRequestMessageSchema.entries,
433
- ...v7.object({
434
- method: v7.literal(getWalletTypeMethodName),
759
+ ...v14.object({
760
+ method: v14.literal(getWalletTypeMethodName),
435
761
  params: getWalletTypeParamsSchema,
436
- id: v7.string()
762
+ id: v14.string()
437
763
  }).entries
438
764
  });
439
765
  var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
440
- var getCurrentPermissionsParamsSchema = v7.nullish(v7.null());
441
- var getCurrentPermissionsResultSchema = v7.array(permissions.store.permission);
442
- var getCurrentPermissionsRequestMessageSchema = v7.object({
766
+ var getCurrentPermissionsParamsSchema = v14.nullish(v14.null());
767
+ var getCurrentPermissionsResultSchema = v14.array(permissions.store.permission);
768
+ var getCurrentPermissionsRequestMessageSchema = v14.object({
443
769
  ...rpcRequestMessageSchema.entries,
444
- ...v7.object({
445
- method: v7.literal(getCurrentPermissionsMethodName),
770
+ ...v14.object({
771
+ method: v14.literal(getCurrentPermissionsMethodName),
446
772
  params: getCurrentPermissionsParamsSchema,
447
- id: v7.string()
773
+ id: v14.string()
448
774
  }).entries
449
775
  });
450
776
  var getAccountMethodName = "wallet_getAccount";
451
- var getAccountParamsSchema = v7.nullish(v7.null());
452
- var getAccountResultSchema = v7.object({
777
+ var getAccountParamsSchema = v14.nullish(v14.null());
778
+ var getAccountResultSchema = v14.object({
453
779
  id: permissions.utils.account.accountIdSchema,
454
- addresses: v7.array(addressSchema),
780
+ addresses: v14.array(addressSchema),
455
781
  walletType: walletTypeSchema
456
782
  });
457
- var getAccountRequestMessageSchema = v7.object({
783
+ var getAccountRequestMessageSchema = v14.object({
458
784
  ...rpcRequestMessageSchema.entries,
459
- ...v7.object({
460
- method: v7.literal(getAccountMethodName),
785
+ ...v14.object({
786
+ method: v14.literal(getAccountMethodName),
461
787
  params: getAccountParamsSchema,
462
- id: v7.string()
463
- }).entries
464
- });
465
- var registerClientMethodName = "wallet_registerClient";
466
- var registerClientParamsSchema = v7.object({
467
- name: v7.optional(v7.string()),
468
- description: v7.optional(v7.string())
469
- });
470
- var registerClientResultSchema = v7.object({
471
- id: v7.string()
472
- });
473
- var registerClientRequestMessageSchema = v7.object({
474
- ...rpcRequestMessageSchema.entries,
475
- ...v7.object({
476
- method: v7.literal(registerClientMethodName),
477
- params: registerClientParamsSchema,
478
- id: v7.string()
788
+ id: v14.string()
479
789
  }).entries
480
790
  });
481
791
  var connectMethodName = "wallet_connect";
482
- var connectParamsSchema = v7.nullish(
483
- v7.object({
484
- permissions: v7.optional(permissionsWithoutClientId),
485
- clientInfo: registerClientParamsSchema
792
+ var connectParamsSchema = v14.nullish(
793
+ v14.object({
794
+ permissions: v14.optional(v14.array(permissionTemplate))
486
795
  })
487
796
  );
488
797
  var connectResultSchema = getAccountResultSchema;
489
- var connectRequestMessageSchema = v7.object({
798
+ var connectRequestMessageSchema = v14.object({
490
799
  ...rpcRequestMessageSchema.entries,
491
- ...v7.object({
492
- method: v7.literal(connectMethodName),
800
+ ...v14.object({
801
+ method: v14.literal(connectMethodName),
493
802
  params: connectParamsSchema,
494
- id: v7.string()
803
+ id: v14.string()
495
804
  }).entries
496
805
  });
497
806
 
498
807
  // src/request/types/runesMethods.ts
499
- import * as v8 from "valibot";
808
+ import * as v15 from "valibot";
500
809
  var getRunesBalanceMethodName = "runes_getBalance";
501
- var getRunesBalanceParamsSchema = v8.nullish(v8.null());
502
- var getRunesBalanceResultSchema = v8.object({
503
- balances: v8.array(
504
- v8.object({
505
- runeName: v8.string(),
506
- amount: v8.string(),
507
- divisibility: v8.number(),
508
- symbol: v8.string(),
509
- inscriptionId: v8.nullish(v8.string())
810
+ var getRunesBalanceParamsSchema = v15.nullish(v15.null());
811
+ var getRunesBalanceResultSchema = v15.object({
812
+ balances: v15.array(
813
+ v15.object({
814
+ runeName: v15.string(),
815
+ amount: v15.string(),
816
+ divisibility: v15.number(),
817
+ symbol: v15.string(),
818
+ inscriptionId: v15.nullish(v15.string())
510
819
  })
511
820
  )
512
821
  });
513
- var getRunesBalanceRequestMessageSchema = v8.object({
822
+ var getRunesBalanceRequestMessageSchema = v15.object({
514
823
  ...rpcRequestMessageSchema.entries,
515
- ...v8.object({
516
- method: v8.literal(getRunesBalanceMethodName),
824
+ ...v15.object({
825
+ method: v15.literal(getRunesBalanceMethodName),
517
826
  params: getRunesBalanceParamsSchema,
518
- id: v8.string()
827
+ id: v15.string()
519
828
  }).entries
520
829
  });
521
830
  var transferRunesMethodName = "runes_transfer";
522
- var transferRunesParamsSchema = v8.object({
523
- recipients: v8.array(
524
- v8.object({
525
- runeName: v8.string(),
526
- amount: v8.string(),
527
- address: v8.string()
831
+ var transferRunesParamsSchema = v15.object({
832
+ recipients: v15.array(
833
+ v15.object({
834
+ runeName: v15.string(),
835
+ amount: v15.string(),
836
+ address: v15.string()
528
837
  })
529
838
  )
530
839
  });
531
- var transferRunesRequestSchema = v8.object({
840
+ var transferRunesRequestSchema = v15.object({
532
841
  ...rpcRequestMessageSchema.entries,
533
- ...v8.object({
534
- method: v8.literal(transferRunesMethodName),
842
+ ...v15.object({
843
+ method: v15.literal(transferRunesMethodName),
535
844
  params: transferRunesParamsSchema,
536
- id: v8.string()
845
+ id: v15.string()
537
846
  }).entries
538
847
  });
539
- var TransferRunesResultSchema = v8.object({
540
- txid: v8.string()
848
+ var TransferRunesResultSchema = v15.object({
849
+ txid: v15.string()
541
850
  });
542
851
 
543
852
  // src/request/types/ordinalsMethods.ts
544
- import * as v9 from "valibot";
853
+ import * as v16 from "valibot";
545
854
  var getInscriptionsMethodName = "ord_getInscriptions";
546
- var getInscriptionsParamsSchema = v9.object({
547
- offset: v9.number(),
548
- limit: v9.number()
549
- });
550
- var getInscriptionsResultSchema = v9.object({
551
- total: v9.number(),
552
- limit: v9.number(),
553
- offset: v9.number(),
554
- inscriptions: v9.array(
555
- v9.object({
556
- inscriptionId: v9.string(),
557
- inscriptionNumber: v9.string(),
558
- address: v9.string(),
559
- collectionName: v9.optional(v9.string()),
560
- postage: v9.string(),
561
- contentLength: v9.string(),
562
- contentType: v9.string(),
563
- timestamp: v9.number(),
564
- offset: v9.number(),
565
- genesisTransaction: v9.string(),
566
- output: v9.string()
855
+ var getInscriptionsParamsSchema = v16.object({
856
+ offset: v16.number(),
857
+ limit: v16.number()
858
+ });
859
+ var getInscriptionsResultSchema = v16.object({
860
+ total: v16.number(),
861
+ limit: v16.number(),
862
+ offset: v16.number(),
863
+ inscriptions: v16.array(
864
+ v16.object({
865
+ inscriptionId: v16.string(),
866
+ inscriptionNumber: v16.string(),
867
+ address: v16.string(),
868
+ collectionName: v16.optional(v16.string()),
869
+ postage: v16.string(),
870
+ contentLength: v16.string(),
871
+ contentType: v16.string(),
872
+ timestamp: v16.number(),
873
+ offset: v16.number(),
874
+ genesisTransaction: v16.string(),
875
+ output: v16.string()
567
876
  })
568
877
  )
569
878
  });
570
- var getInscriptionsSchema = v9.object({
879
+ var getInscriptionsSchema = v16.object({
571
880
  ...rpcRequestMessageSchema.entries,
572
- ...v9.object({
573
- method: v9.literal(getInscriptionsMethodName),
881
+ ...v16.object({
882
+ method: v16.literal(getInscriptionsMethodName),
574
883
  params: getInscriptionsParamsSchema,
575
- id: v9.string()
884
+ id: v16.string()
576
885
  }).entries
577
886
  });
578
887
  var sendInscriptionsMethodName = "ord_sendInscriptions";
579
- var sendInscriptionsParamsSchema = v9.object({
580
- transfers: v9.array(
581
- v9.object({
582
- address: v9.string(),
583
- inscriptionId: v9.string()
888
+ var sendInscriptionsParamsSchema = v16.object({
889
+ transfers: v16.array(
890
+ v16.object({
891
+ address: v16.string(),
892
+ inscriptionId: v16.string()
584
893
  })
585
894
  )
586
895
  });
587
- var sendInscriptionsResultSchema = v9.object({
588
- txid: v9.string()
896
+ var sendInscriptionsResultSchema = v16.object({
897
+ txid: v16.string()
589
898
  });
590
- var sendInscriptionsSchema = v9.object({
899
+ var sendInscriptionsSchema = v16.object({
591
900
  ...rpcRequestMessageSchema.entries,
592
- ...v9.object({
593
- method: v9.literal(sendInscriptionsMethodName),
901
+ ...v16.object({
902
+ method: v16.literal(sendInscriptionsMethodName),
594
903
  params: sendInscriptionsParamsSchema,
595
- id: v9.string()
904
+ id: v16.string()
596
905
  }).entries
597
906
  });
598
907
 
@@ -609,13 +918,13 @@ var request = async (method, params, providerId) => {
609
918
  throw new Error("A wallet method is required");
610
919
  }
611
920
  const response = await provider.request(method, params);
612
- if (v10.is(rpcErrorResponseMessageSchema, response)) {
921
+ if (v17.is(rpcErrorResponseMessageSchema, response)) {
613
922
  return {
614
923
  status: "error",
615
924
  error: response.error
616
925
  };
617
926
  }
618
- if (v10.is(rpcSuccessResponseMessageSchema, response)) {
927
+ if (v17.is(rpcSuccessResponseMessageSchema, response)) {
619
928
  return {
620
929
  status: "success",
621
930
  result: response.result
@@ -1126,17 +1435,16 @@ var XverseAdapter = class extends SatsConnectAdapter {
1126
1435
  };
1127
1436
 
1128
1437
  // src/adapters/unisat.ts
1129
- import { Buffer } from "buffer";
1130
1438
  import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
1131
- function convertSignInputsToInputType(signInputs, allowedSignHash) {
1439
+ import { Buffer } from "buffer";
1440
+ function convertSignInputsToInputType(signInputs) {
1132
1441
  let result = [];
1133
1442
  for (let address in signInputs) {
1134
1443
  let indexes = signInputs[address];
1135
1444
  for (let index of indexes) {
1136
1445
  result.push({
1137
1446
  index,
1138
- address,
1139
- sighashTypes: allowedSignHash ? [allowedSignHash] : void 0
1447
+ address
1140
1448
  });
1141
1449
  }
1142
1450
  }
@@ -1168,10 +1476,10 @@ var UnisatAdapter = class extends SatsConnectAdapter {
1168
1476
  };
1169
1477
  const response = [];
1170
1478
  if (purposes.includes("payment" /* Payment */)) {
1171
- response.push(paymentAddress);
1479
+ response.push({ ...paymentAddress, walletType: "software" });
1172
1480
  }
1173
1481
  if (purposes.includes("ordinals" /* Ordinals */)) {
1174
- response.push(ordinalsAddress);
1482
+ response.push({ ...ordinalsAddress, walletType: "software" });
1175
1483
  }
1176
1484
  return response;
1177
1485
  }
@@ -1184,14 +1492,16 @@ var UnisatAdapter = class extends SatsConnectAdapter {
1184
1492
  return {
1185
1493
  address,
1186
1494
  messageHash: "",
1187
- signature: response2
1495
+ signature: response2,
1496
+ protocol: "BIP322" /* BIP322 */
1188
1497
  };
1189
1498
  }
1190
1499
  const response = await window.unisat.signMessage(message, "ecdsa");
1191
1500
  return {
1192
1501
  address,
1193
1502
  messageHash: "",
1194
- signature: response
1503
+ signature: response,
1504
+ protocol: "ECDSA" /* ECDSA */
1195
1505
  };
1196
1506
  }
1197
1507
  async sendTransfer(params) {
@@ -1205,11 +1515,11 @@ var UnisatAdapter = class extends SatsConnectAdapter {
1205
1515
  };
1206
1516
  }
1207
1517
  async signPsbt(params) {
1208
- const { psbt, signInputs, allowedSignHash, broadcast } = params;
1518
+ const { psbt, signInputs, broadcast } = params;
1209
1519
  const psbtHex = Buffer.from(psbt, "base64").toString("hex");
1210
1520
  const signedPsbt = await window.unisat.signPsbt(psbtHex, {
1211
1521
  autoFinalized: broadcast,
1212
- toSignInputs: convertSignInputsToInputType(signInputs, allowedSignHash)
1522
+ toSignInputs: convertSignInputsToInputType(signInputs)
1213
1523
  });
1214
1524
  if (broadcast) {
1215
1525
  const txid = await window.unisat.pushPsbt(psbtHex);
@@ -1279,6 +1589,33 @@ var UnisatAdapter = class extends SatsConnectAdapter {
1279
1589
  };
1280
1590
  }
1281
1591
  };
1592
+ addListener = (eventName, cb) => {
1593
+ switch (eventName) {
1594
+ case "accountChange": {
1595
+ const handler = () => {
1596
+ cb({ type: "accountChange" });
1597
+ };
1598
+ window.unisat.on("accountsChanged", handler);
1599
+ return () => {
1600
+ window.unisat.removeListener("accountsChanged", handler);
1601
+ };
1602
+ }
1603
+ case "networkChange": {
1604
+ const handler = () => {
1605
+ cb({ type: "networkChange" });
1606
+ };
1607
+ window.unisat.on("networkChanged", handler);
1608
+ return () => {
1609
+ window.unisat.removeListener("networkChanged", handler);
1610
+ };
1611
+ }
1612
+ default: {
1613
+ console.error("Event not supported by the selected wallet");
1614
+ return () => {
1615
+ };
1616
+ }
1617
+ }
1618
+ };
1282
1619
  };
1283
1620
 
1284
1621
  // src/adapters/BaseAdapter.ts
@@ -1602,11 +1939,7 @@ export {
1602
1939
  isProviderInstalled,
1603
1940
  networkChangeEventName,
1604
1941
  networkChangeSchema,
1605
- permissionsWithoutClientId,
1606
- registerClientMethodName,
1607
- registerClientParamsSchema,
1608
- registerClientRequestMessageSchema,
1609
- registerClientResultSchema,
1942
+ permissionTemplate,
1610
1943
  removeDefaultProvider,
1611
1944
  renouncePermissionsMethodName,
1612
1945
  renouncePermissionsParamsSchema,
@@ -1626,6 +1959,10 @@ export {
1626
1959
  sendInscriptionsParamsSchema,
1627
1960
  sendInscriptionsResultSchema,
1628
1961
  sendInscriptionsSchema,
1962
+ sendTransferMethodName,
1963
+ sendTransferParamsSchema,
1964
+ sendTransferRequestMessageSchema,
1965
+ sendTransferResultSchema,
1629
1966
  setDefaultProvider,
1630
1967
  signMessage,
1631
1968
  signMessageMethodName,
@@ -1633,15 +1970,43 @@ export {
1633
1970
  signMessageRequestMessageSchema,
1634
1971
  signMessageResultSchema,
1635
1972
  signMultipleTransactions,
1973
+ signPsbtMethodName,
1974
+ signPsbtParamsSchema,
1975
+ signPsbtRequestMessageSchema,
1976
+ signPsbtResultSchema,
1636
1977
  signTransaction,
1978
+ stxCallContractMethodName,
1979
+ stxCallContractParamsSchema,
1980
+ stxCallContractRequestMessageSchema,
1981
+ stxCallContractResultSchema,
1982
+ stxDeployContractMethodName,
1983
+ stxDeployContractParamsSchema,
1984
+ stxDeployContractRequestMessageSchema,
1985
+ stxDeployContractResultSchema,
1986
+ stxGetAccountsMethodName,
1987
+ stxGetAccountsParamsSchema,
1988
+ stxGetAccountsRequestMessageSchema,
1989
+ stxGetAccountsResultSchema,
1637
1990
  stxGetAddressesMethodName,
1638
1991
  stxGetAddressesParamsSchema,
1639
1992
  stxGetAddressesRequestMessageSchema,
1640
1993
  stxGetAddressesResultSchema,
1994
+ stxSignMessageMethodName,
1995
+ stxSignMessageParamsSchema,
1996
+ stxSignMessageRequestMessageSchema,
1997
+ stxSignMessageResultSchema,
1998
+ stxSignStructuredMessageMethodName,
1999
+ stxSignStructuredMessageParamsSchema,
2000
+ stxSignStructuredMessageRequestMessageSchema,
2001
+ stxSignStructuredMessageResultSchema,
1641
2002
  stxSignTransactionMethodName,
1642
2003
  stxSignTransactionParamsSchema,
1643
2004
  stxSignTransactionRequestMessageSchema,
1644
2005
  stxSignTransactionResultSchema,
2006
+ stxTransferStxMethodName,
2007
+ stxTransferStxParamsSchema,
2008
+ stxTransferStxRequestMessageSchema,
2009
+ stxTransferStxResultSchema,
1645
2010
  transferRunesMethodName,
1646
2011
  transferRunesParamsSchema,
1647
2012
  transferRunesRequestSchema,