@sats-connect/core 0.0.11-1501a20 → 0.0.11-196e2fc

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;
@@ -219,6 +220,28 @@ declare enum RpcErrorCode {
219
220
  */
220
221
  ACCESS_DENIED = -32002
221
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>;
222
245
  interface RpcError {
223
246
  code: number | RpcErrorCode;
224
247
  message: string;
@@ -469,12 +492,25 @@ declare const getBalanceMethodName = "getBalance";
469
492
  declare const getBalanceParamsSchema: v.UndefinedSchema<undefined>;
470
493
  declare const getBalanceResultSchema: v.ObjectSchema<{
471
494
  /**
472
- * 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).
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).
473
504
  */
474
- readonly confirmedBalance: v.BigintSchema<undefined>;
475
- readonly unconfirmedUtxosBalance: v.BigintSchema<undefined>;
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>;
476
512
  }, undefined>;
477
- declare const getBalanceSchema: v.ObjectSchema<{
513
+ declare const getBalanceRequestMessageSchema: v.ObjectSchema<{
478
514
  readonly method: v.LiteralSchema<"getBalance", undefined>;
479
515
  readonly id: v.StringSchema<undefined>;
480
516
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
@@ -482,6 +518,37 @@ declare const getBalanceSchema: v.ObjectSchema<{
482
518
  }, undefined>;
483
519
  type GetBalance = MethodParamsAndResult<v.InferOutput<typeof getBalanceParamsSchema>, v.InferOutput<typeof getBalanceResultSchema>>;
484
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
+
485
552
  type CreateMintOrderRequest = {
486
553
  runeName: string;
487
554
  repeats: number;
@@ -593,17 +660,24 @@ interface RbfOrderResult {
593
660
  fundingAddress: string;
594
661
  }
595
662
  type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
596
- type GetRunesBalanceParams = null;
597
- interface GetRunesBalanceResult {
598
- balances: {
599
- runeName: string;
600
- amount: string;
601
- divisibility: number;
602
- symbol: string;
603
- inscriptionId: string | null;
604
- }[];
605
- }
606
- 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>>;
607
681
 
608
682
  interface Pubkey {
609
683
  /**
@@ -785,26 +859,26 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
785
859
  type SignTransactionResult = Transaction;
786
860
  type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
787
861
 
788
- declare const connectMethodName = "wallet_connect";
789
- declare const connectParamsSchema: v.UndefinedSchema<undefined>;
790
- declare const connectResultSchema: v.UndefinedSchema<undefined>;
791
- declare const connectSchema: v.ObjectSchema<{
792
- readonly method: v.LiteralSchema<"wallet_connect", undefined>;
862
+ declare const requestPermissionsMethodName = "wallet_requestPermissions";
863
+ declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
864
+ declare const requestPermissionsResultSchema: v.LiteralSchema<true, undefined>;
865
+ declare const requestPermissionsRequestMessageSchema: v.ObjectSchema<{
866
+ readonly method: v.LiteralSchema<"wallet_requestPermissions", undefined>;
793
867
  readonly params: v.UndefinedSchema<undefined>;
794
868
  readonly id: v.StringSchema<undefined>;
795
869
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
796
870
  }, undefined>;
797
- type Connect = MethodParamsAndResult<v.InferOutput<typeof connectParamsSchema>, v.InferOutput<typeof connectResultSchema>>;
798
- declare const disconnectMethodName = "wallet_disconnect";
799
- declare const disconnectParamsSchema: v.UndefinedSchema<undefined>;
800
- declare const disconnectResultSchema: v.UndefinedSchema<undefined>;
801
- declare const disconnectSchema: v.ObjectSchema<{
802
- readonly method: v.LiteralSchema<"wallet_disconnect", undefined>;
871
+ type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof requestPermissionsParamsSchema>, v.InferOutput<typeof requestPermissionsResultSchema>>;
872
+ declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
873
+ declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
874
+ declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
875
+ declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
876
+ readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
803
877
  readonly params: v.UndefinedSchema<undefined>;
804
878
  readonly id: v.StringSchema<undefined>;
805
879
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
806
880
  }, undefined>;
807
- type Disconnect = MethodParamsAndResult<v.InferOutput<typeof disconnectParamsSchema>, v.InferOutput<typeof disconnectResultSchema>>;
881
+ type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
808
882
 
809
883
  interface StxRequests {
810
884
  stx_callContract: StxCallContract;
@@ -838,15 +912,19 @@ interface RunesRequests {
838
912
  runes_getBalance: GetRunesBalance;
839
913
  }
840
914
  type RunesRequestMethod = keyof RunesRequests;
915
+ interface OrdinalsRequests {
916
+ ord_getInscriptions: GetInscriptions;
917
+ }
918
+ type OrdinalsRequestMethod = keyof OrdinalsRequests;
841
919
  interface WalletMethods {
842
- wallet_connect: Connect;
843
- wallet_disconnect: Disconnect;
920
+ wallet_requestPermissions: RequestPermissions;
921
+ wallet_renouncePermissions: RenouncePermissions;
844
922
  }
845
- type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
923
+ type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods & OrdinalsRequests;
846
924
  type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
847
925
  type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
848
926
 
849
- declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
927
+ 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>>;
850
928
 
851
929
  declare abstract class SatsConnectAdapter {
852
930
  abstract readonly id: string;
@@ -864,10 +942,10 @@ declare abstract class SatsConnectAdapter {
864
942
  declare class BaseAdapter extends SatsConnectAdapter {
865
943
  id: string;
866
944
  constructor(providerId: string);
867
- requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
945
+ requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods | "ord_getInscriptions">(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
868
946
  }
869
947
 
870
948
  declare const DefaultAdaptersInfo: Record<string, Provider>;
871
949
  declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
872
950
 
873
- 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, 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, rpcRequestMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction };
951
+ 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 GetAddressesParams, type GetAddressesResult, 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 };
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";
@@ -33,6 +34,20 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
33
34
  RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
34
35
  return RpcErrorCode2;
35
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
+ ]);
36
51
 
37
52
  // src/runes/api.ts
38
53
  import axios from "axios";
@@ -510,6 +525,9 @@ function getSupportedWallets() {
510
525
  return wallets;
511
526
  }
512
527
 
528
+ // src/request/index.ts
529
+ import * as v7 from "valibot";
530
+
513
531
  // src/addresses/index.ts
514
532
  import { createUnsecuredToken } from "jsontokens";
515
533
 
@@ -654,12 +672,25 @@ var getBalanceMethodName = "getBalance";
654
672
  var getBalanceParamsSchema = v3.undefined();
655
673
  var getBalanceResultSchema = v3.object({
656
674
  /**
657
- * The balance of the wallet in sats.
675
+ * The confirmed balance of the wallet in sats. Using a string due to chrome
676
+ * messages not supporting bigint
677
+ * (https://issues.chromium.org/issues/40116184).
678
+ */
679
+ confirmed: v3.string(),
680
+ /**
681
+ * The unconfirmed balance of the wallet in sats. Using a string due to chrome
682
+ * messages not supporting bigint
683
+ * (https://issues.chromium.org/issues/40116184).
684
+ */
685
+ unconfirmed: v3.string(),
686
+ /**
687
+ * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
688
+ * sats. Using a string due to chrome messages not supporting bigint
689
+ * (https://issues.chromium.org/issues/40116184).
658
690
  */
659
- confirmedBalance: v3.bigint(),
660
- unconfirmedUtxosBalance: v3.bigint()
691
+ total: v3.string()
661
692
  });
662
- var getBalanceSchema = v3.object({
693
+ var getBalanceRequestMessageSchema = v3.object({
663
694
  ...rpcRequestMessageSchema.entries,
664
695
  ...v3.object({
665
696
  method: v3.literal(getBalanceMethodName),
@@ -669,29 +700,86 @@ var getBalanceSchema = v3.object({
669
700
 
670
701
  // src/request/types/walletMethods.ts
671
702
  import * as v4 from "valibot";
672
- var connectMethodName = "wallet_connect";
673
- var connectParamsSchema = v4.undefined();
674
- var connectResultSchema = v4.undefined();
675
- var connectSchema = v4.object({
703
+ var requestPermissionsMethodName = "wallet_requestPermissions";
704
+ var requestPermissionsParamsSchema = v4.undefined();
705
+ var requestPermissionsResultSchema = v4.literal(true);
706
+ var requestPermissionsRequestMessageSchema = v4.object({
676
707
  ...rpcRequestMessageSchema.entries,
677
708
  ...v4.object({
678
- method: v4.literal(connectMethodName),
679
- params: connectParamsSchema,
709
+ method: v4.literal(requestPermissionsMethodName),
710
+ params: requestPermissionsParamsSchema,
680
711
  id: v4.string()
681
712
  }).entries
682
713
  });
683
- var disconnectMethodName = "wallet_disconnect";
684
- var disconnectParamsSchema = v4.undefined();
685
- var disconnectResultSchema = v4.undefined();
686
- var disconnectSchema = v4.object({
714
+ var renouncePermissionsMethodName = "wallet_renouncePermissions";
715
+ var renouncePermissionsParamsSchema = v4.undefined();
716
+ var renouncePermissionsResultSchema = v4.literal(true);
717
+ var renouncePermissionsRequestMessageSchema = v4.object({
687
718
  ...rpcRequestMessageSchema.entries,
688
719
  ...v4.object({
689
- method: v4.literal(disconnectMethodName),
690
- params: disconnectParamsSchema,
720
+ method: v4.literal(renouncePermissionsMethodName),
721
+ params: renouncePermissionsParamsSchema,
691
722
  id: v4.string()
692
723
  }).entries
693
724
  });
694
725
 
726
+ // src/request/types/runesMethods.ts
727
+ import * as v5 from "valibot";
728
+ var getRunesBalanceMethodName = "runes_getBalance";
729
+ var getRunesBalanceParamsSchema = v5.null();
730
+ var getRunesBalanceResultSchema = v5.object({
731
+ balances: v5.array(
732
+ v5.object({
733
+ runeName: v5.string(),
734
+ amount: v5.string(),
735
+ divisibility: v5.number(),
736
+ symbol: v5.string(),
737
+ inscriptionId: v5.nullish(v5.string())
738
+ })
739
+ )
740
+ });
741
+ var getRunesBalanceRequestMessageSchema = v5.object({
742
+ ...rpcRequestMessageSchema.entries,
743
+ ...v5.object({
744
+ method: v5.literal(getRunesBalanceMethodName),
745
+ params: getRunesBalanceParamsSchema,
746
+ id: v5.string()
747
+ }).entries
748
+ });
749
+
750
+ // src/request/types/ordinalsMethods.ts
751
+ import * as v6 from "valibot";
752
+ var getInscriptionsMethodName = "ord_getInscriptions";
753
+ var getInscriptionsParamsSchema = v6.object({
754
+ offset: v6.number(),
755
+ limit: v6.number()
756
+ });
757
+ var getInscriptionsResultSchema = v6.object({
758
+ inscriptions: v6.array(
759
+ v6.object({
760
+ inscriptionId: v6.string(),
761
+ inscriptionNumber: v6.string(),
762
+ address: v6.string(),
763
+ collectionName: v6.optional(v6.string()),
764
+ postage: v6.string(),
765
+ contentLength: v6.string(),
766
+ contentType: v6.string(),
767
+ timestamp: v6.number(),
768
+ offset: v6.number(),
769
+ genesisTransaction: v6.string(),
770
+ output: v6.string()
771
+ })
772
+ )
773
+ });
774
+ var getInscriptionsSchema = v6.object({
775
+ ...rpcRequestMessageSchema.entries,
776
+ ...v6.object({
777
+ method: v6.literal(getInscriptionsMethodName),
778
+ params: getInscriptionsParamsSchema,
779
+ id: v6.string()
780
+ }).entries
781
+ });
782
+
695
783
  // src/request/index.ts
696
784
  var request = async (method, params, providerId) => {
697
785
  let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
@@ -705,7 +793,13 @@ var request = async (method, params, providerId) => {
705
793
  throw new Error("A wallet method is required");
706
794
  }
707
795
  const response = await provider.request(method, params);
708
- if (isRpcSuccessResponse(response)) {
796
+ if (v7.is(rpcErrorResponseMessageSchema, response)) {
797
+ return {
798
+ status: "error",
799
+ error: response.error
800
+ };
801
+ }
802
+ if (v7.is(rpcSuccessResponseMessageSchema, response)) {
709
803
  return {
710
804
  status: "success",
711
805
  result: response.result
@@ -713,12 +807,13 @@ var request = async (method, params, providerId) => {
713
807
  }
714
808
  return {
715
809
  status: "error",
716
- error: response.error
810
+ error: {
811
+ code: -32603 /* INTERNAL_ERROR */,
812
+ message: "Received unknown response from provider.",
813
+ data: response
814
+ }
717
815
  };
718
816
  };
719
- var isRpcSuccessResponse = (response) => {
720
- return Object.hasOwn(response, "result") && !!response.result;
721
- };
722
817
 
723
818
  // src/adapters/xverse.ts
724
819
  var XverseAdapter = class extends SatsConnectAdapter {
@@ -1134,19 +1229,12 @@ export {
1134
1229
  BitcoinNetworkType,
1135
1230
  DefaultAdaptersInfo,
1136
1231
  RpcErrorCode,
1232
+ RpcIdSchema,
1137
1233
  SatsConnectAdapter,
1138
1234
  addressSchema,
1139
- connectMethodName,
1140
- connectParamsSchema,
1141
- connectResultSchema,
1142
- connectSchema,
1143
1235
  createInscription,
1144
1236
  createRepeatInscriptions,
1145
1237
  defaultAdapters,
1146
- disconnectMethodName,
1147
- disconnectParamsSchema,
1148
- disconnectResultSchema,
1149
- disconnectSchema,
1150
1238
  getAccountsMethodName,
1151
1239
  getAccountsParamsSchema,
1152
1240
  getAccountsRequestMessageSchema,
@@ -1158,22 +1246,41 @@ export {
1158
1246
  getAddressesResultSchema,
1159
1247
  getBalanceMethodName,
1160
1248
  getBalanceParamsSchema,
1249
+ getBalanceRequestMessageSchema,
1161
1250
  getBalanceResultSchema,
1162
- getBalanceSchema,
1163
1251
  getCapabilities,
1164
1252
  getDefaultProvider,
1165
1253
  getInfoMethodName,
1166
1254
  getInfoParamsSchema,
1167
1255
  getInfoResultSchema,
1168
1256
  getInfoSchema,
1257
+ getInscriptionsMethodName,
1258
+ getInscriptionsParamsSchema,
1259
+ getInscriptionsResultSchema,
1260
+ getInscriptionsSchema,
1169
1261
  getProviderById,
1170
1262
  getProviderOrThrow,
1171
1263
  getProviders,
1264
+ getRunesBalanceMethodName,
1265
+ getRunesBalanceParamsSchema,
1266
+ getRunesBalanceRequestMessageSchema,
1267
+ getRunesBalanceResultSchema,
1172
1268
  getSupportedWallets,
1173
1269
  isProviderInstalled,
1174
1270
  removeDefaultProvider,
1271
+ renouncePermissionsMethodName,
1272
+ renouncePermissionsParamsSchema,
1273
+ renouncePermissionsRequestMessageSchema,
1274
+ renouncePermissionsResultSchema,
1175
1275
  request,
1276
+ requestPermissionsMethodName,
1277
+ requestPermissionsParamsSchema,
1278
+ requestPermissionsRequestMessageSchema,
1279
+ requestPermissionsResultSchema,
1280
+ rpcErrorResponseMessageSchema,
1176
1281
  rpcRequestMessageSchema,
1282
+ rpcResponseMessageSchema,
1283
+ rpcSuccessResponseMessageSchema,
1177
1284
  sendBtcTransaction,
1178
1285
  setDefaultProvider,
1179
1286
  signMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.11-1501a20",
3
+ "version": "0.0.11-196e2fc",
4
4
  "main": "dist/index.mjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.mts",