@sats-connect/core 0.0.10 → 0.0.11-6fcd68a

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 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
- interface Address$1 {
246
- address: string;
247
- publicKey: string;
248
- purpose?: AddressPurpose;
249
- addressType?: 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
- * Represents the types and interfaces related to BTC methods.
260
- */
261
-
262
- type GetInfoResult = {
263
- version: number | string;
264
- methods?: Array<string>;
265
- supports?: Array<string>;
266
- };
267
- type GetInfo = MethodParamsAndResult<null, GetInfoResult>;
268
- type GetAddressesParams$1 = {
269
- /**
270
- * The purposes for which to generate addresses.
271
- * possible values are "payment", "ordinals", ...
272
- */
273
- purposes: Array<AddressPurpose>;
274
- /**
275
- * a message to be displayed to the user in the request prompt.
276
- */
277
- message?: string;
278
- };
279
- /**
280
- * The addresses generated for the given purposes.
281
- */
282
- type GetAddressesResult$1 = {
283
- addresses: Array<Address$1>;
284
- };
285
- type GetAddresses = MethodParamsAndResult<GetAddressesParams$1, GetAddressesResult$1>;
286
- type SignMessageParams = {
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: string;
337
+ readonly address: v.StringSchema<undefined>;
291
338
  /**
292
339
  * The message to sign.
293
340
  **/
294
- message: string;
295
- };
296
- type SignMessageResult = {
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: string;
347
+ readonly signature: v.StringSchema<undefined>;
301
348
  /**
302
349
  * hash of the message.
303
350
  */
304
- messageHash: string;
351
+ readonly messageHash: v.StringSchema<undefined>;
305
352
  /**
306
353
  * The address used for signing.
307
354
  */
308
- address: string;
309
- };
310
- type SignMessage = MethodParamsAndResult<SignMessageParams, SignMessageResult>;
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
- type GetAccountsParams = {
368
- /**
369
- * The purposes for which to generate addresses.
370
- * possible values are "payment", "ordinals", ...
371
- */
372
- purposes: Array<AddressPurpose>;
373
- /**
374
- * a message to be displayed to the user in the request prompt.
375
- */
376
- /**
377
- * a message to be displayed to the user in the request prompt.
378
- */
379
- message?: string;
380
- };
381
- type GetAccountResult = Address$1[];
382
- type GetAccounts = MethodParamsAndResult<GetAccountsParams, GetAccountResult>;
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;
@@ -743,4 +824,4 @@ declare class BaseAdapter extends SatsConnectAdapter {
743
824
  declare const DefaultAdaptersInfo: Record<string, Provider>;
744
825
  declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
745
826
 
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 GetAccountResult, type GetAccounts, type GetAccountsParams, 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 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 SignMessageParams, 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, createInscription, createRepeatInscriptions, defaultAdapters, getAddress, getCapabilities, getDefaultProvider, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, sendBtcTransaction, setDefaultProvider, signMessage, signMultipleTransactions, signTransaction };
827
+ 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 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, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, 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 ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => `https://ordinals${network === "Testnet" /* Testnet */ ? "-testnet" : ""}.xverse.app/v1`;
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,9 +174,13 @@ var RunesApi = class {
151
174
  }
152
175
  };
153
176
  };
154
- var testnetClient = new RunesApi("Testnet" /* Testnet */);
155
- var mainnetClient = new RunesApi("Mainnet" /* Mainnet */);
156
- var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => network === "Mainnet" /* Mainnet */ ? mainnetClient : testnetClient;
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 {
@@ -482,6 +509,147 @@ function getSupportedWallets() {
482
509
  return wallets;
483
510
  }
484
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
+
485
653
  // src/request/index.ts
486
654
  var request = async (method, params, providerId) => {
487
655
  let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
@@ -521,45 +689,6 @@ var XverseAdapter = class extends SatsConnectAdapter {
521
689
  // src/adapters/unisat.ts
522
690
  import { Buffer } from "buffer";
523
691
  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
692
  function convertSignInputsToInputType(signInputs, allowedSignHash) {
564
693
  let result = [];
565
694
  for (let address in signInputs) {
@@ -964,12 +1093,25 @@ export {
964
1093
  DefaultAdaptersInfo,
965
1094
  RpcErrorCode,
966
1095
  SatsConnectAdapter,
1096
+ addressSchema,
967
1097
  createInscription,
968
1098
  createRepeatInscriptions,
969
1099
  defaultAdapters,
1100
+ getAccountsMethodName,
1101
+ getAccountsParamsSchema,
1102
+ getAccountsRequestMessageSchema,
1103
+ getAccountsResultSchema,
970
1104
  getAddress,
1105
+ getAddressesMethodName,
1106
+ getAddressesParamsSchema,
1107
+ getAddressesRequestMessageSchema,
1108
+ getAddressesResultSchema,
971
1109
  getCapabilities,
972
1110
  getDefaultProvider,
1111
+ getInfoMethodName,
1112
+ getInfoParamsSchema,
1113
+ getInfoResultSchema,
1114
+ getInfoSchema,
973
1115
  getProviderById,
974
1116
  getProviderOrThrow,
975
1117
  getProviders,
@@ -977,9 +1119,14 @@ export {
977
1119
  isProviderInstalled,
978
1120
  removeDefaultProvider,
979
1121
  request,
1122
+ rpcRequestMessageSchema,
980
1123
  sendBtcTransaction,
981
1124
  setDefaultProvider,
982
1125
  signMessage,
1126
+ signMessageMethodName,
1127
+ signMessageParamsSchema,
1128
+ signMessageRequestMessageSchema,
1129
+ signMessageResultSchema,
983
1130
  signMultipleTransactions,
984
1131
  signTransaction
985
1132
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.10",
3
+ "version": "0.0.11-6fcd68a",
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": "^4.9.4",
48
+ "typescript": "5.4.5",
46
49
  "util": "^0.12.4",
47
50
  "vm-browserify": "^1.1.2",
48
51
  "webpack": "^5.74.0",