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

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.NullishSchema<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>, never>;
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.NullishSchema<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>, never>;
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";
@@ -186,6 +202,16 @@ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
186
202
  var SatsConnectAdapter = class {
187
203
  async mintRunes(params) {
188
204
  try {
205
+ const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
206
+ if (walletInfo && walletInfo.status === "success") {
207
+ const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
208
+ if (isMintSupported) {
209
+ const response = await this.requestInternal("runes_mint", params);
210
+ if (response) {
211
+ return response;
212
+ }
213
+ }
214
+ }
189
215
  const mintRequest = {
190
216
  destinationAddress: params.destinationAddress,
191
217
  feeRate: params.feeRate,
@@ -255,6 +281,16 @@ var SatsConnectAdapter = class {
255
281
  appServiceFeeAddress: params.appServiceFeeAddress
256
282
  };
257
283
  try {
284
+ const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
285
+ if (walletInfo && walletInfo.status === "success") {
286
+ const isEtchSupported = walletInfo.result.methods?.includes("runes_etch");
287
+ if (isEtchSupported) {
288
+ const response = await this.requestInternal("runes_etch", params);
289
+ if (response) {
290
+ return response;
291
+ }
292
+ }
293
+ }
258
294
  const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
259
295
  if (!orderResponse.data) {
260
296
  return {
@@ -509,6 +545,9 @@ function getSupportedWallets() {
509
545
  return wallets;
510
546
  }
511
547
 
548
+ // src/request/index.ts
549
+ import * as v8 from "valibot";
550
+
512
551
  // src/addresses/index.ts
513
552
  import { createUnsecuredToken } from "jsontokens";
514
553
 
@@ -553,125 +592,237 @@ var getAddress = async (options) => {
553
592
  }
554
593
  };
555
594
 
556
- // src/request/types/btcMethods.ts
595
+ // src/request/types/stxMethods.ts
557
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";
558
623
  var getInfoMethodName = "getInfo";
559
- var getInfoParamsSchema = v3.null();
560
- var getInfoResultSchema = v3.object({
624
+ var getInfoParamsSchema = v4.null();
625
+ var getInfoResultSchema = v4.object({
561
626
  /**
562
627
  * Version of the wallet.
563
628
  */
564
- version: v3.string(),
629
+ version: v4.string(),
565
630
  /**
566
631
  * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
567
632
  */
568
- methods: v3.optional(v3.array(v3.string())),
633
+ methods: v4.optional(v4.array(v4.string())),
569
634
  /**
570
635
  * List of WBIP standards supported by the wallet. Not currently used.
571
636
  */
572
- supports: v3.array(v3.string())
637
+ supports: v4.array(v4.string())
573
638
  });
574
- var getInfoSchema = v3.object({
639
+ var getInfoSchema = v4.object({
575
640
  ...rpcRequestMessageSchema.entries,
576
- ...v3.object({
577
- method: v3.literal(getInfoMethodName),
641
+ ...v4.object({
642
+ method: v4.literal(getInfoMethodName),
578
643
  params: getInfoParamsSchema,
579
- id: v3.string()
644
+ id: v4.string()
580
645
  }).entries
581
646
  });
582
647
  var getAddressesMethodName = "getAddresses";
583
- var getAddressesParamsSchema = v3.object({
648
+ var getAddressesParamsSchema = v4.object({
584
649
  /**
585
650
  * The purposes for which to generate addresses. See
586
651
  * {@linkcode AddressPurpose} for available purposes.
587
652
  */
588
- purposes: v3.array(v3.enum(AddressPurpose)),
653
+ purposes: v4.array(v4.enum(AddressPurpose)),
589
654
  /**
590
655
  * A message to be displayed to the user in the request prompt.
591
656
  */
592
- message: v3.optional(v3.string())
657
+ message: v4.optional(v4.string())
593
658
  });
594
- var getAddressesResultSchema = v3.object({
659
+ var getAddressesResultSchema = v4.object({
595
660
  /**
596
661
  * The addresses generated for the given purposes.
597
662
  */
598
- addresses: v3.array(addressSchema)
663
+ addresses: v4.array(addressSchema)
599
664
  });
600
- var getAddressesRequestMessageSchema = v3.object({
665
+ var getAddressesRequestMessageSchema = v4.object({
601
666
  ...rpcRequestMessageSchema.entries,
602
- ...v3.object({
603
- method: v3.literal(getAddressesMethodName),
667
+ ...v4.object({
668
+ method: v4.literal(getAddressesMethodName),
604
669
  params: getAddressesParamsSchema,
605
- id: v3.string()
670
+ id: v4.string()
606
671
  }).entries
607
672
  });
608
673
  var signMessageMethodName = "signMessage";
609
- var signMessageParamsSchema = v3.object({
674
+ var signMessageParamsSchema = v4.object({
610
675
  /**
611
676
  * The address used for signing.
612
677
  **/
613
- address: v3.string(),
678
+ address: v4.string(),
614
679
  /**
615
680
  * The message to sign.
616
681
  **/
617
- message: v3.string()
682
+ message: v4.string()
618
683
  });
619
- var signMessageResultSchema = v3.object({
684
+ var signMessageResultSchema = v4.object({
620
685
  /**
621
686
  * The signature of the message.
622
687
  */
623
- signature: v3.string(),
688
+ signature: v4.string(),
624
689
  /**
625
690
  * hash of the message.
626
691
  */
627
- messageHash: v3.string(),
692
+ messageHash: v4.string(),
628
693
  /**
629
694
  * The address used for signing.
630
695
  */
631
- address: v3.string()
696
+ address: v4.string()
632
697
  });
633
- var signMessageRequestMessageSchema = v3.object({
698
+ var signMessageRequestMessageSchema = v4.object({
634
699
  ...rpcRequestMessageSchema.entries,
635
- ...v3.object({
636
- method: v3.literal(signMessageMethodName),
700
+ ...v4.object({
701
+ method: v4.literal(signMessageMethodName),
637
702
  params: signMessageParamsSchema,
638
- id: v3.string()
703
+ id: v4.string()
639
704
  }).entries
640
705
  });
641
706
  var getAccountsMethodName = "getAccounts";
642
707
  var getAccountsParamsSchema = getAddressesParamsSchema;
643
- var getAccountsResultSchema = v3.array(addressSchema);
644
- var getAccountsRequestMessageSchema = v3.object({
708
+ var getAccountsResultSchema = v4.array(addressSchema);
709
+ var getAccountsRequestMessageSchema = v4.object({
645
710
  ...rpcRequestMessageSchema.entries,
646
- ...v3.object({
647
- method: v3.literal(getAccountsMethodName),
711
+ ...v4.object({
712
+ method: v4.literal(getAccountsMethodName),
648
713
  params: getAccountsParamsSchema,
649
- id: v3.string()
714
+ id: v4.string()
650
715
  }).entries
651
716
  });
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({
717
+ var getBalanceMethodName = "getBalance";
718
+ var getBalanceParamsSchema = v4.undefined();
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({
659
740
  ...rpcRequestMessageSchema.entries,
660
741
  ...v4.object({
661
- method: v4.literal(connectMethodName),
662
- params: connectParamsSchema,
742
+ method: v4.literal(getBalanceMethodName),
663
743
  id: v4.string()
664
744
  }).entries
665
745
  });
666
- var disconnectMethodName = "wallet_disconnect";
667
- var disconnectParamsSchema = v4.undefined();
668
- var disconnectResultSchema = v4.undefined();
669
- var disconnectSchema = v4.object({
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({
670
753
  ...rpcRequestMessageSchema.entries,
671
- ...v4.object({
672
- method: v4.literal(disconnectMethodName),
673
- params: disconnectParamsSchema,
674
- id: v4.string()
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.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()
675
826
  }).entries
676
827
  });
677
828
 
@@ -688,7 +839,13 @@ var request = async (method, params, providerId) => {
688
839
  throw new Error("A wallet method is required");
689
840
  }
690
841
  const response = await provider.request(method, params);
691
- if (isRpcSuccessResponse(response)) {
842
+ if (v8.is(rpcErrorResponseMessageSchema, response)) {
843
+ return {
844
+ status: "error",
845
+ error: response.error
846
+ };
847
+ }
848
+ if (v8.is(rpcSuccessResponseMessageSchema, response)) {
692
849
  return {
693
850
  status: "success",
694
851
  result: response.result
@@ -696,12 +853,13 @@ var request = async (method, params, providerId) => {
696
853
  }
697
854
  return {
698
855
  status: "error",
699
- error: response.error
856
+ error: {
857
+ code: -32603 /* INTERNAL_ERROR */,
858
+ message: "Received unknown response from provider.",
859
+ data: response
860
+ }
700
861
  };
701
862
  };
702
- var isRpcSuccessResponse = (response) => {
703
- return Object.hasOwn(response, "result") && !!response.result;
704
- };
705
863
 
706
864
  // src/adapters/xverse.ts
707
865
  var XverseAdapter = class extends SatsConnectAdapter {
@@ -1117,19 +1275,12 @@ export {
1117
1275
  BitcoinNetworkType,
1118
1276
  DefaultAdaptersInfo,
1119
1277
  RpcErrorCode,
1278
+ RpcIdSchema,
1120
1279
  SatsConnectAdapter,
1121
1280
  addressSchema,
1122
- connectMethodName,
1123
- connectParamsSchema,
1124
- connectResultSchema,
1125
- connectSchema,
1126
1281
  createInscription,
1127
1282
  createRepeatInscriptions,
1128
1283
  defaultAdapters,
1129
- disconnectMethodName,
1130
- disconnectParamsSchema,
1131
- disconnectResultSchema,
1132
- disconnectSchema,
1133
1284
  getAccountsMethodName,
1134
1285
  getAccountsParamsSchema,
1135
1286
  getAccountsRequestMessageSchema,
@@ -1139,20 +1290,43 @@ export {
1139
1290
  getAddressesParamsSchema,
1140
1291
  getAddressesRequestMessageSchema,
1141
1292
  getAddressesResultSchema,
1293
+ getBalanceMethodName,
1294
+ getBalanceParamsSchema,
1295
+ getBalanceRequestMessageSchema,
1296
+ getBalanceResultSchema,
1142
1297
  getCapabilities,
1143
1298
  getDefaultProvider,
1144
1299
  getInfoMethodName,
1145
1300
  getInfoParamsSchema,
1146
1301
  getInfoResultSchema,
1147
1302
  getInfoSchema,
1303
+ getInscriptionsMethodName,
1304
+ getInscriptionsParamsSchema,
1305
+ getInscriptionsResultSchema,
1306
+ getInscriptionsSchema,
1148
1307
  getProviderById,
1149
1308
  getProviderOrThrow,
1150
1309
  getProviders,
1310
+ getRunesBalanceMethodName,
1311
+ getRunesBalanceParamsSchema,
1312
+ getRunesBalanceRequestMessageSchema,
1313
+ getRunesBalanceResultSchema,
1151
1314
  getSupportedWallets,
1152
1315
  isProviderInstalled,
1153
1316
  removeDefaultProvider,
1317
+ renouncePermissionsMethodName,
1318
+ renouncePermissionsParamsSchema,
1319
+ renouncePermissionsRequestMessageSchema,
1320
+ renouncePermissionsResultSchema,
1154
1321
  request,
1322
+ requestPermissionsMethodName,
1323
+ requestPermissionsParamsSchema,
1324
+ requestPermissionsRequestMessageSchema,
1325
+ requestPermissionsResultSchema,
1326
+ rpcErrorResponseMessageSchema,
1155
1327
  rpcRequestMessageSchema,
1328
+ rpcResponseMessageSchema,
1329
+ rpcSuccessResponseMessageSchema,
1156
1330
  sendBtcTransaction,
1157
1331
  setDefaultProvider,
1158
1332
  signMessage,
@@ -1161,5 +1335,9 @@ export {
1161
1335
  signMessageRequestMessageSchema,
1162
1336
  signMessageResultSchema,
1163
1337
  signMultipleTransactions,
1164
- signTransaction
1338
+ signTransaction,
1339
+ stxGetAddressesMethodName,
1340
+ stxGetAddressesParamsSchema,
1341
+ stxGetAddressesRequestMessageSchema,
1342
+ stxGetAddressesResultSchema
1165
1343
  };
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-a4c2633",
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"