@sats-connect/core 0.0.11-760c033 → 0.0.11-a271383
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 +169 -64
- package/dist/index.mjs +209 -59
- package/package.json +5 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
1
3
|
interface GetCapabilitiesPayload extends RequestPayload {
|
|
2
4
|
}
|
|
3
5
|
type GetCapabilitiesResponse = Capability[];
|
|
@@ -157,6 +159,13 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
157
159
|
payload: Payload;
|
|
158
160
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
159
161
|
}
|
|
162
|
+
declare const rpcRequestMessageSchema: v.ObjectSchema<{
|
|
163
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
164
|
+
readonly method: v.StringSchema<undefined>;
|
|
165
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
166
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
167
|
+
}, undefined>;
|
|
168
|
+
type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
|
|
160
169
|
type RpcId = string | null;
|
|
161
170
|
interface RpcBase {
|
|
162
171
|
jsonrpc: '2.0';
|
|
@@ -243,12 +252,13 @@ declare enum AddressType {
|
|
|
243
252
|
p2tr = "p2tr",
|
|
244
253
|
stacks = "stacks"
|
|
245
254
|
}
|
|
246
|
-
|
|
247
|
-
address:
|
|
248
|
-
publicKey:
|
|
249
|
-
purpose
|
|
250
|
-
addressType
|
|
251
|
-
}
|
|
255
|
+
declare const addressSchema: v.ObjectSchema<{
|
|
256
|
+
readonly address: v.StringSchema<undefined>;
|
|
257
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
258
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
259
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
260
|
+
}, undefined>;
|
|
261
|
+
type Address$1 = v.InferOutput<typeof addressSchema>;
|
|
252
262
|
interface GetAddressResponse {
|
|
253
263
|
addresses: Address$1[];
|
|
254
264
|
}
|
|
@@ -256,59 +266,110 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
|
256
266
|
|
|
257
267
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
258
268
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
*
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
269
|
+
declare const getInfoMethodName = "getInfo";
|
|
270
|
+
declare const getInfoParamsSchema: v.NullSchema<undefined>;
|
|
271
|
+
declare const getInfoResultSchema: v.ObjectSchema<{
|
|
272
|
+
/**
|
|
273
|
+
* Version of the wallet.
|
|
274
|
+
*/
|
|
275
|
+
readonly version: v.StringSchema<undefined>;
|
|
276
|
+
/**
|
|
277
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
278
|
+
*/
|
|
279
|
+
readonly methods: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, never>;
|
|
280
|
+
/**
|
|
281
|
+
* List of WBIP standards supported by the wallet. Not currently used.
|
|
282
|
+
*/
|
|
283
|
+
readonly supports: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
284
|
+
}, undefined>;
|
|
285
|
+
declare const getInfoSchema: v.ObjectSchema<{
|
|
286
|
+
readonly method: v.LiteralSchema<"getInfo", undefined>;
|
|
287
|
+
readonly params: v.NullSchema<undefined>;
|
|
288
|
+
readonly id: v.StringSchema<undefined>;
|
|
289
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
290
|
+
}, undefined>;
|
|
291
|
+
type GetInfo = MethodParamsAndResult<v.InferOutput<typeof getInfoParamsSchema>, v.InferOutput<typeof getInfoResultSchema>>;
|
|
292
|
+
declare const getAddressesMethodName = "getAddresses";
|
|
293
|
+
declare const getAddressesParamsSchema: v.ObjectSchema<{
|
|
294
|
+
/**
|
|
295
|
+
* The purposes for which to generate addresses. See
|
|
296
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
297
|
+
*/
|
|
298
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
299
|
+
/**
|
|
300
|
+
* A message to be displayed to the user in the request prompt.
|
|
301
|
+
*/
|
|
302
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
303
|
+
}, undefined>;
|
|
304
|
+
declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
305
|
+
/**
|
|
306
|
+
* The addresses generated for the given purposes.
|
|
307
|
+
*/
|
|
308
|
+
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
309
|
+
readonly address: v.StringSchema<undefined>;
|
|
310
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
311
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
312
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
313
|
+
}, undefined>, undefined>;
|
|
314
|
+
}, undefined>;
|
|
315
|
+
declare const getAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
316
|
+
readonly method: v.LiteralSchema<"getAddresses", undefined>;
|
|
317
|
+
readonly params: v.ObjectSchema<{
|
|
318
|
+
/**
|
|
319
|
+
* The purposes for which to generate addresses. See
|
|
320
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
321
|
+
*/
|
|
322
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
323
|
+
/**
|
|
324
|
+
* A message to be displayed to the user in the request prompt.
|
|
325
|
+
*/
|
|
326
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
327
|
+
}, undefined>;
|
|
328
|
+
readonly id: v.StringSchema<undefined>;
|
|
329
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
330
|
+
}, undefined>;
|
|
331
|
+
type GetAddresses = MethodParamsAndResult<v.InferOutput<typeof getAddressesParamsSchema>, v.InferOutput<typeof getAddressesResultSchema>>;
|
|
332
|
+
declare const signMessageMethodName = "signMessage";
|
|
333
|
+
declare const signMessageParamsSchema: v.ObjectSchema<{
|
|
288
334
|
/**
|
|
289
335
|
* The address used for signing.
|
|
290
336
|
**/
|
|
291
|
-
address:
|
|
337
|
+
readonly address: v.StringSchema<undefined>;
|
|
292
338
|
/**
|
|
293
339
|
* The message to sign.
|
|
294
340
|
**/
|
|
295
|
-
message:
|
|
296
|
-
}
|
|
297
|
-
|
|
341
|
+
readonly message: v.StringSchema<undefined>;
|
|
342
|
+
}, undefined>;
|
|
343
|
+
declare const signMessageResultSchema: v.ObjectSchema<{
|
|
298
344
|
/**
|
|
299
345
|
* The signature of the message.
|
|
300
346
|
*/
|
|
301
|
-
signature:
|
|
347
|
+
readonly signature: v.StringSchema<undefined>;
|
|
302
348
|
/**
|
|
303
349
|
* hash of the message.
|
|
304
350
|
*/
|
|
305
|
-
messageHash:
|
|
351
|
+
readonly messageHash: v.StringSchema<undefined>;
|
|
306
352
|
/**
|
|
307
353
|
* The address used for signing.
|
|
308
354
|
*/
|
|
309
|
-
address:
|
|
310
|
-
}
|
|
311
|
-
|
|
355
|
+
readonly address: v.StringSchema<undefined>;
|
|
356
|
+
}, undefined>;
|
|
357
|
+
declare const signMessageRequestMessageSchema: v.ObjectSchema<{
|
|
358
|
+
readonly method: v.LiteralSchema<"signMessage", undefined>;
|
|
359
|
+
readonly params: v.ObjectSchema<{
|
|
360
|
+
/**
|
|
361
|
+
* The address used for signing.
|
|
362
|
+
**/
|
|
363
|
+
readonly address: v.StringSchema<undefined>;
|
|
364
|
+
/**
|
|
365
|
+
* The message to sign.
|
|
366
|
+
**/
|
|
367
|
+
readonly message: v.StringSchema<undefined>;
|
|
368
|
+
}, undefined>;
|
|
369
|
+
readonly id: v.StringSchema<undefined>;
|
|
370
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
371
|
+
}, undefined>;
|
|
372
|
+
type SignMessage = MethodParamsAndResult<v.InferOutput<typeof signMessageParamsSchema>, v.InferOutput<typeof signMessageResultSchema>>;
|
|
312
373
|
type Recipient$1 = {
|
|
313
374
|
/**
|
|
314
375
|
* The recipient's address.
|
|
@@ -365,22 +426,41 @@ type SignPsbtResult = {
|
|
|
365
426
|
txid?: string;
|
|
366
427
|
};
|
|
367
428
|
type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
*
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
429
|
+
declare const getAccountsMethodName = "getAccounts";
|
|
430
|
+
declare const getAccountsParamsSchema: v.ObjectSchema<{
|
|
431
|
+
/**
|
|
432
|
+
* The purposes for which to generate addresses. See
|
|
433
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
434
|
+
*/
|
|
435
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
436
|
+
/**
|
|
437
|
+
* A message to be displayed to the user in the request prompt.
|
|
438
|
+
*/
|
|
439
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
440
|
+
}, undefined>;
|
|
441
|
+
declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
|
|
442
|
+
readonly address: v.StringSchema<undefined>;
|
|
443
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
444
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
445
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
446
|
+
}, undefined>, undefined>;
|
|
447
|
+
declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
|
|
448
|
+
readonly method: v.LiteralSchema<"getAccounts", undefined>;
|
|
449
|
+
readonly params: v.ObjectSchema<{
|
|
450
|
+
/**
|
|
451
|
+
* The purposes for which to generate addresses. See
|
|
452
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
453
|
+
*/
|
|
454
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
455
|
+
/**
|
|
456
|
+
* A message to be displayed to the user in the request prompt.
|
|
457
|
+
*/
|
|
458
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
459
|
+
}, undefined>;
|
|
460
|
+
readonly id: v.StringSchema<undefined>;
|
|
461
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
462
|
+
}, undefined>;
|
|
463
|
+
type GetAccounts = MethodParamsAndResult<v.InferOutput<typeof getAccountsParamsSchema>, v.InferOutput<typeof getAccountsResultSchema>>;
|
|
384
464
|
|
|
385
465
|
type CreateMintOrderRequest = {
|
|
386
466
|
runeName: string;
|
|
@@ -685,6 +765,27 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
685
765
|
type SignTransactionResult = Transaction;
|
|
686
766
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
687
767
|
|
|
768
|
+
declare const connectMethodName = "wallet_connect";
|
|
769
|
+
declare const connectParamsSchema: v.UndefinedSchema<undefined>;
|
|
770
|
+
declare const connectResultSchema: v.UndefinedSchema<undefined>;
|
|
771
|
+
declare const connectSchema: v.ObjectSchema<{
|
|
772
|
+
readonly method: v.LiteralSchema<"wallet_connect", undefined>;
|
|
773
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
774
|
+
readonly id: v.StringSchema<undefined>;
|
|
775
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
776
|
+
}, undefined>;
|
|
777
|
+
type Connect = MethodParamsAndResult<v.InferOutput<typeof connectParamsSchema>, v.InferOutput<typeof connectResultSchema>>;
|
|
778
|
+
declare const disconnectMethodName = "wallet_disconnect";
|
|
779
|
+
declare const disconnectParamsSchema: v.UndefinedSchema<undefined>;
|
|
780
|
+
declare const disconnectResultSchema: v.UndefinedSchema<undefined>;
|
|
781
|
+
declare const disconnectSchema: v.ObjectSchema<{
|
|
782
|
+
readonly method: v.LiteralSchema<"wallet_disconnect", undefined>;
|
|
783
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
784
|
+
readonly id: v.StringSchema<undefined>;
|
|
785
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
786
|
+
}, undefined>;
|
|
787
|
+
type Disconnect = MethodParamsAndResult<v.InferOutput<typeof disconnectParamsSchema>, v.InferOutput<typeof disconnectResultSchema>>;
|
|
788
|
+
|
|
688
789
|
interface StxRequests {
|
|
689
790
|
stx_callContract: StxCallContract;
|
|
690
791
|
stx_deployContract: StxDeployContract;
|
|
@@ -716,11 +817,15 @@ interface RunesRequests {
|
|
|
716
817
|
runes_getBalance: GetRunesBalance;
|
|
717
818
|
}
|
|
718
819
|
type RunesRequestMethod = keyof RunesRequests;
|
|
719
|
-
|
|
820
|
+
interface WalletMethods {
|
|
821
|
+
wallet_connect: Connect;
|
|
822
|
+
wallet_disconnect: Disconnect;
|
|
823
|
+
}
|
|
824
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
|
|
720
825
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
721
826
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
722
827
|
|
|
723
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
828
|
+
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
724
829
|
|
|
725
830
|
declare abstract class SatsConnectAdapter {
|
|
726
831
|
abstract readonly id: string;
|
|
@@ -738,10 +843,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
738
843
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
739
844
|
id: string;
|
|
740
845
|
constructor(providerId: string);
|
|
741
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
846
|
+
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
742
847
|
}
|
|
743
848
|
|
|
744
849
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
745
850
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
746
851
|
|
|
747
|
-
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
|
|
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, connectMethodName, connectParamsSchema, connectResultSchema, connectSchema, createInscription, createRepeatInscriptions, defaultAdapters, disconnectMethodName, disconnectParamsSchema, disconnectResultSchema, disconnectSchema, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
|
+
import * as v from "valibot";
|
|
2
3
|
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
3
4
|
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
4
5
|
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
5
6
|
BitcoinNetworkType2["Signet"] = "Signet";
|
|
6
7
|
return BitcoinNetworkType2;
|
|
7
8
|
})(BitcoinNetworkType || {});
|
|
9
|
+
var rpcRequestMessageSchema = v.object({
|
|
10
|
+
jsonrpc: v.literal("2.0"),
|
|
11
|
+
method: v.string(),
|
|
12
|
+
params: v.optional(
|
|
13
|
+
v.union([
|
|
14
|
+
v.array(v.unknown()),
|
|
15
|
+
v.looseObject({}),
|
|
16
|
+
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
17
|
+
// to be either an array or an object when provided. Changing this now would
|
|
18
|
+
// be a breaking change, so accepting null values for now. Tracking in
|
|
19
|
+
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
20
|
+
v.null()
|
|
21
|
+
])
|
|
22
|
+
),
|
|
23
|
+
id: v.optional(v.union([v.string(), v.number(), v.null()]))
|
|
24
|
+
});
|
|
8
25
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
9
26
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
10
27
|
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
@@ -169,16 +186,6 @@ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
|
|
|
169
186
|
var SatsConnectAdapter = class {
|
|
170
187
|
async mintRunes(params) {
|
|
171
188
|
try {
|
|
172
|
-
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
173
|
-
if (walletInfo && walletInfo.status === "success") {
|
|
174
|
-
const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
|
|
175
|
-
if (isMintSupported) {
|
|
176
|
-
const response = await this.requestInternal("runes_mint", params);
|
|
177
|
-
if (response) {
|
|
178
|
-
return response;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
189
|
const mintRequest = {
|
|
183
190
|
destinationAddress: params.destinationAddress,
|
|
184
191
|
feeRate: params.feeRate,
|
|
@@ -248,16 +255,6 @@ var SatsConnectAdapter = class {
|
|
|
248
255
|
appServiceFeeAddress: params.appServiceFeeAddress
|
|
249
256
|
};
|
|
250
257
|
try {
|
|
251
|
-
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
252
|
-
if (walletInfo && walletInfo.status === "success") {
|
|
253
|
-
const isEtchSupported = walletInfo.result.methods?.includes("runes_etch");
|
|
254
|
-
if (isEtchSupported) {
|
|
255
|
-
const response = await this.requestInternal("runes_etch", params);
|
|
256
|
-
if (response) {
|
|
257
|
-
return response;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
258
|
const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
|
|
262
259
|
if (!orderResponse.data) {
|
|
263
260
|
return {
|
|
@@ -512,6 +509,172 @@ function getSupportedWallets() {
|
|
|
512
509
|
return wallets;
|
|
513
510
|
}
|
|
514
511
|
|
|
512
|
+
// src/addresses/index.ts
|
|
513
|
+
import { createUnsecuredToken } from "jsontokens";
|
|
514
|
+
|
|
515
|
+
// src/addresses/types.ts
|
|
516
|
+
import * as v2 from "valibot";
|
|
517
|
+
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
518
|
+
AddressPurpose2["Ordinals"] = "ordinals";
|
|
519
|
+
AddressPurpose2["Payment"] = "payment";
|
|
520
|
+
AddressPurpose2["Stacks"] = "stacks";
|
|
521
|
+
return AddressPurpose2;
|
|
522
|
+
})(AddressPurpose || {});
|
|
523
|
+
var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
524
|
+
AddressType3["p2pkh"] = "p2pkh";
|
|
525
|
+
AddressType3["p2sh"] = "p2sh";
|
|
526
|
+
AddressType3["p2wpkh"] = "p2wpkh";
|
|
527
|
+
AddressType3["p2wsh"] = "p2wsh";
|
|
528
|
+
AddressType3["p2tr"] = "p2tr";
|
|
529
|
+
AddressType3["stacks"] = "stacks";
|
|
530
|
+
return AddressType3;
|
|
531
|
+
})(AddressType || {});
|
|
532
|
+
var addressSchema = v2.object({
|
|
533
|
+
address: v2.string(),
|
|
534
|
+
publicKey: v2.string(),
|
|
535
|
+
purpose: v2.enum(AddressPurpose),
|
|
536
|
+
addressType: v2.enum(AddressType)
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
// src/addresses/index.ts
|
|
540
|
+
var getAddress = async (options) => {
|
|
541
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
542
|
+
const { purposes } = options.payload;
|
|
543
|
+
if (!purposes) {
|
|
544
|
+
throw new Error("Address purposes are required");
|
|
545
|
+
}
|
|
546
|
+
try {
|
|
547
|
+
const request2 = createUnsecuredToken(options.payload);
|
|
548
|
+
const response = await provider.connect(request2);
|
|
549
|
+
options.onFinish?.(response);
|
|
550
|
+
} catch (error) {
|
|
551
|
+
console.error("[Connect] Error during address request", error);
|
|
552
|
+
options.onCancel?.();
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
// src/request/types/btcMethods.ts
|
|
557
|
+
import * as v3 from "valibot";
|
|
558
|
+
var getInfoMethodName = "getInfo";
|
|
559
|
+
var getInfoParamsSchema = v3.null();
|
|
560
|
+
var getInfoResultSchema = v3.object({
|
|
561
|
+
/**
|
|
562
|
+
* Version of the wallet.
|
|
563
|
+
*/
|
|
564
|
+
version: v3.string(),
|
|
565
|
+
/**
|
|
566
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
567
|
+
*/
|
|
568
|
+
methods: v3.optional(v3.array(v3.string())),
|
|
569
|
+
/**
|
|
570
|
+
* List of WBIP standards supported by the wallet. Not currently used.
|
|
571
|
+
*/
|
|
572
|
+
supports: v3.array(v3.string())
|
|
573
|
+
});
|
|
574
|
+
var getInfoSchema = v3.object({
|
|
575
|
+
...rpcRequestMessageSchema.entries,
|
|
576
|
+
...v3.object({
|
|
577
|
+
method: v3.literal(getInfoMethodName),
|
|
578
|
+
params: getInfoParamsSchema,
|
|
579
|
+
id: v3.string()
|
|
580
|
+
}).entries
|
|
581
|
+
});
|
|
582
|
+
var getAddressesMethodName = "getAddresses";
|
|
583
|
+
var getAddressesParamsSchema = v3.object({
|
|
584
|
+
/**
|
|
585
|
+
* The purposes for which to generate addresses. See
|
|
586
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
587
|
+
*/
|
|
588
|
+
purposes: v3.array(v3.enum(AddressPurpose)),
|
|
589
|
+
/**
|
|
590
|
+
* A message to be displayed to the user in the request prompt.
|
|
591
|
+
*/
|
|
592
|
+
message: v3.optional(v3.string())
|
|
593
|
+
});
|
|
594
|
+
var getAddressesResultSchema = v3.object({
|
|
595
|
+
/**
|
|
596
|
+
* The addresses generated for the given purposes.
|
|
597
|
+
*/
|
|
598
|
+
addresses: v3.array(addressSchema)
|
|
599
|
+
});
|
|
600
|
+
var getAddressesRequestMessageSchema = v3.object({
|
|
601
|
+
...rpcRequestMessageSchema.entries,
|
|
602
|
+
...v3.object({
|
|
603
|
+
method: v3.literal(getAddressesMethodName),
|
|
604
|
+
params: getAddressesParamsSchema,
|
|
605
|
+
id: v3.string()
|
|
606
|
+
}).entries
|
|
607
|
+
});
|
|
608
|
+
var signMessageMethodName = "signMessage";
|
|
609
|
+
var signMessageParamsSchema = v3.object({
|
|
610
|
+
/**
|
|
611
|
+
* The address used for signing.
|
|
612
|
+
**/
|
|
613
|
+
address: v3.string(),
|
|
614
|
+
/**
|
|
615
|
+
* The message to sign.
|
|
616
|
+
**/
|
|
617
|
+
message: v3.string()
|
|
618
|
+
});
|
|
619
|
+
var signMessageResultSchema = v3.object({
|
|
620
|
+
/**
|
|
621
|
+
* The signature of the message.
|
|
622
|
+
*/
|
|
623
|
+
signature: v3.string(),
|
|
624
|
+
/**
|
|
625
|
+
* hash of the message.
|
|
626
|
+
*/
|
|
627
|
+
messageHash: v3.string(),
|
|
628
|
+
/**
|
|
629
|
+
* The address used for signing.
|
|
630
|
+
*/
|
|
631
|
+
address: v3.string()
|
|
632
|
+
});
|
|
633
|
+
var signMessageRequestMessageSchema = v3.object({
|
|
634
|
+
...rpcRequestMessageSchema.entries,
|
|
635
|
+
...v3.object({
|
|
636
|
+
method: v3.literal(signMessageMethodName),
|
|
637
|
+
params: signMessageParamsSchema,
|
|
638
|
+
id: v3.string()
|
|
639
|
+
}).entries
|
|
640
|
+
});
|
|
641
|
+
var getAccountsMethodName = "getAccounts";
|
|
642
|
+
var getAccountsParamsSchema = getAddressesParamsSchema;
|
|
643
|
+
var getAccountsResultSchema = v3.array(addressSchema);
|
|
644
|
+
var getAccountsRequestMessageSchema = v3.object({
|
|
645
|
+
...rpcRequestMessageSchema.entries,
|
|
646
|
+
...v3.object({
|
|
647
|
+
method: v3.literal(getAccountsMethodName),
|
|
648
|
+
params: getAccountsParamsSchema,
|
|
649
|
+
id: v3.string()
|
|
650
|
+
}).entries
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
// src/request/types/walletMethods.ts
|
|
654
|
+
import * as v4 from "valibot";
|
|
655
|
+
var connectMethodName = "wallet_connect";
|
|
656
|
+
var connectParamsSchema = v4.undefined();
|
|
657
|
+
var connectResultSchema = v4.undefined();
|
|
658
|
+
var connectSchema = v4.object({
|
|
659
|
+
...rpcRequestMessageSchema.entries,
|
|
660
|
+
...v4.object({
|
|
661
|
+
method: v4.literal(connectMethodName),
|
|
662
|
+
params: connectParamsSchema,
|
|
663
|
+
id: v4.string()
|
|
664
|
+
}).entries
|
|
665
|
+
});
|
|
666
|
+
var disconnectMethodName = "wallet_disconnect";
|
|
667
|
+
var disconnectParamsSchema = v4.undefined();
|
|
668
|
+
var disconnectResultSchema = v4.undefined();
|
|
669
|
+
var disconnectSchema = v4.object({
|
|
670
|
+
...rpcRequestMessageSchema.entries,
|
|
671
|
+
...v4.object({
|
|
672
|
+
method: v4.literal(disconnectMethodName),
|
|
673
|
+
params: disconnectParamsSchema,
|
|
674
|
+
id: v4.string()
|
|
675
|
+
}).entries
|
|
676
|
+
});
|
|
677
|
+
|
|
515
678
|
// src/request/index.ts
|
|
516
679
|
var request = async (method, params, providerId) => {
|
|
517
680
|
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
@@ -551,45 +714,6 @@ var XverseAdapter = class extends SatsConnectAdapter {
|
|
|
551
714
|
// src/adapters/unisat.ts
|
|
552
715
|
import { Buffer } from "buffer";
|
|
553
716
|
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
554
|
-
|
|
555
|
-
// src/addresses/index.ts
|
|
556
|
-
import { createUnsecuredToken } from "jsontokens";
|
|
557
|
-
|
|
558
|
-
// src/addresses/types.ts
|
|
559
|
-
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
560
|
-
AddressPurpose2["Ordinals"] = "ordinals";
|
|
561
|
-
AddressPurpose2["Payment"] = "payment";
|
|
562
|
-
AddressPurpose2["Stacks"] = "stacks";
|
|
563
|
-
return AddressPurpose2;
|
|
564
|
-
})(AddressPurpose || {});
|
|
565
|
-
var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
566
|
-
AddressType3["p2pkh"] = "p2pkh";
|
|
567
|
-
AddressType3["p2sh"] = "p2sh";
|
|
568
|
-
AddressType3["p2wpkh"] = "p2wpkh";
|
|
569
|
-
AddressType3["p2wsh"] = "p2wsh";
|
|
570
|
-
AddressType3["p2tr"] = "p2tr";
|
|
571
|
-
AddressType3["stacks"] = "stacks";
|
|
572
|
-
return AddressType3;
|
|
573
|
-
})(AddressType || {});
|
|
574
|
-
|
|
575
|
-
// src/addresses/index.ts
|
|
576
|
-
var getAddress = async (options) => {
|
|
577
|
-
const provider = await getProviderOrThrow(options.getProvider);
|
|
578
|
-
const { purposes } = options.payload;
|
|
579
|
-
if (!purposes) {
|
|
580
|
-
throw new Error("Address purposes are required");
|
|
581
|
-
}
|
|
582
|
-
try {
|
|
583
|
-
const request2 = createUnsecuredToken(options.payload);
|
|
584
|
-
const response = await provider.connect(request2);
|
|
585
|
-
options.onFinish?.(response);
|
|
586
|
-
} catch (error) {
|
|
587
|
-
console.error("[Connect] Error during address request", error);
|
|
588
|
-
options.onCancel?.();
|
|
589
|
-
}
|
|
590
|
-
};
|
|
591
|
-
|
|
592
|
-
// src/adapters/unisat.ts
|
|
593
717
|
function convertSignInputsToInputType(signInputs, allowedSignHash) {
|
|
594
718
|
let result = [];
|
|
595
719
|
for (let address in signInputs) {
|
|
@@ -994,12 +1118,33 @@ export {
|
|
|
994
1118
|
DefaultAdaptersInfo,
|
|
995
1119
|
RpcErrorCode,
|
|
996
1120
|
SatsConnectAdapter,
|
|
1121
|
+
addressSchema,
|
|
1122
|
+
connectMethodName,
|
|
1123
|
+
connectParamsSchema,
|
|
1124
|
+
connectResultSchema,
|
|
1125
|
+
connectSchema,
|
|
997
1126
|
createInscription,
|
|
998
1127
|
createRepeatInscriptions,
|
|
999
1128
|
defaultAdapters,
|
|
1129
|
+
disconnectMethodName,
|
|
1130
|
+
disconnectParamsSchema,
|
|
1131
|
+
disconnectResultSchema,
|
|
1132
|
+
disconnectSchema,
|
|
1133
|
+
getAccountsMethodName,
|
|
1134
|
+
getAccountsParamsSchema,
|
|
1135
|
+
getAccountsRequestMessageSchema,
|
|
1136
|
+
getAccountsResultSchema,
|
|
1000
1137
|
getAddress,
|
|
1138
|
+
getAddressesMethodName,
|
|
1139
|
+
getAddressesParamsSchema,
|
|
1140
|
+
getAddressesRequestMessageSchema,
|
|
1141
|
+
getAddressesResultSchema,
|
|
1001
1142
|
getCapabilities,
|
|
1002
1143
|
getDefaultProvider,
|
|
1144
|
+
getInfoMethodName,
|
|
1145
|
+
getInfoParamsSchema,
|
|
1146
|
+
getInfoResultSchema,
|
|
1147
|
+
getInfoSchema,
|
|
1003
1148
|
getProviderById,
|
|
1004
1149
|
getProviderOrThrow,
|
|
1005
1150
|
getProviders,
|
|
@@ -1007,9 +1152,14 @@ export {
|
|
|
1007
1152
|
isProviderInstalled,
|
|
1008
1153
|
removeDefaultProvider,
|
|
1009
1154
|
request,
|
|
1155
|
+
rpcRequestMessageSchema,
|
|
1010
1156
|
sendBtcTransaction,
|
|
1011
1157
|
setDefaultProvider,
|
|
1012
1158
|
signMessage,
|
|
1159
|
+
signMessageMethodName,
|
|
1160
|
+
signMessageParamsSchema,
|
|
1161
|
+
signMessageRequestMessageSchema,
|
|
1162
|
+
signMessageResultSchema,
|
|
1013
1163
|
signMultipleTransactions,
|
|
1014
1164
|
signTransaction
|
|
1015
1165
|
};
|
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-a271383",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
"jsontokens": "4.0.1",
|
|
31
31
|
"lodash.omit": "4.5.0"
|
|
32
32
|
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"valibot": "0.33.2"
|
|
35
|
+
},
|
|
33
36
|
"devDependencies": {
|
|
34
37
|
"@types/jest": "^29.2.6",
|
|
35
38
|
"@types/lodash.omit": "4.5.9",
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
"ts-jest": "^29.0.5",
|
|
43
46
|
"ts-loader": "^9.4.1",
|
|
44
47
|
"tsup": "^8.0.2",
|
|
45
|
-
"typescript": "
|
|
48
|
+
"typescript": "5.4.5",
|
|
46
49
|
"util": "^0.12.4",
|
|
47
50
|
"vm-browserify": "^1.1.2",
|
|
48
51
|
"webpack": "^5.74.0",
|