@sats-connect/core 0.0.9-4995067 → 0.0.9-53097ea
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 +236 -41
- package/dist/index.mjs +113 -39
- package/package.json +4 -1
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
|
-
|
|
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
|
|
249
|
-
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,34 +285,138 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
|
255
285
|
|
|
256
286
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
257
287
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
288
|
+
declare const getInfoMethodName = "getInfo";
|
|
289
|
+
declare const getInfoParamsSchema: z.ZodUndefined;
|
|
290
|
+
declare const getInfoResultSchema: z.ZodObject<{
|
|
291
|
+
version: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
292
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
293
|
+
supports: z.ZodArray<z.ZodString, "many">;
|
|
294
|
+
}, "strip", z.ZodTypeAny, {
|
|
295
|
+
version: string | number;
|
|
296
|
+
supports: string[];
|
|
297
|
+
methods?: string[] | undefined;
|
|
298
|
+
}, {
|
|
299
|
+
version: string | number;
|
|
300
|
+
supports: string[];
|
|
301
|
+
methods?: string[] | undefined;
|
|
302
|
+
}>;
|
|
303
|
+
declare const getInfoSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
304
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
305
|
+
method: z.ZodString;
|
|
306
|
+
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">>]>>;
|
|
307
|
+
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
308
|
+
}, {
|
|
309
|
+
method: z.ZodLiteral<"getInfo">;
|
|
310
|
+
params: z.ZodUndefined;
|
|
311
|
+
id: z.ZodString;
|
|
312
|
+
}>, "strip", z.ZodTypeAny, {
|
|
313
|
+
jsonrpc: "2.0";
|
|
314
|
+
method: "getInfo";
|
|
315
|
+
id: string;
|
|
316
|
+
params?: undefined;
|
|
317
|
+
}, {
|
|
318
|
+
jsonrpc: "2.0";
|
|
319
|
+
method: "getInfo";
|
|
320
|
+
id: string;
|
|
321
|
+
params?: undefined;
|
|
322
|
+
}>;
|
|
323
|
+
type GetInfo = MethodParamsAndResult<z.infer<typeof getInfoParamsSchema>, z.infer<typeof getInfoResultSchema>>;
|
|
324
|
+
declare const getAddressesMethodName = "getAddresses";
|
|
325
|
+
declare const getAddressesParamsSchema: z.ZodObject<{
|
|
269
326
|
/**
|
|
270
|
-
* The purposes for which to generate addresses.
|
|
271
|
-
*
|
|
327
|
+
* The purposes for which to generate addresses. See
|
|
328
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
272
329
|
*/
|
|
273
|
-
purposes:
|
|
330
|
+
purposes: z.ZodArray<z.ZodNativeEnum<typeof AddressPurpose>, "many">;
|
|
274
331
|
/**
|
|
275
|
-
*
|
|
332
|
+
* A message to be displayed to the user in the request prompt.
|
|
276
333
|
*/
|
|
277
|
-
message
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
334
|
+
message: z.ZodOptional<z.ZodString>;
|
|
335
|
+
}, "strip", z.ZodTypeAny, {
|
|
336
|
+
purposes: AddressPurpose[];
|
|
337
|
+
message?: string | undefined;
|
|
338
|
+
}, {
|
|
339
|
+
purposes: AddressPurpose[];
|
|
340
|
+
message?: string | undefined;
|
|
341
|
+
}>;
|
|
342
|
+
declare const getAddressesResultSchema: z.ZodObject<{
|
|
343
|
+
/**
|
|
344
|
+
* The addresses generated for the given purposes.
|
|
345
|
+
*/
|
|
346
|
+
addresses: z.ZodArray<z.ZodObject<{
|
|
347
|
+
address: z.ZodString;
|
|
348
|
+
publicKey: z.ZodString;
|
|
349
|
+
purpose: z.ZodNativeEnum<typeof AddressPurpose>;
|
|
350
|
+
addressType: z.ZodNativeEnum<typeof AddressType>;
|
|
351
|
+
}, "strip", z.ZodTypeAny, {
|
|
352
|
+
address: string;
|
|
353
|
+
publicKey: string;
|
|
354
|
+
purpose: AddressPurpose;
|
|
355
|
+
addressType: AddressType;
|
|
356
|
+
}, {
|
|
357
|
+
address: string;
|
|
358
|
+
publicKey: string;
|
|
359
|
+
purpose: AddressPurpose;
|
|
360
|
+
addressType: AddressType;
|
|
361
|
+
}>, "many">;
|
|
362
|
+
}, "strip", z.ZodTypeAny, {
|
|
363
|
+
addresses: {
|
|
364
|
+
address: string;
|
|
365
|
+
publicKey: string;
|
|
366
|
+
purpose: AddressPurpose;
|
|
367
|
+
addressType: AddressType;
|
|
368
|
+
}[];
|
|
369
|
+
}, {
|
|
370
|
+
addresses: {
|
|
371
|
+
address: string;
|
|
372
|
+
publicKey: string;
|
|
373
|
+
purpose: AddressPurpose;
|
|
374
|
+
addressType: AddressType;
|
|
375
|
+
}[];
|
|
376
|
+
}>;
|
|
377
|
+
declare const getAddressesRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
378
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
379
|
+
method: z.ZodString;
|
|
380
|
+
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">>]>>;
|
|
381
|
+
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
382
|
+
}, {
|
|
383
|
+
method: z.ZodLiteral<"getAddresses">;
|
|
384
|
+
params: z.ZodObject<{
|
|
385
|
+
/**
|
|
386
|
+
* The purposes for which to generate addresses. See
|
|
387
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
388
|
+
*/
|
|
389
|
+
purposes: z.ZodArray<z.ZodNativeEnum<typeof AddressPurpose>, "many">;
|
|
390
|
+
/**
|
|
391
|
+
* A message to be displayed to the user in the request prompt.
|
|
392
|
+
*/
|
|
393
|
+
message: z.ZodOptional<z.ZodString>;
|
|
394
|
+
}, "strip", z.ZodTypeAny, {
|
|
395
|
+
purposes: AddressPurpose[];
|
|
396
|
+
message?: string | undefined;
|
|
397
|
+
}, {
|
|
398
|
+
purposes: AddressPurpose[];
|
|
399
|
+
message?: string | undefined;
|
|
400
|
+
}>;
|
|
401
|
+
id: z.ZodString;
|
|
402
|
+
}>, "strip", z.ZodTypeAny, {
|
|
403
|
+
jsonrpc: "2.0";
|
|
404
|
+
params: {
|
|
405
|
+
purposes: AddressPurpose[];
|
|
406
|
+
message?: string | undefined;
|
|
407
|
+
};
|
|
408
|
+
method: "getAddresses";
|
|
409
|
+
id: string;
|
|
410
|
+
}, {
|
|
411
|
+
jsonrpc: "2.0";
|
|
412
|
+
params: {
|
|
413
|
+
purposes: AddressPurpose[];
|
|
414
|
+
message?: string | undefined;
|
|
415
|
+
};
|
|
416
|
+
method: "getAddresses";
|
|
417
|
+
id: string;
|
|
418
|
+
}>;
|
|
419
|
+
type GetAddresses = MethodParamsAndResult<z.infer<typeof getAddressesParamsSchema>, z.infer<typeof getAddressesResultSchema>>;
|
|
286
420
|
type SignMessageParams = {
|
|
287
421
|
/**
|
|
288
422
|
* The address used for signing.
|
|
@@ -364,22 +498,83 @@ type SignPsbtResult = {
|
|
|
364
498
|
txid?: string;
|
|
365
499
|
};
|
|
366
500
|
type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
* The purposes for which to generate addresses.
|
|
370
|
-
* possible values are "payment", "ordinals", ...
|
|
371
|
-
*/
|
|
372
|
-
purposes: Array<AddressPurpose>;
|
|
501
|
+
declare const getAccountsMethodName = "getAccounts";
|
|
502
|
+
declare const getAccountsParamsSchema: z.ZodObject<{
|
|
373
503
|
/**
|
|
374
|
-
*
|
|
504
|
+
* The purposes for which to generate addresses. See
|
|
505
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
375
506
|
*/
|
|
507
|
+
purposes: z.ZodArray<z.ZodNativeEnum<typeof AddressPurpose>, "many">;
|
|
376
508
|
/**
|
|
377
|
-
*
|
|
509
|
+
* A message to be displayed to the user in the request prompt.
|
|
378
510
|
*/
|
|
379
|
-
message
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
511
|
+
message: z.ZodOptional<z.ZodString>;
|
|
512
|
+
}, "strip", z.ZodTypeAny, {
|
|
513
|
+
purposes: AddressPurpose[];
|
|
514
|
+
message?: string | undefined;
|
|
515
|
+
}, {
|
|
516
|
+
purposes: AddressPurpose[];
|
|
517
|
+
message?: string | undefined;
|
|
518
|
+
}>;
|
|
519
|
+
declare const getAccountsResultSchema: z.ZodArray<z.ZodObject<{
|
|
520
|
+
address: z.ZodString;
|
|
521
|
+
publicKey: z.ZodString;
|
|
522
|
+
purpose: z.ZodNativeEnum<typeof AddressPurpose>;
|
|
523
|
+
addressType: z.ZodNativeEnum<typeof AddressType>;
|
|
524
|
+
}, "strip", z.ZodTypeAny, {
|
|
525
|
+
address: string;
|
|
526
|
+
publicKey: string;
|
|
527
|
+
purpose: AddressPurpose;
|
|
528
|
+
addressType: AddressType;
|
|
529
|
+
}, {
|
|
530
|
+
address: string;
|
|
531
|
+
publicKey: string;
|
|
532
|
+
purpose: AddressPurpose;
|
|
533
|
+
addressType: AddressType;
|
|
534
|
+
}>, "many">;
|
|
535
|
+
declare const getAccountsRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
536
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
537
|
+
method: z.ZodString;
|
|
538
|
+
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">>]>>;
|
|
539
|
+
id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodNull]>>;
|
|
540
|
+
}, {
|
|
541
|
+
method: z.ZodLiteral<"getAccounts">;
|
|
542
|
+
params: z.ZodObject<{
|
|
543
|
+
/**
|
|
544
|
+
* The purposes for which to generate addresses. See
|
|
545
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
546
|
+
*/
|
|
547
|
+
purposes: z.ZodArray<z.ZodNativeEnum<typeof AddressPurpose>, "many">;
|
|
548
|
+
/**
|
|
549
|
+
* A message to be displayed to the user in the request prompt.
|
|
550
|
+
*/
|
|
551
|
+
message: z.ZodOptional<z.ZodString>;
|
|
552
|
+
}, "strip", z.ZodTypeAny, {
|
|
553
|
+
purposes: AddressPurpose[];
|
|
554
|
+
message?: string | undefined;
|
|
555
|
+
}, {
|
|
556
|
+
purposes: AddressPurpose[];
|
|
557
|
+
message?: string | undefined;
|
|
558
|
+
}>;
|
|
559
|
+
id: z.ZodString;
|
|
560
|
+
}>, "strip", z.ZodTypeAny, {
|
|
561
|
+
jsonrpc: "2.0";
|
|
562
|
+
params: {
|
|
563
|
+
purposes: AddressPurpose[];
|
|
564
|
+
message?: string | undefined;
|
|
565
|
+
};
|
|
566
|
+
method: "getAccounts";
|
|
567
|
+
id: string;
|
|
568
|
+
}, {
|
|
569
|
+
jsonrpc: "2.0";
|
|
570
|
+
params: {
|
|
571
|
+
purposes: AddressPurpose[];
|
|
572
|
+
message?: string | undefined;
|
|
573
|
+
};
|
|
574
|
+
method: "getAccounts";
|
|
575
|
+
id: string;
|
|
576
|
+
}>;
|
|
577
|
+
type GetAccounts = MethodParamsAndResult<z.infer<typeof getAccountsParamsSchema>, z.infer<typeof getAccountsResultSchema>>;
|
|
383
578
|
|
|
384
579
|
type CreateMintOrderRequest = {
|
|
385
580
|
runeName: string;
|
|
@@ -743,4 +938,4 @@ declare class BaseAdapter extends SatsConnectAdapter {
|
|
|
743
938
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
744
939
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
745
940
|
|
|
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
|
|
941
|
+
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 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, 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, 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";
|
|
@@ -500,50 +507,14 @@ function getSupportedWallets() {
|
|
|
500
507
|
return wallets;
|
|
501
508
|
}
|
|
502
509
|
|
|
503
|
-
// src/request/
|
|
504
|
-
|
|
505
|
-
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
506
|
-
if (providerId) {
|
|
507
|
-
provider = await getProviderById(providerId);
|
|
508
|
-
}
|
|
509
|
-
if (!provider) {
|
|
510
|
-
throw new Error("no wallet provider was found");
|
|
511
|
-
}
|
|
512
|
-
if (!method) {
|
|
513
|
-
throw new Error("A wallet method is required");
|
|
514
|
-
}
|
|
515
|
-
const response = await provider.request(method, params);
|
|
516
|
-
if (isRpcSuccessResponse(response)) {
|
|
517
|
-
return {
|
|
518
|
-
status: "success",
|
|
519
|
-
result: response.result
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
return {
|
|
523
|
-
status: "error",
|
|
524
|
-
error: response.error
|
|
525
|
-
};
|
|
526
|
-
};
|
|
527
|
-
var isRpcSuccessResponse = (response) => {
|
|
528
|
-
return Object.hasOwn(response, "result") && !!response.result;
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
// src/adapters/xverse.ts
|
|
532
|
-
var XverseAdapter = class extends SatsConnectAdapter {
|
|
533
|
-
id = DefaultAdaptersInfo.xverse.id;
|
|
534
|
-
requestInternal = async (method, params) => {
|
|
535
|
-
return request(method, params, this.id);
|
|
536
|
-
};
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
// src/adapters/unisat.ts
|
|
540
|
-
import { Buffer } from "buffer";
|
|
541
|
-
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
510
|
+
// src/request/types/btcMethods.ts
|
|
511
|
+
import { z as z3 } from "zod";
|
|
542
512
|
|
|
543
513
|
// src/addresses/index.ts
|
|
544
514
|
import { createUnsecuredToken } from "jsontokens";
|
|
545
515
|
|
|
546
516
|
// src/addresses/types.ts
|
|
517
|
+
import { z as z2 } from "zod";
|
|
547
518
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
548
519
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
549
520
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -559,6 +530,12 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
559
530
|
AddressType3["stacks"] = "stacks";
|
|
560
531
|
return AddressType3;
|
|
561
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
|
+
});
|
|
562
539
|
|
|
563
540
|
// src/addresses/index.ts
|
|
564
541
|
var getAddress = async (options) => {
|
|
@@ -577,7 +554,90 @@ var getAddress = async (options) => {
|
|
|
577
554
|
}
|
|
578
555
|
};
|
|
579
556
|
|
|
557
|
+
// src/request/types/btcMethods.ts
|
|
558
|
+
var getInfoMethodName = "getInfo";
|
|
559
|
+
var getInfoParamsSchema = z3.undefined();
|
|
560
|
+
var getInfoResultSchema = z3.object({
|
|
561
|
+
version: z3.union([z3.number(), z3.string()]),
|
|
562
|
+
methods: z3.array(z3.string()).optional(),
|
|
563
|
+
supports: z3.array(z3.string())
|
|
564
|
+
});
|
|
565
|
+
var getInfoSchema = rpcRequestMessageSchema.extend({
|
|
566
|
+
method: z3.literal(getInfoMethodName),
|
|
567
|
+
params: getInfoParamsSchema,
|
|
568
|
+
id: z3.string()
|
|
569
|
+
});
|
|
570
|
+
var getAddressesMethodName = "getAddresses";
|
|
571
|
+
var getAddressesParamsSchema = z3.object({
|
|
572
|
+
/**
|
|
573
|
+
* The purposes for which to generate addresses. See
|
|
574
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
575
|
+
*/
|
|
576
|
+
purposes: z3.array(z3.nativeEnum(AddressPurpose)),
|
|
577
|
+
/**
|
|
578
|
+
* A message to be displayed to the user in the request prompt.
|
|
579
|
+
*/
|
|
580
|
+
message: z3.string().optional()
|
|
581
|
+
});
|
|
582
|
+
var getAddressesResultSchema = z3.object({
|
|
583
|
+
/**
|
|
584
|
+
* The addresses generated for the given purposes.
|
|
585
|
+
*/
|
|
586
|
+
addresses: z3.array(addressSchema)
|
|
587
|
+
});
|
|
588
|
+
var getAddressesRequestMessageSchema = rpcRequestMessageSchema.extend({
|
|
589
|
+
method: z3.literal(getAddressesMethodName),
|
|
590
|
+
params: getAddressesParamsSchema,
|
|
591
|
+
id: z3.string()
|
|
592
|
+
});
|
|
593
|
+
var getAccountsMethodName = "getAccounts";
|
|
594
|
+
var getAccountsParamsSchema = getAddressesParamsSchema;
|
|
595
|
+
var getAccountsResultSchema = z3.array(addressSchema);
|
|
596
|
+
var getAccountsRequestMessageSchema = rpcRequestMessageSchema.extend({
|
|
597
|
+
method: z3.literal(getAccountsMethodName),
|
|
598
|
+
params: getAccountsParamsSchema,
|
|
599
|
+
id: z3.string()
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
// src/request/index.ts
|
|
603
|
+
var request = async (method, params, providerId) => {
|
|
604
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
605
|
+
if (providerId) {
|
|
606
|
+
provider = await getProviderById(providerId);
|
|
607
|
+
}
|
|
608
|
+
if (!provider) {
|
|
609
|
+
throw new Error("no wallet provider was found");
|
|
610
|
+
}
|
|
611
|
+
if (!method) {
|
|
612
|
+
throw new Error("A wallet method is required");
|
|
613
|
+
}
|
|
614
|
+
const response = await provider.request(method, params);
|
|
615
|
+
if (isRpcSuccessResponse(response)) {
|
|
616
|
+
return {
|
|
617
|
+
status: "success",
|
|
618
|
+
result: response.result
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
return {
|
|
622
|
+
status: "error",
|
|
623
|
+
error: response.error
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
var isRpcSuccessResponse = (response) => {
|
|
627
|
+
return Object.hasOwn(response, "result") && !!response.result;
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
// src/adapters/xverse.ts
|
|
631
|
+
var XverseAdapter = class extends SatsConnectAdapter {
|
|
632
|
+
id = DefaultAdaptersInfo.xverse.id;
|
|
633
|
+
requestInternal = async (method, params) => {
|
|
634
|
+
return request(method, params, this.id);
|
|
635
|
+
};
|
|
636
|
+
};
|
|
637
|
+
|
|
580
638
|
// src/adapters/unisat.ts
|
|
639
|
+
import { Buffer } from "buffer";
|
|
640
|
+
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
581
641
|
function convertSignInputsToInputType(signInputs, allowedSignHash) {
|
|
582
642
|
let result = [];
|
|
583
643
|
for (let address in signInputs) {
|
|
@@ -982,12 +1042,25 @@ export {
|
|
|
982
1042
|
DefaultAdaptersInfo,
|
|
983
1043
|
RpcErrorCode,
|
|
984
1044
|
SatsConnectAdapter,
|
|
1045
|
+
addressSchema,
|
|
985
1046
|
createInscription,
|
|
986
1047
|
createRepeatInscriptions,
|
|
987
1048
|
defaultAdapters,
|
|
1049
|
+
getAccountsMethodName,
|
|
1050
|
+
getAccountsParamsSchema,
|
|
1051
|
+
getAccountsRequestMessageSchema,
|
|
1052
|
+
getAccountsResultSchema,
|
|
988
1053
|
getAddress,
|
|
1054
|
+
getAddressesMethodName,
|
|
1055
|
+
getAddressesParamsSchema,
|
|
1056
|
+
getAddressesRequestMessageSchema,
|
|
1057
|
+
getAddressesResultSchema,
|
|
989
1058
|
getCapabilities,
|
|
990
1059
|
getDefaultProvider,
|
|
1060
|
+
getInfoMethodName,
|
|
1061
|
+
getInfoParamsSchema,
|
|
1062
|
+
getInfoResultSchema,
|
|
1063
|
+
getInfoSchema,
|
|
991
1064
|
getProviderById,
|
|
992
1065
|
getProviderOrThrow,
|
|
993
1066
|
getProviders,
|
|
@@ -995,6 +1068,7 @@ export {
|
|
|
995
1068
|
isProviderInstalled,
|
|
996
1069
|
removeDefaultProvider,
|
|
997
1070
|
request,
|
|
1071
|
+
rpcRequestMessageSchema,
|
|
998
1072
|
sendBtcTransaction,
|
|
999
1073
|
setDefaultProvider,
|
|
1000
1074
|
signMessage,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.0.9-
|
|
3
|
+
"version": "0.0.9-53097ea",
|
|
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",
|