@sats-connect/core 0.0.12-81e158a → 0.0.12

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.d.mts CHANGED
@@ -1,5 +1,3 @@
1
- import * as v from 'valibot';
2
-
3
1
  interface GetCapabilitiesPayload extends RequestPayload {
4
2
  }
5
3
  type GetCapabilitiesResponse = Capability[];
@@ -116,7 +114,7 @@ interface Provider {
116
114
  mozillaAddOnsUrl?: string;
117
115
  googlePlayStoreUrl?: string;
118
116
  iOSAppStoreUrl?: string;
119
- methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod | OrdinalsRequestMethod)[];
117
+ methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod)[];
120
118
  }
121
119
  interface SupportedWallet extends Provider {
122
120
  isInstalled: boolean;
@@ -159,15 +157,7 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
159
157
  payload: Payload;
160
158
  getProvider?: () => Promise<BitcoinProvider | undefined>;
161
159
  }
162
- declare const RpcIdSchema: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
163
- type RpcId = v.InferOutput<typeof RpcIdSchema>;
164
- declare const rpcRequestMessageSchema: v.ObjectSchema<{
165
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
166
- readonly method: v.StringSchema<undefined>;
167
- readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
168
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
169
- }, undefined>;
170
- type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
160
+ type RpcId = string | null;
171
161
  interface RpcBase {
172
162
  jsonrpc: '2.0';
173
163
  id: RpcId;
@@ -214,34 +204,8 @@ declare enum RpcErrorCode {
214
204
  /**
215
205
  * method is not supported for the address provided
216
206
  */
217
- METHOD_NOT_SUPPORTED = -32001,
218
- /**
219
- * The client does not have permission to access the requested resource.
220
- */
221
- ACCESS_DENIED = -32002
222
- }
223
- declare const rpcSuccessResponseMessageSchema: v.ObjectSchema<{
224
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
225
- readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
226
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
227
- }, undefined>;
228
- type RpcSuccessResponseMessage = v.InferOutput<typeof rpcSuccessResponseMessageSchema>;
229
- declare const rpcErrorResponseMessageSchema: v.ObjectSchema<{
230
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
231
- readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
232
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
233
- }, undefined>;
234
- type RpcErrorResponseMessage = v.InferOutput<typeof rpcErrorResponseMessageSchema>;
235
- declare const rpcResponseMessageSchema: v.UnionSchema<[v.ObjectSchema<{
236
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
237
- readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
238
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
239
- }, undefined>, v.ObjectSchema<{
240
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
241
- readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
242
- readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
243
- }, undefined>], undefined>;
244
- type RpcResponseMessage = v.InferOutput<typeof rpcResponseMessageSchema>;
207
+ METHOD_NOT_SUPPORTED = -32001
208
+ }
245
209
  interface RpcError {
246
210
  code: number | RpcErrorCode;
247
211
  message: string;
@@ -279,13 +243,12 @@ declare enum AddressType {
279
243
  p2tr = "p2tr",
280
244
  stacks = "stacks"
281
245
  }
282
- declare const addressSchema: v.ObjectSchema<{
283
- readonly address: v.StringSchema<undefined>;
284
- readonly publicKey: v.StringSchema<undefined>;
285
- readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
286
- readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
287
- }, undefined>;
288
- type Address$1 = v.InferOutput<typeof addressSchema>;
246
+ interface Address$1 {
247
+ address: string;
248
+ publicKey: string;
249
+ purpose?: AddressPurpose;
250
+ addressType?: AddressType;
251
+ }
289
252
  interface GetAddressResponse {
290
253
  addresses: Address$1[];
291
254
  }
@@ -293,119 +256,59 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
293
256
 
294
257
  declare const getAddress: (options: GetAddressOptions) => Promise<void>;
295
258
 
296
- declare const getInfoMethodName = "getInfo";
297
- declare const getInfoParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
298
- type GetInfoParams = v.InferOutput<typeof getInfoParamsSchema>;
299
- declare const getInfoResultSchema: v.ObjectSchema<{
300
- /**
301
- * Version of the wallet.
302
- */
303
- readonly version: v.StringSchema<undefined>;
304
- /**
305
- * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
306
- */
307
- readonly methods: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, never>;
308
- /**
309
- * List of WBIP standards supported by the wallet. Not currently used.
310
- */
311
- readonly supports: v.ArraySchema<v.StringSchema<undefined>, undefined>;
312
- }, undefined>;
313
- type GetInfoResult = v.InferOutput<typeof getInfoResultSchema>;
314
- declare const getInfoRequestMessageSchema: v.ObjectSchema<{
315
- readonly method: v.LiteralSchema<"getInfo", undefined>;
316
- readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
317
- readonly id: v.StringSchema<undefined>;
318
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
319
- }, undefined>;
320
- type GetInfoRequestMessage = v.InferOutput<typeof getInfoRequestMessageSchema>;
321
- type GetInfo = MethodParamsAndResult<v.InferOutput<typeof getInfoParamsSchema>, v.InferOutput<typeof getInfoResultSchema>>;
322
- declare const getAddressesMethodName = "getAddresses";
323
- declare const getAddressesParamsSchema: v.ObjectSchema<{
324
- /**
325
- * The purposes for which to generate addresses. See
326
- * {@linkcode AddressPurpose} for available purposes.
327
- */
328
- readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
329
- /**
330
- * A message to be displayed to the user in the request prompt.
331
- */
332
- readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
333
- }, undefined>;
334
- type GetAddressesParams = v.InferOutput<typeof getAddressesParamsSchema>;
335
- declare const getAddressesResultSchema: v.ObjectSchema<{
336
- /**
337
- * The addresses generated for the given purposes.
338
- */
339
- readonly addresses: v.ArraySchema<v.ObjectSchema<{
340
- readonly address: v.StringSchema<undefined>;
341
- readonly publicKey: v.StringSchema<undefined>;
342
- readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
343
- readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
344
- }, undefined>, undefined>;
345
- }, undefined>;
346
- type GetAddressesResult = v.InferOutput<typeof getAddressesResultSchema>;
347
- declare const getAddressesRequestMessageSchema: v.ObjectSchema<{
348
- readonly method: v.LiteralSchema<"getAddresses", undefined>;
349
- readonly params: v.ObjectSchema<{
350
- /**
351
- * The purposes for which to generate addresses. See
352
- * {@linkcode AddressPurpose} for available purposes.
353
- */
354
- readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
355
- /**
356
- * A message to be displayed to the user in the request prompt.
357
- */
358
- readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
359
- }, undefined>;
360
- readonly id: v.StringSchema<undefined>;
361
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
362
- }, undefined>;
363
- type GetAddressesRequestMessage = v.InferOutput<typeof getAddressesRequestMessageSchema>;
364
- type GetAddresses = MethodParamsAndResult<v.InferOutput<typeof getAddressesParamsSchema>, v.InferOutput<typeof getAddressesResultSchema>>;
365
- declare const signMessageMethodName = "signMessage";
366
- declare const signMessageParamsSchema: v.ObjectSchema<{
259
+ /**
260
+ * Represents the types and interfaces related to BTC methods.
261
+ */
262
+
263
+ type GetInfoResult = {
264
+ version: number | string;
265
+ methods?: Array<string>;
266
+ supports?: Array<string>;
267
+ };
268
+ type GetInfo = MethodParamsAndResult<null, GetInfoResult>;
269
+ type GetAddressesParams$1 = {
270
+ /**
271
+ * The purposes for which to generate addresses.
272
+ * possible values are "payment", "ordinals", ...
273
+ */
274
+ purposes: Array<AddressPurpose>;
275
+ /**
276
+ * a message to be displayed to the user in the request prompt.
277
+ */
278
+ message?: string;
279
+ };
280
+ /**
281
+ * The addresses generated for the given purposes.
282
+ */
283
+ type GetAddressesResult$1 = {
284
+ addresses: Array<Address$1>;
285
+ };
286
+ type GetAddresses = MethodParamsAndResult<GetAddressesParams$1, GetAddressesResult$1>;
287
+ type SignMessageParams = {
367
288
  /**
368
289
  * The address used for signing.
369
290
  **/
370
- readonly address: v.StringSchema<undefined>;
291
+ address: string;
371
292
  /**
372
293
  * The message to sign.
373
294
  **/
374
- readonly message: v.StringSchema<undefined>;
375
- }, undefined>;
376
- type SignMessageParams = v.InferOutput<typeof signMessageParamsSchema>;
377
- declare const signMessageResultSchema: v.ObjectSchema<{
295
+ message: string;
296
+ };
297
+ type SignMessageResult = {
378
298
  /**
379
299
  * The signature of the message.
380
300
  */
381
- readonly signature: v.StringSchema<undefined>;
301
+ signature: string;
382
302
  /**
383
303
  * hash of the message.
384
304
  */
385
- readonly messageHash: v.StringSchema<undefined>;
305
+ messageHash: string;
386
306
  /**
387
307
  * The address used for signing.
388
308
  */
389
- readonly address: v.StringSchema<undefined>;
390
- }, undefined>;
391
- type SignMessageResult = v.InferOutput<typeof signMessageResultSchema>;
392
- declare const signMessageRequestMessageSchema: v.ObjectSchema<{
393
- readonly method: v.LiteralSchema<"signMessage", undefined>;
394
- readonly params: v.ObjectSchema<{
395
- /**
396
- * The address used for signing.
397
- **/
398
- readonly address: v.StringSchema<undefined>;
399
- /**
400
- * The message to sign.
401
- **/
402
- readonly message: v.StringSchema<undefined>;
403
- }, undefined>;
404
- readonly id: v.StringSchema<undefined>;
405
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
406
- }, undefined>;
407
- type SignMessageRequestMessage = v.InferOutput<typeof signMessageRequestMessageSchema>;
408
- type SignMessage = MethodParamsAndResult<v.InferOutput<typeof signMessageParamsSchema>, v.InferOutput<typeof signMessageResultSchema>>;
309
+ address: string;
310
+ };
311
+ type SignMessage = MethodParamsAndResult<SignMessageParams, SignMessageResult>;
409
312
  type Recipient$1 = {
410
313
  /**
411
314
  * The recipient's address.
@@ -462,104 +365,22 @@ type SignPsbtResult = {
462
365
  txid?: string;
463
366
  };
464
367
  type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
465
- declare const getAccountsMethodName = "getAccounts";
466
- declare const getAccountsParamsSchema: v.ObjectSchema<{
467
- /**
468
- * The purposes for which to generate addresses. See
469
- * {@linkcode AddressPurpose} for available purposes.
470
- */
471
- readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
472
- /**
473
- * A message to be displayed to the user in the request prompt.
474
- */
475
- readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
476
- }, undefined>;
477
- type GetAccountsParams = v.InferOutput<typeof getAccountsParamsSchema>;
478
- declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
479
- readonly address: v.StringSchema<undefined>;
480
- readonly publicKey: v.StringSchema<undefined>;
481
- readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
482
- readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
483
- }, undefined>, undefined>;
484
- type GetAccountsResult = v.InferOutput<typeof getAccountsResultSchema>;
485
- declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
486
- readonly method: v.LiteralSchema<"getAccounts", undefined>;
487
- readonly params: v.ObjectSchema<{
488
- /**
489
- * The purposes for which to generate addresses. See
490
- * {@linkcode AddressPurpose} for available purposes.
491
- */
492
- readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
493
- /**
494
- * A message to be displayed to the user in the request prompt.
495
- */
496
- readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
497
- }, undefined>;
498
- readonly id: v.StringSchema<undefined>;
499
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
500
- }, undefined>;
501
- type GetAccountsRequestMessage = v.InferOutput<typeof getAccountsRequestMessageSchema>;
502
- type GetAccounts = MethodParamsAndResult<v.InferOutput<typeof getAccountsParamsSchema>, v.InferOutput<typeof getAccountsResultSchema>>;
503
- declare const getBalanceMethodName = "getBalance";
504
- declare const getBalanceParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
505
- declare const getBalanceResultSchema: v.ObjectSchema<{
506
- /**
507
- * The confirmed balance of the wallet in sats. Using a string due to chrome
508
- * messages not supporting bigint
509
- * (https://issues.chromium.org/issues/40116184).
510
- */
511
- readonly confirmed: v.StringSchema<undefined>;
512
- /**
513
- * The unconfirmed balance of the wallet in sats. Using a string due to chrome
514
- * messages not supporting bigint
515
- * (https://issues.chromium.org/issues/40116184).
516
- */
517
- readonly unconfirmed: v.StringSchema<undefined>;
518
- /**
519
- * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
520
- * sats. Using a string due to chrome messages not supporting bigint
521
- * (https://issues.chromium.org/issues/40116184).
522
- */
523
- readonly total: v.StringSchema<undefined>;
524
- }, undefined>;
525
- declare const getBalanceRequestMessageSchema: v.ObjectSchema<{
526
- readonly method: v.LiteralSchema<"getBalance", undefined>;
527
- readonly id: v.StringSchema<undefined>;
528
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
529
- readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
530
- }, undefined>;
531
- type GetBalance = MethodParamsAndResult<v.InferOutput<typeof getBalanceParamsSchema>, v.InferOutput<typeof getBalanceResultSchema>>;
532
-
533
- declare const getInscriptionsMethodName = "ord_getInscriptions";
534
- declare const getInscriptionsParamsSchema: v.ObjectSchema<{
535
- readonly offset: v.NumberSchema<undefined>;
536
- readonly limit: v.NumberSchema<undefined>;
537
- }, undefined>;
538
- declare const getInscriptionsResultSchema: v.ObjectSchema<{
539
- readonly inscriptions: v.ArraySchema<v.ObjectSchema<{
540
- readonly inscriptionId: v.StringSchema<undefined>;
541
- readonly inscriptionNumber: v.StringSchema<undefined>;
542
- readonly address: v.StringSchema<undefined>;
543
- readonly collectionName: v.OptionalSchema<v.StringSchema<undefined>, never>;
544
- readonly postage: v.StringSchema<undefined>;
545
- readonly contentLength: v.StringSchema<undefined>;
546
- readonly contentType: v.StringSchema<undefined>;
547
- readonly timestamp: v.NumberSchema<undefined>;
548
- readonly offset: v.NumberSchema<undefined>;
549
- readonly genesisTransaction: v.StringSchema<undefined>;
550
- readonly output: v.StringSchema<undefined>;
551
- }, undefined>, undefined>;
552
- }, undefined>;
553
- declare const getInscriptionsSchema: v.ObjectSchema<{
554
- readonly method: v.LiteralSchema<"ord_getInscriptions", undefined>;
555
- readonly params: v.ObjectSchema<{
556
- readonly offset: v.NumberSchema<undefined>;
557
- readonly limit: v.NumberSchema<undefined>;
558
- }, undefined>;
559
- readonly id: v.StringSchema<undefined>;
560
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
561
- }, undefined>;
562
- type GetInscriptions = MethodParamsAndResult<v.InferOutput<typeof getInscriptionsParamsSchema>, v.InferOutput<typeof getInscriptionsResultSchema>>;
368
+ type GetAccountsParams = {
369
+ /**
370
+ * The purposes for which to generate addresses.
371
+ * possible values are "payment", "ordinals", ...
372
+ */
373
+ purposes: Array<AddressPurpose>;
374
+ /**
375
+ * a message to be displayed to the user in the request prompt.
376
+ */
377
+ /**
378
+ * a message to be displayed to the user in the request prompt.
379
+ */
380
+ message?: string;
381
+ };
382
+ type GetAccountResult = Address$1[];
383
+ type GetAccounts = MethodParamsAndResult<GetAccountsParams, GetAccountResult>;
563
384
 
564
385
  type CreateMintOrderRequest = {
565
386
  runeName: string;
@@ -672,27 +493,17 @@ interface RbfOrderResult {
672
493
  fundingAddress: string;
673
494
  }
674
495
  type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
675
- declare const getRunesBalanceMethodName = "runes_getBalance";
676
- declare const getRunesBalanceParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
677
- type GetRunesBalanceParams = v.InferOutput<typeof getRunesBalanceParamsSchema>;
678
- declare const getRunesBalanceResultSchema: v.ObjectSchema<{
679
- readonly balances: v.ArraySchema<v.ObjectSchema<{
680
- readonly runeName: v.StringSchema<undefined>;
681
- readonly amount: v.StringSchema<undefined>;
682
- readonly divisibility: v.NumberSchema<undefined>;
683
- readonly symbol: v.StringSchema<undefined>;
684
- readonly inscriptionId: v.NullishSchema<v.StringSchema<undefined>, never>;
685
- }, undefined>, undefined>;
686
- }, undefined>;
687
- type GetRunesBalanceResult = v.InferOutput<typeof getRunesBalanceResultSchema>;
688
- declare const getRunesBalanceRequestMessageSchema: v.ObjectSchema<{
689
- readonly method: v.LiteralSchema<"runes_getBalance", undefined>;
690
- readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
691
- readonly id: v.StringSchema<undefined>;
692
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
693
- }, undefined>;
694
- type GetRunesBalanceRequestMessage = v.InferOutput<typeof getRunesBalanceRequestMessageSchema>;
695
- type GetRunesBalance = MethodParamsAndResult<v.InferOutput<typeof getRunesBalanceParamsSchema>, v.InferOutput<typeof getRunesBalanceResultSchema>>;
496
+ type GetRunesBalanceParams = null;
497
+ interface GetRunesBalanceResult {
498
+ balances: {
499
+ runeName: string;
500
+ amount: string;
501
+ divisibility: number;
502
+ symbol: string;
503
+ inscriptionId: string | null;
504
+ }[];
505
+ }
506
+ type GetRunesBalance = MethodParamsAndResult<GetRunesBalanceParams, GetRunesBalanceResult>;
696
507
 
697
508
  interface Pubkey {
698
509
  /**
@@ -858,71 +669,22 @@ interface DeployContractParams {
858
669
  }
859
670
  type DeployContractResult = TxId & Transaction;
860
671
  type StxDeployContract = MethodParamsAndResult<DeployContractParams, DeployContractResult>;
861
- type StxGetAccountsResult = {
672
+ type GetAccountsResult = {
862
673
  addresses: Array<Address & PublicKey & {
863
674
  gaiaHubUrl: string;
864
675
  gaiaAppKey: string;
865
676
  }>;
866
677
  };
867
- type StxGetAccounts = MethodParamsAndResult<{}, StxGetAccountsResult>;
868
- declare const stxGetAddressesMethodName = "stx_getAddresses";
869
- declare const stxGetAddressesParamsSchema: v.NullishSchema<v.ObjectSchema<{
870
- /**
871
- * A message to be displayed to the user in the request prompt.
872
- */
873
- readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
874
- }, undefined>, never>;
875
- type StxGetAddressesParams = v.InferOutput<typeof stxGetAddressesParamsSchema>;
876
- declare const stxGetAddressesResultSchema: v.ObjectSchema<{
877
- /**
878
- * The addresses generated for the given purposes.
879
- */
880
- readonly addresses: v.ArraySchema<v.ObjectSchema<{
881
- readonly address: v.StringSchema<undefined>;
882
- readonly publicKey: v.StringSchema<undefined>;
883
- readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
884
- readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
885
- }, undefined>, undefined>;
886
- }, undefined>;
887
- type StxGetAddressesResult = v.InferOutput<typeof stxGetAddressesResultSchema>;
888
- declare const stxGetAddressesRequestMessageSchema: v.ObjectSchema<{
889
- readonly method: v.LiteralSchema<"stx_getAddresses", undefined>;
890
- readonly params: v.NullishSchema<v.ObjectSchema<{
891
- /**
892
- * A message to be displayed to the user in the request prompt.
893
- */
894
- readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
895
- }, undefined>, never>;
896
- readonly id: v.StringSchema<undefined>;
897
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
898
- }, undefined>;
899
- type StxGetAddressesRequestMessage = v.InferOutput<typeof stxGetAddressesRequestMessageSchema>;
900
- type StxGetAddresses = MethodParamsAndResult<v.InferOutput<typeof stxGetAddressesParamsSchema>, v.InferOutput<typeof stxGetAddressesResultSchema>>;
678
+ type StxGetAccounts = MethodParamsAndResult<{}, GetAccountsResult>;
679
+ type GetAddressesParams = undefined | null;
680
+ type GetAddressesResult = {
681
+ addresses: Array<Address & PublicKey>;
682
+ };
683
+ type StxGetAddresses = MethodParamsAndResult<GetAddressesParams, GetAddressesResult>;
901
684
  type SignTransactionParams = Transaction & Partial<Pubkey>;
902
685
  type SignTransactionResult = Transaction;
903
686
  type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
904
687
 
905
- declare const requestPermissionsMethodName = "wallet_requestPermissions";
906
- declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
907
- declare const requestPermissionsResultSchema: v.LiteralSchema<true, undefined>;
908
- declare const requestPermissionsRequestMessageSchema: v.ObjectSchema<{
909
- readonly method: v.LiteralSchema<"wallet_requestPermissions", undefined>;
910
- readonly params: v.UndefinedSchema<undefined>;
911
- readonly id: v.StringSchema<undefined>;
912
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
913
- }, undefined>;
914
- type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof requestPermissionsParamsSchema>, v.InferOutput<typeof requestPermissionsResultSchema>>;
915
- declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
916
- declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
917
- declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
918
- declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
919
- readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
920
- readonly params: v.UndefinedSchema<undefined>;
921
- readonly id: v.StringSchema<undefined>;
922
- readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
923
- }, undefined>;
924
- type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
925
-
926
688
  interface StxRequests {
927
689
  stx_callContract: StxCallContract;
928
690
  stx_deployContract: StxDeployContract;
@@ -938,7 +700,6 @@ interface BtcRequests {
938
700
  getInfo: GetInfo;
939
701
  getAddresses: GetAddresses;
940
702
  getAccounts: GetAccounts;
941
- getBalance: GetBalance;
942
703
  signMessage: SignMessage;
943
704
  sendTransfer: SendTransfer;
944
705
  signPsbt: SignPsbt;
@@ -955,19 +716,11 @@ interface RunesRequests {
955
716
  runes_getBalance: GetRunesBalance;
956
717
  }
957
718
  type RunesRequestMethod = keyof RunesRequests;
958
- interface OrdinalsRequests {
959
- ord_getInscriptions: GetInscriptions;
960
- }
961
- type OrdinalsRequestMethod = keyof OrdinalsRequests;
962
- interface WalletMethods {
963
- wallet_requestPermissions: RequestPermissions;
964
- wallet_renouncePermissions: RenouncePermissions;
965
- }
966
- type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods & OrdinalsRequests;
719
+ type Requests = BtcRequests & StxRequests & RunesRequests;
967
720
  type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
968
721
  type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
969
722
 
970
- declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods | "ord_getInscriptions">(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
723
+ declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
971
724
 
972
725
  declare abstract class SatsConnectAdapter {
973
726
  abstract readonly id: string;
@@ -985,10 +738,10 @@ declare abstract class SatsConnectAdapter {
985
738
  declare class BaseAdapter extends SatsConnectAdapter {
986
739
  id: string;
987
740
  constructor(providerId: string);
988
- requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods | "ord_getInscriptions">(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
741
+ requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
989
742
  }
990
743
 
991
744
  declare const DefaultAdaptersInfo: Record<string, Provider>;
992
745
  declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
993
746
 
994
- export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type EstimateRbfOrder, type EstimateRunesEtch, type EstimateRunesEtchParams, type EstimateRunesEtchResult, type EstimateRunesMint, type EstimateRunesMintParams, type EstimateRunesMintResult, type EtchRunes, type EtchRunesParams, type EtchRunesResult, type GetAccounts, type GetAccountsParams, type GetAccountsRequestMessage, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesRequestMessage, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetInfoParams, type GetInfoRequestMessage, type GetInfoResult, type GetInscriptions, type GetOrder, type GetRunesBalance, type GetRunesBalanceParams, type GetRunesBalanceRequestMessage, type GetRunesBalanceResult, type InputToSign, type MethodParamsAndResult, type MintRunes, type MintRunesParams, type MintRunesResult, type OrdinalsRequestMethod, type OrdinalsRequests, type Params, type Provider, type PsbtPayload, type RbfOrder, type Recipient$2 as Recipient, type RenouncePermissions, type RequestOptions, type RequestPayload, type RequestPermissions, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcErrorResponseMessage, type RpcId, RpcIdSchema, type RpcRequest, type RpcRequestMessage, type RpcResponse, type RpcResponseMessage, type RpcResult, type RpcSuccessResponse, type RpcSuccessResponseMessage, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessageParams, type SignMessagePayload, type SignMessageRequestMessage, type SignMessageResponse, type SignMessageResult, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAccountsResult, type StxGetAddresses, type StxGetAddressesParams, type StxGetAddressesRequestMessage, type StxGetAddressesResult, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, type WalletMethods, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceRequestMessageSchema, getBalanceResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoRequestMessageSchema, getInfoResultSchema, getInscriptionsMethodName, getInscriptionsParamsSchema, getInscriptionsResultSchema, getInscriptionsSchema, getProviderById, getProviderOrThrow, getProviders, getRunesBalanceMethodName, getRunesBalanceParamsSchema, getRunesBalanceRequestMessageSchema, getRunesBalanceResultSchema, getSupportedWallets, isProviderInstalled, removeDefaultProvider, renouncePermissionsMethodName, renouncePermissionsParamsSchema, renouncePermissionsRequestMessageSchema, renouncePermissionsResultSchema, request, requestPermissionsMethodName, requestPermissionsParamsSchema, requestPermissionsRequestMessageSchema, requestPermissionsResultSchema, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction, stxGetAddressesMethodName, stxGetAddressesParamsSchema, stxGetAddressesRequestMessageSchema, stxGetAddressesResultSchema };
747
+ export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type GetAccountResult, type GetAccounts, type GetAccountsParams, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type InputToSign, type MethodParamsAndResult, type Params, type Provider, type PsbtPayload, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcId, type RpcRequest, type RpcResponse, type RpcResult, type RpcSuccessResponse, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessageParams, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, createInscription, createRepeatInscriptions, defaultAdapters, getAddress, getCapabilities, getDefaultProvider, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, sendBtcTransaction, setDefaultProvider, signMessage, signMultipleTransactions, signTransaction };
package/dist/index.mjs CHANGED
@@ -1,28 +1,10 @@
1
1
  // src/types.ts
2
- import * as v from "valibot";
3
- var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType3) => {
4
- BitcoinNetworkType3["Mainnet"] = "Mainnet";
5
- BitcoinNetworkType3["Testnet"] = "Testnet";
6
- BitcoinNetworkType3["Signet"] = "Signet";
7
- return BitcoinNetworkType3;
2
+ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
3
+ BitcoinNetworkType2["Mainnet"] = "Mainnet";
4
+ BitcoinNetworkType2["Testnet"] = "Testnet";
5
+ BitcoinNetworkType2["Signet"] = "Signet";
6
+ return BitcoinNetworkType2;
8
7
  })(BitcoinNetworkType || {});
9
- var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
10
- var rpcRequestMessageSchema = v.object({
11
- jsonrpc: v.literal("2.0"),
12
- method: v.string(),
13
- params: v.optional(
14
- v.union([
15
- v.array(v.unknown()),
16
- v.looseObject({}),
17
- // Note: This is to support current incorrect usage of RPC 2.0. Params need
18
- // to be either an array or an object when provided. Changing this now would
19
- // be a breaking change, so accepting null values for now. Tracking in
20
- // https://linear.app/xverseapp/issue/ENG-4538.
21
- v.null()
22
- ])
23
- ),
24
- id: RpcIdSchema
25
- });
26
8
  var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
27
9
  RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
28
10
  RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
@@ -31,23 +13,8 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
31
13
  RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
32
14
  RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
33
15
  RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
34
- RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
35
16
  return RpcErrorCode2;
36
17
  })(RpcErrorCode || {});
37
- var rpcSuccessResponseMessageSchema = v.object({
38
- jsonrpc: v.literal("2.0"),
39
- result: v.nonOptional(v.unknown()),
40
- id: RpcIdSchema
41
- });
42
- var rpcErrorResponseMessageSchema = v.object({
43
- jsonrpc: v.literal("2.0"),
44
- error: v.nonOptional(v.unknown()),
45
- id: RpcIdSchema
46
- });
47
- var rpcResponseMessageSchema = v.union([
48
- rpcSuccessResponseMessageSchema,
49
- rpcErrorResponseMessageSchema
50
- ]);
51
18
 
52
19
  // src/runes/api.ts
53
20
  import axios from "axios";
@@ -546,13 +513,49 @@ function getSupportedWallets() {
546
513
  }
547
514
 
548
515
  // src/request/index.ts
549
- import * as v8 from "valibot";
516
+ var request = async (method, params, providerId) => {
517
+ let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
518
+ if (providerId) {
519
+ provider = await getProviderById(providerId);
520
+ }
521
+ if (!provider) {
522
+ throw new Error("no wallet provider was found");
523
+ }
524
+ if (!method) {
525
+ throw new Error("A wallet method is required");
526
+ }
527
+ const response = await provider.request(method, params);
528
+ if (isRpcSuccessResponse(response)) {
529
+ return {
530
+ status: "success",
531
+ result: response.result
532
+ };
533
+ }
534
+ return {
535
+ status: "error",
536
+ error: response.error
537
+ };
538
+ };
539
+ var isRpcSuccessResponse = (response) => {
540
+ return Object.hasOwn(response, "result") && !!response.result;
541
+ };
542
+
543
+ // src/adapters/xverse.ts
544
+ var XverseAdapter = class extends SatsConnectAdapter {
545
+ id = DefaultAdaptersInfo.xverse.id;
546
+ requestInternal = async (method, params) => {
547
+ return request(method, params, this.id);
548
+ };
549
+ };
550
+
551
+ // src/adapters/unisat.ts
552
+ import { Buffer } from "buffer";
553
+ import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
550
554
 
551
555
  // src/addresses/index.ts
552
556
  import { createUnsecuredToken } from "jsontokens";
553
557
 
554
558
  // src/addresses/types.ts
555
- import * as v2 from "valibot";
556
559
  var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
557
560
  AddressPurpose2["Ordinals"] = "ordinals";
558
561
  AddressPurpose2["Payment"] = "payment";
@@ -568,12 +571,6 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
568
571
  AddressType3["stacks"] = "stacks";
569
572
  return AddressType3;
570
573
  })(AddressType || {});
571
- var addressSchema = v2.object({
572
- address: v2.string(),
573
- publicKey: v2.string(),
574
- purpose: v2.enum(AddressPurpose),
575
- addressType: v2.enum(AddressType)
576
- });
577
574
 
578
575
  // src/addresses/index.ts
579
576
  var getAddress = async (options) => {
@@ -592,286 +589,7 @@ var getAddress = async (options) => {
592
589
  }
593
590
  };
594
591
 
595
- // src/request/types/stxMethods.ts
596
- import * as v3 from "valibot";
597
- var stxGetAddressesMethodName = "stx_getAddresses";
598
- var stxGetAddressesParamsSchema = v3.nullish(
599
- v3.object({
600
- /**
601
- * A message to be displayed to the user in the request prompt.
602
- */
603
- message: v3.optional(v3.string())
604
- })
605
- );
606
- var stxGetAddressesResultSchema = v3.object({
607
- /**
608
- * The addresses generated for the given purposes.
609
- */
610
- addresses: v3.array(addressSchema)
611
- });
612
- var stxGetAddressesRequestMessageSchema = v3.object({
613
- ...rpcRequestMessageSchema.entries,
614
- ...v3.object({
615
- method: v3.literal(stxGetAddressesMethodName),
616
- params: stxGetAddressesParamsSchema,
617
- id: v3.string()
618
- }).entries
619
- });
620
-
621
- // src/request/types/btcMethods.ts
622
- import * as v4 from "valibot";
623
- var getInfoMethodName = "getInfo";
624
- var getInfoParamsSchema = v4.nullish(v4.null());
625
- var getInfoResultSchema = v4.object({
626
- /**
627
- * Version of the wallet.
628
- */
629
- version: v4.string(),
630
- /**
631
- * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
632
- */
633
- methods: v4.optional(v4.array(v4.string())),
634
- /**
635
- * List of WBIP standards supported by the wallet. Not currently used.
636
- */
637
- supports: v4.array(v4.string())
638
- });
639
- var getInfoRequestMessageSchema = v4.object({
640
- ...rpcRequestMessageSchema.entries,
641
- ...v4.object({
642
- method: v4.literal(getInfoMethodName),
643
- params: getInfoParamsSchema,
644
- id: v4.string()
645
- }).entries
646
- });
647
- var getAddressesMethodName = "getAddresses";
648
- var getAddressesParamsSchema = v4.object({
649
- /**
650
- * The purposes for which to generate addresses. See
651
- * {@linkcode AddressPurpose} for available purposes.
652
- */
653
- purposes: v4.array(v4.enum(AddressPurpose)),
654
- /**
655
- * A message to be displayed to the user in the request prompt.
656
- */
657
- message: v4.optional(v4.string())
658
- });
659
- var getAddressesResultSchema = v4.object({
660
- /**
661
- * The addresses generated for the given purposes.
662
- */
663
- addresses: v4.array(addressSchema)
664
- });
665
- var getAddressesRequestMessageSchema = v4.object({
666
- ...rpcRequestMessageSchema.entries,
667
- ...v4.object({
668
- method: v4.literal(getAddressesMethodName),
669
- params: getAddressesParamsSchema,
670
- id: v4.string()
671
- }).entries
672
- });
673
- var signMessageMethodName = "signMessage";
674
- var signMessageParamsSchema = v4.object({
675
- /**
676
- * The address used for signing.
677
- **/
678
- address: v4.string(),
679
- /**
680
- * The message to sign.
681
- **/
682
- message: v4.string()
683
- });
684
- var signMessageResultSchema = v4.object({
685
- /**
686
- * The signature of the message.
687
- */
688
- signature: v4.string(),
689
- /**
690
- * hash of the message.
691
- */
692
- messageHash: v4.string(),
693
- /**
694
- * The address used for signing.
695
- */
696
- address: v4.string()
697
- });
698
- var signMessageRequestMessageSchema = v4.object({
699
- ...rpcRequestMessageSchema.entries,
700
- ...v4.object({
701
- method: v4.literal(signMessageMethodName),
702
- params: signMessageParamsSchema,
703
- id: v4.string()
704
- }).entries
705
- });
706
- var getAccountsMethodName = "getAccounts";
707
- var getAccountsParamsSchema = getAddressesParamsSchema;
708
- var getAccountsResultSchema = v4.array(addressSchema);
709
- var getAccountsRequestMessageSchema = v4.object({
710
- ...rpcRequestMessageSchema.entries,
711
- ...v4.object({
712
- method: v4.literal(getAccountsMethodName),
713
- params: getAccountsParamsSchema,
714
- id: v4.string()
715
- }).entries
716
- });
717
- var getBalanceMethodName = "getBalance";
718
- var getBalanceParamsSchema = v4.nullish(v4.null());
719
- var getBalanceResultSchema = v4.object({
720
- /**
721
- * The confirmed balance of the wallet in sats. Using a string due to chrome
722
- * messages not supporting bigint
723
- * (https://issues.chromium.org/issues/40116184).
724
- */
725
- confirmed: v4.string(),
726
- /**
727
- * The unconfirmed balance of the wallet in sats. Using a string due to chrome
728
- * messages not supporting bigint
729
- * (https://issues.chromium.org/issues/40116184).
730
- */
731
- unconfirmed: v4.string(),
732
- /**
733
- * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
734
- * sats. Using a string due to chrome messages not supporting bigint
735
- * (https://issues.chromium.org/issues/40116184).
736
- */
737
- total: v4.string()
738
- });
739
- var getBalanceRequestMessageSchema = v4.object({
740
- ...rpcRequestMessageSchema.entries,
741
- ...v4.object({
742
- method: v4.literal(getBalanceMethodName),
743
- id: v4.string()
744
- }).entries
745
- });
746
-
747
- // src/request/types/walletMethods.ts
748
- import * as v5 from "valibot";
749
- var requestPermissionsMethodName = "wallet_requestPermissions";
750
- var requestPermissionsParamsSchema = v5.undefined();
751
- var requestPermissionsResultSchema = v5.literal(true);
752
- var requestPermissionsRequestMessageSchema = v5.object({
753
- ...rpcRequestMessageSchema.entries,
754
- ...v5.object({
755
- method: v5.literal(requestPermissionsMethodName),
756
- params: requestPermissionsParamsSchema,
757
- id: v5.string()
758
- }).entries
759
- });
760
- var renouncePermissionsMethodName = "wallet_renouncePermissions";
761
- var renouncePermissionsParamsSchema = v5.undefined();
762
- var renouncePermissionsResultSchema = v5.literal(true);
763
- var renouncePermissionsRequestMessageSchema = v5.object({
764
- ...rpcRequestMessageSchema.entries,
765
- ...v5.object({
766
- method: v5.literal(renouncePermissionsMethodName),
767
- params: renouncePermissionsParamsSchema,
768
- id: v5.string()
769
- }).entries
770
- });
771
-
772
- // src/request/types/runesMethods.ts
773
- import * as v6 from "valibot";
774
- var getRunesBalanceMethodName = "runes_getBalance";
775
- var getRunesBalanceParamsSchema = v6.nullish(v6.null());
776
- var getRunesBalanceResultSchema = v6.object({
777
- balances: v6.array(
778
- v6.object({
779
- runeName: v6.string(),
780
- amount: v6.string(),
781
- divisibility: v6.number(),
782
- symbol: v6.string(),
783
- inscriptionId: v6.nullish(v6.string())
784
- })
785
- )
786
- });
787
- var getRunesBalanceRequestMessageSchema = v6.object({
788
- ...rpcRequestMessageSchema.entries,
789
- ...v6.object({
790
- method: v6.literal(getRunesBalanceMethodName),
791
- params: getRunesBalanceParamsSchema,
792
- id: v6.string()
793
- }).entries
794
- });
795
-
796
- // src/request/types/ordinalsMethods.ts
797
- import * as v7 from "valibot";
798
- var getInscriptionsMethodName = "ord_getInscriptions";
799
- var getInscriptionsParamsSchema = v7.object({
800
- offset: v7.number(),
801
- limit: v7.number()
802
- });
803
- var getInscriptionsResultSchema = v7.object({
804
- inscriptions: v7.array(
805
- v7.object({
806
- inscriptionId: v7.string(),
807
- inscriptionNumber: v7.string(),
808
- address: v7.string(),
809
- collectionName: v7.optional(v7.string()),
810
- postage: v7.string(),
811
- contentLength: v7.string(),
812
- contentType: v7.string(),
813
- timestamp: v7.number(),
814
- offset: v7.number(),
815
- genesisTransaction: v7.string(),
816
- output: v7.string()
817
- })
818
- )
819
- });
820
- var getInscriptionsSchema = v7.object({
821
- ...rpcRequestMessageSchema.entries,
822
- ...v7.object({
823
- method: v7.literal(getInscriptionsMethodName),
824
- params: getInscriptionsParamsSchema,
825
- id: v7.string()
826
- }).entries
827
- });
828
-
829
- // src/request/index.ts
830
- var request = async (method, params, providerId) => {
831
- let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
832
- if (providerId) {
833
- provider = await getProviderById(providerId);
834
- }
835
- if (!provider) {
836
- throw new Error("no wallet provider was found");
837
- }
838
- if (!method) {
839
- throw new Error("A wallet method is required");
840
- }
841
- const response = await provider.request(method, params);
842
- if (v8.is(rpcErrorResponseMessageSchema, response)) {
843
- return {
844
- status: "error",
845
- error: response.error
846
- };
847
- }
848
- if (v8.is(rpcSuccessResponseMessageSchema, response)) {
849
- return {
850
- status: "success",
851
- result: response.result
852
- };
853
- }
854
- return {
855
- status: "error",
856
- error: {
857
- code: -32603 /* INTERNAL_ERROR */,
858
- message: "Received unknown response from provider.",
859
- data: response
860
- }
861
- };
862
- };
863
-
864
- // src/adapters/xverse.ts
865
- var XverseAdapter = class extends SatsConnectAdapter {
866
- id = DefaultAdaptersInfo.xverse.id;
867
- requestInternal = async (method, params) => {
868
- return request(method, params, this.id);
869
- };
870
- };
871
-
872
592
  // src/adapters/unisat.ts
873
- import { Buffer } from "buffer";
874
- import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
875
593
  function convertSignInputsToInputType(signInputs, allowedSignHash) {
876
594
  let result = [];
877
595
  for (let address in signInputs) {
@@ -1275,69 +993,23 @@ export {
1275
993
  BitcoinNetworkType,
1276
994
  DefaultAdaptersInfo,
1277
995
  RpcErrorCode,
1278
- RpcIdSchema,
1279
996
  SatsConnectAdapter,
1280
- addressSchema,
1281
997
  createInscription,
1282
998
  createRepeatInscriptions,
1283
999
  defaultAdapters,
1284
- getAccountsMethodName,
1285
- getAccountsParamsSchema,
1286
- getAccountsRequestMessageSchema,
1287
- getAccountsResultSchema,
1288
1000
  getAddress,
1289
- getAddressesMethodName,
1290
- getAddressesParamsSchema,
1291
- getAddressesRequestMessageSchema,
1292
- getAddressesResultSchema,
1293
- getBalanceMethodName,
1294
- getBalanceParamsSchema,
1295
- getBalanceRequestMessageSchema,
1296
- getBalanceResultSchema,
1297
1001
  getCapabilities,
1298
1002
  getDefaultProvider,
1299
- getInfoMethodName,
1300
- getInfoParamsSchema,
1301
- getInfoRequestMessageSchema,
1302
- getInfoResultSchema,
1303
- getInscriptionsMethodName,
1304
- getInscriptionsParamsSchema,
1305
- getInscriptionsResultSchema,
1306
- getInscriptionsSchema,
1307
1003
  getProviderById,
1308
1004
  getProviderOrThrow,
1309
1005
  getProviders,
1310
- getRunesBalanceMethodName,
1311
- getRunesBalanceParamsSchema,
1312
- getRunesBalanceRequestMessageSchema,
1313
- getRunesBalanceResultSchema,
1314
1006
  getSupportedWallets,
1315
1007
  isProviderInstalled,
1316
1008
  removeDefaultProvider,
1317
- renouncePermissionsMethodName,
1318
- renouncePermissionsParamsSchema,
1319
- renouncePermissionsRequestMessageSchema,
1320
- renouncePermissionsResultSchema,
1321
1009
  request,
1322
- requestPermissionsMethodName,
1323
- requestPermissionsParamsSchema,
1324
- requestPermissionsRequestMessageSchema,
1325
- requestPermissionsResultSchema,
1326
- rpcErrorResponseMessageSchema,
1327
- rpcRequestMessageSchema,
1328
- rpcResponseMessageSchema,
1329
- rpcSuccessResponseMessageSchema,
1330
1010
  sendBtcTransaction,
1331
1011
  setDefaultProvider,
1332
1012
  signMessage,
1333
- signMessageMethodName,
1334
- signMessageParamsSchema,
1335
- signMessageRequestMessageSchema,
1336
- signMessageResultSchema,
1337
1013
  signMultipleTransactions,
1338
- signTransaction,
1339
- stxGetAddressesMethodName,
1340
- stxGetAddressesParamsSchema,
1341
- stxGetAddressesRequestMessageSchema,
1342
- stxGetAddressesResultSchema
1014
+ signTransaction
1343
1015
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.12-81e158a",
3
+ "version": "0.0.12",
4
4
  "main": "dist/index.mjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",
@@ -11,7 +11,6 @@
11
11
  "test": "jest",
12
12
  "build-debug": "webpack --mode development",
13
13
  "build": "npm run clean && tsup src/index.ts --format esm --dts",
14
- "build:watch": "npm run clean && tsup src/index.ts --format esm --dts --watch",
15
14
  "clean": "rimraf dist",
16
15
  "lint": "prettier --write .",
17
16
  "prepare": "husky install"
@@ -31,9 +30,6 @@
31
30
  "jsontokens": "4.0.1",
32
31
  "lodash.omit": "4.5.0"
33
32
  },
34
- "peerDependencies": {
35
- "valibot": "0.33.2"
36
- },
37
33
  "devDependencies": {
38
34
  "@types/jest": "^29.2.6",
39
35
  "@types/lodash.omit": "4.5.9",
@@ -46,7 +42,7 @@
46
42
  "ts-jest": "^29.0.5",
47
43
  "ts-loader": "^9.4.1",
48
44
  "tsup": "^8.0.2",
49
- "typescript": "5.4.5",
45
+ "typescript": "^4.9.4",
50
46
  "util": "^0.12.4",
51
47
  "vm-browserify": "^1.1.2",
52
48
  "webpack": "^5.74.0",