@sats-connect/core 0.0.11-a949a0a → 0.0.11-c7e675e
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 +143 -19
- package/dist/index.mjs +183 -12
- package/package.json +2 -1
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,14 +159,15 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
159
159
|
payload: Payload;
|
|
160
160
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
161
161
|
}
|
|
162
|
+
declare const RpcIdSchema: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
163
|
+
type RpcId = v.InferOutput<typeof RpcIdSchema>;
|
|
162
164
|
declare const rpcRequestMessageSchema: v.ObjectSchema<{
|
|
163
165
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
164
166
|
readonly method: v.StringSchema<undefined>;
|
|
165
|
-
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>], undefined>, never>;
|
|
167
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
166
168
|
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
167
169
|
}, undefined>;
|
|
168
170
|
type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
|
|
169
|
-
type RpcId = string | null;
|
|
170
171
|
interface RpcBase {
|
|
171
172
|
jsonrpc: '2.0';
|
|
172
173
|
id: RpcId;
|
|
@@ -213,8 +214,34 @@ declare enum RpcErrorCode {
|
|
|
213
214
|
/**
|
|
214
215
|
* method is not supported for the address provided
|
|
215
216
|
*/
|
|
216
|
-
METHOD_NOT_SUPPORTED = -32001
|
|
217
|
+
METHOD_NOT_SUPPORTED = -32001,
|
|
218
|
+
/**
|
|
219
|
+
* The client does not have permission to access the requested resource.
|
|
220
|
+
*/
|
|
221
|
+
ACCESS_DENIED = -32002
|
|
217
222
|
}
|
|
223
|
+
declare const rpcSuccessResponseMessageSchema: v.ObjectSchema<{
|
|
224
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
225
|
+
readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
|
|
226
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
227
|
+
}, undefined>;
|
|
228
|
+
type RpcSuccessResponseMessage = v.InferOutput<typeof rpcSuccessResponseMessageSchema>;
|
|
229
|
+
declare const rpcErrorResponseMessageSchema: v.ObjectSchema<{
|
|
230
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
231
|
+
readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
|
|
232
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
233
|
+
}, undefined>;
|
|
234
|
+
type RpcErrorResponseMessage = v.InferOutput<typeof rpcErrorResponseMessageSchema>;
|
|
235
|
+
declare const rpcResponseMessageSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
236
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
237
|
+
readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
|
|
238
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
239
|
+
}, undefined>, v.ObjectSchema<{
|
|
240
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
241
|
+
readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
|
|
242
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
243
|
+
}, undefined>], undefined>;
|
|
244
|
+
type RpcResponseMessage = v.InferOutput<typeof rpcResponseMessageSchema>;
|
|
218
245
|
interface RpcError {
|
|
219
246
|
code: number | RpcErrorCode;
|
|
220
247
|
message: string;
|
|
@@ -461,6 +488,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
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
|
|
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
|
/**
|
|
@@ -765,6 +859,27 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
765
859
|
type SignTransactionResult = Transaction;
|
|
766
860
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
767
861
|
|
|
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>;
|
|
867
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
868
|
+
readonly id: v.StringSchema<undefined>;
|
|
869
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
870
|
+
}, 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>;
|
|
877
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
878
|
+
readonly id: v.StringSchema<undefined>;
|
|
879
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
880
|
+
}, undefined>;
|
|
881
|
+
type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
|
|
882
|
+
|
|
768
883
|
interface StxRequests {
|
|
769
884
|
stx_callContract: StxCallContract;
|
|
770
885
|
stx_deployContract: StxDeployContract;
|
|
@@ -780,6 +895,7 @@ interface BtcRequests {
|
|
|
780
895
|
getInfo: GetInfo;
|
|
781
896
|
getAddresses: GetAddresses;
|
|
782
897
|
getAccounts: GetAccounts;
|
|
898
|
+
getBalance: GetBalance;
|
|
783
899
|
signMessage: SignMessage;
|
|
784
900
|
sendTransfer: SendTransfer;
|
|
785
901
|
signPsbt: SignPsbt;
|
|
@@ -796,11 +912,19 @@ interface RunesRequests {
|
|
|
796
912
|
runes_getBalance: GetRunesBalance;
|
|
797
913
|
}
|
|
798
914
|
type RunesRequestMethod = keyof RunesRequests;
|
|
799
|
-
|
|
915
|
+
interface OrdinalsRequests {
|
|
916
|
+
ord_getInscriptions: GetInscriptions;
|
|
917
|
+
}
|
|
918
|
+
type OrdinalsRequestMethod = keyof OrdinalsRequests;
|
|
919
|
+
interface WalletMethods {
|
|
920
|
+
wallet_requestPermissions: RequestPermissions;
|
|
921
|
+
wallet_renouncePermissions: RenouncePermissions;
|
|
922
|
+
}
|
|
923
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods & OrdinalsRequests;
|
|
800
924
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
801
925
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
802
926
|
|
|
803
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(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>>;
|
|
804
928
|
|
|
805
929
|
declare abstract class SatsConnectAdapter {
|
|
806
930
|
abstract readonly id: string;
|
|
@@ -818,10 +942,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
818
942
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
819
943
|
id: string;
|
|
820
944
|
constructor(providerId: string);
|
|
821
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(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>>;
|
|
822
946
|
}
|
|
823
947
|
|
|
824
948
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
825
949
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
826
950
|
|
|
827
|
-
export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type GetAccounts, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type InputToSign, type MethodParamsAndResult, type Params, type Provider, type PsbtPayload, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcId, type RpcRequest, type RpcRequestMessage, type RpcResponse, type RpcResult, type RpcSuccessResponse, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, rpcRequestMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction };
|
|
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,16 +1,27 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
-
var BitcoinNetworkType = /* @__PURE__ */ ((
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
3
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType3) => {
|
|
4
|
+
BitcoinNetworkType3["Mainnet"] = "Mainnet";
|
|
5
|
+
BitcoinNetworkType3["Testnet"] = "Testnet";
|
|
6
|
+
BitcoinNetworkType3["Signet"] = "Signet";
|
|
7
|
+
return BitcoinNetworkType3;
|
|
8
8
|
})(BitcoinNetworkType || {});
|
|
9
|
+
var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
|
|
9
10
|
var rpcRequestMessageSchema = v.object({
|
|
10
11
|
jsonrpc: v.literal("2.0"),
|
|
11
12
|
method: v.string(),
|
|
12
|
-
params: v.optional(
|
|
13
|
-
|
|
13
|
+
params: v.optional(
|
|
14
|
+
v.union([
|
|
15
|
+
v.array(v.unknown()),
|
|
16
|
+
v.looseObject({}),
|
|
17
|
+
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
18
|
+
// to be either an array or an object when provided. Changing this now would
|
|
19
|
+
// be a breaking change, so accepting null values for now. Tracking in
|
|
20
|
+
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
21
|
+
v.null()
|
|
22
|
+
])
|
|
23
|
+
),
|
|
24
|
+
id: RpcIdSchema
|
|
14
25
|
});
|
|
15
26
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
16
27
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
@@ -20,8 +31,23 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
20
31
|
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
21
32
|
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
22
33
|
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
34
|
+
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
23
35
|
return RpcErrorCode2;
|
|
24
36
|
})(RpcErrorCode || {});
|
|
37
|
+
var rpcSuccessResponseMessageSchema = v.object({
|
|
38
|
+
jsonrpc: v.literal("2.0"),
|
|
39
|
+
result: v.nonOptional(v.unknown()),
|
|
40
|
+
id: RpcIdSchema
|
|
41
|
+
});
|
|
42
|
+
var rpcErrorResponseMessageSchema = v.object({
|
|
43
|
+
jsonrpc: v.literal("2.0"),
|
|
44
|
+
error: v.nonOptional(v.unknown()),
|
|
45
|
+
id: RpcIdSchema
|
|
46
|
+
});
|
|
47
|
+
var rpcResponseMessageSchema = v.union([
|
|
48
|
+
rpcSuccessResponseMessageSchema,
|
|
49
|
+
rpcErrorResponseMessageSchema
|
|
50
|
+
]);
|
|
25
51
|
|
|
26
52
|
// src/runes/api.ts
|
|
27
53
|
import axios from "axios";
|
|
@@ -499,6 +525,9 @@ function getSupportedWallets() {
|
|
|
499
525
|
return wallets;
|
|
500
526
|
}
|
|
501
527
|
|
|
528
|
+
// src/request/index.ts
|
|
529
|
+
import * as v7 from "valibot";
|
|
530
|
+
|
|
502
531
|
// src/addresses/index.ts
|
|
503
532
|
import { createUnsecuredToken } from "jsontokens";
|
|
504
533
|
|
|
@@ -639,6 +668,117 @@ var getAccountsRequestMessageSchema = v3.object({
|
|
|
639
668
|
id: v3.string()
|
|
640
669
|
}).entries
|
|
641
670
|
});
|
|
671
|
+
var getBalanceMethodName = "getBalance";
|
|
672
|
+
var getBalanceParamsSchema = v3.undefined();
|
|
673
|
+
var getBalanceResultSchema = v3.object({
|
|
674
|
+
/**
|
|
675
|
+
* The confirmed balance of the wallet in sats. 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).
|
|
690
|
+
*/
|
|
691
|
+
total: v3.string()
|
|
692
|
+
});
|
|
693
|
+
var getBalanceRequestMessageSchema = v3.object({
|
|
694
|
+
...rpcRequestMessageSchema.entries,
|
|
695
|
+
...v3.object({
|
|
696
|
+
method: v3.literal(getBalanceMethodName),
|
|
697
|
+
id: v3.string()
|
|
698
|
+
}).entries
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
// src/request/types/walletMethods.ts
|
|
702
|
+
import * as v4 from "valibot";
|
|
703
|
+
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
704
|
+
var requestPermissionsParamsSchema = v4.undefined();
|
|
705
|
+
var requestPermissionsResultSchema = v4.literal(true);
|
|
706
|
+
var requestPermissionsRequestMessageSchema = v4.object({
|
|
707
|
+
...rpcRequestMessageSchema.entries,
|
|
708
|
+
...v4.object({
|
|
709
|
+
method: v4.literal(requestPermissionsMethodName),
|
|
710
|
+
params: requestPermissionsParamsSchema,
|
|
711
|
+
id: v4.string()
|
|
712
|
+
}).entries
|
|
713
|
+
});
|
|
714
|
+
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
715
|
+
var renouncePermissionsParamsSchema = v4.undefined();
|
|
716
|
+
var renouncePermissionsResultSchema = v4.literal(true);
|
|
717
|
+
var renouncePermissionsRequestMessageSchema = v4.object({
|
|
718
|
+
...rpcRequestMessageSchema.entries,
|
|
719
|
+
...v4.object({
|
|
720
|
+
method: v4.literal(renouncePermissionsMethodName),
|
|
721
|
+
params: renouncePermissionsParamsSchema,
|
|
722
|
+
id: v4.string()
|
|
723
|
+
}).entries
|
|
724
|
+
});
|
|
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
|
+
});
|
|
642
782
|
|
|
643
783
|
// src/request/index.ts
|
|
644
784
|
var request = async (method, params, providerId) => {
|
|
@@ -653,7 +793,13 @@ var request = async (method, params, providerId) => {
|
|
|
653
793
|
throw new Error("A wallet method is required");
|
|
654
794
|
}
|
|
655
795
|
const response = await provider.request(method, params);
|
|
656
|
-
if (
|
|
796
|
+
if (v7.is(rpcErrorResponseMessageSchema, response)) {
|
|
797
|
+
return {
|
|
798
|
+
status: "error",
|
|
799
|
+
error: response.error
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
if (v7.is(rpcSuccessResponseMessageSchema, response)) {
|
|
657
803
|
return {
|
|
658
804
|
status: "success",
|
|
659
805
|
result: response.result
|
|
@@ -661,12 +807,13 @@ var request = async (method, params, providerId) => {
|
|
|
661
807
|
}
|
|
662
808
|
return {
|
|
663
809
|
status: "error",
|
|
664
|
-
error:
|
|
810
|
+
error: {
|
|
811
|
+
code: -32603 /* INTERNAL_ERROR */,
|
|
812
|
+
message: "Received unknown response from provider.",
|
|
813
|
+
data: response
|
|
814
|
+
}
|
|
665
815
|
};
|
|
666
816
|
};
|
|
667
|
-
var isRpcSuccessResponse = (response) => {
|
|
668
|
-
return Object.hasOwn(response, "result") && !!response.result;
|
|
669
|
-
};
|
|
670
817
|
|
|
671
818
|
// src/adapters/xverse.ts
|
|
672
819
|
var XverseAdapter = class extends SatsConnectAdapter {
|
|
@@ -1082,6 +1229,7 @@ export {
|
|
|
1082
1229
|
BitcoinNetworkType,
|
|
1083
1230
|
DefaultAdaptersInfo,
|
|
1084
1231
|
RpcErrorCode,
|
|
1232
|
+
RpcIdSchema,
|
|
1085
1233
|
SatsConnectAdapter,
|
|
1086
1234
|
addressSchema,
|
|
1087
1235
|
createInscription,
|
|
@@ -1096,20 +1244,43 @@ export {
|
|
|
1096
1244
|
getAddressesParamsSchema,
|
|
1097
1245
|
getAddressesRequestMessageSchema,
|
|
1098
1246
|
getAddressesResultSchema,
|
|
1247
|
+
getBalanceMethodName,
|
|
1248
|
+
getBalanceParamsSchema,
|
|
1249
|
+
getBalanceRequestMessageSchema,
|
|
1250
|
+
getBalanceResultSchema,
|
|
1099
1251
|
getCapabilities,
|
|
1100
1252
|
getDefaultProvider,
|
|
1101
1253
|
getInfoMethodName,
|
|
1102
1254
|
getInfoParamsSchema,
|
|
1103
1255
|
getInfoResultSchema,
|
|
1104
1256
|
getInfoSchema,
|
|
1257
|
+
getInscriptionsMethodName,
|
|
1258
|
+
getInscriptionsParamsSchema,
|
|
1259
|
+
getInscriptionsResultSchema,
|
|
1260
|
+
getInscriptionsSchema,
|
|
1105
1261
|
getProviderById,
|
|
1106
1262
|
getProviderOrThrow,
|
|
1107
1263
|
getProviders,
|
|
1264
|
+
getRunesBalanceMethodName,
|
|
1265
|
+
getRunesBalanceParamsSchema,
|
|
1266
|
+
getRunesBalanceRequestMessageSchema,
|
|
1267
|
+
getRunesBalanceResultSchema,
|
|
1108
1268
|
getSupportedWallets,
|
|
1109
1269
|
isProviderInstalled,
|
|
1110
1270
|
removeDefaultProvider,
|
|
1271
|
+
renouncePermissionsMethodName,
|
|
1272
|
+
renouncePermissionsParamsSchema,
|
|
1273
|
+
renouncePermissionsRequestMessageSchema,
|
|
1274
|
+
renouncePermissionsResultSchema,
|
|
1111
1275
|
request,
|
|
1276
|
+
requestPermissionsMethodName,
|
|
1277
|
+
requestPermissionsParamsSchema,
|
|
1278
|
+
requestPermissionsRequestMessageSchema,
|
|
1279
|
+
requestPermissionsResultSchema,
|
|
1280
|
+
rpcErrorResponseMessageSchema,
|
|
1112
1281
|
rpcRequestMessageSchema,
|
|
1282
|
+
rpcResponseMessageSchema,
|
|
1283
|
+
rpcSuccessResponseMessageSchema,
|
|
1113
1284
|
sendBtcTransaction,
|
|
1114
1285
|
setDefaultProvider,
|
|
1115
1286
|
signMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.0.11-
|
|
3
|
+
"version": "0.0.11-c7e675e",
|
|
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"
|