@sats-connect/core 0.0.11-a271383 → 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 +90 -26
- package/dist/index.mjs +122 -31
- 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,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,26 +828,26 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
765
828
|
type SignTransactionResult = Transaction;
|
|
766
829
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
767
830
|
|
|
768
|
-
declare const
|
|
769
|
-
declare const
|
|
770
|
-
declare const
|
|
771
|
-
declare const
|
|
772
|
-
readonly method: v.LiteralSchema<"
|
|
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>;
|
|
773
836
|
readonly params: v.UndefinedSchema<undefined>;
|
|
774
837
|
readonly id: v.StringSchema<undefined>;
|
|
775
838
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
776
839
|
}, undefined>;
|
|
777
|
-
type Connect = MethodParamsAndResult<v.InferOutput<typeof
|
|
778
|
-
declare const
|
|
779
|
-
declare const
|
|
780
|
-
declare const
|
|
781
|
-
declare const
|
|
782
|
-
readonly method: v.LiteralSchema<"
|
|
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>;
|
|
783
846
|
readonly params: v.UndefinedSchema<undefined>;
|
|
784
847
|
readonly id: v.StringSchema<undefined>;
|
|
785
848
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
786
849
|
}, undefined>;
|
|
787
|
-
type Disconnect = MethodParamsAndResult<v.InferOutput<typeof
|
|
850
|
+
type Disconnect = MethodParamsAndResult<v.InferOutput<typeof revokePermissionsParamsSchema>, v.InferOutput<typeof revokePermissionsResultSchema>>;
|
|
788
851
|
|
|
789
852
|
interface StxRequests {
|
|
790
853
|
stx_callContract: StxCallContract;
|
|
@@ -801,6 +864,7 @@ interface BtcRequests {
|
|
|
801
864
|
getInfo: GetInfo;
|
|
802
865
|
getAddresses: GetAddresses;
|
|
803
866
|
getAccounts: GetAccounts;
|
|
867
|
+
getBalance: GetBalance;
|
|
804
868
|
signMessage: SignMessage;
|
|
805
869
|
sendTransfer: SendTransfer;
|
|
806
870
|
signPsbt: SignPsbt;
|
|
@@ -849,4 +913,4 @@ declare class BaseAdapter extends SatsConnectAdapter {
|
|
|
849
913
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
850
914
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
851
915
|
|
|
852
|
-
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 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,
|
|
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,11 +1,12 @@
|
|
|
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(),
|
|
@@ -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.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
|
+
]);
|
|
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 v6 from "valibot";
|
|
530
|
+
|
|
512
531
|
// src/addresses/index.ts
|
|
513
532
|
import { createUnsecuredToken } from "jsontokens";
|
|
514
533
|
|
|
@@ -649,32 +668,85 @@ 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 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
|
+
});
|
|
652
700
|
|
|
653
701
|
// src/request/types/walletMethods.ts
|
|
654
702
|
import * as v4 from "valibot";
|
|
655
|
-
var
|
|
656
|
-
var
|
|
657
|
-
var
|
|
658
|
-
var
|
|
703
|
+
var grantPermissionsMethodName = "wallet_grantPermissions";
|
|
704
|
+
var grantPermissionsParamsSchema = v4.undefined();
|
|
705
|
+
var grantPermissionsResultSchema = v4.literal(true);
|
|
706
|
+
var grantPermissionsRequestMessageSchema = v4.object({
|
|
659
707
|
...rpcRequestMessageSchema.entries,
|
|
660
708
|
...v4.object({
|
|
661
|
-
method: v4.literal(
|
|
662
|
-
params:
|
|
709
|
+
method: v4.literal(grantPermissionsMethodName),
|
|
710
|
+
params: grantPermissionsParamsSchema,
|
|
663
711
|
id: v4.string()
|
|
664
712
|
}).entries
|
|
665
713
|
});
|
|
666
|
-
var
|
|
667
|
-
var
|
|
668
|
-
var
|
|
669
|
-
var
|
|
714
|
+
var revokePermissionsMethodName = "wallet_revokePermissions";
|
|
715
|
+
var revokePermissionsParamsSchema = v4.undefined();
|
|
716
|
+
var revokePermissionsResultSchema = v4.literal(true);
|
|
717
|
+
var revokePermissionsRequestMessageSchema = v4.object({
|
|
670
718
|
...rpcRequestMessageSchema.entries,
|
|
671
719
|
...v4.object({
|
|
672
|
-
method: v4.literal(
|
|
673
|
-
params:
|
|
720
|
+
method: v4.literal(revokePermissionsMethodName),
|
|
721
|
+
params: revokePermissionsParamsSchema,
|
|
674
722
|
id: v4.string()
|
|
675
723
|
}).entries
|
|
676
724
|
});
|
|
677
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
|
+
});
|
|
749
|
+
|
|
678
750
|
// src/request/index.ts
|
|
679
751
|
var request = async (method, params, providerId) => {
|
|
680
752
|
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
@@ -688,7 +760,13 @@ var request = async (method, params, providerId) => {
|
|
|
688
760
|
throw new Error("A wallet method is required");
|
|
689
761
|
}
|
|
690
762
|
const response = await provider.request(method, params);
|
|
691
|
-
if (
|
|
763
|
+
if (v6.is(rpcErrorResponseMessageSchema, response)) {
|
|
764
|
+
return {
|
|
765
|
+
status: "error",
|
|
766
|
+
error: response.error
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
if (v6.is(rpcSuccessResponseMessageSchema, response)) {
|
|
692
770
|
return {
|
|
693
771
|
status: "success",
|
|
694
772
|
result: response.result
|
|
@@ -696,12 +774,13 @@ var request = async (method, params, providerId) => {
|
|
|
696
774
|
}
|
|
697
775
|
return {
|
|
698
776
|
status: "error",
|
|
699
|
-
error:
|
|
777
|
+
error: {
|
|
778
|
+
code: -32603 /* INTERNAL_ERROR */,
|
|
779
|
+
message: "Received unknown response from provider.",
|
|
780
|
+
data: response
|
|
781
|
+
}
|
|
700
782
|
};
|
|
701
783
|
};
|
|
702
|
-
var isRpcSuccessResponse = (response) => {
|
|
703
|
-
return Object.hasOwn(response, "result") && !!response.result;
|
|
704
|
-
};
|
|
705
784
|
|
|
706
785
|
// src/adapters/xverse.ts
|
|
707
786
|
var XverseAdapter = class extends SatsConnectAdapter {
|
|
@@ -1117,19 +1196,12 @@ export {
|
|
|
1117
1196
|
BitcoinNetworkType,
|
|
1118
1197
|
DefaultAdaptersInfo,
|
|
1119
1198
|
RpcErrorCode,
|
|
1199
|
+
RpcIdSchema,
|
|
1120
1200
|
SatsConnectAdapter,
|
|
1121
1201
|
addressSchema,
|
|
1122
|
-
connectMethodName,
|
|
1123
|
-
connectParamsSchema,
|
|
1124
|
-
connectResultSchema,
|
|
1125
|
-
connectSchema,
|
|
1126
1202
|
createInscription,
|
|
1127
1203
|
createRepeatInscriptions,
|
|
1128
1204
|
defaultAdapters,
|
|
1129
|
-
disconnectMethodName,
|
|
1130
|
-
disconnectParamsSchema,
|
|
1131
|
-
disconnectResultSchema,
|
|
1132
|
-
disconnectSchema,
|
|
1133
1205
|
getAccountsMethodName,
|
|
1134
1206
|
getAccountsParamsSchema,
|
|
1135
1207
|
getAccountsRequestMessageSchema,
|
|
@@ -1139,6 +1211,10 @@ export {
|
|
|
1139
1211
|
getAddressesParamsSchema,
|
|
1140
1212
|
getAddressesRequestMessageSchema,
|
|
1141
1213
|
getAddressesResultSchema,
|
|
1214
|
+
getBalanceMethodName,
|
|
1215
|
+
getBalanceParamsSchema,
|
|
1216
|
+
getBalanceRequestMessageSchema,
|
|
1217
|
+
getBalanceResultSchema,
|
|
1142
1218
|
getCapabilities,
|
|
1143
1219
|
getDefaultProvider,
|
|
1144
1220
|
getInfoMethodName,
|
|
@@ -1148,11 +1224,26 @@ export {
|
|
|
1148
1224
|
getProviderById,
|
|
1149
1225
|
getProviderOrThrow,
|
|
1150
1226
|
getProviders,
|
|
1227
|
+
getRunesBalanceMethodName,
|
|
1228
|
+
getRunesBalanceParamsSchema,
|
|
1229
|
+
getRunesBalanceRequestMessageSchema,
|
|
1230
|
+
getRunesBalanceResultSchema,
|
|
1151
1231
|
getSupportedWallets,
|
|
1232
|
+
grantPermissionsMethodName,
|
|
1233
|
+
grantPermissionsParamsSchema,
|
|
1234
|
+
grantPermissionsRequestMessageSchema,
|
|
1235
|
+
grantPermissionsResultSchema,
|
|
1152
1236
|
isProviderInstalled,
|
|
1153
1237
|
removeDefaultProvider,
|
|
1154
1238
|
request,
|
|
1239
|
+
revokePermissionsMethodName,
|
|
1240
|
+
revokePermissionsParamsSchema,
|
|
1241
|
+
revokePermissionsRequestMessageSchema,
|
|
1242
|
+
revokePermissionsResultSchema,
|
|
1243
|
+
rpcErrorResponseMessageSchema,
|
|
1155
1244
|
rpcRequestMessageSchema,
|
|
1245
|
+
rpcResponseMessageSchema,
|
|
1246
|
+
rpcSuccessResponseMessageSchema,
|
|
1156
1247
|
sendBtcTransaction,
|
|
1157
1248
|
setDefaultProvider,
|
|
1158
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"
|