@sats-connect/core 0.0.11-799c3e5 → 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;
@@ -222,23 +222,26 @@ declare enum RpcErrorCode {
222
222
  }
223
223
  declare const rpcSuccessResponseMessageSchema: v.ObjectSchema<{
224
224
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
225
- readonly result: v.UnknownSchema;
225
+ readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
226
226
  readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
227
227
  }, undefined>;
228
+ type RpcSuccessResponseMessage = v.InferOutput<typeof rpcSuccessResponseMessageSchema>;
228
229
  declare const rpcErrorResponseMessageSchema: v.ObjectSchema<{
229
230
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
230
- readonly error: v.UnknownSchema;
231
+ readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
231
232
  readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
232
233
  }, undefined>;
234
+ type RpcErrorResponseMessage = v.InferOutput<typeof rpcErrorResponseMessageSchema>;
233
235
  declare const rpcResponseMessageSchema: v.UnionSchema<[v.ObjectSchema<{
234
236
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
235
- readonly result: v.UnknownSchema;
237
+ readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
236
238
  readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
237
239
  }, undefined>, v.ObjectSchema<{
238
240
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
239
- readonly error: v.UnknownSchema;
241
+ readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
240
242
  readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
241
243
  }, undefined>], undefined>;
244
+ type RpcResponseMessage = v.InferOutput<typeof rpcResponseMessageSchema>;
242
245
  interface RpcError {
243
246
  code: number | RpcErrorCode;
244
247
  message: string;
@@ -489,12 +492,25 @@ declare const getBalanceMethodName = "getBalance";
489
492
  declare const getBalanceParamsSchema: v.UndefinedSchema<undefined>;
490
493
  declare const getBalanceResultSchema: v.ObjectSchema<{
491
494
  /**
492
- * The balance of the wallet in sats.
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).
493
498
  */
494
- readonly confirmedBalance: v.BigintSchema<undefined>;
495
- readonly unconfirmedUtxosBalance: v.BigintSchema<undefined>;
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>;
496
512
  }, undefined>;
497
- declare const getBalanceSchema: v.ObjectSchema<{
513
+ declare const getBalanceRequestMessageSchema: v.ObjectSchema<{
498
514
  readonly method: v.LiteralSchema<"getBalance", undefined>;
499
515
  readonly id: v.StringSchema<undefined>;
500
516
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
@@ -502,6 +518,37 @@ declare const getBalanceSchema: v.ObjectSchema<{
502
518
  }, undefined>;
503
519
  type GetBalance = MethodParamsAndResult<v.InferOutput<typeof getBalanceParamsSchema>, v.InferOutput<typeof getBalanceResultSchema>>;
504
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>>;
551
+
505
552
  type CreateMintOrderRequest = {
506
553
  runeName: string;
507
554
  repeats: number;
@@ -613,17 +660,24 @@ interface RbfOrderResult {
613
660
  fundingAddress: string;
614
661
  }
615
662
  type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
616
- type GetRunesBalanceParams = null;
617
- interface GetRunesBalanceResult {
618
- balances: {
619
- runeName: string;
620
- amount: string;
621
- divisibility: number;
622
- symbol: string;
623
- inscriptionId: string | null;
624
- }[];
625
- }
626
- 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>>;
627
681
 
628
682
  interface Pubkey {
629
683
  /**
@@ -796,35 +850,60 @@ type GetAccountsResult = {
796
850
  }>;
797
851
  };
798
852
  type StxGetAccounts = MethodParamsAndResult<{}, GetAccountsResult>;
799
- type GetAddressesParams = undefined | null;
800
- type GetAddressesResult = {
801
- addresses: Array<Address & PublicKey>;
802
- };
803
- 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>>;
804
883
  type SignTransactionParams = Transaction & Partial<Pubkey>;
805
884
  type SignTransactionResult = Transaction;
806
885
  type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
807
886
 
808
- declare const connectMethodName = "wallet_connect";
809
- declare const connectParamsSchema: v.UndefinedSchema<undefined>;
810
- declare const connectResultSchema: v.UndefinedSchema<undefined>;
811
- declare const connectSchema: v.ObjectSchema<{
812
- 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>;
813
892
  readonly params: v.UndefinedSchema<undefined>;
814
893
  readonly id: v.StringSchema<undefined>;
815
894
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
816
895
  }, undefined>;
817
- type Connect = MethodParamsAndResult<v.InferOutput<typeof connectParamsSchema>, v.InferOutput<typeof connectResultSchema>>;
818
- declare const disconnectMethodName = "wallet_disconnect";
819
- declare const disconnectParamsSchema: v.UndefinedSchema<undefined>;
820
- declare const disconnectResultSchema: v.UndefinedSchema<undefined>;
821
- declare const disconnectSchema: v.ObjectSchema<{
822
- 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>;
823
902
  readonly params: v.UndefinedSchema<undefined>;
824
903
  readonly id: v.StringSchema<undefined>;
825
904
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
826
905
  }, undefined>;
827
- type Disconnect = MethodParamsAndResult<v.InferOutput<typeof disconnectParamsSchema>, v.InferOutput<typeof disconnectResultSchema>>;
906
+ type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
828
907
 
829
908
  interface StxRequests {
830
909
  stx_callContract: StxCallContract;
@@ -858,15 +937,19 @@ interface RunesRequests {
858
937
  runes_getBalance: GetRunesBalance;
859
938
  }
860
939
  type RunesRequestMethod = keyof RunesRequests;
940
+ interface OrdinalsRequests {
941
+ ord_getInscriptions: GetInscriptions;
942
+ }
943
+ type OrdinalsRequestMethod = keyof OrdinalsRequests;
861
944
  interface WalletMethods {
862
- wallet_connect: Connect;
863
- wallet_disconnect: Disconnect;
945
+ wallet_requestPermissions: RequestPermissions;
946
+ wallet_renouncePermissions: RenouncePermissions;
864
947
  }
865
- type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
948
+ type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods & OrdinalsRequests;
866
949
  type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
867
950
  type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
868
951
 
869
- 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>>;
870
953
 
871
954
  declare abstract class SatsConnectAdapter {
872
955
  abstract readonly id: string;
@@ -884,10 +967,10 @@ declare abstract class SatsConnectAdapter {
884
967
  declare class BaseAdapter extends SatsConnectAdapter {
885
968
  id: string;
886
969
  constructor(providerId: string);
887
- 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>>;
888
971
  }
889
972
 
890
973
  declare const DefaultAdaptersInfo: Record<string, Provider>;
891
974
  declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
892
975
 
893
- 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 GetBalance, 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, RpcIdSchema, 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, getBalanceMethodName, getBalanceParamsSchema, getBalanceResultSchema, getBalanceSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, 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,10 +1,10 @@
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
9
  var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
10
10
  var rpcRequestMessageSchema = v.object({
@@ -36,12 +36,12 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
36
36
  })(RpcErrorCode || {});
37
37
  var rpcSuccessResponseMessageSchema = v.object({
38
38
  jsonrpc: v.literal("2.0"),
39
- result: v.unknown(),
39
+ result: v.nonOptional(v.unknown()),
40
40
  id: RpcIdSchema
41
41
  });
42
42
  var rpcErrorResponseMessageSchema = v.object({
43
43
  jsonrpc: v.literal("2.0"),
44
- error: v.unknown(),
44
+ error: v.nonOptional(v.unknown()),
45
45
  id: RpcIdSchema
46
46
  });
47
47
  var rpcResponseMessageSchema = v.union([
@@ -202,6 +202,16 @@ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
202
202
  var SatsConnectAdapter = class {
203
203
  async mintRunes(params) {
204
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
+ }
205
215
  const mintRequest = {
206
216
  destinationAddress: params.destinationAddress,
207
217
  feeRate: params.feeRate,
@@ -271,6 +281,16 @@ var SatsConnectAdapter = class {
271
281
  appServiceFeeAddress: params.appServiceFeeAddress
272
282
  };
273
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
+ }
274
294
  const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
275
295
  if (!orderResponse.data) {
276
296
  return {
@@ -526,7 +546,7 @@ function getSupportedWallets() {
526
546
  }
527
547
 
528
548
  // src/request/index.ts
529
- import * as v5 from "valibot";
549
+ import * as v8 from "valibot";
530
550
 
531
551
  // src/addresses/index.ts
532
552
  import { createUnsecuredToken } from "jsontokens";
@@ -572,141 +592,237 @@ var getAddress = async (options) => {
572
592
  }
573
593
  };
574
594
 
575
- // src/request/types/btcMethods.ts
595
+ // src/request/types/stxMethods.ts
576
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";
577
623
  var getInfoMethodName = "getInfo";
578
- var getInfoParamsSchema = v3.null();
579
- var getInfoResultSchema = v3.object({
624
+ var getInfoParamsSchema = v4.null();
625
+ var getInfoResultSchema = v4.object({
580
626
  /**
581
627
  * Version of the wallet.
582
628
  */
583
- version: v3.string(),
629
+ version: v4.string(),
584
630
  /**
585
631
  * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
586
632
  */
587
- methods: v3.optional(v3.array(v3.string())),
633
+ methods: v4.optional(v4.array(v4.string())),
588
634
  /**
589
635
  * List of WBIP standards supported by the wallet. Not currently used.
590
636
  */
591
- supports: v3.array(v3.string())
637
+ supports: v4.array(v4.string())
592
638
  });
593
- var getInfoSchema = v3.object({
639
+ var getInfoSchema = v4.object({
594
640
  ...rpcRequestMessageSchema.entries,
595
- ...v3.object({
596
- method: v3.literal(getInfoMethodName),
641
+ ...v4.object({
642
+ method: v4.literal(getInfoMethodName),
597
643
  params: getInfoParamsSchema,
598
- id: v3.string()
644
+ id: v4.string()
599
645
  }).entries
600
646
  });
601
647
  var getAddressesMethodName = "getAddresses";
602
- var getAddressesParamsSchema = v3.object({
648
+ var getAddressesParamsSchema = v4.object({
603
649
  /**
604
650
  * The purposes for which to generate addresses. See
605
651
  * {@linkcode AddressPurpose} for available purposes.
606
652
  */
607
- purposes: v3.array(v3.enum(AddressPurpose)),
653
+ purposes: v4.array(v4.enum(AddressPurpose)),
608
654
  /**
609
655
  * A message to be displayed to the user in the request prompt.
610
656
  */
611
- message: v3.optional(v3.string())
657
+ message: v4.optional(v4.string())
612
658
  });
613
- var getAddressesResultSchema = v3.object({
659
+ var getAddressesResultSchema = v4.object({
614
660
  /**
615
661
  * The addresses generated for the given purposes.
616
662
  */
617
- addresses: v3.array(addressSchema)
663
+ addresses: v4.array(addressSchema)
618
664
  });
619
- var getAddressesRequestMessageSchema = v3.object({
665
+ var getAddressesRequestMessageSchema = v4.object({
620
666
  ...rpcRequestMessageSchema.entries,
621
- ...v3.object({
622
- method: v3.literal(getAddressesMethodName),
667
+ ...v4.object({
668
+ method: v4.literal(getAddressesMethodName),
623
669
  params: getAddressesParamsSchema,
624
- id: v3.string()
670
+ id: v4.string()
625
671
  }).entries
626
672
  });
627
673
  var signMessageMethodName = "signMessage";
628
- var signMessageParamsSchema = v3.object({
674
+ var signMessageParamsSchema = v4.object({
629
675
  /**
630
676
  * The address used for signing.
631
677
  **/
632
- address: v3.string(),
678
+ address: v4.string(),
633
679
  /**
634
680
  * The message to sign.
635
681
  **/
636
- message: v3.string()
682
+ message: v4.string()
637
683
  });
638
- var signMessageResultSchema = v3.object({
684
+ var signMessageResultSchema = v4.object({
639
685
  /**
640
686
  * The signature of the message.
641
687
  */
642
- signature: v3.string(),
688
+ signature: v4.string(),
643
689
  /**
644
690
  * hash of the message.
645
691
  */
646
- messageHash: v3.string(),
692
+ messageHash: v4.string(),
647
693
  /**
648
694
  * The address used for signing.
649
695
  */
650
- address: v3.string()
696
+ address: v4.string()
651
697
  });
652
- var signMessageRequestMessageSchema = v3.object({
698
+ var signMessageRequestMessageSchema = v4.object({
653
699
  ...rpcRequestMessageSchema.entries,
654
- ...v3.object({
655
- method: v3.literal(signMessageMethodName),
700
+ ...v4.object({
701
+ method: v4.literal(signMessageMethodName),
656
702
  params: signMessageParamsSchema,
657
- id: v3.string()
703
+ id: v4.string()
658
704
  }).entries
659
705
  });
660
706
  var getAccountsMethodName = "getAccounts";
661
707
  var getAccountsParamsSchema = getAddressesParamsSchema;
662
- var getAccountsResultSchema = v3.array(addressSchema);
663
- var getAccountsRequestMessageSchema = v3.object({
708
+ var getAccountsResultSchema = v4.array(addressSchema);
709
+ var getAccountsRequestMessageSchema = v4.object({
664
710
  ...rpcRequestMessageSchema.entries,
665
- ...v3.object({
666
- method: v3.literal(getAccountsMethodName),
711
+ ...v4.object({
712
+ method: v4.literal(getAccountsMethodName),
667
713
  params: getAccountsParamsSchema,
668
- id: v3.string()
714
+ id: v4.string()
669
715
  }).entries
670
716
  });
671
717
  var getBalanceMethodName = "getBalance";
672
- var getBalanceParamsSchema = v3.undefined();
673
- var getBalanceResultSchema = v3.object({
718
+ var getBalanceParamsSchema = v4.undefined();
719
+ var getBalanceResultSchema = v4.object({
674
720
  /**
675
- * The balance of the wallet in sats.
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).
676
724
  */
677
- confirmedBalance: v3.bigint(),
678
- unconfirmedUtxosBalance: v3.bigint()
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()
679
738
  });
680
- var getBalanceSchema = v3.object({
739
+ var getBalanceRequestMessageSchema = v4.object({
681
740
  ...rpcRequestMessageSchema.entries,
682
- ...v3.object({
683
- method: v3.literal(getBalanceMethodName),
684
- id: v3.string()
741
+ ...v4.object({
742
+ method: v4.literal(getBalanceMethodName),
743
+ id: v4.string()
685
744
  }).entries
686
745
  });
687
746
 
688
747
  // src/request/types/walletMethods.ts
689
- import * as v4 from "valibot";
690
- var connectMethodName = "wallet_connect";
691
- var connectParamsSchema = v4.undefined();
692
- var connectResultSchema = v4.undefined();
693
- var connectSchema = v4.object({
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({
694
753
  ...rpcRequestMessageSchema.entries,
695
- ...v4.object({
696
- method: v4.literal(connectMethodName),
697
- params: connectParamsSchema,
698
- id: v4.string()
754
+ ...v5.object({
755
+ method: v5.literal(requestPermissionsMethodName),
756
+ params: requestPermissionsParamsSchema,
757
+ id: v5.string()
699
758
  }).entries
700
759
  });
701
- var disconnectMethodName = "wallet_disconnect";
702
- var disconnectParamsSchema = v4.undefined();
703
- var disconnectResultSchema = v4.undefined();
704
- var disconnectSchema = v4.object({
760
+ var renouncePermissionsMethodName = "wallet_renouncePermissions";
761
+ var renouncePermissionsParamsSchema = v5.undefined();
762
+ var renouncePermissionsResultSchema = v5.literal(true);
763
+ var renouncePermissionsRequestMessageSchema = v5.object({
705
764
  ...rpcRequestMessageSchema.entries,
706
- ...v4.object({
707
- method: v4.literal(disconnectMethodName),
708
- params: disconnectParamsSchema,
709
- id: v4.string()
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()
710
826
  }).entries
711
827
  });
712
828
 
@@ -723,27 +839,25 @@ var request = async (method, params, providerId) => {
723
839
  throw new Error("A wallet method is required");
724
840
  }
725
841
  const response = await provider.request(method, params);
726
- const parseResult = v5.safeParse(rpcResponseMessageSchema, response);
727
- if (!parseResult.success) {
842
+ if (v8.is(rpcErrorResponseMessageSchema, response)) {
728
843
  return {
729
844
  status: "error",
730
- error: {
731
- code: -32603 /* INTERNAL_ERROR */,
732
- message: "Received unknown response from provider.",
733
- data: response
734
- }
845
+ error: response.error
735
846
  };
736
847
  }
737
- const parsedResponse = parseResult.output;
738
- if ("error" in parsedResponse) {
848
+ if (v8.is(rpcSuccessResponseMessageSchema, response)) {
739
849
  return {
740
- status: "error",
741
- error: parsedResponse.error
850
+ status: "success",
851
+ result: response.result
742
852
  };
743
853
  }
744
854
  return {
745
- status: "success",
746
- result: parsedResponse.result
855
+ status: "error",
856
+ error: {
857
+ code: -32603 /* INTERNAL_ERROR */,
858
+ message: "Received unknown response from provider.",
859
+ data: response
860
+ }
747
861
  };
748
862
  };
749
863
 
@@ -1164,17 +1278,9 @@ export {
1164
1278
  RpcIdSchema,
1165
1279
  SatsConnectAdapter,
1166
1280
  addressSchema,
1167
- connectMethodName,
1168
- connectParamsSchema,
1169
- connectResultSchema,
1170
- connectSchema,
1171
1281
  createInscription,
1172
1282
  createRepeatInscriptions,
1173
1283
  defaultAdapters,
1174
- disconnectMethodName,
1175
- disconnectParamsSchema,
1176
- disconnectResultSchema,
1177
- disconnectSchema,
1178
1284
  getAccountsMethodName,
1179
1285
  getAccountsParamsSchema,
1180
1286
  getAccountsRequestMessageSchema,
@@ -1186,21 +1292,37 @@ export {
1186
1292
  getAddressesResultSchema,
1187
1293
  getBalanceMethodName,
1188
1294
  getBalanceParamsSchema,
1295
+ getBalanceRequestMessageSchema,
1189
1296
  getBalanceResultSchema,
1190
- getBalanceSchema,
1191
1297
  getCapabilities,
1192
1298
  getDefaultProvider,
1193
1299
  getInfoMethodName,
1194
1300
  getInfoParamsSchema,
1195
1301
  getInfoResultSchema,
1196
1302
  getInfoSchema,
1303
+ getInscriptionsMethodName,
1304
+ getInscriptionsParamsSchema,
1305
+ getInscriptionsResultSchema,
1306
+ getInscriptionsSchema,
1197
1307
  getProviderById,
1198
1308
  getProviderOrThrow,
1199
1309
  getProviders,
1310
+ getRunesBalanceMethodName,
1311
+ getRunesBalanceParamsSchema,
1312
+ getRunesBalanceRequestMessageSchema,
1313
+ getRunesBalanceResultSchema,
1200
1314
  getSupportedWallets,
1201
1315
  isProviderInstalled,
1202
1316
  removeDefaultProvider,
1317
+ renouncePermissionsMethodName,
1318
+ renouncePermissionsParamsSchema,
1319
+ renouncePermissionsRequestMessageSchema,
1320
+ renouncePermissionsResultSchema,
1203
1321
  request,
1322
+ requestPermissionsMethodName,
1323
+ requestPermissionsParamsSchema,
1324
+ requestPermissionsRequestMessageSchema,
1325
+ requestPermissionsResultSchema,
1204
1326
  rpcErrorResponseMessageSchema,
1205
1327
  rpcRequestMessageSchema,
1206
1328
  rpcResponseMessageSchema,
@@ -1213,5 +1335,9 @@ export {
1213
1335
  signMessageRequestMessageSchema,
1214
1336
  signMessageResultSchema,
1215
1337
  signMultipleTransactions,
1216
- signTransaction
1338
+ signTransaction,
1339
+ stxGetAddressesMethodName,
1340
+ stxGetAddressesParamsSchema,
1341
+ stxGetAddressesRequestMessageSchema,
1342
+ stxGetAddressesResultSchema
1217
1343
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.11-799c3e5",
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",