@sats-connect/core 0.0.10 → 0.0.11-4781818

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>], 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,17 @@
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(v.union([v.array(v.unknown()), v.looseObject({})])),
13
+ id: v.optional(v.union([v.string(), v.number(), v.null()]))
14
+ });
7
15
  var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
8
16
  RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
9
17
  RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
@@ -17,7 +25,12 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
17
25
 
18
26
  // src/runes/api.ts
19
27
  import axios from "axios";
20
- var ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => `https://ordinals${network === "Testnet" /* Testnet */ ? "-testnet" : ""}.xverse.app/v1`;
28
+ var urlNetworkSuffix = {
29
+ ["Mainnet" /* Mainnet */]: "",
30
+ ["Testnet" /* Testnet */]: "-testnet",
31
+ ["Signet" /* Signet */]: "-signet"
32
+ };
33
+ var ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
21
34
  var RunesApi = class {
22
35
  client;
23
36
  constructor(network) {
@@ -151,9 +164,13 @@ var RunesApi = class {
151
164
  }
152
165
  };
153
166
  };
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;
167
+ var clients = {};
168
+ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
169
+ if (!clients[network]) {
170
+ clients[network] = new RunesApi(network);
171
+ }
172
+ return clients[network];
173
+ };
157
174
 
158
175
  // src/adapters/satsConnectAdapter.ts
159
176
  var SatsConnectAdapter = class {
@@ -482,6 +499,147 @@ function getSupportedWallets() {
482
499
  return wallets;
483
500
  }
484
501
 
502
+ // src/addresses/index.ts
503
+ import { createUnsecuredToken } from "jsontokens";
504
+
505
+ // src/addresses/types.ts
506
+ import * as v2 from "valibot";
507
+ var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
508
+ AddressPurpose2["Ordinals"] = "ordinals";
509
+ AddressPurpose2["Payment"] = "payment";
510
+ AddressPurpose2["Stacks"] = "stacks";
511
+ return AddressPurpose2;
512
+ })(AddressPurpose || {});
513
+ var AddressType = /* @__PURE__ */ ((AddressType3) => {
514
+ AddressType3["p2pkh"] = "p2pkh";
515
+ AddressType3["p2sh"] = "p2sh";
516
+ AddressType3["p2wpkh"] = "p2wpkh";
517
+ AddressType3["p2wsh"] = "p2wsh";
518
+ AddressType3["p2tr"] = "p2tr";
519
+ AddressType3["stacks"] = "stacks";
520
+ return AddressType3;
521
+ })(AddressType || {});
522
+ var addressSchema = v2.object({
523
+ address: v2.string(),
524
+ publicKey: v2.string(),
525
+ purpose: v2.enum(AddressPurpose),
526
+ addressType: v2.enum(AddressType)
527
+ });
528
+
529
+ // src/addresses/index.ts
530
+ var getAddress = async (options) => {
531
+ const provider = await getProviderOrThrow(options.getProvider);
532
+ const { purposes } = options.payload;
533
+ if (!purposes) {
534
+ throw new Error("Address purposes are required");
535
+ }
536
+ try {
537
+ const request2 = createUnsecuredToken(options.payload);
538
+ const response = await provider.connect(request2);
539
+ options.onFinish?.(response);
540
+ } catch (error) {
541
+ console.error("[Connect] Error during address request", error);
542
+ options.onCancel?.();
543
+ }
544
+ };
545
+
546
+ // src/request/types/btcMethods.ts
547
+ import * as v3 from "valibot";
548
+ var getInfoMethodName = "getInfo";
549
+ var getInfoParamsSchema = v3.null();
550
+ var getInfoResultSchema = v3.object({
551
+ /**
552
+ * Version of the wallet.
553
+ */
554
+ version: v3.string(),
555
+ /**
556
+ * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
557
+ */
558
+ methods: v3.optional(v3.array(v3.string())),
559
+ /**
560
+ * List of WBIP standards supported by the wallet. Not currently used.
561
+ */
562
+ supports: v3.array(v3.string())
563
+ });
564
+ var getInfoSchema = v3.object({
565
+ ...rpcRequestMessageSchema.entries,
566
+ ...v3.object({
567
+ method: v3.literal(getInfoMethodName),
568
+ params: getInfoParamsSchema,
569
+ id: v3.string()
570
+ }).entries
571
+ });
572
+ var getAddressesMethodName = "getAddresses";
573
+ var getAddressesParamsSchema = v3.object({
574
+ /**
575
+ * The purposes for which to generate addresses. See
576
+ * {@linkcode AddressPurpose} for available purposes.
577
+ */
578
+ purposes: v3.array(v3.enum(AddressPurpose)),
579
+ /**
580
+ * A message to be displayed to the user in the request prompt.
581
+ */
582
+ message: v3.optional(v3.string())
583
+ });
584
+ var getAddressesResultSchema = v3.object({
585
+ /**
586
+ * The addresses generated for the given purposes.
587
+ */
588
+ addresses: v3.array(addressSchema)
589
+ });
590
+ var getAddressesRequestMessageSchema = v3.object({
591
+ ...rpcRequestMessageSchema.entries,
592
+ ...v3.object({
593
+ method: v3.literal(getAddressesMethodName),
594
+ params: getAddressesParamsSchema,
595
+ id: v3.string()
596
+ }).entries
597
+ });
598
+ var signMessageMethodName = "signMessage";
599
+ var signMessageParamsSchema = v3.object({
600
+ /**
601
+ * The address used for signing.
602
+ **/
603
+ address: v3.string(),
604
+ /**
605
+ * The message to sign.
606
+ **/
607
+ message: v3.string()
608
+ });
609
+ var signMessageResultSchema = v3.object({
610
+ /**
611
+ * The signature of the message.
612
+ */
613
+ signature: v3.string(),
614
+ /**
615
+ * hash of the message.
616
+ */
617
+ messageHash: v3.string(),
618
+ /**
619
+ * The address used for signing.
620
+ */
621
+ address: v3.string()
622
+ });
623
+ var signMessageRequestMessageSchema = v3.object({
624
+ ...rpcRequestMessageSchema.entries,
625
+ ...v3.object({
626
+ method: v3.literal(signMessageMethodName),
627
+ params: signMessageParamsSchema,
628
+ id: v3.string()
629
+ }).entries
630
+ });
631
+ var getAccountsMethodName = "getAccounts";
632
+ var getAccountsParamsSchema = getAddressesParamsSchema;
633
+ var getAccountsResultSchema = v3.array(addressSchema);
634
+ var getAccountsRequestMessageSchema = v3.object({
635
+ ...rpcRequestMessageSchema.entries,
636
+ ...v3.object({
637
+ method: v3.literal(getAccountsMethodName),
638
+ params: getAccountsParamsSchema,
639
+ id: v3.string()
640
+ }).entries
641
+ });
642
+
485
643
  // src/request/index.ts
486
644
  var request = async (method, params, providerId) => {
487
645
  let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
@@ -521,45 +679,6 @@ var XverseAdapter = class extends SatsConnectAdapter {
521
679
  // src/adapters/unisat.ts
522
680
  import { Buffer } from "buffer";
523
681
  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
682
  function convertSignInputsToInputType(signInputs, allowedSignHash) {
564
683
  let result = [];
565
684
  for (let address in signInputs) {
@@ -964,12 +1083,25 @@ export {
964
1083
  DefaultAdaptersInfo,
965
1084
  RpcErrorCode,
966
1085
  SatsConnectAdapter,
1086
+ addressSchema,
967
1087
  createInscription,
968
1088
  createRepeatInscriptions,
969
1089
  defaultAdapters,
1090
+ getAccountsMethodName,
1091
+ getAccountsParamsSchema,
1092
+ getAccountsRequestMessageSchema,
1093
+ getAccountsResultSchema,
970
1094
  getAddress,
1095
+ getAddressesMethodName,
1096
+ getAddressesParamsSchema,
1097
+ getAddressesRequestMessageSchema,
1098
+ getAddressesResultSchema,
971
1099
  getCapabilities,
972
1100
  getDefaultProvider,
1101
+ getInfoMethodName,
1102
+ getInfoParamsSchema,
1103
+ getInfoResultSchema,
1104
+ getInfoSchema,
973
1105
  getProviderById,
974
1106
  getProviderOrThrow,
975
1107
  getProviders,
@@ -977,9 +1109,14 @@ export {
977
1109
  isProviderInstalled,
978
1110
  removeDefaultProvider,
979
1111
  request,
1112
+ rpcRequestMessageSchema,
980
1113
  sendBtcTransaction,
981
1114
  setDefaultProvider,
982
1115
  signMessage,
1116
+ signMessageMethodName,
1117
+ signMessageParamsSchema,
1118
+ signMessageRequestMessageSchema,
1119
+ signMessageResultSchema,
983
1120
  signMultipleTransactions,
984
1121
  signTransaction
985
1122
  };
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-4781818",
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",