@sats-connect/core 0.0.11-4781818 → 0.0.11-65f0852

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
@@ -159,14 +159,15 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
159
159
  payload: Payload;
160
160
  getProvider?: () => Promise<BitcoinProvider | undefined>;
161
161
  }
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>;
162
164
  declare const rpcRequestMessageSchema: v.ObjectSchema<{
163
165
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
164
166
  readonly method: v.StringSchema<undefined>;
165
- readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>], undefined>, never>;
167
+ readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
166
168
  readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
167
169
  }, undefined>;
168
170
  type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
169
- type RpcId = string | null;
170
171
  interface RpcBase {
171
172
  jsonrpc: '2.0';
172
173
  id: RpcId;
@@ -213,8 +214,34 @@ declare enum RpcErrorCode {
213
214
  /**
214
215
  * method is not supported for the address provided
215
216
  */
216
- METHOD_NOT_SUPPORTED = -32001
217
+ METHOD_NOT_SUPPORTED = -32001,
218
+ /**
219
+ * The client does not have permission to access the requested resource.
220
+ */
221
+ ACCESS_DENIED = -32002
217
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>;
218
245
  interface RpcError {
219
246
  code: number | RpcErrorCode;
220
247
  message: string;
@@ -461,6 +488,30 @@ declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
461
488
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
462
489
  }, undefined>;
463
490
  type GetAccounts = MethodParamsAndResult<v.InferOutput<typeof getAccountsParamsSchema>, v.InferOutput<typeof getAccountsResultSchema>>;
491
+ declare const getBalanceMethodName = "getBalance";
492
+ declare const getBalanceParamsSchema: v.UndefinedSchema<undefined>;
493
+ declare const getBalanceResultSchema: v.ObjectSchema<{
494
+ /**
495
+ * The confirmed balance of the wallet in sats.
496
+ */
497
+ readonly confirmed: v.BigintSchema<undefined>;
498
+ /**
499
+ * The unconfirmed balance of the wallet in sats.
500
+ */
501
+ readonly unconfirmed: v.BigintSchema<undefined>;
502
+ /**
503
+ * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
504
+ * sats.
505
+ */
506
+ readonly total: v.BigintSchema<undefined>;
507
+ }, undefined>;
508
+ declare const getBalanceRequestMessageSchema: v.ObjectSchema<{
509
+ readonly method: v.LiteralSchema<"getBalance", undefined>;
510
+ readonly id: v.StringSchema<undefined>;
511
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
512
+ readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
513
+ }, undefined>;
514
+ type GetBalance = MethodParamsAndResult<v.InferOutput<typeof getBalanceParamsSchema>, v.InferOutput<typeof getBalanceResultSchema>>;
464
515
 
465
516
  type CreateMintOrderRequest = {
466
517
  runeName: string;
@@ -573,17 +624,24 @@ interface RbfOrderResult {
573
624
  fundingAddress: string;
574
625
  }
575
626
  type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
576
- type GetRunesBalanceParams = null;
577
- interface GetRunesBalanceResult {
578
- balances: {
579
- runeName: string;
580
- amount: string;
581
- divisibility: number;
582
- symbol: string;
583
- inscriptionId: string | null;
584
- }[];
585
- }
586
- type GetRunesBalance = MethodParamsAndResult<GetRunesBalanceParams, GetRunesBalanceResult>;
627
+ declare const getRunesBalanceMethodName = "getRunesBalance";
628
+ declare const getRunesBalanceParamsSchema: v.NullSchema<undefined>;
629
+ declare const getRunesBalanceResultSchema: v.ObjectSchema<{
630
+ readonly balances: v.ArraySchema<v.ObjectSchema<{
631
+ readonly runeName: v.StringSchema<undefined>;
632
+ readonly amount: v.StringSchema<undefined>;
633
+ readonly divisibility: v.NumberSchema<undefined>;
634
+ readonly symbol: v.StringSchema<undefined>;
635
+ readonly inscriptionId: v.NullishSchema<v.StringSchema<undefined>, never>;
636
+ }, undefined>, undefined>;
637
+ }, undefined>;
638
+ declare const getRunesBalanceRequestMessageSchema: v.ObjectSchema<{
639
+ readonly method: v.LiteralSchema<"getRunesBalance", undefined>;
640
+ readonly params: v.NullSchema<undefined>;
641
+ readonly id: v.StringSchema<undefined>;
642
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
643
+ }, undefined>;
644
+ type GetRunesBalance = MethodParamsAndResult<v.InferOutput<typeof getRunesBalanceParamsSchema>, v.InferOutput<typeof getRunesBalanceResultSchema>>;
587
645
 
588
646
  interface Pubkey {
589
647
  /**
@@ -765,6 +823,27 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
765
823
  type SignTransactionResult = Transaction;
766
824
  type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
767
825
 
826
+ declare const connectMethodName = "wallet_connect";
827
+ declare const connectParamsSchema: v.UndefinedSchema<undefined>;
828
+ declare const connectResultSchema: v.LiteralSchema<true, undefined>;
829
+ declare const connectSchema: v.ObjectSchema<{
830
+ readonly method: v.LiteralSchema<"wallet_connect", undefined>;
831
+ readonly params: v.UndefinedSchema<undefined>;
832
+ readonly id: v.StringSchema<undefined>;
833
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
834
+ }, undefined>;
835
+ type Connect = MethodParamsAndResult<v.InferOutput<typeof connectParamsSchema>, v.InferOutput<typeof connectResultSchema>>;
836
+ declare const disconnectMethodName = "wallet_disconnect";
837
+ declare const disconnectParamsSchema: v.UndefinedSchema<undefined>;
838
+ declare const disconnectResultSchema: v.LiteralSchema<true, undefined>;
839
+ declare const disconnectSchema: v.ObjectSchema<{
840
+ readonly method: v.LiteralSchema<"wallet_disconnect", undefined>;
841
+ readonly params: v.UndefinedSchema<undefined>;
842
+ readonly id: v.StringSchema<undefined>;
843
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
844
+ }, undefined>;
845
+ type Disconnect = MethodParamsAndResult<v.InferOutput<typeof disconnectParamsSchema>, v.InferOutput<typeof disconnectResultSchema>>;
846
+
768
847
  interface StxRequests {
769
848
  stx_callContract: StxCallContract;
770
849
  stx_deployContract: StxDeployContract;
@@ -780,6 +859,7 @@ interface BtcRequests {
780
859
  getInfo: GetInfo;
781
860
  getAddresses: GetAddresses;
782
861
  getAccounts: GetAccounts;
862
+ getBalance: GetBalance;
783
863
  signMessage: SignMessage;
784
864
  sendTransfer: SendTransfer;
785
865
  signPsbt: SignPsbt;
@@ -796,11 +876,15 @@ interface RunesRequests {
796
876
  runes_getBalance: GetRunesBalance;
797
877
  }
798
878
  type RunesRequestMethod = keyof RunesRequests;
799
- type Requests = BtcRequests & StxRequests & RunesRequests;
879
+ interface WalletMethods {
880
+ wallet_connect: Connect;
881
+ wallet_disconnect: Disconnect;
882
+ }
883
+ type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
800
884
  type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
801
885
  type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
802
886
 
803
- declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
887
+ declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
804
888
 
805
889
  declare abstract class SatsConnectAdapter {
806
890
  abstract readonly id: string;
@@ -818,10 +902,10 @@ declare abstract class SatsConnectAdapter {
818
902
  declare class BaseAdapter extends SatsConnectAdapter {
819
903
  id: string;
820
904
  constructor(providerId: string);
821
- requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
905
+ requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
822
906
  }
823
907
 
824
908
  declare const DefaultAdaptersInfo: Record<string, Provider>;
825
909
  declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
826
910
 
827
- 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 GetAccounts, 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 RpcRequestMessage, 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 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, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, rpcRequestMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction };
911
+ 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 Connect, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type Disconnect, type EstimateRbfOrder, type EstimateRunesEtch, type EstimateRunesEtchParams, type EstimateRunesEtchResult, type EstimateRunesMint, type EstimateRunesMintParams, type EstimateRunesMintResult, type EtchRunes, type EtchRunesParams, type EtchRunesResult, type GetAccounts, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetOrder, type GetRunesBalance, type InputToSign, type MethodParamsAndResult, type MintRunes, type MintRunesParams, type MintRunesResult, type Params, type Provider, type PsbtPayload, type RbfOrder, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, 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 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, type WalletMethods, addressSchema, connectMethodName, connectParamsSchema, connectResultSchema, connectSchema, createInscription, createRepeatInscriptions, defaultAdapters, disconnectMethodName, disconnectParamsSchema, disconnectResultSchema, disconnectSchema, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceRequestMessageSchema, getBalanceResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, getProviderById, getProviderOrThrow, getProviders, getRunesBalanceMethodName, getRunesBalanceParamsSchema, getRunesBalanceRequestMessageSchema, getRunesBalanceResultSchema, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction };
package/dist/index.mjs CHANGED
@@ -1,16 +1,27 @@
1
1
  // src/types.ts
2
2
  import * as v from "valibot";
3
- var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
4
- BitcoinNetworkType2["Mainnet"] = "Mainnet";
5
- BitcoinNetworkType2["Testnet"] = "Testnet";
6
- BitcoinNetworkType2["Signet"] = "Signet";
7
- return BitcoinNetworkType2;
3
+ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType3) => {
4
+ BitcoinNetworkType3["Mainnet"] = "Mainnet";
5
+ BitcoinNetworkType3["Testnet"] = "Testnet";
6
+ BitcoinNetworkType3["Signet"] = "Signet";
7
+ return BitcoinNetworkType3;
8
8
  })(BitcoinNetworkType || {});
9
+ var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
9
10
  var rpcRequestMessageSchema = v.object({
10
11
  jsonrpc: v.literal("2.0"),
11
12
  method: v.string(),
12
- params: v.optional(v.union([v.array(v.unknown()), v.looseObject({})])),
13
- id: v.optional(v.union([v.string(), v.number(), v.null()]))
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
14
25
  });
15
26
  var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
16
27
  RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
@@ -20,8 +31,23 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
20
31
  RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
21
32
  RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
22
33
  RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
34
+ RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
23
35
  return RpcErrorCode2;
24
36
  })(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
+ ]);
25
51
 
26
52
  // src/runes/api.ts
27
53
  import axios from "axios";
@@ -499,6 +525,9 @@ function getSupportedWallets() {
499
525
  return wallets;
500
526
  }
501
527
 
528
+ // src/request/index.ts
529
+ import * as v6 from "valibot";
530
+
502
531
  // src/addresses/index.ts
503
532
  import { createUnsecuredToken } from "jsontokens";
504
533
 
@@ -639,6 +668,79 @@ var getAccountsRequestMessageSchema = v3.object({
639
668
  id: v3.string()
640
669
  }).entries
641
670
  });
671
+ var getBalanceMethodName = "getBalance";
672
+ var getBalanceParamsSchema = v3.undefined();
673
+ var getBalanceResultSchema = v3.object({
674
+ /**
675
+ * The confirmed balance of the wallet in sats.
676
+ */
677
+ confirmed: v3.bigint(),
678
+ /**
679
+ * The unconfirmed balance of the wallet in sats.
680
+ */
681
+ unconfirmed: v3.bigint(),
682
+ /**
683
+ * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
684
+ * sats.
685
+ */
686
+ total: v3.bigint()
687
+ });
688
+ var getBalanceRequestMessageSchema = v3.object({
689
+ ...rpcRequestMessageSchema.entries,
690
+ ...v3.object({
691
+ method: v3.literal(getBalanceMethodName),
692
+ id: v3.string()
693
+ }).entries
694
+ });
695
+
696
+ // src/request/types/walletMethods.ts
697
+ import * as v4 from "valibot";
698
+ var connectMethodName = "wallet_connect";
699
+ var connectParamsSchema = v4.undefined();
700
+ var connectResultSchema = v4.literal(true);
701
+ var connectSchema = v4.object({
702
+ ...rpcRequestMessageSchema.entries,
703
+ ...v4.object({
704
+ method: v4.literal(connectMethodName),
705
+ params: connectParamsSchema,
706
+ id: v4.string()
707
+ }).entries
708
+ });
709
+ var disconnectMethodName = "wallet_disconnect";
710
+ var disconnectParamsSchema = v4.undefined();
711
+ var disconnectResultSchema = v4.literal(true);
712
+ var disconnectSchema = v4.object({
713
+ ...rpcRequestMessageSchema.entries,
714
+ ...v4.object({
715
+ method: v4.literal(disconnectMethodName),
716
+ params: disconnectParamsSchema,
717
+ id: v4.string()
718
+ }).entries
719
+ });
720
+
721
+ // src/request/types/runesMethods.ts
722
+ import * as v5 from "valibot";
723
+ var getRunesBalanceMethodName = "getRunesBalance";
724
+ var getRunesBalanceParamsSchema = v5.null();
725
+ var getRunesBalanceResultSchema = v5.object({
726
+ balances: v5.array(
727
+ v5.object({
728
+ runeName: v5.string(),
729
+ amount: v5.string(),
730
+ divisibility: v5.number(),
731
+ symbol: v5.string(),
732
+ inscriptionId: v5.nullish(v5.string())
733
+ })
734
+ )
735
+ });
736
+ var getRunesBalanceRequestMessageSchema = v5.object({
737
+ ...rpcRequestMessageSchema.entries,
738
+ ...v5.object({
739
+ method: v5.literal(getRunesBalanceMethodName),
740
+ params: getRunesBalanceParamsSchema,
741
+ id: v5.string()
742
+ }).entries
743
+ });
642
744
 
643
745
  // src/request/index.ts
644
746
  var request = async (method, params, providerId) => {
@@ -653,7 +755,13 @@ var request = async (method, params, providerId) => {
653
755
  throw new Error("A wallet method is required");
654
756
  }
655
757
  const response = await provider.request(method, params);
656
- if (isRpcSuccessResponse(response)) {
758
+ if (v6.is(rpcErrorResponseMessageSchema, response)) {
759
+ return {
760
+ status: "error",
761
+ error: response.error
762
+ };
763
+ }
764
+ if (v6.is(rpcSuccessResponseMessageSchema, response)) {
657
765
  return {
658
766
  status: "success",
659
767
  result: response.result
@@ -661,12 +769,13 @@ var request = async (method, params, providerId) => {
661
769
  }
662
770
  return {
663
771
  status: "error",
664
- error: response.error
772
+ error: {
773
+ code: -32603 /* INTERNAL_ERROR */,
774
+ message: "Received unknown response from provider.",
775
+ data: response
776
+ }
665
777
  };
666
778
  };
667
- var isRpcSuccessResponse = (response) => {
668
- return Object.hasOwn(response, "result") && !!response.result;
669
- };
670
779
 
671
780
  // src/adapters/xverse.ts
672
781
  var XverseAdapter = class extends SatsConnectAdapter {
@@ -1082,11 +1191,20 @@ export {
1082
1191
  BitcoinNetworkType,
1083
1192
  DefaultAdaptersInfo,
1084
1193
  RpcErrorCode,
1194
+ RpcIdSchema,
1085
1195
  SatsConnectAdapter,
1086
1196
  addressSchema,
1197
+ connectMethodName,
1198
+ connectParamsSchema,
1199
+ connectResultSchema,
1200
+ connectSchema,
1087
1201
  createInscription,
1088
1202
  createRepeatInscriptions,
1089
1203
  defaultAdapters,
1204
+ disconnectMethodName,
1205
+ disconnectParamsSchema,
1206
+ disconnectResultSchema,
1207
+ disconnectSchema,
1090
1208
  getAccountsMethodName,
1091
1209
  getAccountsParamsSchema,
1092
1210
  getAccountsRequestMessageSchema,
@@ -1096,6 +1214,10 @@ export {
1096
1214
  getAddressesParamsSchema,
1097
1215
  getAddressesRequestMessageSchema,
1098
1216
  getAddressesResultSchema,
1217
+ getBalanceMethodName,
1218
+ getBalanceParamsSchema,
1219
+ getBalanceRequestMessageSchema,
1220
+ getBalanceResultSchema,
1099
1221
  getCapabilities,
1100
1222
  getDefaultProvider,
1101
1223
  getInfoMethodName,
@@ -1105,11 +1227,18 @@ export {
1105
1227
  getProviderById,
1106
1228
  getProviderOrThrow,
1107
1229
  getProviders,
1230
+ getRunesBalanceMethodName,
1231
+ getRunesBalanceParamsSchema,
1232
+ getRunesBalanceRequestMessageSchema,
1233
+ getRunesBalanceResultSchema,
1108
1234
  getSupportedWallets,
1109
1235
  isProviderInstalled,
1110
1236
  removeDefaultProvider,
1111
1237
  request,
1238
+ rpcErrorResponseMessageSchema,
1112
1239
  rpcRequestMessageSchema,
1240
+ rpcResponseMessageSchema,
1241
+ rpcSuccessResponseMessageSchema,
1113
1242
  sendBtcTransaction,
1114
1243
  setDefaultProvider,
1115
1244
  signMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.11-4781818",
3
+ "version": "0.0.11-65f0852",
4
4
  "main": "dist/index.mjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",
@@ -11,6 +11,7 @@
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",
14
15
  "clean": "rimraf dist",
15
16
  "lint": "prettier --write .",
16
17
  "prepare": "husky install"