@sats-connect/core 0.0.11-e6aad2f → 0.0.12-635f56e
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 +196 -29
- package/dist/index.mjs +270 -49
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -116,7 +116,7 @@ interface Provider {
|
|
|
116
116
|
mozillaAddOnsUrl?: string;
|
|
117
117
|
googlePlayStoreUrl?: string;
|
|
118
118
|
iOSAppStoreUrl?: string;
|
|
119
|
-
methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod)[];
|
|
119
|
+
methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod | OrdinalsRequestMethod)[];
|
|
120
120
|
}
|
|
121
121
|
interface SupportedWallet extends Provider {
|
|
122
122
|
isInstalled: boolean;
|
|
@@ -159,14 +159,15 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
159
159
|
payload: Payload;
|
|
160
160
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
161
161
|
}
|
|
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>;
|
|
162
164
|
declare const rpcRequestMessageSchema: v.ObjectSchema<{
|
|
163
165
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
164
166
|
readonly method: v.StringSchema<undefined>;
|
|
165
|
-
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>], undefined>, never>;
|
|
167
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
166
168
|
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
167
169
|
}, undefined>;
|
|
168
170
|
type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
|
|
169
|
-
type RpcId = string | null;
|
|
170
171
|
interface RpcBase {
|
|
171
172
|
jsonrpc: '2.0';
|
|
172
173
|
id: RpcId;
|
|
@@ -213,8 +214,34 @@ declare enum RpcErrorCode {
|
|
|
213
214
|
/**
|
|
214
215
|
* method is not supported for the address provided
|
|
215
216
|
*/
|
|
216
|
-
METHOD_NOT_SUPPORTED = -32001
|
|
217
|
+
METHOD_NOT_SUPPORTED = -32001,
|
|
218
|
+
/**
|
|
219
|
+
* The client does not have permission to access the requested resource.
|
|
220
|
+
*/
|
|
221
|
+
ACCESS_DENIED = -32002
|
|
217
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>;
|
|
218
245
|
interface RpcError {
|
|
219
246
|
code: number | RpcErrorCode;
|
|
220
247
|
message: string;
|
|
@@ -267,7 +294,8 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
|
267
294
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
268
295
|
|
|
269
296
|
declare const getInfoMethodName = "getInfo";
|
|
270
|
-
declare const getInfoParamsSchema: v.NullSchema<undefined>;
|
|
297
|
+
declare const getInfoParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
298
|
+
type GetInfoParams = v.InferOutput<typeof getInfoParamsSchema>;
|
|
271
299
|
declare const getInfoResultSchema: v.ObjectSchema<{
|
|
272
300
|
/**
|
|
273
301
|
* Version of the wallet.
|
|
@@ -282,12 +310,14 @@ declare const getInfoResultSchema: v.ObjectSchema<{
|
|
|
282
310
|
*/
|
|
283
311
|
readonly supports: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
284
312
|
}, undefined>;
|
|
285
|
-
|
|
313
|
+
type GetInfoResult = v.InferOutput<typeof getInfoResultSchema>;
|
|
314
|
+
declare const getInfoRequestMessageSchema: v.ObjectSchema<{
|
|
286
315
|
readonly method: v.LiteralSchema<"getInfo", undefined>;
|
|
287
|
-
readonly params: v.NullSchema<undefined>;
|
|
316
|
+
readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
288
317
|
readonly id: v.StringSchema<undefined>;
|
|
289
318
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
290
319
|
}, undefined>;
|
|
320
|
+
type GetInfoRequestMessage = v.InferOutput<typeof getInfoRequestMessageSchema>;
|
|
291
321
|
type GetInfo = MethodParamsAndResult<v.InferOutput<typeof getInfoParamsSchema>, v.InferOutput<typeof getInfoResultSchema>>;
|
|
292
322
|
declare const getAddressesMethodName = "getAddresses";
|
|
293
323
|
declare const getAddressesParamsSchema: v.ObjectSchema<{
|
|
@@ -301,6 +331,7 @@ declare const getAddressesParamsSchema: v.ObjectSchema<{
|
|
|
301
331
|
*/
|
|
302
332
|
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
303
333
|
}, undefined>;
|
|
334
|
+
type GetAddressesParams = v.InferOutput<typeof getAddressesParamsSchema>;
|
|
304
335
|
declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
305
336
|
/**
|
|
306
337
|
* The addresses generated for the given purposes.
|
|
@@ -312,6 +343,7 @@ declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
|
312
343
|
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
313
344
|
}, undefined>, undefined>;
|
|
314
345
|
}, undefined>;
|
|
346
|
+
type GetAddressesResult = v.InferOutput<typeof getAddressesResultSchema>;
|
|
315
347
|
declare const getAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
316
348
|
readonly method: v.LiteralSchema<"getAddresses", undefined>;
|
|
317
349
|
readonly params: v.ObjectSchema<{
|
|
@@ -328,6 +360,7 @@ declare const getAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
|
328
360
|
readonly id: v.StringSchema<undefined>;
|
|
329
361
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
330
362
|
}, undefined>;
|
|
363
|
+
type GetAddressesRequestMessage = v.InferOutput<typeof getAddressesRequestMessageSchema>;
|
|
331
364
|
type GetAddresses = MethodParamsAndResult<v.InferOutput<typeof getAddressesParamsSchema>, v.InferOutput<typeof getAddressesResultSchema>>;
|
|
332
365
|
declare const signMessageMethodName = "signMessage";
|
|
333
366
|
declare const signMessageParamsSchema: v.ObjectSchema<{
|
|
@@ -340,6 +373,7 @@ declare const signMessageParamsSchema: v.ObjectSchema<{
|
|
|
340
373
|
**/
|
|
341
374
|
readonly message: v.StringSchema<undefined>;
|
|
342
375
|
}, undefined>;
|
|
376
|
+
type SignMessageParams = v.InferOutput<typeof signMessageParamsSchema>;
|
|
343
377
|
declare const signMessageResultSchema: v.ObjectSchema<{
|
|
344
378
|
/**
|
|
345
379
|
* The signature of the message.
|
|
@@ -354,6 +388,7 @@ declare const signMessageResultSchema: v.ObjectSchema<{
|
|
|
354
388
|
*/
|
|
355
389
|
readonly address: v.StringSchema<undefined>;
|
|
356
390
|
}, undefined>;
|
|
391
|
+
type SignMessageResult = v.InferOutput<typeof signMessageResultSchema>;
|
|
357
392
|
declare const signMessageRequestMessageSchema: v.ObjectSchema<{
|
|
358
393
|
readonly method: v.LiteralSchema<"signMessage", undefined>;
|
|
359
394
|
readonly params: v.ObjectSchema<{
|
|
@@ -369,6 +404,7 @@ declare const signMessageRequestMessageSchema: v.ObjectSchema<{
|
|
|
369
404
|
readonly id: v.StringSchema<undefined>;
|
|
370
405
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
371
406
|
}, undefined>;
|
|
407
|
+
type SignMessageRequestMessage = v.InferOutput<typeof signMessageRequestMessageSchema>;
|
|
372
408
|
type SignMessage = MethodParamsAndResult<v.InferOutput<typeof signMessageParamsSchema>, v.InferOutput<typeof signMessageResultSchema>>;
|
|
373
409
|
type Recipient$1 = {
|
|
374
410
|
/**
|
|
@@ -438,12 +474,14 @@ declare const getAccountsParamsSchema: v.ObjectSchema<{
|
|
|
438
474
|
*/
|
|
439
475
|
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
440
476
|
}, undefined>;
|
|
477
|
+
type GetAccountsParams = v.InferOutput<typeof getAccountsParamsSchema>;
|
|
441
478
|
declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
|
|
442
479
|
readonly address: v.StringSchema<undefined>;
|
|
443
480
|
readonly publicKey: v.StringSchema<undefined>;
|
|
444
481
|
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
445
482
|
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
446
483
|
}, undefined>, undefined>;
|
|
484
|
+
type GetAccountsResult = v.InferOutput<typeof getAccountsResultSchema>;
|
|
447
485
|
declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
|
|
448
486
|
readonly method: v.LiteralSchema<"getAccounts", undefined>;
|
|
449
487
|
readonly params: v.ObjectSchema<{
|
|
@@ -460,7 +498,68 @@ declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
|
|
|
460
498
|
readonly id: v.StringSchema<undefined>;
|
|
461
499
|
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
462
500
|
}, undefined>;
|
|
501
|
+
type GetAccountsRequestMessage = v.InferOutput<typeof getAccountsRequestMessageSchema>;
|
|
463
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 inscriptions: v.ArraySchema<v.ObjectSchema<{
|
|
540
|
+
readonly inscriptionId: v.StringSchema<undefined>;
|
|
541
|
+
readonly inscriptionNumber: v.StringSchema<undefined>;
|
|
542
|
+
readonly address: v.StringSchema<undefined>;
|
|
543
|
+
readonly collectionName: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
544
|
+
readonly postage: v.StringSchema<undefined>;
|
|
545
|
+
readonly contentLength: v.StringSchema<undefined>;
|
|
546
|
+
readonly contentType: v.StringSchema<undefined>;
|
|
547
|
+
readonly timestamp: v.NumberSchema<undefined>;
|
|
548
|
+
readonly offset: v.NumberSchema<undefined>;
|
|
549
|
+
readonly genesisTransaction: v.StringSchema<undefined>;
|
|
550
|
+
readonly output: v.StringSchema<undefined>;
|
|
551
|
+
}, undefined>, undefined>;
|
|
552
|
+
}, undefined>;
|
|
553
|
+
declare const getInscriptionsSchema: v.ObjectSchema<{
|
|
554
|
+
readonly method: v.LiteralSchema<"ord_getInscriptions", undefined>;
|
|
555
|
+
readonly params: v.ObjectSchema<{
|
|
556
|
+
readonly offset: v.NumberSchema<undefined>;
|
|
557
|
+
readonly limit: v.NumberSchema<undefined>;
|
|
558
|
+
}, undefined>;
|
|
559
|
+
readonly id: v.StringSchema<undefined>;
|
|
560
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
561
|
+
}, undefined>;
|
|
562
|
+
type GetInscriptions = MethodParamsAndResult<v.InferOutput<typeof getInscriptionsParamsSchema>, v.InferOutput<typeof getInscriptionsResultSchema>>;
|
|
464
563
|
|
|
465
564
|
type CreateMintOrderRequest = {
|
|
466
565
|
runeName: string;
|
|
@@ -573,17 +672,27 @@ interface RbfOrderResult {
|
|
|
573
672
|
fundingAddress: string;
|
|
574
673
|
}
|
|
575
674
|
type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
675
|
+
declare const getRunesBalanceMethodName = "runes_getBalance";
|
|
676
|
+
declare const getRunesBalanceParamsSchema: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
677
|
+
type GetRunesBalanceParams = v.InferOutput<typeof getRunesBalanceParamsSchema>;
|
|
678
|
+
declare const getRunesBalanceResultSchema: v.ObjectSchema<{
|
|
679
|
+
readonly balances: v.ArraySchema<v.ObjectSchema<{
|
|
680
|
+
readonly runeName: v.StringSchema<undefined>;
|
|
681
|
+
readonly amount: v.StringSchema<undefined>;
|
|
682
|
+
readonly divisibility: v.NumberSchema<undefined>;
|
|
683
|
+
readonly symbol: v.StringSchema<undefined>;
|
|
684
|
+
readonly inscriptionId: v.NullishSchema<v.StringSchema<undefined>, never>;
|
|
685
|
+
}, undefined>, undefined>;
|
|
686
|
+
}, undefined>;
|
|
687
|
+
type GetRunesBalanceResult = v.InferOutput<typeof getRunesBalanceResultSchema>;
|
|
688
|
+
declare const getRunesBalanceRequestMessageSchema: v.ObjectSchema<{
|
|
689
|
+
readonly method: v.LiteralSchema<"runes_getBalance", undefined>;
|
|
690
|
+
readonly params: v.NullishSchema<v.NullSchema<undefined>, never>;
|
|
691
|
+
readonly id: v.StringSchema<undefined>;
|
|
692
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
693
|
+
}, undefined>;
|
|
694
|
+
type GetRunesBalanceRequestMessage = v.InferOutput<typeof getRunesBalanceRequestMessageSchema>;
|
|
695
|
+
type GetRunesBalance = MethodParamsAndResult<v.InferOutput<typeof getRunesBalanceParamsSchema>, v.InferOutput<typeof getRunesBalanceResultSchema>>;
|
|
587
696
|
|
|
588
697
|
interface Pubkey {
|
|
589
698
|
/**
|
|
@@ -749,22 +858,71 @@ interface DeployContractParams {
|
|
|
749
858
|
}
|
|
750
859
|
type DeployContractResult = TxId & Transaction;
|
|
751
860
|
type StxDeployContract = MethodParamsAndResult<DeployContractParams, DeployContractResult>;
|
|
752
|
-
type
|
|
861
|
+
type StxGetAccountsResult = {
|
|
753
862
|
addresses: Array<Address & PublicKey & {
|
|
754
863
|
gaiaHubUrl: string;
|
|
755
864
|
gaiaAppKey: string;
|
|
756
865
|
}>;
|
|
757
866
|
};
|
|
758
|
-
type StxGetAccounts = MethodParamsAndResult<{},
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
867
|
+
type StxGetAccounts = MethodParamsAndResult<{}, StxGetAccountsResult>;
|
|
868
|
+
declare const stxGetAddressesMethodName = "stx_getAddresses";
|
|
869
|
+
declare const stxGetAddressesParamsSchema: v.NullishSchema<v.ObjectSchema<{
|
|
870
|
+
/**
|
|
871
|
+
* A message to be displayed to the user in the request prompt.
|
|
872
|
+
*/
|
|
873
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
874
|
+
}, undefined>, never>;
|
|
875
|
+
type StxGetAddressesParams = v.InferOutput<typeof stxGetAddressesParamsSchema>;
|
|
876
|
+
declare const stxGetAddressesResultSchema: v.ObjectSchema<{
|
|
877
|
+
/**
|
|
878
|
+
* The addresses generated for the given purposes.
|
|
879
|
+
*/
|
|
880
|
+
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
881
|
+
readonly address: v.StringSchema<undefined>;
|
|
882
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
883
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
884
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
885
|
+
}, undefined>, undefined>;
|
|
886
|
+
}, undefined>;
|
|
887
|
+
type StxGetAddressesResult = v.InferOutput<typeof stxGetAddressesResultSchema>;
|
|
888
|
+
declare const stxGetAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
889
|
+
readonly method: v.LiteralSchema<"stx_getAddresses", undefined>;
|
|
890
|
+
readonly params: v.NullishSchema<v.ObjectSchema<{
|
|
891
|
+
/**
|
|
892
|
+
* A message to be displayed to the user in the request prompt.
|
|
893
|
+
*/
|
|
894
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
895
|
+
}, undefined>, never>;
|
|
896
|
+
readonly id: v.StringSchema<undefined>;
|
|
897
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
898
|
+
}, undefined>;
|
|
899
|
+
type StxGetAddressesRequestMessage = v.InferOutput<typeof stxGetAddressesRequestMessageSchema>;
|
|
900
|
+
type StxGetAddresses = MethodParamsAndResult<v.InferOutput<typeof stxGetAddressesParamsSchema>, v.InferOutput<typeof stxGetAddressesResultSchema>>;
|
|
764
901
|
type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
765
902
|
type SignTransactionResult = Transaction;
|
|
766
903
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
767
904
|
|
|
905
|
+
declare const requestPermissionsMethodName = "wallet_requestPermissions";
|
|
906
|
+
declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
907
|
+
declare const requestPermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
908
|
+
declare const requestPermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
909
|
+
readonly method: v.LiteralSchema<"wallet_requestPermissions", undefined>;
|
|
910
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
911
|
+
readonly id: v.StringSchema<undefined>;
|
|
912
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
913
|
+
}, undefined>;
|
|
914
|
+
type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof requestPermissionsParamsSchema>, v.InferOutput<typeof requestPermissionsResultSchema>>;
|
|
915
|
+
declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
916
|
+
declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
917
|
+
declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
918
|
+
declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
919
|
+
readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
|
|
920
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
921
|
+
readonly id: v.StringSchema<undefined>;
|
|
922
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
923
|
+
}, undefined>;
|
|
924
|
+
type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
|
|
925
|
+
|
|
768
926
|
interface StxRequests {
|
|
769
927
|
stx_callContract: StxCallContract;
|
|
770
928
|
stx_deployContract: StxDeployContract;
|
|
@@ -780,6 +938,7 @@ interface BtcRequests {
|
|
|
780
938
|
getInfo: GetInfo;
|
|
781
939
|
getAddresses: GetAddresses;
|
|
782
940
|
getAccounts: GetAccounts;
|
|
941
|
+
getBalance: GetBalance;
|
|
783
942
|
signMessage: SignMessage;
|
|
784
943
|
sendTransfer: SendTransfer;
|
|
785
944
|
signPsbt: SignPsbt;
|
|
@@ -796,11 +955,19 @@ interface RunesRequests {
|
|
|
796
955
|
runes_getBalance: GetRunesBalance;
|
|
797
956
|
}
|
|
798
957
|
type RunesRequestMethod = keyof RunesRequests;
|
|
799
|
-
|
|
958
|
+
interface OrdinalsRequests {
|
|
959
|
+
ord_getInscriptions: GetInscriptions;
|
|
960
|
+
}
|
|
961
|
+
type OrdinalsRequestMethod = keyof OrdinalsRequests;
|
|
962
|
+
interface WalletMethods {
|
|
963
|
+
wallet_requestPermissions: RequestPermissions;
|
|
964
|
+
wallet_renouncePermissions: RenouncePermissions;
|
|
965
|
+
}
|
|
966
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods & OrdinalsRequests;
|
|
800
967
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
801
968
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
802
969
|
|
|
803
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
970
|
+
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>>;
|
|
804
971
|
|
|
805
972
|
declare abstract class SatsConnectAdapter {
|
|
806
973
|
abstract readonly id: string;
|
|
@@ -818,10 +985,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
818
985
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
819
986
|
id: string;
|
|
820
987
|
constructor(providerId: string);
|
|
821
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
988
|
+
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods | "ord_getInscriptions">(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
822
989
|
}
|
|
823
990
|
|
|
824
991
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
825
992
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
826
993
|
|
|
827
|
-
export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type GetAccounts, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type InputToSign, type MethodParamsAndResult, type Params, type Provider, type PsbtPayload, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcId, type RpcRequest, type RpcRequestMessage, type RpcResponse, type RpcResult, type RpcSuccessResponse, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema,
|
|
994
|
+
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,16 +1,27 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
-
var BitcoinNetworkType = /* @__PURE__ */ ((
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
3
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType3) => {
|
|
4
|
+
BitcoinNetworkType3["Mainnet"] = "Mainnet";
|
|
5
|
+
BitcoinNetworkType3["Testnet"] = "Testnet";
|
|
6
|
+
BitcoinNetworkType3["Signet"] = "Signet";
|
|
7
|
+
return BitcoinNetworkType3;
|
|
8
8
|
})(BitcoinNetworkType || {});
|
|
9
|
+
var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
|
|
9
10
|
var rpcRequestMessageSchema = v.object({
|
|
10
11
|
jsonrpc: v.literal("2.0"),
|
|
11
12
|
method: v.string(),
|
|
12
|
-
params: v.optional(
|
|
13
|
-
|
|
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
|
|
14
25
|
});
|
|
15
26
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
16
27
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
@@ -20,8 +31,23 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
20
31
|
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
21
32
|
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
22
33
|
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
34
|
+
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
23
35
|
return RpcErrorCode2;
|
|
24
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
|
+
]);
|
|
25
51
|
|
|
26
52
|
// src/runes/api.ts
|
|
27
53
|
import axios from "axios";
|
|
@@ -176,6 +202,16 @@ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
|
|
|
176
202
|
var SatsConnectAdapter = class {
|
|
177
203
|
async mintRunes(params) {
|
|
178
204
|
try {
|
|
205
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
206
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
207
|
+
const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
|
|
208
|
+
if (isMintSupported) {
|
|
209
|
+
const response = await this.requestInternal("runes_mint", params);
|
|
210
|
+
if (response) {
|
|
211
|
+
return response;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
179
215
|
const mintRequest = {
|
|
180
216
|
destinationAddress: params.destinationAddress,
|
|
181
217
|
feeRate: params.feeRate,
|
|
@@ -245,6 +281,16 @@ var SatsConnectAdapter = class {
|
|
|
245
281
|
appServiceFeeAddress: params.appServiceFeeAddress
|
|
246
282
|
};
|
|
247
283
|
try {
|
|
284
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
285
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
286
|
+
const isEtchSupported = walletInfo.result.methods?.includes("runes_etch");
|
|
287
|
+
if (isEtchSupported) {
|
|
288
|
+
const response = await this.requestInternal("runes_etch", params);
|
|
289
|
+
if (response) {
|
|
290
|
+
return response;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
248
294
|
const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
|
|
249
295
|
if (!orderResponse.data) {
|
|
250
296
|
return {
|
|
@@ -499,6 +545,9 @@ function getSupportedWallets() {
|
|
|
499
545
|
return wallets;
|
|
500
546
|
}
|
|
501
547
|
|
|
548
|
+
// src/request/index.ts
|
|
549
|
+
import * as v8 from "valibot";
|
|
550
|
+
|
|
502
551
|
// src/addresses/index.ts
|
|
503
552
|
import { createUnsecuredToken } from "jsontokens";
|
|
504
553
|
|
|
@@ -543,100 +592,237 @@ var getAddress = async (options) => {
|
|
|
543
592
|
}
|
|
544
593
|
};
|
|
545
594
|
|
|
546
|
-
// src/request/types/
|
|
595
|
+
// src/request/types/stxMethods.ts
|
|
547
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";
|
|
548
623
|
var getInfoMethodName = "getInfo";
|
|
549
|
-
var getInfoParamsSchema =
|
|
550
|
-
var getInfoResultSchema =
|
|
624
|
+
var getInfoParamsSchema = v4.nullish(v4.null());
|
|
625
|
+
var getInfoResultSchema = v4.object({
|
|
551
626
|
/**
|
|
552
627
|
* Version of the wallet.
|
|
553
628
|
*/
|
|
554
|
-
version:
|
|
629
|
+
version: v4.string(),
|
|
555
630
|
/**
|
|
556
631
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
557
632
|
*/
|
|
558
|
-
methods:
|
|
633
|
+
methods: v4.optional(v4.array(v4.string())),
|
|
559
634
|
/**
|
|
560
635
|
* List of WBIP standards supported by the wallet. Not currently used.
|
|
561
636
|
*/
|
|
562
|
-
supports:
|
|
637
|
+
supports: v4.array(v4.string())
|
|
563
638
|
});
|
|
564
|
-
var
|
|
639
|
+
var getInfoRequestMessageSchema = v4.object({
|
|
565
640
|
...rpcRequestMessageSchema.entries,
|
|
566
|
-
...
|
|
567
|
-
method:
|
|
641
|
+
...v4.object({
|
|
642
|
+
method: v4.literal(getInfoMethodName),
|
|
568
643
|
params: getInfoParamsSchema,
|
|
569
|
-
id:
|
|
644
|
+
id: v4.string()
|
|
570
645
|
}).entries
|
|
571
646
|
});
|
|
572
647
|
var getAddressesMethodName = "getAddresses";
|
|
573
|
-
var getAddressesParamsSchema =
|
|
648
|
+
var getAddressesParamsSchema = v4.object({
|
|
574
649
|
/**
|
|
575
650
|
* The purposes for which to generate addresses. See
|
|
576
651
|
* {@linkcode AddressPurpose} for available purposes.
|
|
577
652
|
*/
|
|
578
|
-
purposes:
|
|
653
|
+
purposes: v4.array(v4.enum(AddressPurpose)),
|
|
579
654
|
/**
|
|
580
655
|
* A message to be displayed to the user in the request prompt.
|
|
581
656
|
*/
|
|
582
|
-
message:
|
|
657
|
+
message: v4.optional(v4.string())
|
|
583
658
|
});
|
|
584
|
-
var getAddressesResultSchema =
|
|
659
|
+
var getAddressesResultSchema = v4.object({
|
|
585
660
|
/**
|
|
586
661
|
* The addresses generated for the given purposes.
|
|
587
662
|
*/
|
|
588
|
-
addresses:
|
|
663
|
+
addresses: v4.array(addressSchema)
|
|
589
664
|
});
|
|
590
|
-
var getAddressesRequestMessageSchema =
|
|
665
|
+
var getAddressesRequestMessageSchema = v4.object({
|
|
591
666
|
...rpcRequestMessageSchema.entries,
|
|
592
|
-
...
|
|
593
|
-
method:
|
|
667
|
+
...v4.object({
|
|
668
|
+
method: v4.literal(getAddressesMethodName),
|
|
594
669
|
params: getAddressesParamsSchema,
|
|
595
|
-
id:
|
|
670
|
+
id: v4.string()
|
|
596
671
|
}).entries
|
|
597
672
|
});
|
|
598
673
|
var signMessageMethodName = "signMessage";
|
|
599
|
-
var signMessageParamsSchema =
|
|
674
|
+
var signMessageParamsSchema = v4.object({
|
|
600
675
|
/**
|
|
601
676
|
* The address used for signing.
|
|
602
677
|
**/
|
|
603
|
-
address:
|
|
678
|
+
address: v4.string(),
|
|
604
679
|
/**
|
|
605
680
|
* The message to sign.
|
|
606
681
|
**/
|
|
607
|
-
message:
|
|
682
|
+
message: v4.string()
|
|
608
683
|
});
|
|
609
|
-
var signMessageResultSchema =
|
|
684
|
+
var signMessageResultSchema = v4.object({
|
|
610
685
|
/**
|
|
611
686
|
* The signature of the message.
|
|
612
687
|
*/
|
|
613
|
-
signature:
|
|
688
|
+
signature: v4.string(),
|
|
614
689
|
/**
|
|
615
690
|
* hash of the message.
|
|
616
691
|
*/
|
|
617
|
-
messageHash:
|
|
692
|
+
messageHash: v4.string(),
|
|
618
693
|
/**
|
|
619
694
|
* The address used for signing.
|
|
620
695
|
*/
|
|
621
|
-
address:
|
|
696
|
+
address: v4.string()
|
|
622
697
|
});
|
|
623
|
-
var signMessageRequestMessageSchema =
|
|
698
|
+
var signMessageRequestMessageSchema = v4.object({
|
|
624
699
|
...rpcRequestMessageSchema.entries,
|
|
625
|
-
...
|
|
626
|
-
method:
|
|
700
|
+
...v4.object({
|
|
701
|
+
method: v4.literal(signMessageMethodName),
|
|
627
702
|
params: signMessageParamsSchema,
|
|
628
|
-
id:
|
|
703
|
+
id: v4.string()
|
|
629
704
|
}).entries
|
|
630
705
|
});
|
|
631
706
|
var getAccountsMethodName = "getAccounts";
|
|
632
707
|
var getAccountsParamsSchema = getAddressesParamsSchema;
|
|
633
|
-
var getAccountsResultSchema =
|
|
634
|
-
var getAccountsRequestMessageSchema =
|
|
708
|
+
var getAccountsResultSchema = v4.array(addressSchema);
|
|
709
|
+
var getAccountsRequestMessageSchema = v4.object({
|
|
635
710
|
...rpcRequestMessageSchema.entries,
|
|
636
|
-
...
|
|
637
|
-
method:
|
|
711
|
+
...v4.object({
|
|
712
|
+
method: v4.literal(getAccountsMethodName),
|
|
638
713
|
params: getAccountsParamsSchema,
|
|
639
|
-
id:
|
|
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
|
+
inscriptions: v7.array(
|
|
805
|
+
v7.object({
|
|
806
|
+
inscriptionId: v7.string(),
|
|
807
|
+
inscriptionNumber: v7.string(),
|
|
808
|
+
address: v7.string(),
|
|
809
|
+
collectionName: v7.optional(v7.string()),
|
|
810
|
+
postage: v7.string(),
|
|
811
|
+
contentLength: v7.string(),
|
|
812
|
+
contentType: v7.string(),
|
|
813
|
+
timestamp: v7.number(),
|
|
814
|
+
offset: v7.number(),
|
|
815
|
+
genesisTransaction: v7.string(),
|
|
816
|
+
output: v7.string()
|
|
817
|
+
})
|
|
818
|
+
)
|
|
819
|
+
});
|
|
820
|
+
var getInscriptionsSchema = v7.object({
|
|
821
|
+
...rpcRequestMessageSchema.entries,
|
|
822
|
+
...v7.object({
|
|
823
|
+
method: v7.literal(getInscriptionsMethodName),
|
|
824
|
+
params: getInscriptionsParamsSchema,
|
|
825
|
+
id: v7.string()
|
|
640
826
|
}).entries
|
|
641
827
|
});
|
|
642
828
|
|
|
@@ -653,7 +839,13 @@ var request = async (method, params, providerId) => {
|
|
|
653
839
|
throw new Error("A wallet method is required");
|
|
654
840
|
}
|
|
655
841
|
const response = await provider.request(method, params);
|
|
656
|
-
if (
|
|
842
|
+
if (v8.is(rpcErrorResponseMessageSchema, response)) {
|
|
843
|
+
return {
|
|
844
|
+
status: "error",
|
|
845
|
+
error: response.error
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
if (v8.is(rpcSuccessResponseMessageSchema, response)) {
|
|
657
849
|
return {
|
|
658
850
|
status: "success",
|
|
659
851
|
result: response.result
|
|
@@ -661,12 +853,13 @@ var request = async (method, params, providerId) => {
|
|
|
661
853
|
}
|
|
662
854
|
return {
|
|
663
855
|
status: "error",
|
|
664
|
-
error:
|
|
856
|
+
error: {
|
|
857
|
+
code: -32603 /* INTERNAL_ERROR */,
|
|
858
|
+
message: "Received unknown response from provider.",
|
|
859
|
+
data: response
|
|
860
|
+
}
|
|
665
861
|
};
|
|
666
862
|
};
|
|
667
|
-
var isRpcSuccessResponse = (response) => {
|
|
668
|
-
return Object.hasOwn(response, "result") && !!response.result;
|
|
669
|
-
};
|
|
670
863
|
|
|
671
864
|
// src/adapters/xverse.ts
|
|
672
865
|
var XverseAdapter = class extends SatsConnectAdapter {
|
|
@@ -1082,6 +1275,7 @@ export {
|
|
|
1082
1275
|
BitcoinNetworkType,
|
|
1083
1276
|
DefaultAdaptersInfo,
|
|
1084
1277
|
RpcErrorCode,
|
|
1278
|
+
RpcIdSchema,
|
|
1085
1279
|
SatsConnectAdapter,
|
|
1086
1280
|
addressSchema,
|
|
1087
1281
|
createInscription,
|
|
@@ -1096,20 +1290,43 @@ export {
|
|
|
1096
1290
|
getAddressesParamsSchema,
|
|
1097
1291
|
getAddressesRequestMessageSchema,
|
|
1098
1292
|
getAddressesResultSchema,
|
|
1293
|
+
getBalanceMethodName,
|
|
1294
|
+
getBalanceParamsSchema,
|
|
1295
|
+
getBalanceRequestMessageSchema,
|
|
1296
|
+
getBalanceResultSchema,
|
|
1099
1297
|
getCapabilities,
|
|
1100
1298
|
getDefaultProvider,
|
|
1101
1299
|
getInfoMethodName,
|
|
1102
1300
|
getInfoParamsSchema,
|
|
1301
|
+
getInfoRequestMessageSchema,
|
|
1103
1302
|
getInfoResultSchema,
|
|
1104
|
-
|
|
1303
|
+
getInscriptionsMethodName,
|
|
1304
|
+
getInscriptionsParamsSchema,
|
|
1305
|
+
getInscriptionsResultSchema,
|
|
1306
|
+
getInscriptionsSchema,
|
|
1105
1307
|
getProviderById,
|
|
1106
1308
|
getProviderOrThrow,
|
|
1107
1309
|
getProviders,
|
|
1310
|
+
getRunesBalanceMethodName,
|
|
1311
|
+
getRunesBalanceParamsSchema,
|
|
1312
|
+
getRunesBalanceRequestMessageSchema,
|
|
1313
|
+
getRunesBalanceResultSchema,
|
|
1108
1314
|
getSupportedWallets,
|
|
1109
1315
|
isProviderInstalled,
|
|
1110
1316
|
removeDefaultProvider,
|
|
1317
|
+
renouncePermissionsMethodName,
|
|
1318
|
+
renouncePermissionsParamsSchema,
|
|
1319
|
+
renouncePermissionsRequestMessageSchema,
|
|
1320
|
+
renouncePermissionsResultSchema,
|
|
1111
1321
|
request,
|
|
1322
|
+
requestPermissionsMethodName,
|
|
1323
|
+
requestPermissionsParamsSchema,
|
|
1324
|
+
requestPermissionsRequestMessageSchema,
|
|
1325
|
+
requestPermissionsResultSchema,
|
|
1326
|
+
rpcErrorResponseMessageSchema,
|
|
1112
1327
|
rpcRequestMessageSchema,
|
|
1328
|
+
rpcResponseMessageSchema,
|
|
1329
|
+
rpcSuccessResponseMessageSchema,
|
|
1113
1330
|
sendBtcTransaction,
|
|
1114
1331
|
setDefaultProvider,
|
|
1115
1332
|
signMessage,
|
|
@@ -1118,5 +1335,9 @@ export {
|
|
|
1118
1335
|
signMessageRequestMessageSchema,
|
|
1119
1336
|
signMessageResultSchema,
|
|
1120
1337
|
signMultipleTransactions,
|
|
1121
|
-
signTransaction
|
|
1338
|
+
signTransaction,
|
|
1339
|
+
stxGetAddressesMethodName,
|
|
1340
|
+
stxGetAddressesParamsSchema,
|
|
1341
|
+
stxGetAddressesRequestMessageSchema,
|
|
1342
|
+
stxGetAddressesResultSchema
|
|
1122
1343
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12-635f56e",
|
|
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"
|