@sats-connect/core 0.0.9-624596 → 0.0.9-69f5b41

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 { z } from 'zod';
2
+
1
3
  interface GetCapabilitiesPayload extends RequestPayload {
2
4
  }
3
5
  type GetCapabilitiesResponse = Capability[];
@@ -156,6 +158,23 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
156
158
  payload: Payload;
157
159
  getProvider?: () => Promise<BitcoinProvider | undefined>;
158
160
  }
161
+ declare const rpcRequestMessageSchema: z.ZodObject<{
162
+ jsonrpc: z.ZodLiteral<"2.0">;
163
+ method: z.ZodString;
164
+ params: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnknown, "many">, z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>]>>;
165
+ id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
166
+ }, "strip", z.ZodTypeAny, {
167
+ jsonrpc: "2.0";
168
+ method: string;
169
+ params?: unknown[] | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
170
+ id?: string | number | null | undefined;
171
+ }, {
172
+ jsonrpc: "2.0";
173
+ method: string;
174
+ params?: unknown[] | z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
175
+ id?: string | number | null | undefined;
176
+ }>;
177
+ type RpcRequestMessage = z.infer<typeof rpcRequestMessageSchema>;
159
178
  type RpcId = string | null;
160
179
  interface RpcBase {
161
180
  jsonrpc: '2.0';
@@ -242,12 +261,23 @@ declare enum AddressType {
242
261
  p2tr = "p2tr",
243
262
  stacks = "stacks"
244
263
  }
245
- interface Address$1 {
264
+ declare const addressSchema: z.ZodObject<{
265
+ address: z.ZodString;
266
+ publicKey: z.ZodString;
267
+ purpose: z.ZodNativeEnum<typeof AddressPurpose>;
268
+ addressType: z.ZodNativeEnum<typeof AddressType>;
269
+ }, "strip", z.ZodTypeAny, {
246
270
  address: string;
247
271
  publicKey: string;
248
- purpose?: AddressPurpose;
249
- addressType?: AddressType;
250
- }
272
+ purpose: AddressPurpose;
273
+ addressType: AddressType;
274
+ }, {
275
+ address: string;
276
+ publicKey: string;
277
+ purpose: AddressPurpose;
278
+ addressType: AddressType;
279
+ }>;
280
+ type Address$1 = z.infer<typeof addressSchema>;
251
281
  interface GetAddressResponse {
252
282
  addresses: Address$1[];
253
283
  }
@@ -255,59 +285,228 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
255
285
 
256
286
  declare const getAddress: (options: GetAddressOptions) => Promise<void>;
257
287
 
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 = {
288
+ declare const getInfoMethodName = "getInfo";
289
+ declare const getInfoParamsSchema: z.ZodUndefined;
290
+ declare const getInfoResultSchema: z.ZodObject<{
269
291
  /**
270
- * The purposes for which to generate addresses.
271
- * possible values are "payment", "ordinals", ...
292
+ * Version of the wallet.
272
293
  */
273
- purposes: Array<AddressPurpose>;
294
+ version: z.ZodString;
274
295
  /**
275
- * a message to be displayed to the user in the request prompt.
296
+ * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
276
297
  */
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 = {
298
+ methods: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
299
+ /**
300
+ * List of WBIP standards supported by the wallet. Not currently used.
301
+ */
302
+ supports: z.ZodArray<z.ZodString, "many">;
303
+ }, "strip", z.ZodTypeAny, {
304
+ version: string;
305
+ supports: string[];
306
+ methods?: string[] | undefined;
307
+ }, {
308
+ version: string;
309
+ supports: string[];
310
+ methods?: string[] | undefined;
311
+ }>;
312
+ declare const getInfoSchema: z.ZodObject<z.objectUtil.extendShape<{
313
+ jsonrpc: z.ZodLiteral<"2.0">;
314
+ method: z.ZodString;
315
+ params: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnknown, "many">, z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>]>>;
316
+ id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
317
+ }, {
318
+ method: z.ZodLiteral<"getInfo">;
319
+ params: z.ZodUndefined;
320
+ id: z.ZodString;
321
+ }>, "strip", z.ZodTypeAny, {
322
+ jsonrpc: "2.0";
323
+ method: "getInfo";
324
+ id: string;
325
+ params?: undefined;
326
+ }, {
327
+ jsonrpc: "2.0";
328
+ method: "getInfo";
329
+ id: string;
330
+ params?: undefined;
331
+ }>;
332
+ type GetInfo = MethodParamsAndResult<z.infer<typeof getInfoParamsSchema>, z.infer<typeof getInfoResultSchema>>;
333
+ declare const getAddressesMethodName = "getAddresses";
334
+ declare const getAddressesParamsSchema: z.ZodObject<{
335
+ /**
336
+ * The purposes for which to generate addresses. See
337
+ * {@linkcode AddressPurpose} for available purposes.
338
+ */
339
+ purposes: z.ZodArray<z.ZodNativeEnum<typeof AddressPurpose>, "many">;
340
+ /**
341
+ * A message to be displayed to the user in the request prompt.
342
+ */
343
+ message: z.ZodOptional<z.ZodString>;
344
+ }, "strip", z.ZodTypeAny, {
345
+ purposes: AddressPurpose[];
346
+ message?: string | undefined;
347
+ }, {
348
+ purposes: AddressPurpose[];
349
+ message?: string | undefined;
350
+ }>;
351
+ declare const getAddressesResultSchema: z.ZodObject<{
352
+ /**
353
+ * The addresses generated for the given purposes.
354
+ */
355
+ addresses: z.ZodArray<z.ZodObject<{
356
+ address: z.ZodString;
357
+ publicKey: z.ZodString;
358
+ purpose: z.ZodNativeEnum<typeof AddressPurpose>;
359
+ addressType: z.ZodNativeEnum<typeof AddressType>;
360
+ }, "strip", z.ZodTypeAny, {
361
+ address: string;
362
+ publicKey: string;
363
+ purpose: AddressPurpose;
364
+ addressType: AddressType;
365
+ }, {
366
+ address: string;
367
+ publicKey: string;
368
+ purpose: AddressPurpose;
369
+ addressType: AddressType;
370
+ }>, "many">;
371
+ }, "strip", z.ZodTypeAny, {
372
+ addresses: {
373
+ address: string;
374
+ publicKey: string;
375
+ purpose: AddressPurpose;
376
+ addressType: AddressType;
377
+ }[];
378
+ }, {
379
+ addresses: {
380
+ address: string;
381
+ publicKey: string;
382
+ purpose: AddressPurpose;
383
+ addressType: AddressType;
384
+ }[];
385
+ }>;
386
+ declare const getAddressesRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
387
+ jsonrpc: z.ZodLiteral<"2.0">;
388
+ method: z.ZodString;
389
+ params: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnknown, "many">, z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>]>>;
390
+ id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
391
+ }, {
392
+ method: z.ZodLiteral<"getAddresses">;
393
+ params: z.ZodObject<{
394
+ /**
395
+ * The purposes for which to generate addresses. See
396
+ * {@linkcode AddressPurpose} for available purposes.
397
+ */
398
+ purposes: z.ZodArray<z.ZodNativeEnum<typeof AddressPurpose>, "many">;
399
+ /**
400
+ * A message to be displayed to the user in the request prompt.
401
+ */
402
+ message: z.ZodOptional<z.ZodString>;
403
+ }, "strip", z.ZodTypeAny, {
404
+ purposes: AddressPurpose[];
405
+ message?: string | undefined;
406
+ }, {
407
+ purposes: AddressPurpose[];
408
+ message?: string | undefined;
409
+ }>;
410
+ id: z.ZodString;
411
+ }>, "strip", z.ZodTypeAny, {
412
+ jsonrpc: "2.0";
413
+ params: {
414
+ purposes: AddressPurpose[];
415
+ message?: string | undefined;
416
+ };
417
+ method: "getAddresses";
418
+ id: string;
419
+ }, {
420
+ jsonrpc: "2.0";
421
+ params: {
422
+ purposes: AddressPurpose[];
423
+ message?: string | undefined;
424
+ };
425
+ method: "getAddresses";
426
+ id: string;
427
+ }>;
428
+ type GetAddresses = MethodParamsAndResult<z.infer<typeof getAddressesParamsSchema>, z.infer<typeof getAddressesResultSchema>>;
429
+ declare const signMessageMethodName = "signMessage";
430
+ declare const signMessageParamsSchema: z.ZodObject<{
287
431
  /**
288
432
  * The address used for signing.
289
433
  **/
290
- address: string;
434
+ address: z.ZodString;
291
435
  /**
292
436
  * The message to sign.
293
437
  **/
438
+ message: z.ZodString;
439
+ }, "strip", z.ZodTypeAny, {
294
440
  message: string;
295
- };
296
- type SignMessageResult = {
441
+ address: string;
442
+ }, {
443
+ message: string;
444
+ address: string;
445
+ }>;
446
+ declare const signMessageResultSchema: z.ZodObject<{
297
447
  /**
298
448
  * The signature of the message.
299
449
  */
300
- signature: string;
450
+ signature: z.ZodString;
301
451
  /**
302
452
  * hash of the message.
303
453
  */
304
- messageHash: string;
454
+ messageHash: z.ZodString;
305
455
  /**
306
456
  * The address used for signing.
307
457
  */
458
+ address: z.ZodString;
459
+ }, "strip", z.ZodTypeAny, {
308
460
  address: string;
309
- };
310
- type SignMessage = MethodParamsAndResult<SignMessageParams, SignMessageResult>;
461
+ signature: string;
462
+ messageHash: string;
463
+ }, {
464
+ address: string;
465
+ signature: string;
466
+ messageHash: string;
467
+ }>;
468
+ declare const signMessageRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
469
+ jsonrpc: z.ZodLiteral<"2.0">;
470
+ method: z.ZodString;
471
+ params: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnknown, "many">, z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>]>>;
472
+ id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
473
+ }, {
474
+ method: z.ZodLiteral<"getAddresses">;
475
+ params: z.ZodObject<{
476
+ /**
477
+ * The address used for signing.
478
+ **/
479
+ address: z.ZodString;
480
+ /**
481
+ * The message to sign.
482
+ **/
483
+ message: z.ZodString;
484
+ }, "strip", z.ZodTypeAny, {
485
+ message: string;
486
+ address: string;
487
+ }, {
488
+ message: string;
489
+ address: string;
490
+ }>;
491
+ id: z.ZodString;
492
+ }>, "strip", z.ZodTypeAny, {
493
+ jsonrpc: "2.0";
494
+ params: {
495
+ message: string;
496
+ address: string;
497
+ };
498
+ method: "getAddresses";
499
+ id: string;
500
+ }, {
501
+ jsonrpc: "2.0";
502
+ params: {
503
+ message: string;
504
+ address: string;
505
+ };
506
+ method: "getAddresses";
507
+ id: string;
508
+ }>;
509
+ type SignMessage = MethodParamsAndResult<z.infer<typeof signMessageParamsSchema>, z.infer<typeof signMessageResultSchema>>;
311
510
  type Recipient$1 = {
312
511
  /**
313
512
  * The recipient's address.
@@ -364,22 +563,83 @@ type SignPsbtResult = {
364
563
  txid?: string;
365
564
  };
366
565
  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>;
566
+ declare const getAccountsMethodName = "getAccounts";
567
+ declare const getAccountsParamsSchema: z.ZodObject<{
373
568
  /**
374
- * a message to be displayed to the user in the request prompt.
569
+ * The purposes for which to generate addresses. See
570
+ * {@linkcode AddressPurpose} for available purposes.
375
571
  */
572
+ purposes: z.ZodArray<z.ZodNativeEnum<typeof AddressPurpose>, "many">;
376
573
  /**
377
- * a message to be displayed to the user in the request prompt.
574
+ * A message to be displayed to the user in the request prompt.
378
575
  */
379
- message?: string;
380
- };
381
- type GetAccountResult = Address$1[];
382
- type GetAccounts = MethodParamsAndResult<GetAccountsParams, GetAccountResult>;
576
+ message: z.ZodOptional<z.ZodString>;
577
+ }, "strip", z.ZodTypeAny, {
578
+ purposes: AddressPurpose[];
579
+ message?: string | undefined;
580
+ }, {
581
+ purposes: AddressPurpose[];
582
+ message?: string | undefined;
583
+ }>;
584
+ declare const getAccountsResultSchema: z.ZodArray<z.ZodObject<{
585
+ address: z.ZodString;
586
+ publicKey: z.ZodString;
587
+ purpose: z.ZodNativeEnum<typeof AddressPurpose>;
588
+ addressType: z.ZodNativeEnum<typeof AddressType>;
589
+ }, "strip", z.ZodTypeAny, {
590
+ address: string;
591
+ publicKey: string;
592
+ purpose: AddressPurpose;
593
+ addressType: AddressType;
594
+ }, {
595
+ address: string;
596
+ publicKey: string;
597
+ purpose: AddressPurpose;
598
+ addressType: AddressType;
599
+ }>, "many">;
600
+ declare const getAccountsRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
601
+ jsonrpc: z.ZodLiteral<"2.0">;
602
+ method: z.ZodString;
603
+ params: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodUnknown, "many">, z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>]>>;
604
+ id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
605
+ }, {
606
+ method: z.ZodLiteral<"getAccounts">;
607
+ params: z.ZodObject<{
608
+ /**
609
+ * The purposes for which to generate addresses. See
610
+ * {@linkcode AddressPurpose} for available purposes.
611
+ */
612
+ purposes: z.ZodArray<z.ZodNativeEnum<typeof AddressPurpose>, "many">;
613
+ /**
614
+ * A message to be displayed to the user in the request prompt.
615
+ */
616
+ message: z.ZodOptional<z.ZodString>;
617
+ }, "strip", z.ZodTypeAny, {
618
+ purposes: AddressPurpose[];
619
+ message?: string | undefined;
620
+ }, {
621
+ purposes: AddressPurpose[];
622
+ message?: string | undefined;
623
+ }>;
624
+ id: z.ZodString;
625
+ }>, "strip", z.ZodTypeAny, {
626
+ jsonrpc: "2.0";
627
+ params: {
628
+ purposes: AddressPurpose[];
629
+ message?: string | undefined;
630
+ };
631
+ method: "getAccounts";
632
+ id: string;
633
+ }, {
634
+ jsonrpc: "2.0";
635
+ params: {
636
+ purposes: AddressPurpose[];
637
+ message?: string | undefined;
638
+ };
639
+ method: "getAccounts";
640
+ id: string;
641
+ }>;
642
+ type GetAccounts = MethodParamsAndResult<z.infer<typeof getAccountsParamsSchema>, z.infer<typeof getAccountsResultSchema>>;
383
643
 
384
644
  type CreateMintOrderRequest = {
385
645
  runeName: string;
@@ -743,4 +1003,4 @@ declare class BaseAdapter extends SatsConnectAdapter {
743
1003
  declare const DefaultAdaptersInfo: Record<string, Provider>;
744
1004
  declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
745
1005
 
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 };
1006
+ 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,16 @@
1
1
  // src/types.ts
2
+ import { z } from "zod";
2
3
  var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
3
4
  BitcoinNetworkType2["Mainnet"] = "Mainnet";
4
5
  BitcoinNetworkType2["Testnet"] = "Testnet";
5
6
  return BitcoinNetworkType2;
6
7
  })(BitcoinNetworkType || {});
8
+ var rpcRequestMessageSchema = z.object({
9
+ jsonrpc: z.literal("2.0"),
10
+ method: z.string(),
11
+ params: z.union([z.array(z.unknown()), z.object({}).passthrough()]).optional(),
12
+ id: z.union([z.string(), z.number(), z.null()]).optional()
13
+ });
7
14
  var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
8
15
  RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
9
16
  RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
@@ -159,16 +166,6 @@ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => network === "Main
159
166
  var SatsConnectAdapter = class {
160
167
  async mintRunes(params) {
161
168
  try {
162
- const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
163
- if (walletInfo && walletInfo.status === "success") {
164
- const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
165
- if (isMintSupported) {
166
- const response = await this.requestInternal("runes_mint", params);
167
- if (response) {
168
- return response;
169
- }
170
- }
171
- }
172
169
  const mintRequest = {
173
170
  destinationAddress: params.destinationAddress,
174
171
  feeRate: params.feeRate,
@@ -510,50 +507,14 @@ function getSupportedWallets() {
510
507
  return wallets;
511
508
  }
512
509
 
513
- // src/request/index.ts
514
- var request = async (method, params, providerId) => {
515
- let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
516
- if (providerId) {
517
- provider = await getProviderById(providerId);
518
- }
519
- if (!provider) {
520
- throw new Error("no wallet provider was found");
521
- }
522
- if (!method) {
523
- throw new Error("A wallet method is required");
524
- }
525
- const response = await provider.request(method, params);
526
- if (isRpcSuccessResponse(response)) {
527
- return {
528
- status: "success",
529
- result: response.result
530
- };
531
- }
532
- return {
533
- status: "error",
534
- error: response.error
535
- };
536
- };
537
- var isRpcSuccessResponse = (response) => {
538
- return Object.hasOwn(response, "result") && !!response.result;
539
- };
540
-
541
- // src/adapters/xverse.ts
542
- var XverseAdapter = class extends SatsConnectAdapter {
543
- id = DefaultAdaptersInfo.xverse.id;
544
- requestInternal = async (method, params) => {
545
- return request(method, params, this.id);
546
- };
547
- };
548
-
549
- // src/adapters/unisat.ts
550
- import { Buffer } from "buffer";
551
- import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
510
+ // src/request/types/btcMethods.ts
511
+ import { z as z3 } from "zod";
552
512
 
553
513
  // src/addresses/index.ts
554
514
  import { createUnsecuredToken } from "jsontokens";
555
515
 
556
516
  // src/addresses/types.ts
517
+ import { z as z2 } from "zod";
557
518
  var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
558
519
  AddressPurpose2["Ordinals"] = "ordinals";
559
520
  AddressPurpose2["Payment"] = "payment";
@@ -569,6 +530,12 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
569
530
  AddressType3["stacks"] = "stacks";
570
531
  return AddressType3;
571
532
  })(AddressType || {});
533
+ var addressSchema = z2.object({
534
+ address: z2.string(),
535
+ publicKey: z2.string(),
536
+ purpose: z2.nativeEnum(AddressPurpose),
537
+ addressType: z2.nativeEnum(AddressType)
538
+ });
572
539
 
573
540
  // src/addresses/index.ts
574
541
  var getAddress = async (options) => {
@@ -587,7 +554,129 @@ var getAddress = async (options) => {
587
554
  }
588
555
  };
589
556
 
557
+ // src/request/types/btcMethods.ts
558
+ var getInfoMethodName = "getInfo";
559
+ var getInfoParamsSchema = z3.undefined();
560
+ var getInfoResultSchema = z3.object({
561
+ /**
562
+ * Version of the wallet.
563
+ */
564
+ version: z3.string(),
565
+ /**
566
+ * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
567
+ */
568
+ methods: z3.array(z3.string()).optional(),
569
+ /**
570
+ * List of WBIP standards supported by the wallet. Not currently used.
571
+ */
572
+ supports: z3.array(z3.string())
573
+ });
574
+ var getInfoSchema = rpcRequestMessageSchema.extend({
575
+ method: z3.literal(getInfoMethodName),
576
+ params: getInfoParamsSchema,
577
+ id: z3.string()
578
+ });
579
+ var getAddressesMethodName = "getAddresses";
580
+ var getAddressesParamsSchema = z3.object({
581
+ /**
582
+ * The purposes for which to generate addresses. See
583
+ * {@linkcode AddressPurpose} for available purposes.
584
+ */
585
+ purposes: z3.array(z3.nativeEnum(AddressPurpose)),
586
+ /**
587
+ * A message to be displayed to the user in the request prompt.
588
+ */
589
+ message: z3.string().optional()
590
+ });
591
+ var getAddressesResultSchema = z3.object({
592
+ /**
593
+ * The addresses generated for the given purposes.
594
+ */
595
+ addresses: z3.array(addressSchema)
596
+ });
597
+ var getAddressesRequestMessageSchema = rpcRequestMessageSchema.extend({
598
+ method: z3.literal(getAddressesMethodName),
599
+ params: getAddressesParamsSchema,
600
+ id: z3.string()
601
+ });
602
+ var signMessageMethodName = "signMessage";
603
+ var signMessageParamsSchema = z3.object({
604
+ /**
605
+ * The address used for signing.
606
+ **/
607
+ address: z3.string(),
608
+ /**
609
+ * The message to sign.
610
+ **/
611
+ message: z3.string()
612
+ });
613
+ var signMessageResultSchema = z3.object({
614
+ /**
615
+ * The signature of the message.
616
+ */
617
+ signature: z3.string(),
618
+ /**
619
+ * hash of the message.
620
+ */
621
+ messageHash: z3.string(),
622
+ /**
623
+ * The address used for signing.
624
+ */
625
+ address: z3.string()
626
+ });
627
+ var signMessageRequestMessageSchema = rpcRequestMessageSchema.extend({
628
+ method: z3.literal(getAddressesMethodName),
629
+ params: signMessageParamsSchema,
630
+ id: z3.string()
631
+ });
632
+ var getAccountsMethodName = "getAccounts";
633
+ var getAccountsParamsSchema = getAddressesParamsSchema;
634
+ var getAccountsResultSchema = z3.array(addressSchema);
635
+ var getAccountsRequestMessageSchema = rpcRequestMessageSchema.extend({
636
+ method: z3.literal(getAccountsMethodName),
637
+ params: getAccountsParamsSchema,
638
+ id: z3.string()
639
+ });
640
+
641
+ // src/request/index.ts
642
+ var request = async (method, params, providerId) => {
643
+ let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
644
+ if (providerId) {
645
+ provider = await getProviderById(providerId);
646
+ }
647
+ if (!provider) {
648
+ throw new Error("no wallet provider was found");
649
+ }
650
+ if (!method) {
651
+ throw new Error("A wallet method is required");
652
+ }
653
+ const response = await provider.request(method, params);
654
+ if (isRpcSuccessResponse(response)) {
655
+ return {
656
+ status: "success",
657
+ result: response.result
658
+ };
659
+ }
660
+ return {
661
+ status: "error",
662
+ error: response.error
663
+ };
664
+ };
665
+ var isRpcSuccessResponse = (response) => {
666
+ return Object.hasOwn(response, "result") && !!response.result;
667
+ };
668
+
669
+ // src/adapters/xverse.ts
670
+ var XverseAdapter = class extends SatsConnectAdapter {
671
+ id = DefaultAdaptersInfo.xverse.id;
672
+ requestInternal = async (method, params) => {
673
+ return request(method, params, this.id);
674
+ };
675
+ };
676
+
590
677
  // src/adapters/unisat.ts
678
+ import { Buffer } from "buffer";
679
+ import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
591
680
  function convertSignInputsToInputType(signInputs, allowedSignHash) {
592
681
  let result = [];
593
682
  for (let address in signInputs) {
@@ -992,12 +1081,25 @@ export {
992
1081
  DefaultAdaptersInfo,
993
1082
  RpcErrorCode,
994
1083
  SatsConnectAdapter,
1084
+ addressSchema,
995
1085
  createInscription,
996
1086
  createRepeatInscriptions,
997
1087
  defaultAdapters,
1088
+ getAccountsMethodName,
1089
+ getAccountsParamsSchema,
1090
+ getAccountsRequestMessageSchema,
1091
+ getAccountsResultSchema,
998
1092
  getAddress,
1093
+ getAddressesMethodName,
1094
+ getAddressesParamsSchema,
1095
+ getAddressesRequestMessageSchema,
1096
+ getAddressesResultSchema,
999
1097
  getCapabilities,
1000
1098
  getDefaultProvider,
1099
+ getInfoMethodName,
1100
+ getInfoParamsSchema,
1101
+ getInfoResultSchema,
1102
+ getInfoSchema,
1001
1103
  getProviderById,
1002
1104
  getProviderOrThrow,
1003
1105
  getProviders,
@@ -1005,9 +1107,14 @@ export {
1005
1107
  isProviderInstalled,
1006
1108
  removeDefaultProvider,
1007
1109
  request,
1110
+ rpcRequestMessageSchema,
1008
1111
  sendBtcTransaction,
1009
1112
  setDefaultProvider,
1010
1113
  signMessage,
1114
+ signMessageMethodName,
1115
+ signMessageParamsSchema,
1116
+ signMessageRequestMessageSchema,
1117
+ signMessageResultSchema,
1011
1118
  signMultipleTransactions,
1012
1119
  signTransaction
1013
1120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sats-connect/core",
3
- "version": "0.0.9-624596",
3
+ "version": "0.0.9-69f5b41",
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
+ "zod": ">=3.23.8"
35
+ },
33
36
  "devDependencies": {
34
37
  "@types/jest": "^29.2.6",
35
38
  "@types/lodash.omit": "4.5.9",