@sats-connect/core 0.0.10 → 0.0.11-06e5be7
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 +171 -65
- package/dist/index.mjs +243 -43
- 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[];
|
|
@@ -141,7 +143,8 @@ declare function getSupportedWallets(): SupportedWallet[];
|
|
|
141
143
|
|
|
142
144
|
declare enum BitcoinNetworkType {
|
|
143
145
|
Mainnet = "Mainnet",
|
|
144
|
-
Testnet = "Testnet"
|
|
146
|
+
Testnet = "Testnet",
|
|
147
|
+
Signet = "Signet"
|
|
145
148
|
}
|
|
146
149
|
interface BitcoinNetwork {
|
|
147
150
|
type: BitcoinNetworkType;
|
|
@@ -156,6 +159,13 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
156
159
|
payload: Payload;
|
|
157
160
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
158
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>;
|
|
159
169
|
type RpcId = string | null;
|
|
160
170
|
interface RpcBase {
|
|
161
171
|
jsonrpc: '2.0';
|
|
@@ -242,12 +252,13 @@ declare enum AddressType {
|
|
|
242
252
|
p2tr = "p2tr",
|
|
243
253
|
stacks = "stacks"
|
|
244
254
|
}
|
|
245
|
-
|
|
246
|
-
address:
|
|
247
|
-
publicKey:
|
|
248
|
-
purpose
|
|
249
|
-
addressType
|
|
250
|
-
}
|
|
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>;
|
|
251
262
|
interface GetAddressResponse {
|
|
252
263
|
addresses: Address$1[];
|
|
253
264
|
}
|
|
@@ -255,59 +266,110 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
|
255
266
|
|
|
256
267
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
257
268
|
|
|
258
|
-
|
|
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
|
-
|
|
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<{
|
|
287
334
|
/**
|
|
288
335
|
* The address used for signing.
|
|
289
336
|
**/
|
|
290
|
-
address:
|
|
337
|
+
readonly address: v.StringSchema<undefined>;
|
|
291
338
|
/**
|
|
292
339
|
* The message to sign.
|
|
293
340
|
**/
|
|
294
|
-
message:
|
|
295
|
-
}
|
|
296
|
-
|
|
341
|
+
readonly message: v.StringSchema<undefined>;
|
|
342
|
+
}, undefined>;
|
|
343
|
+
declare const signMessageResultSchema: v.ObjectSchema<{
|
|
297
344
|
/**
|
|
298
345
|
* The signature of the message.
|
|
299
346
|
*/
|
|
300
|
-
signature:
|
|
347
|
+
readonly signature: v.StringSchema<undefined>;
|
|
301
348
|
/**
|
|
302
349
|
* hash of the message.
|
|
303
350
|
*/
|
|
304
|
-
messageHash:
|
|
351
|
+
readonly messageHash: v.StringSchema<undefined>;
|
|
305
352
|
/**
|
|
306
353
|
* The address used for signing.
|
|
307
354
|
*/
|
|
308
|
-
address:
|
|
309
|
-
}
|
|
310
|
-
|
|
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>>;
|
|
311
373
|
type Recipient$1 = {
|
|
312
374
|
/**
|
|
313
375
|
* The recipient's address.
|
|
@@ -364,22 +426,41 @@ type SignPsbtResult = {
|
|
|
364
426
|
txid?: string;
|
|
365
427
|
};
|
|
366
428
|
type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
*
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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>>;
|
|
383
464
|
|
|
384
465
|
type CreateMintOrderRequest = {
|
|
385
466
|
runeName: string;
|
|
@@ -684,6 +765,27 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
684
765
|
type SignTransactionResult = Transaction;
|
|
685
766
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
686
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
|
+
|
|
687
789
|
interface StxRequests {
|
|
688
790
|
stx_callContract: StxCallContract;
|
|
689
791
|
stx_deployContract: StxDeployContract;
|
|
@@ -715,11 +817,15 @@ interface RunesRequests {
|
|
|
715
817
|
runes_getBalance: GetRunesBalance;
|
|
716
818
|
}
|
|
717
819
|
type RunesRequestMethod = keyof RunesRequests;
|
|
718
|
-
|
|
820
|
+
interface WalletMethods {
|
|
821
|
+
wallet_connect: Connect;
|
|
822
|
+
wallet_disconnect: Disconnect;
|
|
823
|
+
}
|
|
824
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
|
|
719
825
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
720
826
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
721
827
|
|
|
722
|
-
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>>;
|
|
723
829
|
|
|
724
830
|
declare abstract class SatsConnectAdapter {
|
|
725
831
|
abstract readonly id: string;
|
|
@@ -737,10 +843,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
737
843
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
738
844
|
id: string;
|
|
739
845
|
constructor(providerId: string);
|
|
740
|
-
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>>;
|
|
741
847
|
}
|
|
742
848
|
|
|
743
849
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
744
850
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
745
851
|
|
|
746
|
-
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,9 +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";
|
|
6
|
+
BitcoinNetworkType2["Signet"] = "Signet";
|
|
5
7
|
return BitcoinNetworkType2;
|
|
6
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
|
+
});
|
|
7
25
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
8
26
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
9
27
|
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
@@ -17,7 +35,12 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
17
35
|
|
|
18
36
|
// src/runes/api.ts
|
|
19
37
|
import axios from "axios";
|
|
20
|
-
var
|
|
38
|
+
var urlNetworkSuffix = {
|
|
39
|
+
["Mainnet" /* Mainnet */]: "",
|
|
40
|
+
["Testnet" /* Testnet */]: "-testnet",
|
|
41
|
+
["Signet" /* Signet */]: "-signet"
|
|
42
|
+
};
|
|
43
|
+
var ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
|
|
21
44
|
var RunesApi = class {
|
|
22
45
|
client;
|
|
23
46
|
constructor(network) {
|
|
@@ -151,14 +174,28 @@ var RunesApi = class {
|
|
|
151
174
|
}
|
|
152
175
|
};
|
|
153
176
|
};
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
|
|
177
|
+
var clients = {};
|
|
178
|
+
var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
|
|
179
|
+
if (!clients[network]) {
|
|
180
|
+
clients[network] = new RunesApi(network);
|
|
181
|
+
}
|
|
182
|
+
return clients[network];
|
|
183
|
+
};
|
|
157
184
|
|
|
158
185
|
// src/adapters/satsConnectAdapter.ts
|
|
159
186
|
var SatsConnectAdapter = class {
|
|
160
187
|
async mintRunes(params) {
|
|
161
188
|
try {
|
|
189
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
190
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
191
|
+
const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
|
|
192
|
+
if (isMintSupported) {
|
|
193
|
+
const response = await this.requestInternal("runes_mint", params);
|
|
194
|
+
if (response) {
|
|
195
|
+
return response;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
162
199
|
const mintRequest = {
|
|
163
200
|
destinationAddress: params.destinationAddress,
|
|
164
201
|
feeRate: params.feeRate,
|
|
@@ -228,6 +265,16 @@ var SatsConnectAdapter = class {
|
|
|
228
265
|
appServiceFeeAddress: params.appServiceFeeAddress
|
|
229
266
|
};
|
|
230
267
|
try {
|
|
268
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
269
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
270
|
+
const isEtchSupported = walletInfo.result.methods?.includes("runes_etch");
|
|
271
|
+
if (isEtchSupported) {
|
|
272
|
+
const response = await this.requestInternal("runes_etch", params);
|
|
273
|
+
if (response) {
|
|
274
|
+
return response;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
231
278
|
const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
|
|
232
279
|
if (!orderResponse.data) {
|
|
233
280
|
return {
|
|
@@ -482,6 +529,172 @@ function getSupportedWallets() {
|
|
|
482
529
|
return wallets;
|
|
483
530
|
}
|
|
484
531
|
|
|
532
|
+
// src/addresses/index.ts
|
|
533
|
+
import { createUnsecuredToken } from "jsontokens";
|
|
534
|
+
|
|
535
|
+
// src/addresses/types.ts
|
|
536
|
+
import * as v2 from "valibot";
|
|
537
|
+
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
538
|
+
AddressPurpose2["Ordinals"] = "ordinals";
|
|
539
|
+
AddressPurpose2["Payment"] = "payment";
|
|
540
|
+
AddressPurpose2["Stacks"] = "stacks";
|
|
541
|
+
return AddressPurpose2;
|
|
542
|
+
})(AddressPurpose || {});
|
|
543
|
+
var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
544
|
+
AddressType3["p2pkh"] = "p2pkh";
|
|
545
|
+
AddressType3["p2sh"] = "p2sh";
|
|
546
|
+
AddressType3["p2wpkh"] = "p2wpkh";
|
|
547
|
+
AddressType3["p2wsh"] = "p2wsh";
|
|
548
|
+
AddressType3["p2tr"] = "p2tr";
|
|
549
|
+
AddressType3["stacks"] = "stacks";
|
|
550
|
+
return AddressType3;
|
|
551
|
+
})(AddressType || {});
|
|
552
|
+
var addressSchema = v2.object({
|
|
553
|
+
address: v2.string(),
|
|
554
|
+
publicKey: v2.string(),
|
|
555
|
+
purpose: v2.enum(AddressPurpose),
|
|
556
|
+
addressType: v2.enum(AddressType)
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
// src/addresses/index.ts
|
|
560
|
+
var getAddress = async (options) => {
|
|
561
|
+
const provider = await getProviderOrThrow(options.getProvider);
|
|
562
|
+
const { purposes } = options.payload;
|
|
563
|
+
if (!purposes) {
|
|
564
|
+
throw new Error("Address purposes are required");
|
|
565
|
+
}
|
|
566
|
+
try {
|
|
567
|
+
const request2 = createUnsecuredToken(options.payload);
|
|
568
|
+
const response = await provider.connect(request2);
|
|
569
|
+
options.onFinish?.(response);
|
|
570
|
+
} catch (error) {
|
|
571
|
+
console.error("[Connect] Error during address request", error);
|
|
572
|
+
options.onCancel?.();
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
// src/request/types/btcMethods.ts
|
|
577
|
+
import * as v3 from "valibot";
|
|
578
|
+
var getInfoMethodName = "getInfo";
|
|
579
|
+
var getInfoParamsSchema = v3.null();
|
|
580
|
+
var getInfoResultSchema = v3.object({
|
|
581
|
+
/**
|
|
582
|
+
* Version of the wallet.
|
|
583
|
+
*/
|
|
584
|
+
version: v3.string(),
|
|
585
|
+
/**
|
|
586
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
587
|
+
*/
|
|
588
|
+
methods: v3.optional(v3.array(v3.string())),
|
|
589
|
+
/**
|
|
590
|
+
* List of WBIP standards supported by the wallet. Not currently used.
|
|
591
|
+
*/
|
|
592
|
+
supports: v3.array(v3.string())
|
|
593
|
+
});
|
|
594
|
+
var getInfoSchema = v3.object({
|
|
595
|
+
...rpcRequestMessageSchema.entries,
|
|
596
|
+
...v3.object({
|
|
597
|
+
method: v3.literal(getInfoMethodName),
|
|
598
|
+
params: getInfoParamsSchema,
|
|
599
|
+
id: v3.string()
|
|
600
|
+
}).entries
|
|
601
|
+
});
|
|
602
|
+
var getAddressesMethodName = "getAddresses";
|
|
603
|
+
var getAddressesParamsSchema = v3.object({
|
|
604
|
+
/**
|
|
605
|
+
* The purposes for which to generate addresses. See
|
|
606
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
607
|
+
*/
|
|
608
|
+
purposes: v3.array(v3.enum(AddressPurpose)),
|
|
609
|
+
/**
|
|
610
|
+
* A message to be displayed to the user in the request prompt.
|
|
611
|
+
*/
|
|
612
|
+
message: v3.optional(v3.string())
|
|
613
|
+
});
|
|
614
|
+
var getAddressesResultSchema = v3.object({
|
|
615
|
+
/**
|
|
616
|
+
* The addresses generated for the given purposes.
|
|
617
|
+
*/
|
|
618
|
+
addresses: v3.array(addressSchema)
|
|
619
|
+
});
|
|
620
|
+
var getAddressesRequestMessageSchema = v3.object({
|
|
621
|
+
...rpcRequestMessageSchema.entries,
|
|
622
|
+
...v3.object({
|
|
623
|
+
method: v3.literal(getAddressesMethodName),
|
|
624
|
+
params: getAddressesParamsSchema,
|
|
625
|
+
id: v3.string()
|
|
626
|
+
}).entries
|
|
627
|
+
});
|
|
628
|
+
var signMessageMethodName = "signMessage";
|
|
629
|
+
var signMessageParamsSchema = v3.object({
|
|
630
|
+
/**
|
|
631
|
+
* The address used for signing.
|
|
632
|
+
**/
|
|
633
|
+
address: v3.string(),
|
|
634
|
+
/**
|
|
635
|
+
* The message to sign.
|
|
636
|
+
**/
|
|
637
|
+
message: v3.string()
|
|
638
|
+
});
|
|
639
|
+
var signMessageResultSchema = v3.object({
|
|
640
|
+
/**
|
|
641
|
+
* The signature of the message.
|
|
642
|
+
*/
|
|
643
|
+
signature: v3.string(),
|
|
644
|
+
/**
|
|
645
|
+
* hash of the message.
|
|
646
|
+
*/
|
|
647
|
+
messageHash: v3.string(),
|
|
648
|
+
/**
|
|
649
|
+
* The address used for signing.
|
|
650
|
+
*/
|
|
651
|
+
address: v3.string()
|
|
652
|
+
});
|
|
653
|
+
var signMessageRequestMessageSchema = v3.object({
|
|
654
|
+
...rpcRequestMessageSchema.entries,
|
|
655
|
+
...v3.object({
|
|
656
|
+
method: v3.literal(signMessageMethodName),
|
|
657
|
+
params: signMessageParamsSchema,
|
|
658
|
+
id: v3.string()
|
|
659
|
+
}).entries
|
|
660
|
+
});
|
|
661
|
+
var getAccountsMethodName = "getAccounts";
|
|
662
|
+
var getAccountsParamsSchema = getAddressesParamsSchema;
|
|
663
|
+
var getAccountsResultSchema = v3.array(addressSchema);
|
|
664
|
+
var getAccountsRequestMessageSchema = v3.object({
|
|
665
|
+
...rpcRequestMessageSchema.entries,
|
|
666
|
+
...v3.object({
|
|
667
|
+
method: v3.literal(getAccountsMethodName),
|
|
668
|
+
params: getAccountsParamsSchema,
|
|
669
|
+
id: v3.string()
|
|
670
|
+
}).entries
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
// src/request/types/walletMethods.ts
|
|
674
|
+
import * as v4 from "valibot";
|
|
675
|
+
var connectMethodName = "wallet_connect";
|
|
676
|
+
var connectParamsSchema = v4.undefined();
|
|
677
|
+
var connectResultSchema = v4.undefined();
|
|
678
|
+
var connectSchema = v4.object({
|
|
679
|
+
...rpcRequestMessageSchema.entries,
|
|
680
|
+
...v4.object({
|
|
681
|
+
method: v4.literal(connectMethodName),
|
|
682
|
+
params: connectParamsSchema,
|
|
683
|
+
id: v4.string()
|
|
684
|
+
}).entries
|
|
685
|
+
});
|
|
686
|
+
var disconnectMethodName = "wallet_disconnect";
|
|
687
|
+
var disconnectParamsSchema = v4.undefined();
|
|
688
|
+
var disconnectResultSchema = v4.undefined();
|
|
689
|
+
var disconnectSchema = v4.object({
|
|
690
|
+
...rpcRequestMessageSchema.entries,
|
|
691
|
+
...v4.object({
|
|
692
|
+
method: v4.literal(disconnectMethodName),
|
|
693
|
+
params: disconnectParamsSchema,
|
|
694
|
+
id: v4.string()
|
|
695
|
+
}).entries
|
|
696
|
+
});
|
|
697
|
+
|
|
485
698
|
// src/request/index.ts
|
|
486
699
|
var request = async (method, params, providerId) => {
|
|
487
700
|
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
@@ -521,45 +734,6 @@ var XverseAdapter = class extends SatsConnectAdapter {
|
|
|
521
734
|
// src/adapters/unisat.ts
|
|
522
735
|
import { Buffer } from "buffer";
|
|
523
736
|
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
524
|
-
|
|
525
|
-
// src/addresses/index.ts
|
|
526
|
-
import { createUnsecuredToken } from "jsontokens";
|
|
527
|
-
|
|
528
|
-
// src/addresses/types.ts
|
|
529
|
-
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
530
|
-
AddressPurpose2["Ordinals"] = "ordinals";
|
|
531
|
-
AddressPurpose2["Payment"] = "payment";
|
|
532
|
-
AddressPurpose2["Stacks"] = "stacks";
|
|
533
|
-
return AddressPurpose2;
|
|
534
|
-
})(AddressPurpose || {});
|
|
535
|
-
var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
536
|
-
AddressType3["p2pkh"] = "p2pkh";
|
|
537
|
-
AddressType3["p2sh"] = "p2sh";
|
|
538
|
-
AddressType3["p2wpkh"] = "p2wpkh";
|
|
539
|
-
AddressType3["p2wsh"] = "p2wsh";
|
|
540
|
-
AddressType3["p2tr"] = "p2tr";
|
|
541
|
-
AddressType3["stacks"] = "stacks";
|
|
542
|
-
return AddressType3;
|
|
543
|
-
})(AddressType || {});
|
|
544
|
-
|
|
545
|
-
// src/addresses/index.ts
|
|
546
|
-
var getAddress = async (options) => {
|
|
547
|
-
const provider = await getProviderOrThrow(options.getProvider);
|
|
548
|
-
const { purposes } = options.payload;
|
|
549
|
-
if (!purposes) {
|
|
550
|
-
throw new Error("Address purposes are required");
|
|
551
|
-
}
|
|
552
|
-
try {
|
|
553
|
-
const request2 = createUnsecuredToken(options.payload);
|
|
554
|
-
const response = await provider.connect(request2);
|
|
555
|
-
options.onFinish?.(response);
|
|
556
|
-
} catch (error) {
|
|
557
|
-
console.error("[Connect] Error during address request", error);
|
|
558
|
-
options.onCancel?.();
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
|
|
562
|
-
// src/adapters/unisat.ts
|
|
563
737
|
function convertSignInputsToInputType(signInputs, allowedSignHash) {
|
|
564
738
|
let result = [];
|
|
565
739
|
for (let address in signInputs) {
|
|
@@ -964,12 +1138,33 @@ export {
|
|
|
964
1138
|
DefaultAdaptersInfo,
|
|
965
1139
|
RpcErrorCode,
|
|
966
1140
|
SatsConnectAdapter,
|
|
1141
|
+
addressSchema,
|
|
1142
|
+
connectMethodName,
|
|
1143
|
+
connectParamsSchema,
|
|
1144
|
+
connectResultSchema,
|
|
1145
|
+
connectSchema,
|
|
967
1146
|
createInscription,
|
|
968
1147
|
createRepeatInscriptions,
|
|
969
1148
|
defaultAdapters,
|
|
1149
|
+
disconnectMethodName,
|
|
1150
|
+
disconnectParamsSchema,
|
|
1151
|
+
disconnectResultSchema,
|
|
1152
|
+
disconnectSchema,
|
|
1153
|
+
getAccountsMethodName,
|
|
1154
|
+
getAccountsParamsSchema,
|
|
1155
|
+
getAccountsRequestMessageSchema,
|
|
1156
|
+
getAccountsResultSchema,
|
|
970
1157
|
getAddress,
|
|
1158
|
+
getAddressesMethodName,
|
|
1159
|
+
getAddressesParamsSchema,
|
|
1160
|
+
getAddressesRequestMessageSchema,
|
|
1161
|
+
getAddressesResultSchema,
|
|
971
1162
|
getCapabilities,
|
|
972
1163
|
getDefaultProvider,
|
|
1164
|
+
getInfoMethodName,
|
|
1165
|
+
getInfoParamsSchema,
|
|
1166
|
+
getInfoResultSchema,
|
|
1167
|
+
getInfoSchema,
|
|
973
1168
|
getProviderById,
|
|
974
1169
|
getProviderOrThrow,
|
|
975
1170
|
getProviders,
|
|
@@ -977,9 +1172,14 @@ export {
|
|
|
977
1172
|
isProviderInstalled,
|
|
978
1173
|
removeDefaultProvider,
|
|
979
1174
|
request,
|
|
1175
|
+
rpcRequestMessageSchema,
|
|
980
1176
|
sendBtcTransaction,
|
|
981
1177
|
setDefaultProvider,
|
|
982
1178
|
signMessage,
|
|
1179
|
+
signMessageMethodName,
|
|
1180
|
+
signMessageParamsSchema,
|
|
1181
|
+
signMessageRequestMessageSchema,
|
|
1182
|
+
signMessageResultSchema,
|
|
983
1183
|
signMultipleTransactions,
|
|
984
1184
|
signTransaction
|
|
985
1185
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11-06e5be7",
|
|
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",
|