@sats-connect/core 0.0.11-a949a0a → 0.0.11-aaf7b1c
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 +107 -18
- package/dist/index.mjs +146 -12
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -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,35 @@ 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>>;
|
|
464
520
|
|
|
465
521
|
type CreateMintOrderRequest = {
|
|
466
522
|
runeName: string;
|
|
@@ -573,17 +629,24 @@ interface RbfOrderResult {
|
|
|
573
629
|
fundingAddress: string;
|
|
574
630
|
}
|
|
575
631
|
type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
|
|
632
|
+
declare const getRunesBalanceMethodName = "getRunesBalance";
|
|
633
|
+
declare const getRunesBalanceParamsSchema: v.NullSchema<undefined>;
|
|
634
|
+
declare const getRunesBalanceResultSchema: v.ObjectSchema<{
|
|
635
|
+
readonly balances: v.ArraySchema<v.ObjectSchema<{
|
|
636
|
+
readonly runeName: v.StringSchema<undefined>;
|
|
637
|
+
readonly amount: v.StringSchema<undefined>;
|
|
638
|
+
readonly divisibility: v.NumberSchema<undefined>;
|
|
639
|
+
readonly symbol: v.StringSchema<undefined>;
|
|
640
|
+
readonly inscriptionId: v.NullishSchema<v.StringSchema<undefined>, never>;
|
|
641
|
+
}, undefined>, undefined>;
|
|
642
|
+
}, undefined>;
|
|
643
|
+
declare const getRunesBalanceRequestMessageSchema: v.ObjectSchema<{
|
|
644
|
+
readonly method: v.LiteralSchema<"getRunesBalance", undefined>;
|
|
645
|
+
readonly params: v.NullSchema<undefined>;
|
|
646
|
+
readonly id: v.StringSchema<undefined>;
|
|
647
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
648
|
+
}, undefined>;
|
|
649
|
+
type GetRunesBalance = MethodParamsAndResult<v.InferOutput<typeof getRunesBalanceParamsSchema>, v.InferOutput<typeof getRunesBalanceResultSchema>>;
|
|
587
650
|
|
|
588
651
|
interface Pubkey {
|
|
589
652
|
/**
|
|
@@ -765,6 +828,27 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
765
828
|
type SignTransactionResult = Transaction;
|
|
766
829
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
767
830
|
|
|
831
|
+
declare const grantPermissionsMethodName = "wallet_grantPermissions";
|
|
832
|
+
declare const grantPermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
833
|
+
declare const grantPermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
834
|
+
declare const grantPermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
835
|
+
readonly method: v.LiteralSchema<"wallet_grantPermissions", undefined>;
|
|
836
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
837
|
+
readonly id: v.StringSchema<undefined>;
|
|
838
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
839
|
+
}, undefined>;
|
|
840
|
+
type Connect = MethodParamsAndResult<v.InferOutput<typeof grantPermissionsParamsSchema>, v.InferOutput<typeof grantPermissionsResultSchema>>;
|
|
841
|
+
declare const revokePermissionsMethodName = "wallet_revokePermissions";
|
|
842
|
+
declare const revokePermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
843
|
+
declare const revokePermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
844
|
+
declare const revokePermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
845
|
+
readonly method: v.LiteralSchema<"wallet_revokePermissions", undefined>;
|
|
846
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
847
|
+
readonly id: v.StringSchema<undefined>;
|
|
848
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
849
|
+
}, undefined>;
|
|
850
|
+
type Disconnect = MethodParamsAndResult<v.InferOutput<typeof revokePermissionsParamsSchema>, v.InferOutput<typeof revokePermissionsResultSchema>>;
|
|
851
|
+
|
|
768
852
|
interface StxRequests {
|
|
769
853
|
stx_callContract: StxCallContract;
|
|
770
854
|
stx_deployContract: StxDeployContract;
|
|
@@ -780,6 +864,7 @@ interface BtcRequests {
|
|
|
780
864
|
getInfo: GetInfo;
|
|
781
865
|
getAddresses: GetAddresses;
|
|
782
866
|
getAccounts: GetAccounts;
|
|
867
|
+
getBalance: GetBalance;
|
|
783
868
|
signMessage: SignMessage;
|
|
784
869
|
sendTransfer: SendTransfer;
|
|
785
870
|
signPsbt: SignPsbt;
|
|
@@ -796,11 +881,15 @@ interface RunesRequests {
|
|
|
796
881
|
runes_getBalance: GetRunesBalance;
|
|
797
882
|
}
|
|
798
883
|
type RunesRequestMethod = keyof RunesRequests;
|
|
799
|
-
|
|
884
|
+
interface WalletMethods {
|
|
885
|
+
wallet_connect: Connect;
|
|
886
|
+
wallet_disconnect: Disconnect;
|
|
887
|
+
}
|
|
888
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
|
|
800
889
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
801
890
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
802
891
|
|
|
803
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
892
|
+
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
804
893
|
|
|
805
894
|
declare abstract class SatsConnectAdapter {
|
|
806
895
|
abstract readonly id: string;
|
|
@@ -818,10 +907,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
818
907
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
819
908
|
id: string;
|
|
820
909
|
constructor(providerId: string);
|
|
821
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
910
|
+
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
822
911
|
}
|
|
823
912
|
|
|
824
913
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
825
914
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
826
915
|
|
|
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 };
|
|
916
|
+
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 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 GetOrder, type GetRunesBalance, type InputToSign, type MethodParamsAndResult, type MintRunes, type MintRunesParams, type MintRunesResult, type Params, type Provider, type PsbtPayload, type RbfOrder, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, 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, getProviderById, getProviderOrThrow, getProviders, getRunesBalanceMethodName, getRunesBalanceParamsSchema, getRunesBalanceRequestMessageSchema, getRunesBalanceResultSchema, getSupportedWallets, grantPermissionsMethodName, grantPermissionsParamsSchema, grantPermissionsRequestMessageSchema, grantPermissionsResultSchema, isProviderInstalled, removeDefaultProvider, request, revokePermissionsMethodName, revokePermissionsParamsSchema, revokePermissionsRequestMessageSchema, revokePermissionsResultSchema, 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 v6 from "valibot";
|
|
530
|
+
|
|
502
531
|
// src/addresses/index.ts
|
|
503
532
|
import { createUnsecuredToken } from "jsontokens";
|
|
504
533
|
|
|
@@ -639,6 +668,84 @@ 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 grantPermissionsMethodName = "wallet_grantPermissions";
|
|
704
|
+
var grantPermissionsParamsSchema = v4.undefined();
|
|
705
|
+
var grantPermissionsResultSchema = v4.literal(true);
|
|
706
|
+
var grantPermissionsRequestMessageSchema = v4.object({
|
|
707
|
+
...rpcRequestMessageSchema.entries,
|
|
708
|
+
...v4.object({
|
|
709
|
+
method: v4.literal(grantPermissionsMethodName),
|
|
710
|
+
params: grantPermissionsParamsSchema,
|
|
711
|
+
id: v4.string()
|
|
712
|
+
}).entries
|
|
713
|
+
});
|
|
714
|
+
var revokePermissionsMethodName = "wallet_revokePermissions";
|
|
715
|
+
var revokePermissionsParamsSchema = v4.undefined();
|
|
716
|
+
var revokePermissionsResultSchema = v4.literal(true);
|
|
717
|
+
var revokePermissionsRequestMessageSchema = v4.object({
|
|
718
|
+
...rpcRequestMessageSchema.entries,
|
|
719
|
+
...v4.object({
|
|
720
|
+
method: v4.literal(revokePermissionsMethodName),
|
|
721
|
+
params: revokePermissionsParamsSchema,
|
|
722
|
+
id: v4.string()
|
|
723
|
+
}).entries
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
// src/request/types/runesMethods.ts
|
|
727
|
+
import * as v5 from "valibot";
|
|
728
|
+
var getRunesBalanceMethodName = "getRunesBalance";
|
|
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
|
+
});
|
|
642
749
|
|
|
643
750
|
// src/request/index.ts
|
|
644
751
|
var request = async (method, params, providerId) => {
|
|
@@ -653,7 +760,13 @@ var request = async (method, params, providerId) => {
|
|
|
653
760
|
throw new Error("A wallet method is required");
|
|
654
761
|
}
|
|
655
762
|
const response = await provider.request(method, params);
|
|
656
|
-
if (
|
|
763
|
+
if (v6.is(rpcErrorResponseMessageSchema, response)) {
|
|
764
|
+
return {
|
|
765
|
+
status: "error",
|
|
766
|
+
error: response.error
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
if (v6.is(rpcSuccessResponseMessageSchema, response)) {
|
|
657
770
|
return {
|
|
658
771
|
status: "success",
|
|
659
772
|
result: response.result
|
|
@@ -661,12 +774,13 @@ var request = async (method, params, providerId) => {
|
|
|
661
774
|
}
|
|
662
775
|
return {
|
|
663
776
|
status: "error",
|
|
664
|
-
error:
|
|
777
|
+
error: {
|
|
778
|
+
code: -32603 /* INTERNAL_ERROR */,
|
|
779
|
+
message: "Received unknown response from provider.",
|
|
780
|
+
data: response
|
|
781
|
+
}
|
|
665
782
|
};
|
|
666
783
|
};
|
|
667
|
-
var isRpcSuccessResponse = (response) => {
|
|
668
|
-
return Object.hasOwn(response, "result") && !!response.result;
|
|
669
|
-
};
|
|
670
784
|
|
|
671
785
|
// src/adapters/xverse.ts
|
|
672
786
|
var XverseAdapter = class extends SatsConnectAdapter {
|
|
@@ -1082,6 +1196,7 @@ export {
|
|
|
1082
1196
|
BitcoinNetworkType,
|
|
1083
1197
|
DefaultAdaptersInfo,
|
|
1084
1198
|
RpcErrorCode,
|
|
1199
|
+
RpcIdSchema,
|
|
1085
1200
|
SatsConnectAdapter,
|
|
1086
1201
|
addressSchema,
|
|
1087
1202
|
createInscription,
|
|
@@ -1096,6 +1211,10 @@ export {
|
|
|
1096
1211
|
getAddressesParamsSchema,
|
|
1097
1212
|
getAddressesRequestMessageSchema,
|
|
1098
1213
|
getAddressesResultSchema,
|
|
1214
|
+
getBalanceMethodName,
|
|
1215
|
+
getBalanceParamsSchema,
|
|
1216
|
+
getBalanceRequestMessageSchema,
|
|
1217
|
+
getBalanceResultSchema,
|
|
1099
1218
|
getCapabilities,
|
|
1100
1219
|
getDefaultProvider,
|
|
1101
1220
|
getInfoMethodName,
|
|
@@ -1105,11 +1224,26 @@ export {
|
|
|
1105
1224
|
getProviderById,
|
|
1106
1225
|
getProviderOrThrow,
|
|
1107
1226
|
getProviders,
|
|
1227
|
+
getRunesBalanceMethodName,
|
|
1228
|
+
getRunesBalanceParamsSchema,
|
|
1229
|
+
getRunesBalanceRequestMessageSchema,
|
|
1230
|
+
getRunesBalanceResultSchema,
|
|
1108
1231
|
getSupportedWallets,
|
|
1232
|
+
grantPermissionsMethodName,
|
|
1233
|
+
grantPermissionsParamsSchema,
|
|
1234
|
+
grantPermissionsRequestMessageSchema,
|
|
1235
|
+
grantPermissionsResultSchema,
|
|
1109
1236
|
isProviderInstalled,
|
|
1110
1237
|
removeDefaultProvider,
|
|
1111
1238
|
request,
|
|
1239
|
+
revokePermissionsMethodName,
|
|
1240
|
+
revokePermissionsParamsSchema,
|
|
1241
|
+
revokePermissionsRequestMessageSchema,
|
|
1242
|
+
revokePermissionsResultSchema,
|
|
1243
|
+
rpcErrorResponseMessageSchema,
|
|
1112
1244
|
rpcRequestMessageSchema,
|
|
1245
|
+
rpcResponseMessageSchema,
|
|
1246
|
+
rpcSuccessResponseMessageSchema,
|
|
1113
1247
|
sendBtcTransaction,
|
|
1114
1248
|
setDefaultProvider,
|
|
1115
1249
|
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-aaf7b1c",
|
|
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"
|