@sats-connect/core 0.0.11-a271383 → 0.0.11-a6e103e

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
@@ -116,7 +116,7 @@ interface Provider {
116
116
  mozillaAddOnsUrl?: string;
117
117
  googlePlayStoreUrl?: string;
118
118
  iOSAppStoreUrl?: string;
119
- methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod)[];
119
+ methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod | OrdinalsRequestMethod)[];
120
120
  }
121
121
  interface SupportedWallet extends Provider {
122
122
  isInstalled: boolean;
@@ -159,6 +159,8 @@ 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>;
@@ -166,7 +168,6 @@ declare const rpcRequestMessageSchema: v.ObjectSchema<{
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,66 @@ 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. Using a string due to chrome
496
+ * messages not supporting bigint
497
+ * (https://issues.chromium.org/issues/40116184).
498
+ */
499
+ readonly confirmed: v.StringSchema<undefined>;
500
+ /**
501
+ * The unconfirmed balance of the wallet in sats. Using a string due to chrome
502
+ * messages not supporting bigint
503
+ * (https://issues.chromium.org/issues/40116184).
504
+ */
505
+ readonly unconfirmed: v.StringSchema<undefined>;
506
+ /**
507
+ * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
508
+ * sats. Using a string due to chrome messages not supporting bigint
509
+ * (https://issues.chromium.org/issues/40116184).
510
+ */
511
+ readonly total: v.StringSchema<undefined>;
512
+ }, undefined>;
513
+ declare const getBalanceRequestMessageSchema: v.ObjectSchema<{
514
+ readonly method: v.LiteralSchema<"getBalance", undefined>;
515
+ readonly id: v.StringSchema<undefined>;
516
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
517
+ readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
518
+ }, undefined>;
519
+ type GetBalance = MethodParamsAndResult<v.InferOutput<typeof getBalanceParamsSchema>, v.InferOutput<typeof getBalanceResultSchema>>;
520
+
521
+ declare const getInscriptionsMethodName = "ord_getInscriptions";
522
+ declare const getInscriptionsParamsSchema: v.ObjectSchema<{
523
+ readonly offset: v.NumberSchema<undefined>;
524
+ readonly limit: v.NumberSchema<undefined>;
525
+ }, undefined>;
526
+ declare const getInscriptionsResultSchema: v.ObjectSchema<{
527
+ readonly inscriptions: v.ArraySchema<v.ObjectSchema<{
528
+ readonly inscriptionId: v.StringSchema<undefined>;
529
+ readonly inscriptionNumber: v.StringSchema<undefined>;
530
+ readonly address: v.StringSchema<undefined>;
531
+ readonly collectionName: v.OptionalSchema<v.StringSchema<undefined>, never>;
532
+ readonly postage: v.StringSchema<undefined>;
533
+ readonly contentLength: v.StringSchema<undefined>;
534
+ readonly contentType: v.StringSchema<undefined>;
535
+ readonly timestamp: v.NumberSchema<undefined>;
536
+ readonly offset: v.NumberSchema<undefined>;
537
+ readonly genesisTransaction: v.StringSchema<undefined>;
538
+ readonly output: v.StringSchema<undefined>;
539
+ }, undefined>, undefined>;
540
+ }, undefined>;
541
+ declare const getInscriptionsSchema: v.ObjectSchema<{
542
+ readonly method: v.LiteralSchema<"ord_getInscriptions", undefined>;
543
+ readonly params: v.ObjectSchema<{
544
+ readonly offset: v.NumberSchema<undefined>;
545
+ readonly limit: v.NumberSchema<undefined>;
546
+ }, undefined>;
547
+ readonly id: v.StringSchema<undefined>;
548
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
549
+ }, undefined>;
550
+ type GetInscriptions = MethodParamsAndResult<v.InferOutput<typeof getInscriptionsParamsSchema>, v.InferOutput<typeof getInscriptionsResultSchema>>;
464
551
 
465
552
  type CreateMintOrderRequest = {
466
553
  runeName: string;
@@ -573,17 +660,24 @@ interface RbfOrderResult {
573
660
  fundingAddress: string;
574
661
  }
575
662
  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>;
663
+ declare const getRunesBalanceMethodName = "runes_getBalance";
664
+ declare const getRunesBalanceParamsSchema: v.NullSchema<undefined>;
665
+ declare const getRunesBalanceResultSchema: v.ObjectSchema<{
666
+ readonly balances: v.ArraySchema<v.ObjectSchema<{
667
+ readonly runeName: v.StringSchema<undefined>;
668
+ readonly amount: v.StringSchema<undefined>;
669
+ readonly divisibility: v.NumberSchema<undefined>;
670
+ readonly symbol: v.StringSchema<undefined>;
671
+ readonly inscriptionId: v.NullishSchema<v.StringSchema<undefined>, never>;
672
+ }, undefined>, undefined>;
673
+ }, undefined>;
674
+ declare const getRunesBalanceRequestMessageSchema: v.ObjectSchema<{
675
+ readonly method: v.LiteralSchema<"runes_getBalance", undefined>;
676
+ readonly params: v.NullSchema<undefined>;
677
+ readonly id: v.StringSchema<undefined>;
678
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
679
+ }, undefined>;
680
+ type GetRunesBalance = MethodParamsAndResult<v.InferOutput<typeof getRunesBalanceParamsSchema>, v.InferOutput<typeof getRunesBalanceResultSchema>>;
587
681
 
588
682
  interface Pubkey {
589
683
  /**
@@ -756,35 +850,60 @@ type GetAccountsResult = {
756
850
  }>;
757
851
  };
758
852
  type StxGetAccounts = MethodParamsAndResult<{}, GetAccountsResult>;
759
- type GetAddressesParams = undefined | null;
760
- type GetAddressesResult = {
761
- addresses: Array<Address & PublicKey>;
762
- };
763
- type StxGetAddresses = MethodParamsAndResult<GetAddressesParams, GetAddressesResult>;
853
+ declare const stxGetAddressesMethodName = "stx_getAddresses";
854
+ declare const stxGetAddressesParamsSchema: v.ObjectSchema<{
855
+ /**
856
+ * A message to be displayed to the user in the request prompt.
857
+ */
858
+ readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
859
+ }, undefined>;
860
+ declare const stxGetAddressesResultSchema: v.ObjectSchema<{
861
+ /**
862
+ * The addresses generated for the given purposes.
863
+ */
864
+ readonly addresses: v.ArraySchema<v.ObjectSchema<{
865
+ readonly address: v.StringSchema<undefined>;
866
+ readonly publicKey: v.StringSchema<undefined>;
867
+ readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
868
+ readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
869
+ }, undefined>, undefined>;
870
+ }, undefined>;
871
+ declare const stxGetAddressesRequestMessageSchema: v.ObjectSchema<{
872
+ readonly method: v.LiteralSchema<"stx_getAddresses", undefined>;
873
+ readonly params: v.ObjectSchema<{
874
+ /**
875
+ * A message to be displayed to the user in the request prompt.
876
+ */
877
+ readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
878
+ }, undefined>;
879
+ readonly id: v.StringSchema<undefined>;
880
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
881
+ }, undefined>;
882
+ type StxGetAddresses = MethodParamsAndResult<v.InferOutput<typeof stxGetAddressesParamsSchema>, v.InferOutput<typeof stxGetAddressesResultSchema>>;
764
883
  type SignTransactionParams = Transaction & Partial<Pubkey>;
765
884
  type SignTransactionResult = Transaction;
766
885
  type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
767
886
 
768
- declare const connectMethodName = "wallet_connect";
769
- declare const connectParamsSchema: v.UndefinedSchema<undefined>;
770
- declare const connectResultSchema: v.UndefinedSchema<undefined>;
771
- declare const connectSchema: v.ObjectSchema<{
772
- readonly method: v.LiteralSchema<"wallet_connect", undefined>;
887
+ declare const requestPermissionsMethodName = "wallet_requestPermissions";
888
+ declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
889
+ declare const requestPermissionsResultSchema: v.LiteralSchema<true, undefined>;
890
+ declare const requestPermissionsRequestMessageSchema: v.ObjectSchema<{
891
+ readonly method: v.LiteralSchema<"wallet_requestPermissions", undefined>;
773
892
  readonly params: v.UndefinedSchema<undefined>;
774
893
  readonly id: v.StringSchema<undefined>;
775
894
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
776
895
  }, undefined>;
777
- type Connect = MethodParamsAndResult<v.InferOutput<typeof connectParamsSchema>, v.InferOutput<typeof connectResultSchema>>;
778
- declare const disconnectMethodName = "wallet_disconnect";
779
- declare const disconnectParamsSchema: v.UndefinedSchema<undefined>;
780
- declare const disconnectResultSchema: v.UndefinedSchema<undefined>;
781
- declare const disconnectSchema: v.ObjectSchema<{
782
- readonly method: v.LiteralSchema<"wallet_disconnect", undefined>;
896
+ type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof requestPermissionsParamsSchema>, v.InferOutput<typeof requestPermissionsResultSchema>>;
897
+ declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
898
+ declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
899
+ declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
900
+ declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
901
+ readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
783
902
  readonly params: v.UndefinedSchema<undefined>;
784
903
  readonly id: v.StringSchema<undefined>;
785
904
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
786
905
  }, undefined>;
787
- type Disconnect = MethodParamsAndResult<v.InferOutput<typeof disconnectParamsSchema>, v.InferOutput<typeof disconnectResultSchema>>;
906
+ type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
788
907
 
789
908
  interface StxRequests {
790
909
  stx_callContract: StxCallContract;
@@ -801,6 +920,7 @@ interface BtcRequests {
801
920
  getInfo: GetInfo;
802
921
  getAddresses: GetAddresses;
803
922
  getAccounts: GetAccounts;
923
+ getBalance: GetBalance;
804
924
  signMessage: SignMessage;
805
925
  sendTransfer: SendTransfer;
806
926
  signPsbt: SignPsbt;
@@ -817,15 +937,19 @@ interface RunesRequests {
817
937
  runes_getBalance: GetRunesBalance;
818
938
  }
819
939
  type RunesRequestMethod = keyof RunesRequests;
940
+ interface OrdinalsRequests {
941
+ ord_getInscriptions: GetInscriptions;
942
+ }
943
+ type OrdinalsRequestMethod = keyof OrdinalsRequests;
820
944
  interface WalletMethods {
821
- wallet_connect: Connect;
822
- wallet_disconnect: Disconnect;
945
+ wallet_requestPermissions: RequestPermissions;
946
+ wallet_renouncePermissions: RenouncePermissions;
823
947
  }
824
- type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
948
+ type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods & OrdinalsRequests;
825
949
  type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
826
950
  type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
827
951
 
828
- declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
952
+ 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>>;
829
953
 
830
954
  declare abstract class SatsConnectAdapter {
831
955
  abstract readonly id: string;
@@ -843,10 +967,10 @@ declare abstract class SatsConnectAdapter {
843
967
  declare class BaseAdapter extends SatsConnectAdapter {
844
968
  id: string;
845
969
  constructor(providerId: string);
846
- requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
970
+ requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods | "ord_getInscriptions">(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
847
971
  }
848
972
 
849
973
  declare const DefaultAdaptersInfo: Record<string, Provider>;
850
974
  declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
851
975
 
852
- 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 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, type WalletMethods, addressSchema, connectMethodName, connectParamsSchema, connectResultSchema, connectSchema, createInscription, createRepeatInscriptions, defaultAdapters, disconnectMethodName, disconnectParamsSchema, disconnectResultSchema, disconnectSchema, 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 };
976
+ 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 GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetInscriptions, type GetOrder, type GetRunesBalance, 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 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, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceRequestMessageSchema, getBalanceResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, 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 };
package/dist/index.mjs CHANGED
@@ -1,11 +1,12 @@
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(),
@@ -20,7 +21,7 @@ var rpcRequestMessageSchema = v.object({
20
21
  v.null()
21
22
  ])
22
23
  ),
23
- id: v.optional(v.union([v.string(), v.number(), v.null()]))
24
+ id: RpcIdSchema
24
25
  });
25
26
  var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
26
27
  RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
@@ -30,8 +31,23 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
30
31
  RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
31
32
  RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
32
33
  RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
34
+ RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
33
35
  return RpcErrorCode2;
34
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
+ ]);
35
51
 
36
52
  // src/runes/api.ts
37
53
  import axios from "axios";
@@ -509,6 +525,9 @@ function getSupportedWallets() {
509
525
  return wallets;
510
526
  }
511
527
 
528
+ // src/request/index.ts
529
+ import * as v8 from "valibot";
530
+
512
531
  // src/addresses/index.ts
513
532
  import { createUnsecuredToken } from "jsontokens";
514
533
 
@@ -553,125 +572,235 @@ var getAddress = async (options) => {
553
572
  }
554
573
  };
555
574
 
556
- // src/request/types/btcMethods.ts
575
+ // src/request/types/stxMethods.ts
557
576
  import * as v3 from "valibot";
577
+ var stxGetAddressesMethodName = "stx_getAddresses";
578
+ var stxGetAddressesParamsSchema = v3.object({
579
+ /**
580
+ * A message to be displayed to the user in the request prompt.
581
+ */
582
+ message: v3.optional(v3.string())
583
+ });
584
+ var stxGetAddressesResultSchema = v3.object({
585
+ /**
586
+ * The addresses generated for the given purposes.
587
+ */
588
+ addresses: v3.array(addressSchema)
589
+ });
590
+ var stxGetAddressesRequestMessageSchema = v3.object({
591
+ ...rpcRequestMessageSchema.entries,
592
+ ...v3.object({
593
+ method: v3.literal(stxGetAddressesMethodName),
594
+ params: stxGetAddressesParamsSchema,
595
+ id: v3.string()
596
+ }).entries
597
+ });
598
+
599
+ // src/request/types/btcMethods.ts
600
+ import * as v4 from "valibot";
558
601
  var getInfoMethodName = "getInfo";
559
- var getInfoParamsSchema = v3.null();
560
- var getInfoResultSchema = v3.object({
602
+ var getInfoParamsSchema = v4.null();
603
+ var getInfoResultSchema = v4.object({
561
604
  /**
562
605
  * Version of the wallet.
563
606
  */
564
- version: v3.string(),
607
+ version: v4.string(),
565
608
  /**
566
609
  * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
567
610
  */
568
- methods: v3.optional(v3.array(v3.string())),
611
+ methods: v4.optional(v4.array(v4.string())),
569
612
  /**
570
613
  * List of WBIP standards supported by the wallet. Not currently used.
571
614
  */
572
- supports: v3.array(v3.string())
615
+ supports: v4.array(v4.string())
573
616
  });
574
- var getInfoSchema = v3.object({
617
+ var getInfoSchema = v4.object({
575
618
  ...rpcRequestMessageSchema.entries,
576
- ...v3.object({
577
- method: v3.literal(getInfoMethodName),
619
+ ...v4.object({
620
+ method: v4.literal(getInfoMethodName),
578
621
  params: getInfoParamsSchema,
579
- id: v3.string()
622
+ id: v4.string()
580
623
  }).entries
581
624
  });
582
625
  var getAddressesMethodName = "getAddresses";
583
- var getAddressesParamsSchema = v3.object({
626
+ var getAddressesParamsSchema = v4.object({
584
627
  /**
585
628
  * The purposes for which to generate addresses. See
586
629
  * {@linkcode AddressPurpose} for available purposes.
587
630
  */
588
- purposes: v3.array(v3.enum(AddressPurpose)),
631
+ purposes: v4.array(v4.enum(AddressPurpose)),
589
632
  /**
590
633
  * A message to be displayed to the user in the request prompt.
591
634
  */
592
- message: v3.optional(v3.string())
635
+ message: v4.optional(v4.string())
593
636
  });
594
- var getAddressesResultSchema = v3.object({
637
+ var getAddressesResultSchema = v4.object({
595
638
  /**
596
639
  * The addresses generated for the given purposes.
597
640
  */
598
- addresses: v3.array(addressSchema)
641
+ addresses: v4.array(addressSchema)
599
642
  });
600
- var getAddressesRequestMessageSchema = v3.object({
643
+ var getAddressesRequestMessageSchema = v4.object({
601
644
  ...rpcRequestMessageSchema.entries,
602
- ...v3.object({
603
- method: v3.literal(getAddressesMethodName),
645
+ ...v4.object({
646
+ method: v4.literal(getAddressesMethodName),
604
647
  params: getAddressesParamsSchema,
605
- id: v3.string()
648
+ id: v4.string()
606
649
  }).entries
607
650
  });
608
651
  var signMessageMethodName = "signMessage";
609
- var signMessageParamsSchema = v3.object({
652
+ var signMessageParamsSchema = v4.object({
610
653
  /**
611
654
  * The address used for signing.
612
655
  **/
613
- address: v3.string(),
656
+ address: v4.string(),
614
657
  /**
615
658
  * The message to sign.
616
659
  **/
617
- message: v3.string()
660
+ message: v4.string()
618
661
  });
619
- var signMessageResultSchema = v3.object({
662
+ var signMessageResultSchema = v4.object({
620
663
  /**
621
664
  * The signature of the message.
622
665
  */
623
- signature: v3.string(),
666
+ signature: v4.string(),
624
667
  /**
625
668
  * hash of the message.
626
669
  */
627
- messageHash: v3.string(),
670
+ messageHash: v4.string(),
628
671
  /**
629
672
  * The address used for signing.
630
673
  */
631
- address: v3.string()
674
+ address: v4.string()
632
675
  });
633
- var signMessageRequestMessageSchema = v3.object({
676
+ var signMessageRequestMessageSchema = v4.object({
634
677
  ...rpcRequestMessageSchema.entries,
635
- ...v3.object({
636
- method: v3.literal(signMessageMethodName),
678
+ ...v4.object({
679
+ method: v4.literal(signMessageMethodName),
637
680
  params: signMessageParamsSchema,
638
- id: v3.string()
681
+ id: v4.string()
639
682
  }).entries
640
683
  });
641
684
  var getAccountsMethodName = "getAccounts";
642
685
  var getAccountsParamsSchema = getAddressesParamsSchema;
643
- var getAccountsResultSchema = v3.array(addressSchema);
644
- var getAccountsRequestMessageSchema = v3.object({
686
+ var getAccountsResultSchema = v4.array(addressSchema);
687
+ var getAccountsRequestMessageSchema = v4.object({
645
688
  ...rpcRequestMessageSchema.entries,
646
- ...v3.object({
647
- method: v3.literal(getAccountsMethodName),
689
+ ...v4.object({
690
+ method: v4.literal(getAccountsMethodName),
648
691
  params: getAccountsParamsSchema,
649
- id: v3.string()
692
+ id: v4.string()
650
693
  }).entries
651
694
  });
652
-
653
- // src/request/types/walletMethods.ts
654
- import * as v4 from "valibot";
655
- var connectMethodName = "wallet_connect";
656
- var connectParamsSchema = v4.undefined();
657
- var connectResultSchema = v4.undefined();
658
- var connectSchema = v4.object({
695
+ var getBalanceMethodName = "getBalance";
696
+ var getBalanceParamsSchema = v4.undefined();
697
+ var getBalanceResultSchema = v4.object({
698
+ /**
699
+ * The confirmed balance of the wallet in sats. Using a string due to chrome
700
+ * messages not supporting bigint
701
+ * (https://issues.chromium.org/issues/40116184).
702
+ */
703
+ confirmed: v4.string(),
704
+ /**
705
+ * The unconfirmed balance of the wallet in sats. Using a string due to chrome
706
+ * messages not supporting bigint
707
+ * (https://issues.chromium.org/issues/40116184).
708
+ */
709
+ unconfirmed: v4.string(),
710
+ /**
711
+ * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
712
+ * sats. Using a string due to chrome messages not supporting bigint
713
+ * (https://issues.chromium.org/issues/40116184).
714
+ */
715
+ total: v4.string()
716
+ });
717
+ var getBalanceRequestMessageSchema = v4.object({
659
718
  ...rpcRequestMessageSchema.entries,
660
719
  ...v4.object({
661
- method: v4.literal(connectMethodName),
662
- params: connectParamsSchema,
720
+ method: v4.literal(getBalanceMethodName),
663
721
  id: v4.string()
664
722
  }).entries
665
723
  });
666
- var disconnectMethodName = "wallet_disconnect";
667
- var disconnectParamsSchema = v4.undefined();
668
- var disconnectResultSchema = v4.undefined();
669
- var disconnectSchema = v4.object({
724
+
725
+ // src/request/types/walletMethods.ts
726
+ import * as v5 from "valibot";
727
+ var requestPermissionsMethodName = "wallet_requestPermissions";
728
+ var requestPermissionsParamsSchema = v5.undefined();
729
+ var requestPermissionsResultSchema = v5.literal(true);
730
+ var requestPermissionsRequestMessageSchema = v5.object({
670
731
  ...rpcRequestMessageSchema.entries,
671
- ...v4.object({
672
- method: v4.literal(disconnectMethodName),
673
- params: disconnectParamsSchema,
674
- id: v4.string()
732
+ ...v5.object({
733
+ method: v5.literal(requestPermissionsMethodName),
734
+ params: requestPermissionsParamsSchema,
735
+ id: v5.string()
736
+ }).entries
737
+ });
738
+ var renouncePermissionsMethodName = "wallet_renouncePermissions";
739
+ var renouncePermissionsParamsSchema = v5.undefined();
740
+ var renouncePermissionsResultSchema = v5.literal(true);
741
+ var renouncePermissionsRequestMessageSchema = v5.object({
742
+ ...rpcRequestMessageSchema.entries,
743
+ ...v5.object({
744
+ method: v5.literal(renouncePermissionsMethodName),
745
+ params: renouncePermissionsParamsSchema,
746
+ id: v5.string()
747
+ }).entries
748
+ });
749
+
750
+ // src/request/types/runesMethods.ts
751
+ import * as v6 from "valibot";
752
+ var getRunesBalanceMethodName = "runes_getBalance";
753
+ var getRunesBalanceParamsSchema = v6.null();
754
+ var getRunesBalanceResultSchema = v6.object({
755
+ balances: v6.array(
756
+ v6.object({
757
+ runeName: v6.string(),
758
+ amount: v6.string(),
759
+ divisibility: v6.number(),
760
+ symbol: v6.string(),
761
+ inscriptionId: v6.nullish(v6.string())
762
+ })
763
+ )
764
+ });
765
+ var getRunesBalanceRequestMessageSchema = v6.object({
766
+ ...rpcRequestMessageSchema.entries,
767
+ ...v6.object({
768
+ method: v6.literal(getRunesBalanceMethodName),
769
+ params: getRunesBalanceParamsSchema,
770
+ id: v6.string()
771
+ }).entries
772
+ });
773
+
774
+ // src/request/types/ordinalsMethods.ts
775
+ import * as v7 from "valibot";
776
+ var getInscriptionsMethodName = "ord_getInscriptions";
777
+ var getInscriptionsParamsSchema = v7.object({
778
+ offset: v7.number(),
779
+ limit: v7.number()
780
+ });
781
+ var getInscriptionsResultSchema = v7.object({
782
+ inscriptions: v7.array(
783
+ v7.object({
784
+ inscriptionId: v7.string(),
785
+ inscriptionNumber: v7.string(),
786
+ address: v7.string(),
787
+ collectionName: v7.optional(v7.string()),
788
+ postage: v7.string(),
789
+ contentLength: v7.string(),
790
+ contentType: v7.string(),
791
+ timestamp: v7.number(),
792
+ offset: v7.number(),
793
+ genesisTransaction: v7.string(),
794
+ output: v7.string()
795
+ })
796
+ )
797
+ });
798
+ var getInscriptionsSchema = v7.object({
799
+ ...rpcRequestMessageSchema.entries,
800
+ ...v7.object({
801
+ method: v7.literal(getInscriptionsMethodName),
802
+ params: getInscriptionsParamsSchema,
803
+ id: v7.string()
675
804
  }).entries
676
805
  });
677
806
 
@@ -688,7 +817,13 @@ var request = async (method, params, providerId) => {
688
817
  throw new Error("A wallet method is required");
689
818
  }
690
819
  const response = await provider.request(method, params);
691
- if (isRpcSuccessResponse(response)) {
820
+ if (v8.is(rpcErrorResponseMessageSchema, response)) {
821
+ return {
822
+ status: "error",
823
+ error: response.error
824
+ };
825
+ }
826
+ if (v8.is(rpcSuccessResponseMessageSchema, response)) {
692
827
  return {
693
828
  status: "success",
694
829
  result: response.result
@@ -696,12 +831,13 @@ var request = async (method, params, providerId) => {
696
831
  }
697
832
  return {
698
833
  status: "error",
699
- error: response.error
834
+ error: {
835
+ code: -32603 /* INTERNAL_ERROR */,
836
+ message: "Received unknown response from provider.",
837
+ data: response
838
+ }
700
839
  };
701
840
  };
702
- var isRpcSuccessResponse = (response) => {
703
- return Object.hasOwn(response, "result") && !!response.result;
704
- };
705
841
 
706
842
  // src/adapters/xverse.ts
707
843
  var XverseAdapter = class extends SatsConnectAdapter {
@@ -1117,19 +1253,12 @@ export {
1117
1253
  BitcoinNetworkType,
1118
1254
  DefaultAdaptersInfo,
1119
1255
  RpcErrorCode,
1256
+ RpcIdSchema,
1120
1257
  SatsConnectAdapter,
1121
1258
  addressSchema,
1122
- connectMethodName,
1123
- connectParamsSchema,
1124
- connectResultSchema,
1125
- connectSchema,
1126
1259
  createInscription,
1127
1260
  createRepeatInscriptions,
1128
1261
  defaultAdapters,
1129
- disconnectMethodName,
1130
- disconnectParamsSchema,
1131
- disconnectResultSchema,
1132
- disconnectSchema,
1133
1262
  getAccountsMethodName,
1134
1263
  getAccountsParamsSchema,
1135
1264
  getAccountsRequestMessageSchema,
@@ -1139,20 +1268,43 @@ export {
1139
1268
  getAddressesParamsSchema,
1140
1269
  getAddressesRequestMessageSchema,
1141
1270
  getAddressesResultSchema,
1271
+ getBalanceMethodName,
1272
+ getBalanceParamsSchema,
1273
+ getBalanceRequestMessageSchema,
1274
+ getBalanceResultSchema,
1142
1275
  getCapabilities,
1143
1276
  getDefaultProvider,
1144
1277
  getInfoMethodName,
1145
1278
  getInfoParamsSchema,
1146
1279
  getInfoResultSchema,
1147
1280
  getInfoSchema,
1281
+ getInscriptionsMethodName,
1282
+ getInscriptionsParamsSchema,
1283
+ getInscriptionsResultSchema,
1284
+ getInscriptionsSchema,
1148
1285
  getProviderById,
1149
1286
  getProviderOrThrow,
1150
1287
  getProviders,
1288
+ getRunesBalanceMethodName,
1289
+ getRunesBalanceParamsSchema,
1290
+ getRunesBalanceRequestMessageSchema,
1291
+ getRunesBalanceResultSchema,
1151
1292
  getSupportedWallets,
1152
1293
  isProviderInstalled,
1153
1294
  removeDefaultProvider,
1295
+ renouncePermissionsMethodName,
1296
+ renouncePermissionsParamsSchema,
1297
+ renouncePermissionsRequestMessageSchema,
1298
+ renouncePermissionsResultSchema,
1154
1299
  request,
1300
+ requestPermissionsMethodName,
1301
+ requestPermissionsParamsSchema,
1302
+ requestPermissionsRequestMessageSchema,
1303
+ requestPermissionsResultSchema,
1304
+ rpcErrorResponseMessageSchema,
1155
1305
  rpcRequestMessageSchema,
1306
+ rpcResponseMessageSchema,
1307
+ rpcSuccessResponseMessageSchema,
1156
1308
  sendBtcTransaction,
1157
1309
  setDefaultProvider,
1158
1310
  signMessage,
@@ -1161,5 +1313,9 @@ export {
1161
1313
  signMessageRequestMessageSchema,
1162
1314
  signMessageResultSchema,
1163
1315
  signMultipleTransactions,
1164
- signTransaction
1316
+ signTransaction,
1317
+ stxGetAddressesMethodName,
1318
+ stxGetAddressesParamsSchema,
1319
+ stxGetAddressesRequestMessageSchema,
1320
+ stxGetAddressesResultSchema
1165
1321
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.11-a271383",
3
+ "version": "0.0.11-a6e103e",
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"