@sats-connect/core 0.0.11-6fcd68a → 0.0.11-799c3e5
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 +72 -6
- package/dist/index.mjs +94 -9
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -159,6 +159,8 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
159
159
|
payload: Payload;
|
|
160
160
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
161
161
|
}
|
|
162
|
+
declare const RpcIdSchema: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
163
|
+
type RpcId = v.InferOutput<typeof RpcIdSchema>;
|
|
162
164
|
declare const rpcRequestMessageSchema: v.ObjectSchema<{
|
|
163
165
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
164
166
|
readonly method: v.StringSchema<undefined>;
|
|
@@ -166,7 +168,6 @@ declare const rpcRequestMessageSchema: v.ObjectSchema<{
|
|
|
166
168
|
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
167
169
|
}, undefined>;
|
|
168
170
|
type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
|
|
169
|
-
type RpcId = string | null;
|
|
170
171
|
interface RpcBase {
|
|
171
172
|
jsonrpc: '2.0';
|
|
172
173
|
id: RpcId;
|
|
@@ -213,8 +214,31 @@ 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.UnknownSchema;
|
|
226
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
227
|
+
}, undefined>;
|
|
228
|
+
declare const rpcErrorResponseMessageSchema: v.ObjectSchema<{
|
|
229
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
230
|
+
readonly error: v.UnknownSchema;
|
|
231
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
232
|
+
}, undefined>;
|
|
233
|
+
declare const rpcResponseMessageSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
234
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
235
|
+
readonly result: v.UnknownSchema;
|
|
236
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
237
|
+
}, undefined>, v.ObjectSchema<{
|
|
238
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
239
|
+
readonly error: v.UnknownSchema;
|
|
240
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
241
|
+
}, undefined>], undefined>;
|
|
218
242
|
interface RpcError {
|
|
219
243
|
code: number | RpcErrorCode;
|
|
220
244
|
message: string;
|
|
@@ -461,6 +485,22 @@ declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
|
|
|
461
485
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
462
486
|
}, undefined>;
|
|
463
487
|
type GetAccounts = MethodParamsAndResult<v.InferOutput<typeof getAccountsParamsSchema>, v.InferOutput<typeof getAccountsResultSchema>>;
|
|
488
|
+
declare const getBalanceMethodName = "getBalance";
|
|
489
|
+
declare const getBalanceParamsSchema: v.UndefinedSchema<undefined>;
|
|
490
|
+
declare const getBalanceResultSchema: v.ObjectSchema<{
|
|
491
|
+
/**
|
|
492
|
+
* The balance of the wallet in sats.
|
|
493
|
+
*/
|
|
494
|
+
readonly confirmedBalance: v.BigintSchema<undefined>;
|
|
495
|
+
readonly unconfirmedUtxosBalance: v.BigintSchema<undefined>;
|
|
496
|
+
}, undefined>;
|
|
497
|
+
declare const getBalanceSchema: v.ObjectSchema<{
|
|
498
|
+
readonly method: v.LiteralSchema<"getBalance", undefined>;
|
|
499
|
+
readonly id: v.StringSchema<undefined>;
|
|
500
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
501
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
502
|
+
}, undefined>;
|
|
503
|
+
type GetBalance = MethodParamsAndResult<v.InferOutput<typeof getBalanceParamsSchema>, v.InferOutput<typeof getBalanceResultSchema>>;
|
|
464
504
|
|
|
465
505
|
type CreateMintOrderRequest = {
|
|
466
506
|
runeName: string;
|
|
@@ -765,6 +805,27 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
765
805
|
type SignTransactionResult = Transaction;
|
|
766
806
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
767
807
|
|
|
808
|
+
declare const connectMethodName = "wallet_connect";
|
|
809
|
+
declare const connectParamsSchema: v.UndefinedSchema<undefined>;
|
|
810
|
+
declare const connectResultSchema: v.UndefinedSchema<undefined>;
|
|
811
|
+
declare const connectSchema: v.ObjectSchema<{
|
|
812
|
+
readonly method: v.LiteralSchema<"wallet_connect", undefined>;
|
|
813
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
814
|
+
readonly id: v.StringSchema<undefined>;
|
|
815
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
816
|
+
}, undefined>;
|
|
817
|
+
type Connect = MethodParamsAndResult<v.InferOutput<typeof connectParamsSchema>, v.InferOutput<typeof connectResultSchema>>;
|
|
818
|
+
declare const disconnectMethodName = "wallet_disconnect";
|
|
819
|
+
declare const disconnectParamsSchema: v.UndefinedSchema<undefined>;
|
|
820
|
+
declare const disconnectResultSchema: v.UndefinedSchema<undefined>;
|
|
821
|
+
declare const disconnectSchema: v.ObjectSchema<{
|
|
822
|
+
readonly method: v.LiteralSchema<"wallet_disconnect", undefined>;
|
|
823
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
824
|
+
readonly id: v.StringSchema<undefined>;
|
|
825
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
826
|
+
}, undefined>;
|
|
827
|
+
type Disconnect = MethodParamsAndResult<v.InferOutput<typeof disconnectParamsSchema>, v.InferOutput<typeof disconnectResultSchema>>;
|
|
828
|
+
|
|
768
829
|
interface StxRequests {
|
|
769
830
|
stx_callContract: StxCallContract;
|
|
770
831
|
stx_deployContract: StxDeployContract;
|
|
@@ -780,6 +841,7 @@ interface BtcRequests {
|
|
|
780
841
|
getInfo: GetInfo;
|
|
781
842
|
getAddresses: GetAddresses;
|
|
782
843
|
getAccounts: GetAccounts;
|
|
844
|
+
getBalance: GetBalance;
|
|
783
845
|
signMessage: SignMessage;
|
|
784
846
|
sendTransfer: SendTransfer;
|
|
785
847
|
signPsbt: SignPsbt;
|
|
@@ -796,11 +858,15 @@ interface RunesRequests {
|
|
|
796
858
|
runes_getBalance: GetRunesBalance;
|
|
797
859
|
}
|
|
798
860
|
type RunesRequestMethod = keyof RunesRequests;
|
|
799
|
-
|
|
861
|
+
interface WalletMethods {
|
|
862
|
+
wallet_connect: Connect;
|
|
863
|
+
wallet_disconnect: Disconnect;
|
|
864
|
+
}
|
|
865
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
|
|
800
866
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
801
867
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
802
868
|
|
|
803
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
869
|
+
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
804
870
|
|
|
805
871
|
declare abstract class SatsConnectAdapter {
|
|
806
872
|
abstract readonly id: string;
|
|
@@ -818,10 +884,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
818
884
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
819
885
|
id: string;
|
|
820
886
|
constructor(providerId: string);
|
|
821
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
887
|
+
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
822
888
|
}
|
|
823
889
|
|
|
824
890
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
825
891
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
826
892
|
|
|
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 };
|
|
893
|
+
export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type Connect, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type Disconnect, type GetAccounts, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type InputToSign, type MethodParamsAndResult, type Params, type Provider, type PsbtPayload, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcId, RpcIdSchema, type RpcRequest, type RpcRequestMessage, type RpcResponse, type RpcResult, type RpcSuccessResponse, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, type WalletMethods, addressSchema, connectMethodName, connectParamsSchema, connectResultSchema, connectSchema, createInscription, createRepeatInscriptions, defaultAdapters, disconnectMethodName, disconnectParamsSchema, disconnectResultSchema, disconnectSchema, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceResultSchema, getBalanceSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction };
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
|
6
6
|
BitcoinNetworkType2["Signet"] = "Signet";
|
|
7
7
|
return BitcoinNetworkType2;
|
|
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:
|
|
24
|
+
id: RpcIdSchema
|
|
24
25
|
});
|
|
25
26
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
26
27
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
@@ -30,8 +31,23 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
30
31
|
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
31
32
|
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
32
33
|
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
34
|
+
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
33
35
|
return RpcErrorCode2;
|
|
34
36
|
})(RpcErrorCode || {});
|
|
37
|
+
var rpcSuccessResponseMessageSchema = v.object({
|
|
38
|
+
jsonrpc: v.literal("2.0"),
|
|
39
|
+
result: v.unknown(),
|
|
40
|
+
id: RpcIdSchema
|
|
41
|
+
});
|
|
42
|
+
var rpcErrorResponseMessageSchema = v.object({
|
|
43
|
+
jsonrpc: v.literal("2.0"),
|
|
44
|
+
error: v.unknown(),
|
|
45
|
+
id: RpcIdSchema
|
|
46
|
+
});
|
|
47
|
+
var rpcResponseMessageSchema = v.union([
|
|
48
|
+
rpcSuccessResponseMessageSchema,
|
|
49
|
+
rpcErrorResponseMessageSchema
|
|
50
|
+
]);
|
|
35
51
|
|
|
36
52
|
// src/runes/api.ts
|
|
37
53
|
import axios from "axios";
|
|
@@ -509,6 +525,9 @@ function getSupportedWallets() {
|
|
|
509
525
|
return wallets;
|
|
510
526
|
}
|
|
511
527
|
|
|
528
|
+
// src/request/index.ts
|
|
529
|
+
import * as v5 from "valibot";
|
|
530
|
+
|
|
512
531
|
// src/addresses/index.ts
|
|
513
532
|
import { createUnsecuredToken } from "jsontokens";
|
|
514
533
|
|
|
@@ -649,6 +668,47 @@ var getAccountsRequestMessageSchema = v3.object({
|
|
|
649
668
|
id: v3.string()
|
|
650
669
|
}).entries
|
|
651
670
|
});
|
|
671
|
+
var getBalanceMethodName = "getBalance";
|
|
672
|
+
var getBalanceParamsSchema = v3.undefined();
|
|
673
|
+
var getBalanceResultSchema = v3.object({
|
|
674
|
+
/**
|
|
675
|
+
* The balance of the wallet in sats.
|
|
676
|
+
*/
|
|
677
|
+
confirmedBalance: v3.bigint(),
|
|
678
|
+
unconfirmedUtxosBalance: v3.bigint()
|
|
679
|
+
});
|
|
680
|
+
var getBalanceSchema = v3.object({
|
|
681
|
+
...rpcRequestMessageSchema.entries,
|
|
682
|
+
...v3.object({
|
|
683
|
+
method: v3.literal(getBalanceMethodName),
|
|
684
|
+
id: v3.string()
|
|
685
|
+
}).entries
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
// src/request/types/walletMethods.ts
|
|
689
|
+
import * as v4 from "valibot";
|
|
690
|
+
var connectMethodName = "wallet_connect";
|
|
691
|
+
var connectParamsSchema = v4.undefined();
|
|
692
|
+
var connectResultSchema = v4.undefined();
|
|
693
|
+
var connectSchema = v4.object({
|
|
694
|
+
...rpcRequestMessageSchema.entries,
|
|
695
|
+
...v4.object({
|
|
696
|
+
method: v4.literal(connectMethodName),
|
|
697
|
+
params: connectParamsSchema,
|
|
698
|
+
id: v4.string()
|
|
699
|
+
}).entries
|
|
700
|
+
});
|
|
701
|
+
var disconnectMethodName = "wallet_disconnect";
|
|
702
|
+
var disconnectParamsSchema = v4.undefined();
|
|
703
|
+
var disconnectResultSchema = v4.undefined();
|
|
704
|
+
var disconnectSchema = v4.object({
|
|
705
|
+
...rpcRequestMessageSchema.entries,
|
|
706
|
+
...v4.object({
|
|
707
|
+
method: v4.literal(disconnectMethodName),
|
|
708
|
+
params: disconnectParamsSchema,
|
|
709
|
+
id: v4.string()
|
|
710
|
+
}).entries
|
|
711
|
+
});
|
|
652
712
|
|
|
653
713
|
// src/request/index.ts
|
|
654
714
|
var request = async (method, params, providerId) => {
|
|
@@ -663,20 +723,29 @@ var request = async (method, params, providerId) => {
|
|
|
663
723
|
throw new Error("A wallet method is required");
|
|
664
724
|
}
|
|
665
725
|
const response = await provider.request(method, params);
|
|
666
|
-
|
|
726
|
+
const parseResult = v5.safeParse(rpcResponseMessageSchema, response);
|
|
727
|
+
if (!parseResult.success) {
|
|
728
|
+
return {
|
|
729
|
+
status: "error",
|
|
730
|
+
error: {
|
|
731
|
+
code: -32603 /* INTERNAL_ERROR */,
|
|
732
|
+
message: "Received unknown response from provider.",
|
|
733
|
+
data: response
|
|
734
|
+
}
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
const parsedResponse = parseResult.output;
|
|
738
|
+
if ("error" in parsedResponse) {
|
|
667
739
|
return {
|
|
668
|
-
status: "
|
|
669
|
-
|
|
740
|
+
status: "error",
|
|
741
|
+
error: parsedResponse.error
|
|
670
742
|
};
|
|
671
743
|
}
|
|
672
744
|
return {
|
|
673
|
-
status: "
|
|
674
|
-
|
|
745
|
+
status: "success",
|
|
746
|
+
result: parsedResponse.result
|
|
675
747
|
};
|
|
676
748
|
};
|
|
677
|
-
var isRpcSuccessResponse = (response) => {
|
|
678
|
-
return Object.hasOwn(response, "result") && !!response.result;
|
|
679
|
-
};
|
|
680
749
|
|
|
681
750
|
// src/adapters/xverse.ts
|
|
682
751
|
var XverseAdapter = class extends SatsConnectAdapter {
|
|
@@ -1092,11 +1161,20 @@ export {
|
|
|
1092
1161
|
BitcoinNetworkType,
|
|
1093
1162
|
DefaultAdaptersInfo,
|
|
1094
1163
|
RpcErrorCode,
|
|
1164
|
+
RpcIdSchema,
|
|
1095
1165
|
SatsConnectAdapter,
|
|
1096
1166
|
addressSchema,
|
|
1167
|
+
connectMethodName,
|
|
1168
|
+
connectParamsSchema,
|
|
1169
|
+
connectResultSchema,
|
|
1170
|
+
connectSchema,
|
|
1097
1171
|
createInscription,
|
|
1098
1172
|
createRepeatInscriptions,
|
|
1099
1173
|
defaultAdapters,
|
|
1174
|
+
disconnectMethodName,
|
|
1175
|
+
disconnectParamsSchema,
|
|
1176
|
+
disconnectResultSchema,
|
|
1177
|
+
disconnectSchema,
|
|
1100
1178
|
getAccountsMethodName,
|
|
1101
1179
|
getAccountsParamsSchema,
|
|
1102
1180
|
getAccountsRequestMessageSchema,
|
|
@@ -1106,6 +1184,10 @@ export {
|
|
|
1106
1184
|
getAddressesParamsSchema,
|
|
1107
1185
|
getAddressesRequestMessageSchema,
|
|
1108
1186
|
getAddressesResultSchema,
|
|
1187
|
+
getBalanceMethodName,
|
|
1188
|
+
getBalanceParamsSchema,
|
|
1189
|
+
getBalanceResultSchema,
|
|
1190
|
+
getBalanceSchema,
|
|
1109
1191
|
getCapabilities,
|
|
1110
1192
|
getDefaultProvider,
|
|
1111
1193
|
getInfoMethodName,
|
|
@@ -1119,7 +1201,10 @@ export {
|
|
|
1119
1201
|
isProviderInstalled,
|
|
1120
1202
|
removeDefaultProvider,
|
|
1121
1203
|
request,
|
|
1204
|
+
rpcErrorResponseMessageSchema,
|
|
1122
1205
|
rpcRequestMessageSchema,
|
|
1206
|
+
rpcResponseMessageSchema,
|
|
1207
|
+
rpcSuccessResponseMessageSchema,
|
|
1123
1208
|
sendBtcTransaction,
|
|
1124
1209
|
setDefaultProvider,
|
|
1125
1210
|
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-799c3e5",
|
|
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"
|