@sats-connect/core 0.0.12 → 0.0.13-d1f5108
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 +336 -86
- package/dist/index.mjs +375 -44
- package/package.json +6 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
1
3
|
interface GetCapabilitiesPayload extends RequestPayload {
|
|
2
4
|
}
|
|
3
5
|
type GetCapabilitiesResponse = Capability[];
|
|
@@ -114,7 +116,7 @@ interface Provider {
|
|
|
114
116
|
mozillaAddOnsUrl?: string;
|
|
115
117
|
googlePlayStoreUrl?: string;
|
|
116
118
|
iOSAppStoreUrl?: string;
|
|
117
|
-
methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod)[];
|
|
119
|
+
methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod | OrdinalsRequestMethod)[];
|
|
118
120
|
}
|
|
119
121
|
interface SupportedWallet extends Provider {
|
|
120
122
|
isInstalled: boolean;
|
|
@@ -157,7 +159,15 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
157
159
|
payload: Payload;
|
|
158
160
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
159
161
|
}
|
|
160
|
-
|
|
162
|
+
declare const RpcIdSchema: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
163
|
+
type RpcId = v.InferOutput<typeof RpcIdSchema>;
|
|
164
|
+
declare const rpcRequestMessageSchema: v.ObjectSchema<{
|
|
165
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
166
|
+
readonly method: v.StringSchema<undefined>;
|
|
167
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
168
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
169
|
+
}, undefined>;
|
|
170
|
+
type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
|
|
161
171
|
interface RpcBase {
|
|
162
172
|
jsonrpc: '2.0';
|
|
163
173
|
id: RpcId;
|
|
@@ -204,8 +214,34 @@ declare enum RpcErrorCode {
|
|
|
204
214
|
/**
|
|
205
215
|
* method is not supported for the address provided
|
|
206
216
|
*/
|
|
207
|
-
METHOD_NOT_SUPPORTED = -32001
|
|
208
|
-
|
|
217
|
+
METHOD_NOT_SUPPORTED = -32001,
|
|
218
|
+
/**
|
|
219
|
+
* The client does not have permission to access the requested resource.
|
|
220
|
+
*/
|
|
221
|
+
ACCESS_DENIED = -32002
|
|
222
|
+
}
|
|
223
|
+
declare const rpcSuccessResponseMessageSchema: v.ObjectSchema<{
|
|
224
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
225
|
+
readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
|
|
226
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
227
|
+
}, undefined>;
|
|
228
|
+
type RpcSuccessResponseMessage = v.InferOutput<typeof rpcSuccessResponseMessageSchema>;
|
|
229
|
+
declare const rpcErrorResponseMessageSchema: v.ObjectSchema<{
|
|
230
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
231
|
+
readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
|
|
232
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
233
|
+
}, undefined>;
|
|
234
|
+
type RpcErrorResponseMessage = v.InferOutput<typeof rpcErrorResponseMessageSchema>;
|
|
235
|
+
declare const rpcResponseMessageSchema: v.UnionSchema<[v.ObjectSchema<{
|
|
236
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
237
|
+
readonly result: v.NonOptionalSchema<v.UnknownSchema, undefined>;
|
|
238
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
239
|
+
}, undefined>, v.ObjectSchema<{
|
|
240
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
241
|
+
readonly error: v.NonOptionalSchema<v.UnknownSchema, undefined>;
|
|
242
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
243
|
+
}, undefined>], undefined>;
|
|
244
|
+
type RpcResponseMessage = v.InferOutput<typeof rpcResponseMessageSchema>;
|
|
209
245
|
interface RpcError {
|
|
210
246
|
code: number | RpcErrorCode;
|
|
211
247
|
message: string;
|
|
@@ -243,12 +279,13 @@ declare enum AddressType {
|
|
|
243
279
|
p2tr = "p2tr",
|
|
244
280
|
stacks = "stacks"
|
|
245
281
|
}
|
|
246
|
-
|
|
247
|
-
address:
|
|
248
|
-
publicKey:
|
|
249
|
-
purpose
|
|
250
|
-
addressType
|
|
251
|
-
}
|
|
282
|
+
declare const addressSchema: v.ObjectSchema<{
|
|
283
|
+
readonly address: v.StringSchema<undefined>;
|
|
284
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
285
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
286
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
287
|
+
}, undefined>;
|
|
288
|
+
type Address$1 = v.InferOutput<typeof addressSchema>;
|
|
252
289
|
interface GetAddressResponse {
|
|
253
290
|
addresses: Address$1[];
|
|
254
291
|
}
|
|
@@ -256,59 +293,119 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
|
256
293
|
|
|
257
294
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
258
295
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
*
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
type
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
296
|
+
declare const getInfoMethodName = "getInfo";
|
|
297
|
+
declare const getInfoParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
298
|
+
type GetInfoParams = v.InferOutput<typeof getInfoParamsSchema>;
|
|
299
|
+
declare const getInfoResultSchema: v.ObjectSchema<{
|
|
300
|
+
/**
|
|
301
|
+
* Version of the wallet.
|
|
302
|
+
*/
|
|
303
|
+
readonly version: v.StringSchema<undefined>;
|
|
304
|
+
/**
|
|
305
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
306
|
+
*/
|
|
307
|
+
readonly methods: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, never>;
|
|
308
|
+
/**
|
|
309
|
+
* List of WBIP standards supported by the wallet. Not currently used.
|
|
310
|
+
*/
|
|
311
|
+
readonly supports: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
312
|
+
}, undefined>;
|
|
313
|
+
type GetInfoResult = v.InferOutput<typeof getInfoResultSchema>;
|
|
314
|
+
declare const getInfoRequestMessageSchema: v.ObjectSchema<{
|
|
315
|
+
readonly method: v.LiteralSchema<"getInfo", undefined>;
|
|
316
|
+
readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
317
|
+
readonly id: v.StringSchema<undefined>;
|
|
318
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
319
|
+
}, undefined>;
|
|
320
|
+
type GetInfoRequestMessage = v.InferOutput<typeof getInfoRequestMessageSchema>;
|
|
321
|
+
type GetInfo = MethodParamsAndResult<v.InferOutput<typeof getInfoParamsSchema>, v.InferOutput<typeof getInfoResultSchema>>;
|
|
322
|
+
declare const getAddressesMethodName = "getAddresses";
|
|
323
|
+
declare const getAddressesParamsSchema: v.ObjectSchema<{
|
|
324
|
+
/**
|
|
325
|
+
* The purposes for which to generate addresses. See
|
|
326
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
327
|
+
*/
|
|
328
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
329
|
+
/**
|
|
330
|
+
* A message to be displayed to the user in the request prompt.
|
|
331
|
+
*/
|
|
332
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
333
|
+
}, undefined>;
|
|
334
|
+
type GetAddressesParams = v.InferOutput<typeof getAddressesParamsSchema>;
|
|
335
|
+
declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
336
|
+
/**
|
|
337
|
+
* The addresses generated for the given purposes.
|
|
338
|
+
*/
|
|
339
|
+
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
340
|
+
readonly address: v.StringSchema<undefined>;
|
|
341
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
342
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
343
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
344
|
+
}, undefined>, undefined>;
|
|
345
|
+
}, undefined>;
|
|
346
|
+
type GetAddressesResult = v.InferOutput<typeof getAddressesResultSchema>;
|
|
347
|
+
declare const getAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
348
|
+
readonly method: v.LiteralSchema<"getAddresses", undefined>;
|
|
349
|
+
readonly params: v.ObjectSchema<{
|
|
350
|
+
/**
|
|
351
|
+
* The purposes for which to generate addresses. See
|
|
352
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
353
|
+
*/
|
|
354
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
355
|
+
/**
|
|
356
|
+
* A message to be displayed to the user in the request prompt.
|
|
357
|
+
*/
|
|
358
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
359
|
+
}, undefined>;
|
|
360
|
+
readonly id: v.StringSchema<undefined>;
|
|
361
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
362
|
+
}, undefined>;
|
|
363
|
+
type GetAddressesRequestMessage = v.InferOutput<typeof getAddressesRequestMessageSchema>;
|
|
364
|
+
type GetAddresses = MethodParamsAndResult<v.InferOutput<typeof getAddressesParamsSchema>, v.InferOutput<typeof getAddressesResultSchema>>;
|
|
365
|
+
declare const signMessageMethodName = "signMessage";
|
|
366
|
+
declare const signMessageParamsSchema: v.ObjectSchema<{
|
|
288
367
|
/**
|
|
289
368
|
* The address used for signing.
|
|
290
369
|
**/
|
|
291
|
-
address:
|
|
370
|
+
readonly address: v.StringSchema<undefined>;
|
|
292
371
|
/**
|
|
293
372
|
* The message to sign.
|
|
294
373
|
**/
|
|
295
|
-
message:
|
|
296
|
-
}
|
|
297
|
-
type
|
|
374
|
+
readonly message: v.StringSchema<undefined>;
|
|
375
|
+
}, undefined>;
|
|
376
|
+
type SignMessageParams = v.InferOutput<typeof signMessageParamsSchema>;
|
|
377
|
+
declare const signMessageResultSchema: v.ObjectSchema<{
|
|
298
378
|
/**
|
|
299
379
|
* The signature of the message.
|
|
300
380
|
*/
|
|
301
|
-
signature:
|
|
381
|
+
readonly signature: v.StringSchema<undefined>;
|
|
302
382
|
/**
|
|
303
383
|
* hash of the message.
|
|
304
384
|
*/
|
|
305
|
-
messageHash:
|
|
385
|
+
readonly messageHash: v.StringSchema<undefined>;
|
|
306
386
|
/**
|
|
307
387
|
* The address used for signing.
|
|
308
388
|
*/
|
|
309
|
-
address:
|
|
310
|
-
}
|
|
311
|
-
type
|
|
389
|
+
readonly address: v.StringSchema<undefined>;
|
|
390
|
+
}, undefined>;
|
|
391
|
+
type SignMessageResult = v.InferOutput<typeof signMessageResultSchema>;
|
|
392
|
+
declare const signMessageRequestMessageSchema: v.ObjectSchema<{
|
|
393
|
+
readonly method: v.LiteralSchema<"signMessage", undefined>;
|
|
394
|
+
readonly params: v.ObjectSchema<{
|
|
395
|
+
/**
|
|
396
|
+
* The address used for signing.
|
|
397
|
+
**/
|
|
398
|
+
readonly address: v.StringSchema<undefined>;
|
|
399
|
+
/**
|
|
400
|
+
* The message to sign.
|
|
401
|
+
**/
|
|
402
|
+
readonly message: v.StringSchema<undefined>;
|
|
403
|
+
}, undefined>;
|
|
404
|
+
readonly id: v.StringSchema<undefined>;
|
|
405
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
406
|
+
}, undefined>;
|
|
407
|
+
type SignMessageRequestMessage = v.InferOutput<typeof signMessageRequestMessageSchema>;
|
|
408
|
+
type SignMessage = MethodParamsAndResult<v.InferOutput<typeof signMessageParamsSchema>, v.InferOutput<typeof signMessageResultSchema>>;
|
|
312
409
|
type Recipient$1 = {
|
|
313
410
|
/**
|
|
314
411
|
* The recipient's address.
|
|
@@ -365,22 +462,107 @@ type SignPsbtResult = {
|
|
|
365
462
|
txid?: string;
|
|
366
463
|
};
|
|
367
464
|
type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
*
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
465
|
+
declare const getAccountsMethodName = "getAccounts";
|
|
466
|
+
declare const getAccountsParamsSchema: v.ObjectSchema<{
|
|
467
|
+
/**
|
|
468
|
+
* The purposes for which to generate addresses. See
|
|
469
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
470
|
+
*/
|
|
471
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
472
|
+
/**
|
|
473
|
+
* A message to be displayed to the user in the request prompt.
|
|
474
|
+
*/
|
|
475
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
476
|
+
}, undefined>;
|
|
477
|
+
type GetAccountsParams = v.InferOutput<typeof getAccountsParamsSchema>;
|
|
478
|
+
declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
|
|
479
|
+
readonly address: v.StringSchema<undefined>;
|
|
480
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
481
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
482
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
483
|
+
}, undefined>, undefined>;
|
|
484
|
+
type GetAccountsResult = v.InferOutput<typeof getAccountsResultSchema>;
|
|
485
|
+
declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
|
|
486
|
+
readonly method: v.LiteralSchema<"getAccounts", undefined>;
|
|
487
|
+
readonly params: v.ObjectSchema<{
|
|
488
|
+
/**
|
|
489
|
+
* The purposes for which to generate addresses. See
|
|
490
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
491
|
+
*/
|
|
492
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
493
|
+
/**
|
|
494
|
+
* A message to be displayed to the user in the request prompt.
|
|
495
|
+
*/
|
|
496
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
497
|
+
}, undefined>;
|
|
498
|
+
readonly id: v.StringSchema<undefined>;
|
|
499
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
500
|
+
}, undefined>;
|
|
501
|
+
type GetAccountsRequestMessage = v.InferOutput<typeof getAccountsRequestMessageSchema>;
|
|
502
|
+
type GetAccounts = MethodParamsAndResult<v.InferOutput<typeof getAccountsParamsSchema>, v.InferOutput<typeof getAccountsResultSchema>>;
|
|
503
|
+
declare const getBalanceMethodName = "getBalance";
|
|
504
|
+
declare const getBalanceParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
505
|
+
declare const getBalanceResultSchema: v.ObjectSchema<{
|
|
506
|
+
/**
|
|
507
|
+
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
508
|
+
* messages not supporting bigint
|
|
509
|
+
* (https://issues.chromium.org/issues/40116184).
|
|
510
|
+
*/
|
|
511
|
+
readonly confirmed: v.StringSchema<undefined>;
|
|
512
|
+
/**
|
|
513
|
+
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
514
|
+
* messages not supporting bigint
|
|
515
|
+
* (https://issues.chromium.org/issues/40116184).
|
|
516
|
+
*/
|
|
517
|
+
readonly unconfirmed: v.StringSchema<undefined>;
|
|
518
|
+
/**
|
|
519
|
+
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
520
|
+
* sats. Using a string due to chrome messages not supporting bigint
|
|
521
|
+
* (https://issues.chromium.org/issues/40116184).
|
|
522
|
+
*/
|
|
523
|
+
readonly total: v.StringSchema<undefined>;
|
|
524
|
+
}, undefined>;
|
|
525
|
+
declare const getBalanceRequestMessageSchema: v.ObjectSchema<{
|
|
526
|
+
readonly method: v.LiteralSchema<"getBalance", undefined>;
|
|
527
|
+
readonly id: v.StringSchema<undefined>;
|
|
528
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
529
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
530
|
+
}, undefined>;
|
|
531
|
+
type GetBalance = MethodParamsAndResult<v.InferOutput<typeof getBalanceParamsSchema>, v.InferOutput<typeof getBalanceResultSchema>>;
|
|
532
|
+
|
|
533
|
+
declare const getInscriptionsMethodName = "ord_getInscriptions";
|
|
534
|
+
declare const getInscriptionsParamsSchema: v.ObjectSchema<{
|
|
535
|
+
readonly offset: v.NumberSchema<undefined>;
|
|
536
|
+
readonly limit: v.NumberSchema<undefined>;
|
|
537
|
+
}, undefined>;
|
|
538
|
+
declare const getInscriptionsResultSchema: v.ObjectSchema<{
|
|
539
|
+
readonly total: v.NumberSchema<undefined>;
|
|
540
|
+
readonly limit: v.NumberSchema<undefined>;
|
|
541
|
+
readonly offset: v.NumberSchema<undefined>;
|
|
542
|
+
readonly inscriptions: v.ArraySchema<v.ObjectSchema<{
|
|
543
|
+
readonly inscriptionId: v.StringSchema<undefined>;
|
|
544
|
+
readonly inscriptionNumber: v.StringSchema<undefined>;
|
|
545
|
+
readonly address: v.StringSchema<undefined>;
|
|
546
|
+
readonly collectionName: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
547
|
+
readonly postage: v.StringSchema<undefined>;
|
|
548
|
+
readonly contentLength: v.StringSchema<undefined>;
|
|
549
|
+
readonly contentType: v.StringSchema<undefined>;
|
|
550
|
+
readonly timestamp: v.NumberSchema<undefined>;
|
|
551
|
+
readonly offset: v.NumberSchema<undefined>;
|
|
552
|
+
readonly genesisTransaction: v.StringSchema<undefined>;
|
|
553
|
+
readonly output: v.StringSchema<undefined>;
|
|
554
|
+
}, undefined>, undefined>;
|
|
555
|
+
}, undefined>;
|
|
556
|
+
declare const getInscriptionsSchema: v.ObjectSchema<{
|
|
557
|
+
readonly method: v.LiteralSchema<"ord_getInscriptions", undefined>;
|
|
558
|
+
readonly params: v.ObjectSchema<{
|
|
559
|
+
readonly offset: v.NumberSchema<undefined>;
|
|
560
|
+
readonly limit: v.NumberSchema<undefined>;
|
|
561
|
+
}, undefined>;
|
|
562
|
+
readonly id: v.StringSchema<undefined>;
|
|
563
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
564
|
+
}, undefined>;
|
|
565
|
+
type GetInscriptions = MethodParamsAndResult<v.InferOutput<typeof getInscriptionsParamsSchema>, v.InferOutput<typeof getInscriptionsResultSchema>>;
|
|
384
566
|
|
|
385
567
|
type CreateMintOrderRequest = {
|
|
386
568
|
runeName: string;
|
|
@@ -493,17 +675,27 @@ interface RbfOrderResult {
|
|
|
493
675
|
fundingAddress: string;
|
|
494
676
|
}
|
|
495
677
|
type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
678
|
+
declare const getRunesBalanceMethodName = "runes_getBalance";
|
|
679
|
+
declare const getRunesBalanceParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
680
|
+
type GetRunesBalanceParams = v.InferOutput<typeof getRunesBalanceParamsSchema>;
|
|
681
|
+
declare const getRunesBalanceResultSchema: v.ObjectSchema<{
|
|
682
|
+
readonly balances: v.ArraySchema<v.ObjectSchema<{
|
|
683
|
+
readonly runeName: v.StringSchema<undefined>;
|
|
684
|
+
readonly amount: v.StringSchema<undefined>;
|
|
685
|
+
readonly divisibility: v.NumberSchema<undefined>;
|
|
686
|
+
readonly symbol: v.StringSchema<undefined>;
|
|
687
|
+
readonly inscriptionId: v.NullishSchema<v.StringSchema<undefined>, never>;
|
|
688
|
+
}, undefined>, undefined>;
|
|
689
|
+
}, undefined>;
|
|
690
|
+
type GetRunesBalanceResult = v.InferOutput<typeof getRunesBalanceResultSchema>;
|
|
691
|
+
declare const getRunesBalanceRequestMessageSchema: v.ObjectSchema<{
|
|
692
|
+
readonly method: v.LiteralSchema<"runes_getBalance", undefined>;
|
|
693
|
+
readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
694
|
+
readonly id: v.StringSchema<undefined>;
|
|
695
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
696
|
+
}, undefined>;
|
|
697
|
+
type GetRunesBalanceRequestMessage = v.InferOutput<typeof getRunesBalanceRequestMessageSchema>;
|
|
698
|
+
type GetRunesBalance = MethodParamsAndResult<v.InferOutput<typeof getRunesBalanceParamsSchema>, v.InferOutput<typeof getRunesBalanceResultSchema>>;
|
|
507
699
|
|
|
508
700
|
interface Pubkey {
|
|
509
701
|
/**
|
|
@@ -669,22 +861,71 @@ interface DeployContractParams {
|
|
|
669
861
|
}
|
|
670
862
|
type DeployContractResult = TxId & Transaction;
|
|
671
863
|
type StxDeployContract = MethodParamsAndResult<DeployContractParams, DeployContractResult>;
|
|
672
|
-
type
|
|
864
|
+
type StxGetAccountsResult = {
|
|
673
865
|
addresses: Array<Address & PublicKey & {
|
|
674
866
|
gaiaHubUrl: string;
|
|
675
867
|
gaiaAppKey: string;
|
|
676
868
|
}>;
|
|
677
869
|
};
|
|
678
|
-
type StxGetAccounts = MethodParamsAndResult<{},
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
870
|
+
type StxGetAccounts = MethodParamsAndResult<{}, StxGetAccountsResult>;
|
|
871
|
+
declare const stxGetAddressesMethodName = "stx_getAddresses";
|
|
872
|
+
declare const stxGetAddressesParamsSchema: v.NullishSchema<v.ObjectSchema<{
|
|
873
|
+
/**
|
|
874
|
+
* A message to be displayed to the user in the request prompt.
|
|
875
|
+
*/
|
|
876
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
877
|
+
}, undefined>, never>;
|
|
878
|
+
type StxGetAddressesParams = v.InferOutput<typeof stxGetAddressesParamsSchema>;
|
|
879
|
+
declare const stxGetAddressesResultSchema: v.ObjectSchema<{
|
|
880
|
+
/**
|
|
881
|
+
* The addresses generated for the given purposes.
|
|
882
|
+
*/
|
|
883
|
+
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
884
|
+
readonly address: v.StringSchema<undefined>;
|
|
885
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
886
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
887
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
888
|
+
}, undefined>, undefined>;
|
|
889
|
+
}, undefined>;
|
|
890
|
+
type StxGetAddressesResult = v.InferOutput<typeof stxGetAddressesResultSchema>;
|
|
891
|
+
declare const stxGetAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
892
|
+
readonly method: v.LiteralSchema<"stx_getAddresses", undefined>;
|
|
893
|
+
readonly params: v.NullishSchema<v.ObjectSchema<{
|
|
894
|
+
/**
|
|
895
|
+
* A message to be displayed to the user in the request prompt.
|
|
896
|
+
*/
|
|
897
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
898
|
+
}, undefined>, never>;
|
|
899
|
+
readonly id: v.StringSchema<undefined>;
|
|
900
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
901
|
+
}, undefined>;
|
|
902
|
+
type StxGetAddressesRequestMessage = v.InferOutput<typeof stxGetAddressesRequestMessageSchema>;
|
|
903
|
+
type StxGetAddresses = MethodParamsAndResult<v.InferOutput<typeof stxGetAddressesParamsSchema>, v.InferOutput<typeof stxGetAddressesResultSchema>>;
|
|
684
904
|
type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
685
905
|
type SignTransactionResult = Transaction;
|
|
686
906
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
687
907
|
|
|
908
|
+
declare const requestPermissionsMethodName = "wallet_requestPermissions";
|
|
909
|
+
declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
910
|
+
declare const requestPermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
911
|
+
declare const requestPermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
912
|
+
readonly method: v.LiteralSchema<"wallet_requestPermissions", undefined>;
|
|
913
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
914
|
+
readonly id: v.StringSchema<undefined>;
|
|
915
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
916
|
+
}, undefined>;
|
|
917
|
+
type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof requestPermissionsParamsSchema>, v.InferOutput<typeof requestPermissionsResultSchema>>;
|
|
918
|
+
declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
919
|
+
declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
920
|
+
declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
921
|
+
declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
922
|
+
readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
|
|
923
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
924
|
+
readonly id: v.StringSchema<undefined>;
|
|
925
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
926
|
+
}, undefined>;
|
|
927
|
+
type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
|
|
928
|
+
|
|
688
929
|
interface StxRequests {
|
|
689
930
|
stx_callContract: StxCallContract;
|
|
690
931
|
stx_deployContract: StxDeployContract;
|
|
@@ -700,6 +941,7 @@ interface BtcRequests {
|
|
|
700
941
|
getInfo: GetInfo;
|
|
701
942
|
getAddresses: GetAddresses;
|
|
702
943
|
getAccounts: GetAccounts;
|
|
944
|
+
getBalance: GetBalance;
|
|
703
945
|
signMessage: SignMessage;
|
|
704
946
|
sendTransfer: SendTransfer;
|
|
705
947
|
signPsbt: SignPsbt;
|
|
@@ -716,11 +958,19 @@ interface RunesRequests {
|
|
|
716
958
|
runes_getBalance: GetRunesBalance;
|
|
717
959
|
}
|
|
718
960
|
type RunesRequestMethod = keyof RunesRequests;
|
|
719
|
-
|
|
961
|
+
interface OrdinalsRequests {
|
|
962
|
+
ord_getInscriptions: GetInscriptions;
|
|
963
|
+
}
|
|
964
|
+
type OrdinalsRequestMethod = keyof OrdinalsRequests;
|
|
965
|
+
interface WalletMethods {
|
|
966
|
+
wallet_requestPermissions: RequestPermissions;
|
|
967
|
+
wallet_renouncePermissions: RenouncePermissions;
|
|
968
|
+
}
|
|
969
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods & OrdinalsRequests;
|
|
720
970
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
721
971
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
722
972
|
|
|
723
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
973
|
+
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods | "ord_getInscriptions">(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
724
974
|
|
|
725
975
|
declare abstract class SatsConnectAdapter {
|
|
726
976
|
abstract readonly id: string;
|
|
@@ -738,10 +988,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
738
988
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
739
989
|
id: string;
|
|
740
990
|
constructor(providerId: string);
|
|
741
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
991
|
+
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods | "ord_getInscriptions">(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
742
992
|
}
|
|
743
993
|
|
|
744
994
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
745
995
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
746
996
|
|
|
747
|
-
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
|
|
997
|
+
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 EstimateRbfOrder, type EstimateRunesEtch, type EstimateRunesEtchParams, type EstimateRunesEtchResult, type EstimateRunesMint, type EstimateRunesMintParams, type EstimateRunesMintResult, type EtchRunes, type EtchRunesParams, type EtchRunesResult, type GetAccounts, type GetAccountsParams, type GetAccountsRequestMessage, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesRequestMessage, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetInfoParams, type GetInfoRequestMessage, type GetInfoResult, type GetInscriptions, type GetOrder, type GetRunesBalance, type GetRunesBalanceParams, type GetRunesBalanceRequestMessage, type GetRunesBalanceResult, type InputToSign, type MethodParamsAndResult, type MintRunes, type MintRunesParams, type MintRunesResult, type OrdinalsRequestMethod, type OrdinalsRequests, type Params, type Provider, type PsbtPayload, type RbfOrder, type Recipient$2 as Recipient, type RenouncePermissions, type RequestOptions, type RequestPayload, type RequestPermissions, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcErrorResponseMessage, type RpcId, RpcIdSchema, type RpcRequest, type RpcRequestMessage, type RpcResponse, type RpcResponseMessage, type RpcResult, type RpcSuccessResponse, type RpcSuccessResponseMessage, 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 SignMessageRequestMessage, type SignMessageResponse, type SignMessageResult, 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 StxGetAccountsResult, type StxGetAddresses, type StxGetAddressesParams, type StxGetAddressesRequestMessage, type StxGetAddressesResult, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, type WalletMethods, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceRequestMessageSchema, getBalanceResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoRequestMessageSchema, getInfoResultSchema, getInscriptionsMethodName, getInscriptionsParamsSchema, getInscriptionsResultSchema, getInscriptionsSchema, getProviderById, getProviderOrThrow, getProviders, getRunesBalanceMethodName, getRunesBalanceParamsSchema, getRunesBalanceRequestMessageSchema, getRunesBalanceResultSchema, getSupportedWallets, isProviderInstalled, removeDefaultProvider, renouncePermissionsMethodName, renouncePermissionsParamsSchema, renouncePermissionsRequestMessageSchema, renouncePermissionsResultSchema, request, requestPermissionsMethodName, requestPermissionsParamsSchema, requestPermissionsRequestMessageSchema, requestPermissionsResultSchema, rpcErrorResponseMessageSchema, rpcRequestMessageSchema, rpcResponseMessageSchema, rpcSuccessResponseMessageSchema, sendBtcTransaction, setDefaultProvider, signMessage, signMessageMethodName, signMessageParamsSchema, signMessageRequestMessageSchema, signMessageResultSchema, signMultipleTransactions, signTransaction, stxGetAddressesMethodName, stxGetAddressesParamsSchema, stxGetAddressesRequestMessageSchema, stxGetAddressesResultSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType3) => {
|
|
4
|
+
BitcoinNetworkType3["Mainnet"] = "Mainnet";
|
|
5
|
+
BitcoinNetworkType3["Testnet"] = "Testnet";
|
|
6
|
+
BitcoinNetworkType3["Signet"] = "Signet";
|
|
7
|
+
return BitcoinNetworkType3;
|
|
7
8
|
})(BitcoinNetworkType || {});
|
|
9
|
+
var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
|
|
10
|
+
var rpcRequestMessageSchema = v.object({
|
|
11
|
+
jsonrpc: v.literal("2.0"),
|
|
12
|
+
method: v.string(),
|
|
13
|
+
params: v.optional(
|
|
14
|
+
v.union([
|
|
15
|
+
v.array(v.unknown()),
|
|
16
|
+
v.looseObject({}),
|
|
17
|
+
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
18
|
+
// to be either an array or an object when provided. Changing this now would
|
|
19
|
+
// be a breaking change, so accepting null values for now. Tracking in
|
|
20
|
+
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
21
|
+
v.null()
|
|
22
|
+
])
|
|
23
|
+
),
|
|
24
|
+
id: RpcIdSchema
|
|
25
|
+
});
|
|
8
26
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
9
27
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
10
28
|
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
@@ -13,8 +31,23 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
13
31
|
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
14
32
|
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
15
33
|
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
34
|
+
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
16
35
|
return RpcErrorCode2;
|
|
17
36
|
})(RpcErrorCode || {});
|
|
37
|
+
var rpcSuccessResponseMessageSchema = v.object({
|
|
38
|
+
jsonrpc: v.literal("2.0"),
|
|
39
|
+
result: v.nonOptional(v.unknown()),
|
|
40
|
+
id: RpcIdSchema
|
|
41
|
+
});
|
|
42
|
+
var rpcErrorResponseMessageSchema = v.object({
|
|
43
|
+
jsonrpc: v.literal("2.0"),
|
|
44
|
+
error: v.nonOptional(v.unknown()),
|
|
45
|
+
id: RpcIdSchema
|
|
46
|
+
});
|
|
47
|
+
var rpcResponseMessageSchema = v.union([
|
|
48
|
+
rpcSuccessResponseMessageSchema,
|
|
49
|
+
rpcErrorResponseMessageSchema
|
|
50
|
+
]);
|
|
18
51
|
|
|
19
52
|
// src/runes/api.ts
|
|
20
53
|
import axios from "axios";
|
|
@@ -513,49 +546,13 @@ function getSupportedWallets() {
|
|
|
513
546
|
}
|
|
514
547
|
|
|
515
548
|
// src/request/index.ts
|
|
516
|
-
|
|
517
|
-
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
518
|
-
if (providerId) {
|
|
519
|
-
provider = await getProviderById(providerId);
|
|
520
|
-
}
|
|
521
|
-
if (!provider) {
|
|
522
|
-
throw new Error("no wallet provider was found");
|
|
523
|
-
}
|
|
524
|
-
if (!method) {
|
|
525
|
-
throw new Error("A wallet method is required");
|
|
526
|
-
}
|
|
527
|
-
const response = await provider.request(method, params);
|
|
528
|
-
if (isRpcSuccessResponse(response)) {
|
|
529
|
-
return {
|
|
530
|
-
status: "success",
|
|
531
|
-
result: response.result
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
return {
|
|
535
|
-
status: "error",
|
|
536
|
-
error: response.error
|
|
537
|
-
};
|
|
538
|
-
};
|
|
539
|
-
var isRpcSuccessResponse = (response) => {
|
|
540
|
-
return Object.hasOwn(response, "result") && !!response.result;
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
// src/adapters/xverse.ts
|
|
544
|
-
var XverseAdapter = class extends SatsConnectAdapter {
|
|
545
|
-
id = DefaultAdaptersInfo.xverse.id;
|
|
546
|
-
requestInternal = async (method, params) => {
|
|
547
|
-
return request(method, params, this.id);
|
|
548
|
-
};
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
// src/adapters/unisat.ts
|
|
552
|
-
import { Buffer } from "buffer";
|
|
553
|
-
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
549
|
+
import * as v8 from "valibot";
|
|
554
550
|
|
|
555
551
|
// src/addresses/index.ts
|
|
556
552
|
import { createUnsecuredToken } from "jsontokens";
|
|
557
553
|
|
|
558
554
|
// src/addresses/types.ts
|
|
555
|
+
import * as v2 from "valibot";
|
|
559
556
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
560
557
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
561
558
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -571,6 +568,12 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
571
568
|
AddressType3["stacks"] = "stacks";
|
|
572
569
|
return AddressType3;
|
|
573
570
|
})(AddressType || {});
|
|
571
|
+
var addressSchema = v2.object({
|
|
572
|
+
address: v2.string(),
|
|
573
|
+
publicKey: v2.string(),
|
|
574
|
+
purpose: v2.enum(AddressPurpose),
|
|
575
|
+
addressType: v2.enum(AddressType)
|
|
576
|
+
});
|
|
574
577
|
|
|
575
578
|
// src/addresses/index.ts
|
|
576
579
|
var getAddress = async (options) => {
|
|
@@ -589,7 +592,289 @@ var getAddress = async (options) => {
|
|
|
589
592
|
}
|
|
590
593
|
};
|
|
591
594
|
|
|
595
|
+
// src/request/types/stxMethods.ts
|
|
596
|
+
import * as v3 from "valibot";
|
|
597
|
+
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
598
|
+
var stxGetAddressesParamsSchema = v3.nullish(
|
|
599
|
+
v3.object({
|
|
600
|
+
/**
|
|
601
|
+
* A message to be displayed to the user in the request prompt.
|
|
602
|
+
*/
|
|
603
|
+
message: v3.optional(v3.string())
|
|
604
|
+
})
|
|
605
|
+
);
|
|
606
|
+
var stxGetAddressesResultSchema = v3.object({
|
|
607
|
+
/**
|
|
608
|
+
* The addresses generated for the given purposes.
|
|
609
|
+
*/
|
|
610
|
+
addresses: v3.array(addressSchema)
|
|
611
|
+
});
|
|
612
|
+
var stxGetAddressesRequestMessageSchema = v3.object({
|
|
613
|
+
...rpcRequestMessageSchema.entries,
|
|
614
|
+
...v3.object({
|
|
615
|
+
method: v3.literal(stxGetAddressesMethodName),
|
|
616
|
+
params: stxGetAddressesParamsSchema,
|
|
617
|
+
id: v3.string()
|
|
618
|
+
}).entries
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// src/request/types/btcMethods.ts
|
|
622
|
+
import * as v4 from "valibot";
|
|
623
|
+
var getInfoMethodName = "getInfo";
|
|
624
|
+
var getInfoParamsSchema = v4.nullish(v4.null());
|
|
625
|
+
var getInfoResultSchema = v4.object({
|
|
626
|
+
/**
|
|
627
|
+
* Version of the wallet.
|
|
628
|
+
*/
|
|
629
|
+
version: v4.string(),
|
|
630
|
+
/**
|
|
631
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
632
|
+
*/
|
|
633
|
+
methods: v4.optional(v4.array(v4.string())),
|
|
634
|
+
/**
|
|
635
|
+
* List of WBIP standards supported by the wallet. Not currently used.
|
|
636
|
+
*/
|
|
637
|
+
supports: v4.array(v4.string())
|
|
638
|
+
});
|
|
639
|
+
var getInfoRequestMessageSchema = v4.object({
|
|
640
|
+
...rpcRequestMessageSchema.entries,
|
|
641
|
+
...v4.object({
|
|
642
|
+
method: v4.literal(getInfoMethodName),
|
|
643
|
+
params: getInfoParamsSchema,
|
|
644
|
+
id: v4.string()
|
|
645
|
+
}).entries
|
|
646
|
+
});
|
|
647
|
+
var getAddressesMethodName = "getAddresses";
|
|
648
|
+
var getAddressesParamsSchema = v4.object({
|
|
649
|
+
/**
|
|
650
|
+
* The purposes for which to generate addresses. See
|
|
651
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
652
|
+
*/
|
|
653
|
+
purposes: v4.array(v4.enum(AddressPurpose)),
|
|
654
|
+
/**
|
|
655
|
+
* A message to be displayed to the user in the request prompt.
|
|
656
|
+
*/
|
|
657
|
+
message: v4.optional(v4.string())
|
|
658
|
+
});
|
|
659
|
+
var getAddressesResultSchema = v4.object({
|
|
660
|
+
/**
|
|
661
|
+
* The addresses generated for the given purposes.
|
|
662
|
+
*/
|
|
663
|
+
addresses: v4.array(addressSchema)
|
|
664
|
+
});
|
|
665
|
+
var getAddressesRequestMessageSchema = v4.object({
|
|
666
|
+
...rpcRequestMessageSchema.entries,
|
|
667
|
+
...v4.object({
|
|
668
|
+
method: v4.literal(getAddressesMethodName),
|
|
669
|
+
params: getAddressesParamsSchema,
|
|
670
|
+
id: v4.string()
|
|
671
|
+
}).entries
|
|
672
|
+
});
|
|
673
|
+
var signMessageMethodName = "signMessage";
|
|
674
|
+
var signMessageParamsSchema = v4.object({
|
|
675
|
+
/**
|
|
676
|
+
* The address used for signing.
|
|
677
|
+
**/
|
|
678
|
+
address: v4.string(),
|
|
679
|
+
/**
|
|
680
|
+
* The message to sign.
|
|
681
|
+
**/
|
|
682
|
+
message: v4.string()
|
|
683
|
+
});
|
|
684
|
+
var signMessageResultSchema = v4.object({
|
|
685
|
+
/**
|
|
686
|
+
* The signature of the message.
|
|
687
|
+
*/
|
|
688
|
+
signature: v4.string(),
|
|
689
|
+
/**
|
|
690
|
+
* hash of the message.
|
|
691
|
+
*/
|
|
692
|
+
messageHash: v4.string(),
|
|
693
|
+
/**
|
|
694
|
+
* The address used for signing.
|
|
695
|
+
*/
|
|
696
|
+
address: v4.string()
|
|
697
|
+
});
|
|
698
|
+
var signMessageRequestMessageSchema = v4.object({
|
|
699
|
+
...rpcRequestMessageSchema.entries,
|
|
700
|
+
...v4.object({
|
|
701
|
+
method: v4.literal(signMessageMethodName),
|
|
702
|
+
params: signMessageParamsSchema,
|
|
703
|
+
id: v4.string()
|
|
704
|
+
}).entries
|
|
705
|
+
});
|
|
706
|
+
var getAccountsMethodName = "getAccounts";
|
|
707
|
+
var getAccountsParamsSchema = getAddressesParamsSchema;
|
|
708
|
+
var getAccountsResultSchema = v4.array(addressSchema);
|
|
709
|
+
var getAccountsRequestMessageSchema = v4.object({
|
|
710
|
+
...rpcRequestMessageSchema.entries,
|
|
711
|
+
...v4.object({
|
|
712
|
+
method: v4.literal(getAccountsMethodName),
|
|
713
|
+
params: getAccountsParamsSchema,
|
|
714
|
+
id: v4.string()
|
|
715
|
+
}).entries
|
|
716
|
+
});
|
|
717
|
+
var getBalanceMethodName = "getBalance";
|
|
718
|
+
var getBalanceParamsSchema = v4.nullish(v4.null());
|
|
719
|
+
var getBalanceResultSchema = v4.object({
|
|
720
|
+
/**
|
|
721
|
+
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
722
|
+
* messages not supporting bigint
|
|
723
|
+
* (https://issues.chromium.org/issues/40116184).
|
|
724
|
+
*/
|
|
725
|
+
confirmed: v4.string(),
|
|
726
|
+
/**
|
|
727
|
+
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
728
|
+
* messages not supporting bigint
|
|
729
|
+
* (https://issues.chromium.org/issues/40116184).
|
|
730
|
+
*/
|
|
731
|
+
unconfirmed: v4.string(),
|
|
732
|
+
/**
|
|
733
|
+
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
734
|
+
* sats. Using a string due to chrome messages not supporting bigint
|
|
735
|
+
* (https://issues.chromium.org/issues/40116184).
|
|
736
|
+
*/
|
|
737
|
+
total: v4.string()
|
|
738
|
+
});
|
|
739
|
+
var getBalanceRequestMessageSchema = v4.object({
|
|
740
|
+
...rpcRequestMessageSchema.entries,
|
|
741
|
+
...v4.object({
|
|
742
|
+
method: v4.literal(getBalanceMethodName),
|
|
743
|
+
id: v4.string()
|
|
744
|
+
}).entries
|
|
745
|
+
});
|
|
746
|
+
|
|
747
|
+
// src/request/types/walletMethods.ts
|
|
748
|
+
import * as v5 from "valibot";
|
|
749
|
+
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
750
|
+
var requestPermissionsParamsSchema = v5.undefined();
|
|
751
|
+
var requestPermissionsResultSchema = v5.literal(true);
|
|
752
|
+
var requestPermissionsRequestMessageSchema = v5.object({
|
|
753
|
+
...rpcRequestMessageSchema.entries,
|
|
754
|
+
...v5.object({
|
|
755
|
+
method: v5.literal(requestPermissionsMethodName),
|
|
756
|
+
params: requestPermissionsParamsSchema,
|
|
757
|
+
id: v5.string()
|
|
758
|
+
}).entries
|
|
759
|
+
});
|
|
760
|
+
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
761
|
+
var renouncePermissionsParamsSchema = v5.undefined();
|
|
762
|
+
var renouncePermissionsResultSchema = v5.literal(true);
|
|
763
|
+
var renouncePermissionsRequestMessageSchema = v5.object({
|
|
764
|
+
...rpcRequestMessageSchema.entries,
|
|
765
|
+
...v5.object({
|
|
766
|
+
method: v5.literal(renouncePermissionsMethodName),
|
|
767
|
+
params: renouncePermissionsParamsSchema,
|
|
768
|
+
id: v5.string()
|
|
769
|
+
}).entries
|
|
770
|
+
});
|
|
771
|
+
|
|
772
|
+
// src/request/types/runesMethods.ts
|
|
773
|
+
import * as v6 from "valibot";
|
|
774
|
+
var getRunesBalanceMethodName = "runes_getBalance";
|
|
775
|
+
var getRunesBalanceParamsSchema = v6.nullish(v6.null());
|
|
776
|
+
var getRunesBalanceResultSchema = v6.object({
|
|
777
|
+
balances: v6.array(
|
|
778
|
+
v6.object({
|
|
779
|
+
runeName: v6.string(),
|
|
780
|
+
amount: v6.string(),
|
|
781
|
+
divisibility: v6.number(),
|
|
782
|
+
symbol: v6.string(),
|
|
783
|
+
inscriptionId: v6.nullish(v6.string())
|
|
784
|
+
})
|
|
785
|
+
)
|
|
786
|
+
});
|
|
787
|
+
var getRunesBalanceRequestMessageSchema = v6.object({
|
|
788
|
+
...rpcRequestMessageSchema.entries,
|
|
789
|
+
...v6.object({
|
|
790
|
+
method: v6.literal(getRunesBalanceMethodName),
|
|
791
|
+
params: getRunesBalanceParamsSchema,
|
|
792
|
+
id: v6.string()
|
|
793
|
+
}).entries
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
// src/request/types/ordinalsMethods.ts
|
|
797
|
+
import * as v7 from "valibot";
|
|
798
|
+
var getInscriptionsMethodName = "ord_getInscriptions";
|
|
799
|
+
var getInscriptionsParamsSchema = v7.object({
|
|
800
|
+
offset: v7.number(),
|
|
801
|
+
limit: v7.number()
|
|
802
|
+
});
|
|
803
|
+
var getInscriptionsResultSchema = v7.object({
|
|
804
|
+
total: v7.number(),
|
|
805
|
+
limit: v7.number(),
|
|
806
|
+
offset: v7.number(),
|
|
807
|
+
inscriptions: v7.array(
|
|
808
|
+
v7.object({
|
|
809
|
+
inscriptionId: v7.string(),
|
|
810
|
+
inscriptionNumber: v7.string(),
|
|
811
|
+
address: v7.string(),
|
|
812
|
+
collectionName: v7.optional(v7.string()),
|
|
813
|
+
postage: v7.string(),
|
|
814
|
+
contentLength: v7.string(),
|
|
815
|
+
contentType: v7.string(),
|
|
816
|
+
timestamp: v7.number(),
|
|
817
|
+
offset: v7.number(),
|
|
818
|
+
genesisTransaction: v7.string(),
|
|
819
|
+
output: v7.string()
|
|
820
|
+
})
|
|
821
|
+
)
|
|
822
|
+
});
|
|
823
|
+
var getInscriptionsSchema = v7.object({
|
|
824
|
+
...rpcRequestMessageSchema.entries,
|
|
825
|
+
...v7.object({
|
|
826
|
+
method: v7.literal(getInscriptionsMethodName),
|
|
827
|
+
params: getInscriptionsParamsSchema,
|
|
828
|
+
id: v7.string()
|
|
829
|
+
}).entries
|
|
830
|
+
});
|
|
831
|
+
|
|
832
|
+
// src/request/index.ts
|
|
833
|
+
var request = async (method, params, providerId) => {
|
|
834
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
835
|
+
if (providerId) {
|
|
836
|
+
provider = await getProviderById(providerId);
|
|
837
|
+
}
|
|
838
|
+
if (!provider) {
|
|
839
|
+
throw new Error("no wallet provider was found");
|
|
840
|
+
}
|
|
841
|
+
if (!method) {
|
|
842
|
+
throw new Error("A wallet method is required");
|
|
843
|
+
}
|
|
844
|
+
const response = await provider.request(method, params);
|
|
845
|
+
if (v8.is(rpcErrorResponseMessageSchema, response)) {
|
|
846
|
+
return {
|
|
847
|
+
status: "error",
|
|
848
|
+
error: response.error
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
if (v8.is(rpcSuccessResponseMessageSchema, response)) {
|
|
852
|
+
return {
|
|
853
|
+
status: "success",
|
|
854
|
+
result: response.result
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
status: "error",
|
|
859
|
+
error: {
|
|
860
|
+
code: -32603 /* INTERNAL_ERROR */,
|
|
861
|
+
message: "Received unknown response from provider.",
|
|
862
|
+
data: response
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
// src/adapters/xverse.ts
|
|
868
|
+
var XverseAdapter = class extends SatsConnectAdapter {
|
|
869
|
+
id = DefaultAdaptersInfo.xverse.id;
|
|
870
|
+
requestInternal = async (method, params) => {
|
|
871
|
+
return request(method, params, this.id);
|
|
872
|
+
};
|
|
873
|
+
};
|
|
874
|
+
|
|
592
875
|
// src/adapters/unisat.ts
|
|
876
|
+
import { Buffer } from "buffer";
|
|
877
|
+
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
593
878
|
function convertSignInputsToInputType(signInputs, allowedSignHash) {
|
|
594
879
|
let result = [];
|
|
595
880
|
for (let address in signInputs) {
|
|
@@ -993,23 +1278,69 @@ export {
|
|
|
993
1278
|
BitcoinNetworkType,
|
|
994
1279
|
DefaultAdaptersInfo,
|
|
995
1280
|
RpcErrorCode,
|
|
1281
|
+
RpcIdSchema,
|
|
996
1282
|
SatsConnectAdapter,
|
|
1283
|
+
addressSchema,
|
|
997
1284
|
createInscription,
|
|
998
1285
|
createRepeatInscriptions,
|
|
999
1286
|
defaultAdapters,
|
|
1287
|
+
getAccountsMethodName,
|
|
1288
|
+
getAccountsParamsSchema,
|
|
1289
|
+
getAccountsRequestMessageSchema,
|
|
1290
|
+
getAccountsResultSchema,
|
|
1000
1291
|
getAddress,
|
|
1292
|
+
getAddressesMethodName,
|
|
1293
|
+
getAddressesParamsSchema,
|
|
1294
|
+
getAddressesRequestMessageSchema,
|
|
1295
|
+
getAddressesResultSchema,
|
|
1296
|
+
getBalanceMethodName,
|
|
1297
|
+
getBalanceParamsSchema,
|
|
1298
|
+
getBalanceRequestMessageSchema,
|
|
1299
|
+
getBalanceResultSchema,
|
|
1001
1300
|
getCapabilities,
|
|
1002
1301
|
getDefaultProvider,
|
|
1302
|
+
getInfoMethodName,
|
|
1303
|
+
getInfoParamsSchema,
|
|
1304
|
+
getInfoRequestMessageSchema,
|
|
1305
|
+
getInfoResultSchema,
|
|
1306
|
+
getInscriptionsMethodName,
|
|
1307
|
+
getInscriptionsParamsSchema,
|
|
1308
|
+
getInscriptionsResultSchema,
|
|
1309
|
+
getInscriptionsSchema,
|
|
1003
1310
|
getProviderById,
|
|
1004
1311
|
getProviderOrThrow,
|
|
1005
1312
|
getProviders,
|
|
1313
|
+
getRunesBalanceMethodName,
|
|
1314
|
+
getRunesBalanceParamsSchema,
|
|
1315
|
+
getRunesBalanceRequestMessageSchema,
|
|
1316
|
+
getRunesBalanceResultSchema,
|
|
1006
1317
|
getSupportedWallets,
|
|
1007
1318
|
isProviderInstalled,
|
|
1008
1319
|
removeDefaultProvider,
|
|
1320
|
+
renouncePermissionsMethodName,
|
|
1321
|
+
renouncePermissionsParamsSchema,
|
|
1322
|
+
renouncePermissionsRequestMessageSchema,
|
|
1323
|
+
renouncePermissionsResultSchema,
|
|
1009
1324
|
request,
|
|
1325
|
+
requestPermissionsMethodName,
|
|
1326
|
+
requestPermissionsParamsSchema,
|
|
1327
|
+
requestPermissionsRequestMessageSchema,
|
|
1328
|
+
requestPermissionsResultSchema,
|
|
1329
|
+
rpcErrorResponseMessageSchema,
|
|
1330
|
+
rpcRequestMessageSchema,
|
|
1331
|
+
rpcResponseMessageSchema,
|
|
1332
|
+
rpcSuccessResponseMessageSchema,
|
|
1010
1333
|
sendBtcTransaction,
|
|
1011
1334
|
setDefaultProvider,
|
|
1012
1335
|
signMessage,
|
|
1336
|
+
signMessageMethodName,
|
|
1337
|
+
signMessageParamsSchema,
|
|
1338
|
+
signMessageRequestMessageSchema,
|
|
1339
|
+
signMessageResultSchema,
|
|
1013
1340
|
signMultipleTransactions,
|
|
1014
|
-
signTransaction
|
|
1341
|
+
signTransaction,
|
|
1342
|
+
stxGetAddressesMethodName,
|
|
1343
|
+
stxGetAddressesParamsSchema,
|
|
1344
|
+
stxGetAddressesRequestMessageSchema,
|
|
1345
|
+
stxGetAddressesResultSchema
|
|
1015
1346
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13-d1f5108",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"test": "jest",
|
|
12
12
|
"build-debug": "webpack --mode development",
|
|
13
13
|
"build": "npm run clean && tsup src/index.ts --format esm --dts",
|
|
14
|
+
"build:watch": "npm run clean && tsup src/index.ts --format esm --dts --watch",
|
|
14
15
|
"clean": "rimraf dist",
|
|
15
16
|
"lint": "prettier --write .",
|
|
16
17
|
"prepare": "husky install"
|
|
@@ -30,6 +31,9 @@
|
|
|
30
31
|
"jsontokens": "4.0.1",
|
|
31
32
|
"lodash.omit": "4.5.0"
|
|
32
33
|
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"valibot": "0.33.2"
|
|
36
|
+
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@types/jest": "^29.2.6",
|
|
35
39
|
"@types/lodash.omit": "4.5.9",
|
|
@@ -42,7 +46,7 @@
|
|
|
42
46
|
"ts-jest": "^29.0.5",
|
|
43
47
|
"ts-loader": "^9.4.1",
|
|
44
48
|
"tsup": "^8.0.2",
|
|
45
|
-
"typescript": "
|
|
49
|
+
"typescript": "5.4.5",
|
|
46
50
|
"util": "^0.12.4",
|
|
47
51
|
"vm-browserify": "^1.1.2",
|
|
48
52
|
"webpack": "^5.74.0",
|