@sats-connect/core 0.0.11-69eb4c5 → 0.0.11-6cb912b
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 +45 -33
- package/dist/index.mjs +69 -36
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -492,20 +492,25 @@ declare const getBalanceMethodName = "getBalance";
|
|
|
492
492
|
declare const getBalanceParamsSchema: v.UndefinedSchema<undefined>;
|
|
493
493
|
declare const getBalanceResultSchema: v.ObjectSchema<{
|
|
494
494
|
/**
|
|
495
|
-
* The confirmed balance of the wallet in sats.
|
|
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).
|
|
496
498
|
*/
|
|
497
|
-
readonly confirmed: v.
|
|
499
|
+
readonly confirmed: v.StringSchema<undefined>;
|
|
498
500
|
/**
|
|
499
|
-
* The unconfirmed balance of the wallet in sats.
|
|
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).
|
|
500
504
|
*/
|
|
501
|
-
readonly unconfirmed: v.
|
|
505
|
+
readonly unconfirmed: v.StringSchema<undefined>;
|
|
502
506
|
/**
|
|
503
507
|
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
504
|
-
* sats.
|
|
508
|
+
* sats. Using a string due to chrome messages not supporting bigint
|
|
509
|
+
* (https://issues.chromium.org/issues/40116184).
|
|
505
510
|
*/
|
|
506
|
-
readonly total: v.
|
|
511
|
+
readonly total: v.StringSchema<undefined>;
|
|
507
512
|
}, undefined>;
|
|
508
|
-
declare const
|
|
513
|
+
declare const getBalanceRequestMessageSchema: v.ObjectSchema<{
|
|
509
514
|
readonly method: v.LiteralSchema<"getBalance", undefined>;
|
|
510
515
|
readonly id: v.StringSchema<undefined>;
|
|
511
516
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
@@ -624,17 +629,24 @@ interface RbfOrderResult {
|
|
|
624
629
|
fundingAddress: string;
|
|
625
630
|
}
|
|
626
631
|
type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
|
|
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>>;
|
|
638
650
|
|
|
639
651
|
interface Pubkey {
|
|
640
652
|
/**
|
|
@@ -816,26 +828,26 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
816
828
|
type SignTransactionResult = Transaction;
|
|
817
829
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
818
830
|
|
|
819
|
-
declare const
|
|
820
|
-
declare const
|
|
821
|
-
declare const
|
|
822
|
-
declare const
|
|
823
|
-
readonly method: v.LiteralSchema<"
|
|
831
|
+
declare const grantPermissionsMethodName = "wallet_requestPermissions";
|
|
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_requestPermissions", undefined>;
|
|
824
836
|
readonly params: v.UndefinedSchema<undefined>;
|
|
825
837
|
readonly id: v.StringSchema<undefined>;
|
|
826
838
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
827
839
|
}, undefined>;
|
|
828
|
-
type
|
|
829
|
-
declare const
|
|
830
|
-
declare const
|
|
831
|
-
declare const
|
|
832
|
-
declare const
|
|
833
|
-
readonly method: v.LiteralSchema<"
|
|
840
|
+
type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof grantPermissionsParamsSchema>, v.InferOutput<typeof grantPermissionsResultSchema>>;
|
|
841
|
+
declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
842
|
+
declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
843
|
+
declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
844
|
+
declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
845
|
+
readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
|
|
834
846
|
readonly params: v.UndefinedSchema<undefined>;
|
|
835
847
|
readonly id: v.StringSchema<undefined>;
|
|
836
848
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
837
849
|
}, undefined>;
|
|
838
|
-
type
|
|
850
|
+
type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
|
|
839
851
|
|
|
840
852
|
interface StxRequests {
|
|
841
853
|
stx_callContract: StxCallContract;
|
|
@@ -870,8 +882,8 @@ interface RunesRequests {
|
|
|
870
882
|
}
|
|
871
883
|
type RunesRequestMethod = keyof RunesRequests;
|
|
872
884
|
interface WalletMethods {
|
|
873
|
-
|
|
874
|
-
|
|
885
|
+
wallet_requestPermissions: RequestPermissions;
|
|
886
|
+
wallet_renouncePermissions: RenouncePermissions;
|
|
875
887
|
}
|
|
876
888
|
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
|
|
877
889
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
@@ -901,4 +913,4 @@ declare class BaseAdapter extends SatsConnectAdapter {
|
|
|
901
913
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
902
914
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
903
915
|
|
|
904
|
-
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
|
|
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 CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type EstimateRbfOrder, type EstimateRunesEtch, type EstimateRunesEtchParams, type EstimateRunesEtchResult, type EstimateRunesMint, type EstimateRunesMintParams, type EstimateRunesMintResult, type EtchRunes, type EtchRunesParams, type EtchRunesResult, type GetAccounts, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type 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 RenouncePermissions, type RequestOptions, type RequestPayload, type RequestPermissions, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcErrorResponseMessage, type RpcId, RpcIdSchema, type RpcRequest, type RpcRequestMessage, type RpcResponse, type RpcResponseMessage, type RpcResult, type RpcSuccessResponse, type RpcSuccessResponseMessage, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, type WalletMethods, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceRequestMessageSchema, getBalanceResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, getProviderById, getProviderOrThrow, getProviders, getRunesBalanceMethodName, getRunesBalanceParamsSchema, getRunesBalanceRequestMessageSchema, getRunesBalanceResultSchema, getSupportedWallets, grantPermissionsMethodName, grantPermissionsParamsSchema, grantPermissionsRequestMessageSchema, grantPermissionsResultSchema, isProviderInstalled, removeDefaultProvider, renouncePermissionsMethodName, renouncePermissionsParamsSchema, renouncePermissionsRequestMessageSchema, renouncePermissionsResultSchema, request, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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
9
|
var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
|
|
10
10
|
var rpcRequestMessageSchema = v.object({
|
|
@@ -526,7 +526,7 @@ function getSupportedWallets() {
|
|
|
526
526
|
}
|
|
527
527
|
|
|
528
528
|
// src/request/index.ts
|
|
529
|
-
import * as
|
|
529
|
+
import * as v6 from "valibot";
|
|
530
530
|
|
|
531
531
|
// src/addresses/index.ts
|
|
532
532
|
import { createUnsecuredToken } from "jsontokens";
|
|
@@ -672,20 +672,25 @@ var getBalanceMethodName = "getBalance";
|
|
|
672
672
|
var getBalanceParamsSchema = v3.undefined();
|
|
673
673
|
var getBalanceResultSchema = v3.object({
|
|
674
674
|
/**
|
|
675
|
-
* The confirmed balance of the wallet in sats.
|
|
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).
|
|
676
678
|
*/
|
|
677
|
-
confirmed: v3.
|
|
679
|
+
confirmed: v3.string(),
|
|
678
680
|
/**
|
|
679
|
-
* The unconfirmed balance of the wallet in sats.
|
|
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).
|
|
680
684
|
*/
|
|
681
|
-
unconfirmed: v3.
|
|
685
|
+
unconfirmed: v3.string(),
|
|
682
686
|
/**
|
|
683
687
|
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
684
|
-
* sats.
|
|
688
|
+
* sats. Using a string due to chrome messages not supporting bigint
|
|
689
|
+
* (https://issues.chromium.org/issues/40116184).
|
|
685
690
|
*/
|
|
686
|
-
total: v3.
|
|
691
|
+
total: v3.string()
|
|
687
692
|
});
|
|
688
|
-
var
|
|
693
|
+
var getBalanceRequestMessageSchema = v3.object({
|
|
689
694
|
...rpcRequestMessageSchema.entries,
|
|
690
695
|
...v3.object({
|
|
691
696
|
method: v3.literal(getBalanceMethodName),
|
|
@@ -695,29 +700,53 @@ var getBalanceSchema = v3.object({
|
|
|
695
700
|
|
|
696
701
|
// src/request/types/walletMethods.ts
|
|
697
702
|
import * as v4 from "valibot";
|
|
698
|
-
var
|
|
699
|
-
var
|
|
700
|
-
var
|
|
701
|
-
var
|
|
703
|
+
var grantPermissionsMethodName = "wallet_requestPermissions";
|
|
704
|
+
var grantPermissionsParamsSchema = v4.undefined();
|
|
705
|
+
var grantPermissionsResultSchema = v4.literal(true);
|
|
706
|
+
var grantPermissionsRequestMessageSchema = v4.object({
|
|
702
707
|
...rpcRequestMessageSchema.entries,
|
|
703
708
|
...v4.object({
|
|
704
|
-
method: v4.literal(
|
|
705
|
-
params:
|
|
709
|
+
method: v4.literal(grantPermissionsMethodName),
|
|
710
|
+
params: grantPermissionsParamsSchema,
|
|
706
711
|
id: v4.string()
|
|
707
712
|
}).entries
|
|
708
713
|
});
|
|
709
|
-
var
|
|
710
|
-
var
|
|
711
|
-
var
|
|
712
|
-
var
|
|
714
|
+
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
715
|
+
var renouncePermissionsParamsSchema = v4.undefined();
|
|
716
|
+
var renouncePermissionsResultSchema = v4.literal(true);
|
|
717
|
+
var renouncePermissionsRequestMessageSchema = v4.object({
|
|
713
718
|
...rpcRequestMessageSchema.entries,
|
|
714
719
|
...v4.object({
|
|
715
|
-
method: v4.literal(
|
|
716
|
-
params:
|
|
720
|
+
method: v4.literal(renouncePermissionsMethodName),
|
|
721
|
+
params: renouncePermissionsParamsSchema,
|
|
717
722
|
id: v4.string()
|
|
718
723
|
}).entries
|
|
719
724
|
});
|
|
720
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
|
+
|
|
721
750
|
// src/request/index.ts
|
|
722
751
|
var request = async (method, params, providerId) => {
|
|
723
752
|
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
@@ -731,13 +760,13 @@ var request = async (method, params, providerId) => {
|
|
|
731
760
|
throw new Error("A wallet method is required");
|
|
732
761
|
}
|
|
733
762
|
const response = await provider.request(method, params);
|
|
734
|
-
if (
|
|
763
|
+
if (v6.is(rpcErrorResponseMessageSchema, response)) {
|
|
735
764
|
return {
|
|
736
765
|
status: "error",
|
|
737
766
|
error: response.error
|
|
738
767
|
};
|
|
739
768
|
}
|
|
740
|
-
if (
|
|
769
|
+
if (v6.is(rpcSuccessResponseMessageSchema, response)) {
|
|
741
770
|
return {
|
|
742
771
|
status: "success",
|
|
743
772
|
result: response.result
|
|
@@ -1170,17 +1199,9 @@ export {
|
|
|
1170
1199
|
RpcIdSchema,
|
|
1171
1200
|
SatsConnectAdapter,
|
|
1172
1201
|
addressSchema,
|
|
1173
|
-
connectMethodName,
|
|
1174
|
-
connectParamsSchema,
|
|
1175
|
-
connectResultSchema,
|
|
1176
|
-
connectSchema,
|
|
1177
1202
|
createInscription,
|
|
1178
1203
|
createRepeatInscriptions,
|
|
1179
1204
|
defaultAdapters,
|
|
1180
|
-
disconnectMethodName,
|
|
1181
|
-
disconnectParamsSchema,
|
|
1182
|
-
disconnectResultSchema,
|
|
1183
|
-
disconnectSchema,
|
|
1184
1205
|
getAccountsMethodName,
|
|
1185
1206
|
getAccountsParamsSchema,
|
|
1186
1207
|
getAccountsRequestMessageSchema,
|
|
@@ -1192,8 +1213,8 @@ export {
|
|
|
1192
1213
|
getAddressesResultSchema,
|
|
1193
1214
|
getBalanceMethodName,
|
|
1194
1215
|
getBalanceParamsSchema,
|
|
1216
|
+
getBalanceRequestMessageSchema,
|
|
1195
1217
|
getBalanceResultSchema,
|
|
1196
|
-
getBalanceSchema,
|
|
1197
1218
|
getCapabilities,
|
|
1198
1219
|
getDefaultProvider,
|
|
1199
1220
|
getInfoMethodName,
|
|
@@ -1203,9 +1224,21 @@ export {
|
|
|
1203
1224
|
getProviderById,
|
|
1204
1225
|
getProviderOrThrow,
|
|
1205
1226
|
getProviders,
|
|
1227
|
+
getRunesBalanceMethodName,
|
|
1228
|
+
getRunesBalanceParamsSchema,
|
|
1229
|
+
getRunesBalanceRequestMessageSchema,
|
|
1230
|
+
getRunesBalanceResultSchema,
|
|
1206
1231
|
getSupportedWallets,
|
|
1232
|
+
grantPermissionsMethodName,
|
|
1233
|
+
grantPermissionsParamsSchema,
|
|
1234
|
+
grantPermissionsRequestMessageSchema,
|
|
1235
|
+
grantPermissionsResultSchema,
|
|
1207
1236
|
isProviderInstalled,
|
|
1208
1237
|
removeDefaultProvider,
|
|
1238
|
+
renouncePermissionsMethodName,
|
|
1239
|
+
renouncePermissionsParamsSchema,
|
|
1240
|
+
renouncePermissionsRequestMessageSchema,
|
|
1241
|
+
renouncePermissionsResultSchema,
|
|
1209
1242
|
request,
|
|
1210
1243
|
rpcErrorResponseMessageSchema,
|
|
1211
1244
|
rpcRequestMessageSchema,
|