@sats-connect/core 0.0.15 → 0.1.0-6ee3e3f
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 +73 -10
- package/dist/index.mjs +174 -100
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -339,7 +339,9 @@ declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
|
339
339
|
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
340
340
|
readonly address: v.StringSchema<undefined>;
|
|
341
341
|
readonly publicKey: v.StringSchema<undefined>;
|
|
342
|
-
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
342
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>; /**
|
|
343
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
344
|
+
*/
|
|
343
345
|
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
344
346
|
}, undefined>, undefined>;
|
|
345
347
|
}, undefined>;
|
|
@@ -476,9 +478,12 @@ declare const getAccountsParamsSchema: v.ObjectSchema<{
|
|
|
476
478
|
}, undefined>;
|
|
477
479
|
type GetAccountsParams = v.InferOutput<typeof getAccountsParamsSchema>;
|
|
478
480
|
declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
|
|
481
|
+
readonly walletType: v.PicklistSchema<readonly ["software", "ledger"], undefined>;
|
|
479
482
|
readonly address: v.StringSchema<undefined>;
|
|
480
483
|
readonly publicKey: v.StringSchema<undefined>;
|
|
481
|
-
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
484
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>; /**
|
|
485
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
486
|
+
*/
|
|
482
487
|
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
483
488
|
}, undefined>, undefined>;
|
|
484
489
|
type GetAccountsResult = v.InferOutput<typeof getAccountsResultSchema>;
|
|
@@ -901,9 +906,52 @@ declare const stxGetAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
|
901
906
|
}, undefined>;
|
|
902
907
|
type StxGetAddressesRequestMessage = v.InferOutput<typeof stxGetAddressesRequestMessageSchema>;
|
|
903
908
|
type StxGetAddresses = MethodParamsAndResult<v.InferOutput<typeof stxGetAddressesParamsSchema>, v.InferOutput<typeof stxGetAddressesResultSchema>>;
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
909
|
+
declare const stxSignTransactionMethodName = "stx_signTransaction";
|
|
910
|
+
declare const stxSignTransactionParamsSchema: v.ObjectSchema<{
|
|
911
|
+
/**
|
|
912
|
+
* The transaction to sign as a hex-encoded string.
|
|
913
|
+
*/
|
|
914
|
+
readonly transaction: v.StringSchema<undefined>;
|
|
915
|
+
/**
|
|
916
|
+
* The public key to sign the transaction with. The wallet may use any key
|
|
917
|
+
* when not provided.
|
|
918
|
+
*/
|
|
919
|
+
readonly pubkey: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
920
|
+
/**
|
|
921
|
+
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
922
|
+
*/
|
|
923
|
+
readonly broadcast: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
924
|
+
}, undefined>;
|
|
925
|
+
type StxSignTransactionParams = v.InferOutput<typeof stxSignTransactionParamsSchema>;
|
|
926
|
+
declare const stxSignTransactionResultSchema: v.ObjectSchema<{
|
|
927
|
+
/**
|
|
928
|
+
* The signed transaction as a hex-encoded string.
|
|
929
|
+
*/
|
|
930
|
+
readonly transaction: v.StringSchema<undefined>;
|
|
931
|
+
}, undefined>;
|
|
932
|
+
type StxSignTransactionResult = v.InferOutput<typeof stxSignTransactionResultSchema>;
|
|
933
|
+
declare const stxSignTransactionRequestMessageSchema: v.ObjectSchema<{
|
|
934
|
+
readonly method: v.LiteralSchema<"stx_signTransaction", undefined>;
|
|
935
|
+
readonly params: v.ObjectSchema<{
|
|
936
|
+
/**
|
|
937
|
+
* The transaction to sign as a hex-encoded string.
|
|
938
|
+
*/
|
|
939
|
+
readonly transaction: v.StringSchema<undefined>;
|
|
940
|
+
/**
|
|
941
|
+
* The public key to sign the transaction with. The wallet may use any key
|
|
942
|
+
* when not provided.
|
|
943
|
+
*/
|
|
944
|
+
readonly pubkey: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
945
|
+
/**
|
|
946
|
+
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
947
|
+
*/
|
|
948
|
+
readonly broadcast: v.OptionalSchema<v.BooleanSchema<undefined>, never>;
|
|
949
|
+
}, undefined>;
|
|
950
|
+
readonly id: v.StringSchema<undefined>;
|
|
951
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
952
|
+
}, undefined>;
|
|
953
|
+
type StxSignTransactionRequestMessage = v.InferOutput<typeof stxSignTransactionRequestMessageSchema>;
|
|
954
|
+
type StxSignTransaction = MethodParamsAndResult<StxSignTransactionParams, StxSignTransactionResult>;
|
|
907
955
|
|
|
908
956
|
declare const requestPermissionsMethodName = "wallet_requestPermissions";
|
|
909
957
|
declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
@@ -925,6 +973,20 @@ declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
|
925
973
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
926
974
|
}, undefined>;
|
|
927
975
|
type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
|
|
976
|
+
declare const getWalletTypeMethodName = "wallet_getWalletType";
|
|
977
|
+
declare const getWalletTypeParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
978
|
+
declare const getWalletTypeResultSchema: v.PicklistSchema<readonly ["software", "ledger"], undefined>;
|
|
979
|
+
declare const getWalletTypeRequestMessageSchema: v.ObjectSchema<{
|
|
980
|
+
readonly method: v.LiteralSchema<"wallet_getWalletType", undefined>;
|
|
981
|
+
readonly id: v.StringSchema<undefined>;
|
|
982
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
983
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
984
|
+
}, undefined>;
|
|
985
|
+
type GetWalletType = MethodParamsAndResult<v.InferOutput<typeof getWalletTypeParamsSchema>, v.InferOutput<typeof getWalletTypeResultSchema>>;
|
|
986
|
+
|
|
987
|
+
declare const walletTypes: readonly ["software", "ledger"];
|
|
988
|
+
declare const walletTypeSchema: v.PicklistSchema<readonly ["software", "ledger"], undefined>;
|
|
989
|
+
type WalletType = v.InferOutput<typeof walletTypeSchema>;
|
|
928
990
|
|
|
929
991
|
interface StxRequests {
|
|
930
992
|
stx_callContract: StxCallContract;
|
|
@@ -962,15 +1024,16 @@ interface OrdinalsRequests {
|
|
|
962
1024
|
ord_getInscriptions: GetInscriptions;
|
|
963
1025
|
}
|
|
964
1026
|
type OrdinalsRequestMethod = keyof OrdinalsRequests;
|
|
965
|
-
interface
|
|
1027
|
+
interface WalletRequests {
|
|
966
1028
|
wallet_requestPermissions: RequestPermissions;
|
|
967
1029
|
wallet_renouncePermissions: RenouncePermissions;
|
|
1030
|
+
wallet_getWalletType: GetWalletType;
|
|
968
1031
|
}
|
|
969
|
-
type Requests = BtcRequests & StxRequests & RunesRequests &
|
|
1032
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletRequests & OrdinalsRequests;
|
|
970
1033
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
971
1034
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
972
1035
|
|
|
973
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof
|
|
1036
|
+
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletRequests | "ord_getInscriptions">(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
974
1037
|
|
|
975
1038
|
declare abstract class SatsConnectAdapter {
|
|
976
1039
|
abstract readonly id: string;
|
|
@@ -988,10 +1051,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
988
1051
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
989
1052
|
id: string;
|
|
990
1053
|
constructor(providerId: string);
|
|
991
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof
|
|
1054
|
+
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletRequests | "ord_getInscriptions">(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
992
1055
|
}
|
|
993
1056
|
|
|
994
1057
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
995
1058
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
996
1059
|
|
|
997
|
-
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 GetAccountsParams, type GetAccountsRequestMessage, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesRequestMessage, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetInfoParams, type GetInfoRequestMessage, type GetInfoResult, type GetInscriptions, type GetOrder, type GetRunesBalance, type GetRunesBalanceParams, type GetRunesBalanceRequestMessage, type GetRunesBalanceResult, 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 SignMessageParams, type SignMessagePayload, type SignMessageRequestMessage, type SignMessageResponse, type SignMessageResult, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type
|
|
1060
|
+
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 GetAccountsParams, type GetAccountsRequestMessage, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesRequestMessage, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetInfoParams, type GetInfoRequestMessage, type GetInfoResult, type GetInscriptions, type GetOrder, type GetRunesBalance, type GetRunesBalanceParams, type GetRunesBalanceRequestMessage, type GetRunesBalanceResult, type GetWalletType, 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 SignMessageParams, type SignMessagePayload, type SignMessageRequestMessage, type SignMessageResponse, type SignMessageResult, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionPayload, type SignTransactionResponse, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAccountsResult, type StxGetAddresses, type StxGetAddressesParams, type StxGetAddressesRequestMessage, type StxGetAddressesResult, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxSignTransactionParams, type StxSignTransactionRequestMessage, type StxSignTransactionResult, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, type WalletRequests, type WalletType, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceRequestMessageSchema, getBalanceResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoRequestMessageSchema, getInfoResultSchema, getInscriptionsMethodName, getInscriptionsParamsSchema, getInscriptionsResultSchema, getInscriptionsSchema, getProviderById, getProviderOrThrow, getProviders, getRunesBalanceMethodName, getRunesBalanceParamsSchema, getRunesBalanceRequestMessageSchema, getRunesBalanceResultSchema, getSupportedWallets, getWalletTypeMethodName, getWalletTypeParamsSchema, getWalletTypeRequestMessageSchema, getWalletTypeResultSchema, isProviderInstalled, removeDefaultProvider, renouncePermissionsMethodName, renouncePermissionsParamsSchema, renouncePermissionsRequestMessageSchema, renouncePermissionsResultSchema, request, requestPermissionsMethodName, requestPermissionsParamsSchema, requestPermissionsRequestMessageSchema, requestPermissionsResultSchema, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction, stxGetAddressesMethodName, stxGetAddressesParamsSchema, stxGetAddressesRequestMessageSchema, stxGetAddressesResultSchema, stxSignTransactionMethodName, stxSignTransactionParamsSchema, stxSignTransactionRequestMessageSchema, stxSignTransactionResultSchema, walletTypeSchema, walletTypes };
|
package/dist/index.mjs
CHANGED
|
@@ -556,7 +556,7 @@ function getSupportedWallets() {
|
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
// src/request/index.ts
|
|
559
|
-
import * as
|
|
559
|
+
import * as v9 from "valibot";
|
|
560
560
|
|
|
561
561
|
// src/addresses/index.ts
|
|
562
562
|
import { createUnsecuredToken } from "jsontokens";
|
|
@@ -627,215 +627,279 @@ var stxGetAddressesRequestMessageSchema = v3.object({
|
|
|
627
627
|
id: v3.string()
|
|
628
628
|
}).entries
|
|
629
629
|
});
|
|
630
|
+
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
631
|
+
var stxSignTransactionParamsSchema = v3.object({
|
|
632
|
+
/**
|
|
633
|
+
* The transaction to sign as a hex-encoded string.
|
|
634
|
+
*/
|
|
635
|
+
transaction: v3.string(),
|
|
636
|
+
/**
|
|
637
|
+
* The public key to sign the transaction with. The wallet may use any key
|
|
638
|
+
* when not provided.
|
|
639
|
+
*/
|
|
640
|
+
pubkey: v3.optional(v3.string()),
|
|
641
|
+
/**
|
|
642
|
+
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
643
|
+
*/
|
|
644
|
+
broadcast: v3.optional(v3.boolean())
|
|
645
|
+
});
|
|
646
|
+
var stxSignTransactionResultSchema = v3.object({
|
|
647
|
+
/**
|
|
648
|
+
* The signed transaction as a hex-encoded string.
|
|
649
|
+
*/
|
|
650
|
+
transaction: v3.string()
|
|
651
|
+
});
|
|
652
|
+
var stxSignTransactionRequestMessageSchema = v3.object({
|
|
653
|
+
...rpcRequestMessageSchema.entries,
|
|
654
|
+
...v3.object({
|
|
655
|
+
method: v3.literal(stxSignTransactionMethodName),
|
|
656
|
+
params: stxSignTransactionParamsSchema,
|
|
657
|
+
id: v3.string()
|
|
658
|
+
}).entries
|
|
659
|
+
});
|
|
630
660
|
|
|
631
661
|
// src/request/types/btcMethods.ts
|
|
662
|
+
import * as v5 from "valibot";
|
|
663
|
+
|
|
664
|
+
// src/request/types/common.ts
|
|
632
665
|
import * as v4 from "valibot";
|
|
666
|
+
var walletTypes = ["software", "ledger"];
|
|
667
|
+
var walletTypeSchema = v4.picklist(walletTypes);
|
|
668
|
+
|
|
669
|
+
// src/request/types/btcMethods.ts
|
|
633
670
|
var getInfoMethodName = "getInfo";
|
|
634
|
-
var getInfoParamsSchema =
|
|
635
|
-
var getInfoResultSchema =
|
|
671
|
+
var getInfoParamsSchema = v5.nullish(v5.null());
|
|
672
|
+
var getInfoResultSchema = v5.object({
|
|
636
673
|
/**
|
|
637
674
|
* Version of the wallet.
|
|
638
675
|
*/
|
|
639
|
-
version:
|
|
676
|
+
version: v5.string(),
|
|
640
677
|
/**
|
|
641
678
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
642
679
|
*/
|
|
643
|
-
methods:
|
|
680
|
+
methods: v5.optional(v5.array(v5.string())),
|
|
644
681
|
/**
|
|
645
682
|
* List of WBIP standards supported by the wallet. Not currently used.
|
|
646
683
|
*/
|
|
647
|
-
supports:
|
|
684
|
+
supports: v5.array(v5.string())
|
|
648
685
|
});
|
|
649
|
-
var getInfoRequestMessageSchema =
|
|
686
|
+
var getInfoRequestMessageSchema = v5.object({
|
|
650
687
|
...rpcRequestMessageSchema.entries,
|
|
651
|
-
...
|
|
652
|
-
method:
|
|
688
|
+
...v5.object({
|
|
689
|
+
method: v5.literal(getInfoMethodName),
|
|
653
690
|
params: getInfoParamsSchema,
|
|
654
|
-
id:
|
|
691
|
+
id: v5.string()
|
|
655
692
|
}).entries
|
|
656
693
|
});
|
|
657
694
|
var getAddressesMethodName = "getAddresses";
|
|
658
|
-
var getAddressesParamsSchema =
|
|
695
|
+
var getAddressesParamsSchema = v5.object({
|
|
659
696
|
/**
|
|
660
697
|
* The purposes for which to generate addresses. See
|
|
661
698
|
* {@linkcode AddressPurpose} for available purposes.
|
|
662
699
|
*/
|
|
663
|
-
purposes:
|
|
700
|
+
purposes: v5.array(v5.enum(AddressPurpose)),
|
|
664
701
|
/**
|
|
665
702
|
* A message to be displayed to the user in the request prompt.
|
|
666
703
|
*/
|
|
667
|
-
message:
|
|
704
|
+
message: v5.optional(v5.string())
|
|
668
705
|
});
|
|
669
|
-
var getAddressesResultSchema =
|
|
706
|
+
var getAddressesResultSchema = v5.object({
|
|
670
707
|
/**
|
|
671
708
|
* The addresses generated for the given purposes.
|
|
672
709
|
*/
|
|
673
|
-
addresses:
|
|
710
|
+
addresses: v5.array(addressSchema)
|
|
674
711
|
});
|
|
675
|
-
var getAddressesRequestMessageSchema =
|
|
712
|
+
var getAddressesRequestMessageSchema = v5.object({
|
|
676
713
|
...rpcRequestMessageSchema.entries,
|
|
677
|
-
...
|
|
678
|
-
method:
|
|
714
|
+
...v5.object({
|
|
715
|
+
method: v5.literal(getAddressesMethodName),
|
|
679
716
|
params: getAddressesParamsSchema,
|
|
680
|
-
id:
|
|
717
|
+
id: v5.string()
|
|
681
718
|
}).entries
|
|
682
719
|
});
|
|
683
720
|
var signMessageMethodName = "signMessage";
|
|
684
|
-
var signMessageParamsSchema =
|
|
721
|
+
var signMessageParamsSchema = v5.object({
|
|
685
722
|
/**
|
|
686
723
|
* The address used for signing.
|
|
687
724
|
**/
|
|
688
|
-
address:
|
|
725
|
+
address: v5.string(),
|
|
689
726
|
/**
|
|
690
727
|
* The message to sign.
|
|
691
728
|
**/
|
|
692
|
-
message:
|
|
729
|
+
message: v5.string()
|
|
693
730
|
});
|
|
694
|
-
var signMessageResultSchema =
|
|
731
|
+
var signMessageResultSchema = v5.object({
|
|
695
732
|
/**
|
|
696
733
|
* The signature of the message.
|
|
697
734
|
*/
|
|
698
|
-
signature:
|
|
735
|
+
signature: v5.string(),
|
|
699
736
|
/**
|
|
700
737
|
* hash of the message.
|
|
701
738
|
*/
|
|
702
|
-
messageHash:
|
|
739
|
+
messageHash: v5.string(),
|
|
703
740
|
/**
|
|
704
741
|
* The address used for signing.
|
|
705
742
|
*/
|
|
706
|
-
address:
|
|
743
|
+
address: v5.string()
|
|
707
744
|
});
|
|
708
|
-
var signMessageRequestMessageSchema =
|
|
745
|
+
var signMessageRequestMessageSchema = v5.object({
|
|
709
746
|
...rpcRequestMessageSchema.entries,
|
|
710
|
-
...
|
|
711
|
-
method:
|
|
747
|
+
...v5.object({
|
|
748
|
+
method: v5.literal(signMessageMethodName),
|
|
712
749
|
params: signMessageParamsSchema,
|
|
713
|
-
id:
|
|
750
|
+
id: v5.string()
|
|
714
751
|
}).entries
|
|
715
752
|
});
|
|
716
753
|
var getAccountsMethodName = "getAccounts";
|
|
717
|
-
var getAccountsParamsSchema =
|
|
718
|
-
|
|
719
|
-
|
|
754
|
+
var getAccountsParamsSchema = v5.object({
|
|
755
|
+
/**
|
|
756
|
+
* The purposes for which to generate addresses. See
|
|
757
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
758
|
+
*/
|
|
759
|
+
purposes: v5.array(v5.enum(AddressPurpose)),
|
|
760
|
+
/**
|
|
761
|
+
* A message to be displayed to the user in the request prompt.
|
|
762
|
+
*/
|
|
763
|
+
message: v5.optional(v5.string())
|
|
764
|
+
});
|
|
765
|
+
var getAccountsResultSchema = v5.array(
|
|
766
|
+
v5.object({
|
|
767
|
+
...addressSchema.entries,
|
|
768
|
+
...v5.object({
|
|
769
|
+
walletType: walletTypeSchema
|
|
770
|
+
}).entries
|
|
771
|
+
})
|
|
772
|
+
);
|
|
773
|
+
var getAccountsRequestMessageSchema = v5.object({
|
|
720
774
|
...rpcRequestMessageSchema.entries,
|
|
721
|
-
...
|
|
722
|
-
method:
|
|
775
|
+
...v5.object({
|
|
776
|
+
method: v5.literal(getAccountsMethodName),
|
|
723
777
|
params: getAccountsParamsSchema,
|
|
724
|
-
id:
|
|
778
|
+
id: v5.string()
|
|
725
779
|
}).entries
|
|
726
780
|
});
|
|
727
781
|
var getBalanceMethodName = "getBalance";
|
|
728
|
-
var getBalanceParamsSchema =
|
|
729
|
-
var getBalanceResultSchema =
|
|
782
|
+
var getBalanceParamsSchema = v5.nullish(v5.null());
|
|
783
|
+
var getBalanceResultSchema = v5.object({
|
|
730
784
|
/**
|
|
731
785
|
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
732
786
|
* messages not supporting bigint
|
|
733
787
|
* (https://issues.chromium.org/issues/40116184).
|
|
734
788
|
*/
|
|
735
|
-
confirmed:
|
|
789
|
+
confirmed: v5.string(),
|
|
736
790
|
/**
|
|
737
791
|
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
738
792
|
* messages not supporting bigint
|
|
739
793
|
* (https://issues.chromium.org/issues/40116184).
|
|
740
794
|
*/
|
|
741
|
-
unconfirmed:
|
|
795
|
+
unconfirmed: v5.string(),
|
|
742
796
|
/**
|
|
743
797
|
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
744
798
|
* sats. Using a string due to chrome messages not supporting bigint
|
|
745
799
|
* (https://issues.chromium.org/issues/40116184).
|
|
746
800
|
*/
|
|
747
|
-
total:
|
|
801
|
+
total: v5.string()
|
|
748
802
|
});
|
|
749
|
-
var getBalanceRequestMessageSchema =
|
|
803
|
+
var getBalanceRequestMessageSchema = v5.object({
|
|
750
804
|
...rpcRequestMessageSchema.entries,
|
|
751
|
-
...
|
|
752
|
-
method:
|
|
753
|
-
id:
|
|
805
|
+
...v5.object({
|
|
806
|
+
method: v5.literal(getBalanceMethodName),
|
|
807
|
+
id: v5.string()
|
|
754
808
|
}).entries
|
|
755
809
|
});
|
|
756
810
|
|
|
757
811
|
// src/request/types/walletMethods.ts
|
|
758
|
-
import * as
|
|
812
|
+
import * as v6 from "valibot";
|
|
759
813
|
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
760
|
-
var requestPermissionsParamsSchema =
|
|
761
|
-
var requestPermissionsResultSchema =
|
|
762
|
-
var requestPermissionsRequestMessageSchema =
|
|
814
|
+
var requestPermissionsParamsSchema = v6.undefined();
|
|
815
|
+
var requestPermissionsResultSchema = v6.literal(true);
|
|
816
|
+
var requestPermissionsRequestMessageSchema = v6.object({
|
|
763
817
|
...rpcRequestMessageSchema.entries,
|
|
764
|
-
...
|
|
765
|
-
method:
|
|
818
|
+
...v6.object({
|
|
819
|
+
method: v6.literal(requestPermissionsMethodName),
|
|
766
820
|
params: requestPermissionsParamsSchema,
|
|
767
|
-
id:
|
|
821
|
+
id: v6.string()
|
|
768
822
|
}).entries
|
|
769
823
|
});
|
|
770
824
|
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
771
|
-
var renouncePermissionsParamsSchema =
|
|
772
|
-
var renouncePermissionsResultSchema =
|
|
773
|
-
var renouncePermissionsRequestMessageSchema =
|
|
825
|
+
var renouncePermissionsParamsSchema = v6.undefined();
|
|
826
|
+
var renouncePermissionsResultSchema = v6.literal(true);
|
|
827
|
+
var renouncePermissionsRequestMessageSchema = v6.object({
|
|
774
828
|
...rpcRequestMessageSchema.entries,
|
|
775
|
-
...
|
|
776
|
-
method:
|
|
829
|
+
...v6.object({
|
|
830
|
+
method: v6.literal(renouncePermissionsMethodName),
|
|
777
831
|
params: renouncePermissionsParamsSchema,
|
|
778
|
-
id:
|
|
832
|
+
id: v6.string()
|
|
833
|
+
}).entries
|
|
834
|
+
});
|
|
835
|
+
var getWalletTypeMethodName = "wallet_getWalletType";
|
|
836
|
+
var getWalletTypeParamsSchema = v6.nullish(v6.null());
|
|
837
|
+
var getWalletTypeResultSchema = walletTypeSchema;
|
|
838
|
+
var getWalletTypeRequestMessageSchema = v6.object({
|
|
839
|
+
...rpcRequestMessageSchema.entries,
|
|
840
|
+
...v6.object({
|
|
841
|
+
method: v6.literal(getWalletTypeMethodName),
|
|
842
|
+
id: v6.string()
|
|
779
843
|
}).entries
|
|
780
844
|
});
|
|
781
845
|
|
|
782
846
|
// src/request/types/runesMethods.ts
|
|
783
|
-
import * as
|
|
847
|
+
import * as v7 from "valibot";
|
|
784
848
|
var getRunesBalanceMethodName = "runes_getBalance";
|
|
785
|
-
var getRunesBalanceParamsSchema =
|
|
786
|
-
var getRunesBalanceResultSchema =
|
|
787
|
-
balances:
|
|
788
|
-
|
|
789
|
-
runeName:
|
|
790
|
-
amount:
|
|
791
|
-
divisibility:
|
|
792
|
-
symbol:
|
|
793
|
-
inscriptionId:
|
|
849
|
+
var getRunesBalanceParamsSchema = v7.nullish(v7.null());
|
|
850
|
+
var getRunesBalanceResultSchema = v7.object({
|
|
851
|
+
balances: v7.array(
|
|
852
|
+
v7.object({
|
|
853
|
+
runeName: v7.string(),
|
|
854
|
+
amount: v7.string(),
|
|
855
|
+
divisibility: v7.number(),
|
|
856
|
+
symbol: v7.string(),
|
|
857
|
+
inscriptionId: v7.nullish(v7.string())
|
|
794
858
|
})
|
|
795
859
|
)
|
|
796
860
|
});
|
|
797
|
-
var getRunesBalanceRequestMessageSchema =
|
|
861
|
+
var getRunesBalanceRequestMessageSchema = v7.object({
|
|
798
862
|
...rpcRequestMessageSchema.entries,
|
|
799
|
-
...
|
|
800
|
-
method:
|
|
863
|
+
...v7.object({
|
|
864
|
+
method: v7.literal(getRunesBalanceMethodName),
|
|
801
865
|
params: getRunesBalanceParamsSchema,
|
|
802
|
-
id:
|
|
866
|
+
id: v7.string()
|
|
803
867
|
}).entries
|
|
804
868
|
});
|
|
805
869
|
|
|
806
870
|
// src/request/types/ordinalsMethods.ts
|
|
807
|
-
import * as
|
|
871
|
+
import * as v8 from "valibot";
|
|
808
872
|
var getInscriptionsMethodName = "ord_getInscriptions";
|
|
809
|
-
var getInscriptionsParamsSchema =
|
|
810
|
-
offset:
|
|
811
|
-
limit:
|
|
873
|
+
var getInscriptionsParamsSchema = v8.object({
|
|
874
|
+
offset: v8.number(),
|
|
875
|
+
limit: v8.number()
|
|
812
876
|
});
|
|
813
|
-
var getInscriptionsResultSchema =
|
|
814
|
-
total:
|
|
815
|
-
limit:
|
|
816
|
-
offset:
|
|
817
|
-
inscriptions:
|
|
818
|
-
|
|
819
|
-
inscriptionId:
|
|
820
|
-
inscriptionNumber:
|
|
821
|
-
address:
|
|
822
|
-
collectionName:
|
|
823
|
-
postage:
|
|
824
|
-
contentLength:
|
|
825
|
-
contentType:
|
|
826
|
-
timestamp:
|
|
827
|
-
offset:
|
|
828
|
-
genesisTransaction:
|
|
829
|
-
output:
|
|
877
|
+
var getInscriptionsResultSchema = v8.object({
|
|
878
|
+
total: v8.number(),
|
|
879
|
+
limit: v8.number(),
|
|
880
|
+
offset: v8.number(),
|
|
881
|
+
inscriptions: v8.array(
|
|
882
|
+
v8.object({
|
|
883
|
+
inscriptionId: v8.string(),
|
|
884
|
+
inscriptionNumber: v8.string(),
|
|
885
|
+
address: v8.string(),
|
|
886
|
+
collectionName: v8.optional(v8.string()),
|
|
887
|
+
postage: v8.string(),
|
|
888
|
+
contentLength: v8.string(),
|
|
889
|
+
contentType: v8.string(),
|
|
890
|
+
timestamp: v8.number(),
|
|
891
|
+
offset: v8.number(),
|
|
892
|
+
genesisTransaction: v8.string(),
|
|
893
|
+
output: v8.string()
|
|
830
894
|
})
|
|
831
895
|
)
|
|
832
896
|
});
|
|
833
|
-
var getInscriptionsSchema =
|
|
897
|
+
var getInscriptionsSchema = v8.object({
|
|
834
898
|
...rpcRequestMessageSchema.entries,
|
|
835
|
-
...
|
|
836
|
-
method:
|
|
899
|
+
...v8.object({
|
|
900
|
+
method: v8.literal(getInscriptionsMethodName),
|
|
837
901
|
params: getInscriptionsParamsSchema,
|
|
838
|
-
id:
|
|
902
|
+
id: v8.string()
|
|
839
903
|
}).entries
|
|
840
904
|
});
|
|
841
905
|
|
|
@@ -852,13 +916,13 @@ var request = async (method, params, providerId) => {
|
|
|
852
916
|
throw new Error("A wallet method is required");
|
|
853
917
|
}
|
|
854
918
|
const response = await provider.request(method, params);
|
|
855
|
-
if (
|
|
919
|
+
if (v9.is(rpcErrorResponseMessageSchema, response)) {
|
|
856
920
|
return {
|
|
857
921
|
status: "error",
|
|
858
922
|
error: response.error
|
|
859
923
|
};
|
|
860
924
|
}
|
|
861
|
-
if (
|
|
925
|
+
if (v9.is(rpcSuccessResponseMessageSchema, response)) {
|
|
862
926
|
return {
|
|
863
927
|
status: "success",
|
|
864
928
|
result: response.result
|
|
@@ -1325,6 +1389,10 @@ export {
|
|
|
1325
1389
|
getRunesBalanceRequestMessageSchema,
|
|
1326
1390
|
getRunesBalanceResultSchema,
|
|
1327
1391
|
getSupportedWallets,
|
|
1392
|
+
getWalletTypeMethodName,
|
|
1393
|
+
getWalletTypeParamsSchema,
|
|
1394
|
+
getWalletTypeRequestMessageSchema,
|
|
1395
|
+
getWalletTypeResultSchema,
|
|
1328
1396
|
isProviderInstalled,
|
|
1329
1397
|
removeDefaultProvider,
|
|
1330
1398
|
renouncePermissionsMethodName,
|
|
@@ -1352,5 +1420,11 @@ export {
|
|
|
1352
1420
|
stxGetAddressesMethodName,
|
|
1353
1421
|
stxGetAddressesParamsSchema,
|
|
1354
1422
|
stxGetAddressesRequestMessageSchema,
|
|
1355
|
-
stxGetAddressesResultSchema
|
|
1423
|
+
stxGetAddressesResultSchema,
|
|
1424
|
+
stxSignTransactionMethodName,
|
|
1425
|
+
stxSignTransactionParamsSchema,
|
|
1426
|
+
stxSignTransactionRequestMessageSchema,
|
|
1427
|
+
stxSignTransactionResultSchema,
|
|
1428
|
+
walletTypeSchema,
|
|
1429
|
+
walletTypes
|
|
1356
1430
|
};
|