@sats-connect/core 0.0.11-c7e675e → 0.0.11-da5cf6b
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 +79 -283
- package/dist/index.mjs +63 -341
- package/package.json +2 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
|
-
|
|
3
1
|
interface GetCapabilitiesPayload extends RequestPayload {
|
|
4
2
|
}
|
|
5
3
|
type GetCapabilitiesResponse = Capability[];
|
|
@@ -116,7 +114,7 @@ interface Provider {
|
|
|
116
114
|
mozillaAddOnsUrl?: string;
|
|
117
115
|
googlePlayStoreUrl?: string;
|
|
118
116
|
iOSAppStoreUrl?: string;
|
|
119
|
-
methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod
|
|
117
|
+
methods?: (StxRequestMethod | BtcRequestMethod | RunesRequestMethod)[];
|
|
120
118
|
}
|
|
121
119
|
interface SupportedWallet extends Provider {
|
|
122
120
|
isInstalled: boolean;
|
|
@@ -159,15 +157,7 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
159
157
|
payload: Payload;
|
|
160
158
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
161
159
|
}
|
|
162
|
-
|
|
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>;
|
|
160
|
+
type RpcId = string | null;
|
|
171
161
|
interface RpcBase {
|
|
172
162
|
jsonrpc: '2.0';
|
|
173
163
|
id: RpcId;
|
|
@@ -214,34 +204,8 @@ declare enum RpcErrorCode {
|
|
|
214
204
|
/**
|
|
215
205
|
* method is not supported for the address provided
|
|
216
206
|
*/
|
|
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>;
|
|
207
|
+
METHOD_NOT_SUPPORTED = -32001
|
|
208
|
+
}
|
|
245
209
|
interface RpcError {
|
|
246
210
|
code: number | RpcErrorCode;
|
|
247
211
|
message: string;
|
|
@@ -279,13 +243,12 @@ declare enum AddressType {
|
|
|
279
243
|
p2tr = "p2tr",
|
|
280
244
|
stacks = "stacks"
|
|
281
245
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
type Address$1 = v.InferOutput<typeof addressSchema>;
|
|
246
|
+
interface Address$1 {
|
|
247
|
+
address: string;
|
|
248
|
+
publicKey: string;
|
|
249
|
+
purpose?: AddressPurpose;
|
|
250
|
+
addressType?: AddressType;
|
|
251
|
+
}
|
|
289
252
|
interface GetAddressResponse {
|
|
290
253
|
addresses: Address$1[];
|
|
291
254
|
}
|
|
@@ -293,110 +256,59 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
|
293
256
|
|
|
294
257
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
295
258
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
/**
|
|
308
|
-
*
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
326
|
-
/**
|
|
327
|
-
* A message to be displayed to the user in the request prompt.
|
|
328
|
-
*/
|
|
329
|
-
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
330
|
-
}, undefined>;
|
|
331
|
-
declare const getAddressesResultSchema: v.ObjectSchema<{
|
|
332
|
-
/**
|
|
333
|
-
* The addresses generated for the given purposes.
|
|
334
|
-
*/
|
|
335
|
-
readonly addresses: v.ArraySchema<v.ObjectSchema<{
|
|
336
|
-
readonly address: v.StringSchema<undefined>;
|
|
337
|
-
readonly publicKey: v.StringSchema<undefined>;
|
|
338
|
-
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
339
|
-
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
340
|
-
}, undefined>, undefined>;
|
|
341
|
-
}, undefined>;
|
|
342
|
-
declare const getAddressesRequestMessageSchema: v.ObjectSchema<{
|
|
343
|
-
readonly method: v.LiteralSchema<"getAddresses", undefined>;
|
|
344
|
-
readonly params: v.ObjectSchema<{
|
|
345
|
-
/**
|
|
346
|
-
* The purposes for which to generate addresses. See
|
|
347
|
-
* {@linkcode AddressPurpose} for available purposes.
|
|
348
|
-
*/
|
|
349
|
-
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
350
|
-
/**
|
|
351
|
-
* A message to be displayed to the user in the request prompt.
|
|
352
|
-
*/
|
|
353
|
-
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
354
|
-
}, undefined>;
|
|
355
|
-
readonly id: v.StringSchema<undefined>;
|
|
356
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
357
|
-
}, undefined>;
|
|
358
|
-
type GetAddresses = MethodParamsAndResult<v.InferOutput<typeof getAddressesParamsSchema>, v.InferOutput<typeof getAddressesResultSchema>>;
|
|
359
|
-
declare const signMessageMethodName = "signMessage";
|
|
360
|
-
declare const signMessageParamsSchema: v.ObjectSchema<{
|
|
259
|
+
/**
|
|
260
|
+
* Represents the types and interfaces related to BTC methods.
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
type GetInfoResult = {
|
|
264
|
+
version: number | string;
|
|
265
|
+
methods?: Array<string>;
|
|
266
|
+
supports?: Array<string>;
|
|
267
|
+
};
|
|
268
|
+
type GetInfo = MethodParamsAndResult<null, GetInfoResult>;
|
|
269
|
+
type GetAddressesParams$1 = {
|
|
270
|
+
/**
|
|
271
|
+
* The purposes for which to generate addresses.
|
|
272
|
+
* possible values are "payment", "ordinals", ...
|
|
273
|
+
*/
|
|
274
|
+
purposes: Array<AddressPurpose>;
|
|
275
|
+
/**
|
|
276
|
+
* a message to be displayed to the user in the request prompt.
|
|
277
|
+
*/
|
|
278
|
+
message?: string;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* The addresses generated for the given purposes.
|
|
282
|
+
*/
|
|
283
|
+
type GetAddressesResult$1 = {
|
|
284
|
+
addresses: Array<Address$1>;
|
|
285
|
+
};
|
|
286
|
+
type GetAddresses = MethodParamsAndResult<GetAddressesParams$1, GetAddressesResult$1>;
|
|
287
|
+
type SignMessageParams = {
|
|
361
288
|
/**
|
|
362
289
|
* The address used for signing.
|
|
363
290
|
**/
|
|
364
|
-
|
|
291
|
+
address: string;
|
|
365
292
|
/**
|
|
366
293
|
* The message to sign.
|
|
367
294
|
**/
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
|
|
295
|
+
message: string;
|
|
296
|
+
};
|
|
297
|
+
type SignMessageResult = {
|
|
371
298
|
/**
|
|
372
299
|
* The signature of the message.
|
|
373
300
|
*/
|
|
374
|
-
|
|
301
|
+
signature: string;
|
|
375
302
|
/**
|
|
376
303
|
* hash of the message.
|
|
377
304
|
*/
|
|
378
|
-
|
|
305
|
+
messageHash: string;
|
|
379
306
|
/**
|
|
380
307
|
* The address used for signing.
|
|
381
308
|
*/
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
readonly method: v.LiteralSchema<"signMessage", undefined>;
|
|
386
|
-
readonly params: v.ObjectSchema<{
|
|
387
|
-
/**
|
|
388
|
-
* The address used for signing.
|
|
389
|
-
**/
|
|
390
|
-
readonly address: v.StringSchema<undefined>;
|
|
391
|
-
/**
|
|
392
|
-
* The message to sign.
|
|
393
|
-
**/
|
|
394
|
-
readonly message: v.StringSchema<undefined>;
|
|
395
|
-
}, undefined>;
|
|
396
|
-
readonly id: v.StringSchema<undefined>;
|
|
397
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
398
|
-
}, undefined>;
|
|
399
|
-
type SignMessage = MethodParamsAndResult<v.InferOutput<typeof signMessageParamsSchema>, v.InferOutput<typeof signMessageResultSchema>>;
|
|
309
|
+
address: string;
|
|
310
|
+
};
|
|
311
|
+
type SignMessage = MethodParamsAndResult<SignMessageParams, SignMessageResult>;
|
|
400
312
|
type Recipient$1 = {
|
|
401
313
|
/**
|
|
402
314
|
* The recipient's address.
|
|
@@ -453,101 +365,22 @@ type SignPsbtResult = {
|
|
|
453
365
|
txid?: string;
|
|
454
366
|
};
|
|
455
367
|
type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
*
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
473
|
-
}, undefined>, undefined>;
|
|
474
|
-
declare const getAccountsRequestMessageSchema: v.ObjectSchema<{
|
|
475
|
-
readonly method: v.LiteralSchema<"getAccounts", undefined>;
|
|
476
|
-
readonly params: v.ObjectSchema<{
|
|
477
|
-
/**
|
|
478
|
-
* The purposes for which to generate addresses. See
|
|
479
|
-
* {@linkcode AddressPurpose} for available purposes.
|
|
480
|
-
*/
|
|
481
|
-
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
482
|
-
/**
|
|
483
|
-
* A message to be displayed to the user in the request prompt.
|
|
484
|
-
*/
|
|
485
|
-
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
486
|
-
}, undefined>;
|
|
487
|
-
readonly id: v.StringSchema<undefined>;
|
|
488
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
489
|
-
}, undefined>;
|
|
490
|
-
type GetAccounts = MethodParamsAndResult<v.InferOutput<typeof getAccountsParamsSchema>, v.InferOutput<typeof getAccountsResultSchema>>;
|
|
491
|
-
declare const getBalanceMethodName = "getBalance";
|
|
492
|
-
declare const getBalanceParamsSchema: v.UndefinedSchema<undefined>;
|
|
493
|
-
declare const getBalanceResultSchema: v.ObjectSchema<{
|
|
494
|
-
/**
|
|
495
|
-
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
496
|
-
* messages not supporting bigint
|
|
497
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
498
|
-
*/
|
|
499
|
-
readonly confirmed: v.StringSchema<undefined>;
|
|
500
|
-
/**
|
|
501
|
-
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
502
|
-
* messages not supporting bigint
|
|
503
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
504
|
-
*/
|
|
505
|
-
readonly unconfirmed: v.StringSchema<undefined>;
|
|
506
|
-
/**
|
|
507
|
-
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
508
|
-
* sats. Using a string due to chrome messages not supporting bigint
|
|
509
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
510
|
-
*/
|
|
511
|
-
readonly total: v.StringSchema<undefined>;
|
|
512
|
-
}, undefined>;
|
|
513
|
-
declare const getBalanceRequestMessageSchema: v.ObjectSchema<{
|
|
514
|
-
readonly method: v.LiteralSchema<"getBalance", undefined>;
|
|
515
|
-
readonly id: v.StringSchema<undefined>;
|
|
516
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
517
|
-
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
518
|
-
}, undefined>;
|
|
519
|
-
type GetBalance = MethodParamsAndResult<v.InferOutput<typeof getBalanceParamsSchema>, v.InferOutput<typeof getBalanceResultSchema>>;
|
|
520
|
-
|
|
521
|
-
declare const getInscriptionsMethodName = "ord_getInscriptions";
|
|
522
|
-
declare const getInscriptionsParamsSchema: v.ObjectSchema<{
|
|
523
|
-
readonly offset: v.NumberSchema<undefined>;
|
|
524
|
-
readonly limit: v.NumberSchema<undefined>;
|
|
525
|
-
}, undefined>;
|
|
526
|
-
declare const getInscriptionsResultSchema: v.ObjectSchema<{
|
|
527
|
-
readonly inscriptions: v.ArraySchema<v.ObjectSchema<{
|
|
528
|
-
readonly inscriptionId: v.StringSchema<undefined>;
|
|
529
|
-
readonly inscriptionNumber: v.StringSchema<undefined>;
|
|
530
|
-
readonly address: v.StringSchema<undefined>;
|
|
531
|
-
readonly collectionName: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
532
|
-
readonly postage: v.StringSchema<undefined>;
|
|
533
|
-
readonly contentLength: v.StringSchema<undefined>;
|
|
534
|
-
readonly contentType: v.StringSchema<undefined>;
|
|
535
|
-
readonly timestamp: v.NumberSchema<undefined>;
|
|
536
|
-
readonly offset: v.NumberSchema<undefined>;
|
|
537
|
-
readonly genesisTransaction: v.StringSchema<undefined>;
|
|
538
|
-
readonly output: v.StringSchema<undefined>;
|
|
539
|
-
}, undefined>, undefined>;
|
|
540
|
-
}, undefined>;
|
|
541
|
-
declare const getInscriptionsSchema: v.ObjectSchema<{
|
|
542
|
-
readonly method: v.LiteralSchema<"ord_getInscriptions", undefined>;
|
|
543
|
-
readonly params: v.ObjectSchema<{
|
|
544
|
-
readonly offset: v.NumberSchema<undefined>;
|
|
545
|
-
readonly limit: v.NumberSchema<undefined>;
|
|
546
|
-
}, undefined>;
|
|
547
|
-
readonly id: v.StringSchema<undefined>;
|
|
548
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
549
|
-
}, undefined>;
|
|
550
|
-
type GetInscriptions = MethodParamsAndResult<v.InferOutput<typeof getInscriptionsParamsSchema>, v.InferOutput<typeof getInscriptionsResultSchema>>;
|
|
368
|
+
type GetAccountsParams = {
|
|
369
|
+
/**
|
|
370
|
+
* The purposes for which to generate addresses.
|
|
371
|
+
* possible values are "payment", "ordinals", ...
|
|
372
|
+
*/
|
|
373
|
+
purposes: Array<AddressPurpose>;
|
|
374
|
+
/**
|
|
375
|
+
* a message to be displayed to the user in the request prompt.
|
|
376
|
+
*/
|
|
377
|
+
/**
|
|
378
|
+
* a message to be displayed to the user in the request prompt.
|
|
379
|
+
*/
|
|
380
|
+
message?: string;
|
|
381
|
+
};
|
|
382
|
+
type GetAccountResult = Address$1[];
|
|
383
|
+
type GetAccounts = MethodParamsAndResult<GetAccountsParams, GetAccountResult>;
|
|
551
384
|
|
|
552
385
|
type CreateMintOrderRequest = {
|
|
553
386
|
runeName: string;
|
|
@@ -660,24 +493,17 @@ interface RbfOrderResult {
|
|
|
660
493
|
fundingAddress: string;
|
|
661
494
|
}
|
|
662
495
|
type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
declare const getRunesBalanceRequestMessageSchema: v.ObjectSchema<{
|
|
675
|
-
readonly method: v.LiteralSchema<"runes_getBalance", undefined>;
|
|
676
|
-
readonly params: v.NullSchema<undefined>;
|
|
677
|
-
readonly id: v.StringSchema<undefined>;
|
|
678
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
679
|
-
}, undefined>;
|
|
680
|
-
type GetRunesBalance = MethodParamsAndResult<v.InferOutput<typeof getRunesBalanceParamsSchema>, v.InferOutput<typeof getRunesBalanceResultSchema>>;
|
|
496
|
+
type GetRunesBalanceParams = null;
|
|
497
|
+
interface GetRunesBalanceResult {
|
|
498
|
+
balances: {
|
|
499
|
+
runeName: string;
|
|
500
|
+
amount: string;
|
|
501
|
+
divisibility: number;
|
|
502
|
+
symbol: string;
|
|
503
|
+
inscriptionId: string | null;
|
|
504
|
+
}[];
|
|
505
|
+
}
|
|
506
|
+
type GetRunesBalance = MethodParamsAndResult<GetRunesBalanceParams, GetRunesBalanceResult>;
|
|
681
507
|
|
|
682
508
|
interface Pubkey {
|
|
683
509
|
/**
|
|
@@ -859,27 +685,6 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
859
685
|
type SignTransactionResult = Transaction;
|
|
860
686
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
861
687
|
|
|
862
|
-
declare const requestPermissionsMethodName = "wallet_requestPermissions";
|
|
863
|
-
declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
864
|
-
declare const requestPermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
865
|
-
declare const requestPermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
866
|
-
readonly method: v.LiteralSchema<"wallet_requestPermissions", undefined>;
|
|
867
|
-
readonly params: v.UndefinedSchema<undefined>;
|
|
868
|
-
readonly id: v.StringSchema<undefined>;
|
|
869
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
870
|
-
}, undefined>;
|
|
871
|
-
type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof requestPermissionsParamsSchema>, v.InferOutput<typeof requestPermissionsResultSchema>>;
|
|
872
|
-
declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
873
|
-
declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
874
|
-
declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
875
|
-
declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
876
|
-
readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
|
|
877
|
-
readonly params: v.UndefinedSchema<undefined>;
|
|
878
|
-
readonly id: v.StringSchema<undefined>;
|
|
879
|
-
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
880
|
-
}, undefined>;
|
|
881
|
-
type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
|
|
882
|
-
|
|
883
688
|
interface StxRequests {
|
|
884
689
|
stx_callContract: StxCallContract;
|
|
885
690
|
stx_deployContract: StxDeployContract;
|
|
@@ -895,7 +700,6 @@ interface BtcRequests {
|
|
|
895
700
|
getInfo: GetInfo;
|
|
896
701
|
getAddresses: GetAddresses;
|
|
897
702
|
getAccounts: GetAccounts;
|
|
898
|
-
getBalance: GetBalance;
|
|
899
703
|
signMessage: SignMessage;
|
|
900
704
|
sendTransfer: SendTransfer;
|
|
901
705
|
signPsbt: SignPsbt;
|
|
@@ -912,19 +716,11 @@ interface RunesRequests {
|
|
|
912
716
|
runes_getBalance: GetRunesBalance;
|
|
913
717
|
}
|
|
914
718
|
type RunesRequestMethod = keyof RunesRequests;
|
|
915
|
-
|
|
916
|
-
ord_getInscriptions: GetInscriptions;
|
|
917
|
-
}
|
|
918
|
-
type OrdinalsRequestMethod = keyof OrdinalsRequests;
|
|
919
|
-
interface WalletMethods {
|
|
920
|
-
wallet_requestPermissions: RequestPermissions;
|
|
921
|
-
wallet_renouncePermissions: RenouncePermissions;
|
|
922
|
-
}
|
|
923
|
-
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods & OrdinalsRequests;
|
|
719
|
+
type Requests = BtcRequests & StxRequests & RunesRequests;
|
|
924
720
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
925
721
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
926
722
|
|
|
927
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests
|
|
723
|
+
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
928
724
|
|
|
929
725
|
declare abstract class SatsConnectAdapter {
|
|
930
726
|
abstract readonly id: string;
|
|
@@ -942,10 +738,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
942
738
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
943
739
|
id: string;
|
|
944
740
|
constructor(providerId: string);
|
|
945
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests
|
|
741
|
+
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
946
742
|
}
|
|
947
743
|
|
|
948
744
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
949
745
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
950
746
|
|
|
951
|
-
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
|
|
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 GetAccountResult, type GetAccounts, type GetAccountsParams, type GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type InputToSign, type MethodParamsAndResult, type Params, type Provider, type PsbtPayload, type Recipient$2 as Recipient, type RequestOptions, type RequestPayload, type Requests, type Return, type RpcBase, type RpcError, RpcErrorCode, type RpcErrorResponse, type RpcId, type RpcRequest, type RpcResponse, type RpcResult, type RpcSuccessResponse, type RunesRequestMethod, type RunesRequests, SatsConnectAdapter, type SendBtcTransactionOptions, type SendBtcTransactionPayload, type SendBtcTransactionResponse, type SendTransfer, type SendTransferParams, type SerializedRecipient, type SerializedSendBtcTransactionPayload, type SignMessage, type SignMessageOptions, type SignMessageParams, type SignMessagePayload, type SignMessageResponse, type SignMultiplePsbtPayload, type SignMultipleTransactionOptions, type SignMultipleTransactionsPayload, type SignMultipleTransactionsResponse, type SignPsbt, type SignPsbtParams, type SignPsbtResult, type SignStructuredMessageResult, type SignStxMessageParams, type SignStxMessageResult, type SignTransactionOptions, type SignTransactionParams, type SignTransactionPayload, type SignTransactionResponse, type SignTransactionResult, type StxCallContract, type StxDeployContract, type StxGetAccounts, type StxGetAddresses, type StxRequestMethod, type StxRequests, type StxSignStructuredMessage, type StxSignStxMessage, type StxSignTransaction, type StxTransferStx, type SupportedWallet, type TransferStxParams, type TransferStxResult, createInscription, createRepeatInscriptions, defaultAdapters, getAddress, getCapabilities, getDefaultProvider, getProviderById, getProviderOrThrow, getProviders, getSupportedWallets, isProviderInstalled, removeDefaultProvider, request, sendBtcTransaction, setDefaultProvider, signMessage, signMultipleTransactions, signTransaction };
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return BitcoinNetworkType3;
|
|
2
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
3
|
+
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
4
|
+
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
5
|
+
BitcoinNetworkType2["Signet"] = "Signet";
|
|
6
|
+
return BitcoinNetworkType2;
|
|
8
7
|
})(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
|
-
});
|
|
26
8
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
27
9
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
28
10
|
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
@@ -31,23 +13,8 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
31
13
|
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
32
14
|
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
33
15
|
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
34
|
-
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
35
16
|
return RpcErrorCode2;
|
|
36
17
|
})(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
|
-
]);
|
|
51
18
|
|
|
52
19
|
// src/runes/api.ts
|
|
53
20
|
import axios from "axios";
|
|
@@ -202,6 +169,16 @@ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
|
|
|
202
169
|
var SatsConnectAdapter = class {
|
|
203
170
|
async mintRunes(params) {
|
|
204
171
|
try {
|
|
172
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
173
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
174
|
+
const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
|
|
175
|
+
if (isMintSupported) {
|
|
176
|
+
const response = await this.requestInternal("runes_mint", params);
|
|
177
|
+
if (response) {
|
|
178
|
+
return response;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
205
182
|
const mintRequest = {
|
|
206
183
|
destinationAddress: params.destinationAddress,
|
|
207
184
|
feeRate: params.feeRate,
|
|
@@ -271,6 +248,16 @@ var SatsConnectAdapter = class {
|
|
|
271
248
|
appServiceFeeAddress: params.appServiceFeeAddress
|
|
272
249
|
};
|
|
273
250
|
try {
|
|
251
|
+
const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
|
|
252
|
+
if (walletInfo && walletInfo.status === "success") {
|
|
253
|
+
const isEtchSupported = walletInfo.result.methods?.includes("runes_etch");
|
|
254
|
+
if (isEtchSupported) {
|
|
255
|
+
const response = await this.requestInternal("runes_etch", params);
|
|
256
|
+
if (response) {
|
|
257
|
+
return response;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
274
261
|
const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
|
|
275
262
|
if (!orderResponse.data) {
|
|
276
263
|
return {
|
|
@@ -526,13 +513,49 @@ function getSupportedWallets() {
|
|
|
526
513
|
}
|
|
527
514
|
|
|
528
515
|
// src/request/index.ts
|
|
529
|
-
|
|
516
|
+
var request = async (method, params, providerId) => {
|
|
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";
|
|
530
554
|
|
|
531
555
|
// src/addresses/index.ts
|
|
532
556
|
import { createUnsecuredToken } from "jsontokens";
|
|
533
557
|
|
|
534
558
|
// src/addresses/types.ts
|
|
535
|
-
import * as v2 from "valibot";
|
|
536
559
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
537
560
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
538
561
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -548,12 +571,6 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
548
571
|
AddressType3["stacks"] = "stacks";
|
|
549
572
|
return AddressType3;
|
|
550
573
|
})(AddressType || {});
|
|
551
|
-
var addressSchema = v2.object({
|
|
552
|
-
address: v2.string(),
|
|
553
|
-
publicKey: v2.string(),
|
|
554
|
-
purpose: v2.enum(AddressPurpose),
|
|
555
|
-
addressType: v2.enum(AddressType)
|
|
556
|
-
});
|
|
557
574
|
|
|
558
575
|
// src/addresses/index.ts
|
|
559
576
|
var getAddress = async (options) => {
|
|
@@ -572,260 +589,7 @@ var getAddress = async (options) => {
|
|
|
572
589
|
}
|
|
573
590
|
};
|
|
574
591
|
|
|
575
|
-
// src/request/types/btcMethods.ts
|
|
576
|
-
import * as v3 from "valibot";
|
|
577
|
-
var getInfoMethodName = "getInfo";
|
|
578
|
-
var getInfoParamsSchema = v3.null();
|
|
579
|
-
var getInfoResultSchema = v3.object({
|
|
580
|
-
/**
|
|
581
|
-
* Version of the wallet.
|
|
582
|
-
*/
|
|
583
|
-
version: v3.string(),
|
|
584
|
-
/**
|
|
585
|
-
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
586
|
-
*/
|
|
587
|
-
methods: v3.optional(v3.array(v3.string())),
|
|
588
|
-
/**
|
|
589
|
-
* List of WBIP standards supported by the wallet. Not currently used.
|
|
590
|
-
*/
|
|
591
|
-
supports: v3.array(v3.string())
|
|
592
|
-
});
|
|
593
|
-
var getInfoSchema = v3.object({
|
|
594
|
-
...rpcRequestMessageSchema.entries,
|
|
595
|
-
...v3.object({
|
|
596
|
-
method: v3.literal(getInfoMethodName),
|
|
597
|
-
params: getInfoParamsSchema,
|
|
598
|
-
id: v3.string()
|
|
599
|
-
}).entries
|
|
600
|
-
});
|
|
601
|
-
var getAddressesMethodName = "getAddresses";
|
|
602
|
-
var getAddressesParamsSchema = v3.object({
|
|
603
|
-
/**
|
|
604
|
-
* The purposes for which to generate addresses. See
|
|
605
|
-
* {@linkcode AddressPurpose} for available purposes.
|
|
606
|
-
*/
|
|
607
|
-
purposes: v3.array(v3.enum(AddressPurpose)),
|
|
608
|
-
/**
|
|
609
|
-
* A message to be displayed to the user in the request prompt.
|
|
610
|
-
*/
|
|
611
|
-
message: v3.optional(v3.string())
|
|
612
|
-
});
|
|
613
|
-
var getAddressesResultSchema = v3.object({
|
|
614
|
-
/**
|
|
615
|
-
* The addresses generated for the given purposes.
|
|
616
|
-
*/
|
|
617
|
-
addresses: v3.array(addressSchema)
|
|
618
|
-
});
|
|
619
|
-
var getAddressesRequestMessageSchema = v3.object({
|
|
620
|
-
...rpcRequestMessageSchema.entries,
|
|
621
|
-
...v3.object({
|
|
622
|
-
method: v3.literal(getAddressesMethodName),
|
|
623
|
-
params: getAddressesParamsSchema,
|
|
624
|
-
id: v3.string()
|
|
625
|
-
}).entries
|
|
626
|
-
});
|
|
627
|
-
var signMessageMethodName = "signMessage";
|
|
628
|
-
var signMessageParamsSchema = v3.object({
|
|
629
|
-
/**
|
|
630
|
-
* The address used for signing.
|
|
631
|
-
**/
|
|
632
|
-
address: v3.string(),
|
|
633
|
-
/**
|
|
634
|
-
* The message to sign.
|
|
635
|
-
**/
|
|
636
|
-
message: v3.string()
|
|
637
|
-
});
|
|
638
|
-
var signMessageResultSchema = v3.object({
|
|
639
|
-
/**
|
|
640
|
-
* The signature of the message.
|
|
641
|
-
*/
|
|
642
|
-
signature: v3.string(),
|
|
643
|
-
/**
|
|
644
|
-
* hash of the message.
|
|
645
|
-
*/
|
|
646
|
-
messageHash: v3.string(),
|
|
647
|
-
/**
|
|
648
|
-
* The address used for signing.
|
|
649
|
-
*/
|
|
650
|
-
address: v3.string()
|
|
651
|
-
});
|
|
652
|
-
var signMessageRequestMessageSchema = v3.object({
|
|
653
|
-
...rpcRequestMessageSchema.entries,
|
|
654
|
-
...v3.object({
|
|
655
|
-
method: v3.literal(signMessageMethodName),
|
|
656
|
-
params: signMessageParamsSchema,
|
|
657
|
-
id: v3.string()
|
|
658
|
-
}).entries
|
|
659
|
-
});
|
|
660
|
-
var getAccountsMethodName = "getAccounts";
|
|
661
|
-
var getAccountsParamsSchema = getAddressesParamsSchema;
|
|
662
|
-
var getAccountsResultSchema = v3.array(addressSchema);
|
|
663
|
-
var getAccountsRequestMessageSchema = v3.object({
|
|
664
|
-
...rpcRequestMessageSchema.entries,
|
|
665
|
-
...v3.object({
|
|
666
|
-
method: v3.literal(getAccountsMethodName),
|
|
667
|
-
params: getAccountsParamsSchema,
|
|
668
|
-
id: v3.string()
|
|
669
|
-
}).entries
|
|
670
|
-
});
|
|
671
|
-
var getBalanceMethodName = "getBalance";
|
|
672
|
-
var getBalanceParamsSchema = v3.undefined();
|
|
673
|
-
var getBalanceResultSchema = v3.object({
|
|
674
|
-
/**
|
|
675
|
-
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
676
|
-
* messages not supporting bigint
|
|
677
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
678
|
-
*/
|
|
679
|
-
confirmed: v3.string(),
|
|
680
|
-
/**
|
|
681
|
-
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
682
|
-
* messages not supporting bigint
|
|
683
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
684
|
-
*/
|
|
685
|
-
unconfirmed: v3.string(),
|
|
686
|
-
/**
|
|
687
|
-
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
688
|
-
* sats. Using a string due to chrome messages not supporting bigint
|
|
689
|
-
* (https://issues.chromium.org/issues/40116184).
|
|
690
|
-
*/
|
|
691
|
-
total: v3.string()
|
|
692
|
-
});
|
|
693
|
-
var getBalanceRequestMessageSchema = v3.object({
|
|
694
|
-
...rpcRequestMessageSchema.entries,
|
|
695
|
-
...v3.object({
|
|
696
|
-
method: v3.literal(getBalanceMethodName),
|
|
697
|
-
id: v3.string()
|
|
698
|
-
}).entries
|
|
699
|
-
});
|
|
700
|
-
|
|
701
|
-
// src/request/types/walletMethods.ts
|
|
702
|
-
import * as v4 from "valibot";
|
|
703
|
-
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
704
|
-
var requestPermissionsParamsSchema = v4.undefined();
|
|
705
|
-
var requestPermissionsResultSchema = v4.literal(true);
|
|
706
|
-
var requestPermissionsRequestMessageSchema = v4.object({
|
|
707
|
-
...rpcRequestMessageSchema.entries,
|
|
708
|
-
...v4.object({
|
|
709
|
-
method: v4.literal(requestPermissionsMethodName),
|
|
710
|
-
params: requestPermissionsParamsSchema,
|
|
711
|
-
id: v4.string()
|
|
712
|
-
}).entries
|
|
713
|
-
});
|
|
714
|
-
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
715
|
-
var renouncePermissionsParamsSchema = v4.undefined();
|
|
716
|
-
var renouncePermissionsResultSchema = v4.literal(true);
|
|
717
|
-
var renouncePermissionsRequestMessageSchema = v4.object({
|
|
718
|
-
...rpcRequestMessageSchema.entries,
|
|
719
|
-
...v4.object({
|
|
720
|
-
method: v4.literal(renouncePermissionsMethodName),
|
|
721
|
-
params: renouncePermissionsParamsSchema,
|
|
722
|
-
id: v4.string()
|
|
723
|
-
}).entries
|
|
724
|
-
});
|
|
725
|
-
|
|
726
|
-
// src/request/types/runesMethods.ts
|
|
727
|
-
import * as v5 from "valibot";
|
|
728
|
-
var getRunesBalanceMethodName = "runes_getBalance";
|
|
729
|
-
var getRunesBalanceParamsSchema = v5.null();
|
|
730
|
-
var getRunesBalanceResultSchema = v5.object({
|
|
731
|
-
balances: v5.array(
|
|
732
|
-
v5.object({
|
|
733
|
-
runeName: v5.string(),
|
|
734
|
-
amount: v5.string(),
|
|
735
|
-
divisibility: v5.number(),
|
|
736
|
-
symbol: v5.string(),
|
|
737
|
-
inscriptionId: v5.nullish(v5.string())
|
|
738
|
-
})
|
|
739
|
-
)
|
|
740
|
-
});
|
|
741
|
-
var getRunesBalanceRequestMessageSchema = v5.object({
|
|
742
|
-
...rpcRequestMessageSchema.entries,
|
|
743
|
-
...v5.object({
|
|
744
|
-
method: v5.literal(getRunesBalanceMethodName),
|
|
745
|
-
params: getRunesBalanceParamsSchema,
|
|
746
|
-
id: v5.string()
|
|
747
|
-
}).entries
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
// src/request/types/ordinalsMethods.ts
|
|
751
|
-
import * as v6 from "valibot";
|
|
752
|
-
var getInscriptionsMethodName = "ord_getInscriptions";
|
|
753
|
-
var getInscriptionsParamsSchema = v6.object({
|
|
754
|
-
offset: v6.number(),
|
|
755
|
-
limit: v6.number()
|
|
756
|
-
});
|
|
757
|
-
var getInscriptionsResultSchema = v6.object({
|
|
758
|
-
inscriptions: v6.array(
|
|
759
|
-
v6.object({
|
|
760
|
-
inscriptionId: v6.string(),
|
|
761
|
-
inscriptionNumber: v6.string(),
|
|
762
|
-
address: v6.string(),
|
|
763
|
-
collectionName: v6.optional(v6.string()),
|
|
764
|
-
postage: v6.string(),
|
|
765
|
-
contentLength: v6.string(),
|
|
766
|
-
contentType: v6.string(),
|
|
767
|
-
timestamp: v6.number(),
|
|
768
|
-
offset: v6.number(),
|
|
769
|
-
genesisTransaction: v6.string(),
|
|
770
|
-
output: v6.string()
|
|
771
|
-
})
|
|
772
|
-
)
|
|
773
|
-
});
|
|
774
|
-
var getInscriptionsSchema = v6.object({
|
|
775
|
-
...rpcRequestMessageSchema.entries,
|
|
776
|
-
...v6.object({
|
|
777
|
-
method: v6.literal(getInscriptionsMethodName),
|
|
778
|
-
params: getInscriptionsParamsSchema,
|
|
779
|
-
id: v6.string()
|
|
780
|
-
}).entries
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
// src/request/index.ts
|
|
784
|
-
var request = async (method, params, providerId) => {
|
|
785
|
-
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
786
|
-
if (providerId) {
|
|
787
|
-
provider = await getProviderById(providerId);
|
|
788
|
-
}
|
|
789
|
-
if (!provider) {
|
|
790
|
-
throw new Error("no wallet provider was found");
|
|
791
|
-
}
|
|
792
|
-
if (!method) {
|
|
793
|
-
throw new Error("A wallet method is required");
|
|
794
|
-
}
|
|
795
|
-
const response = await provider.request(method, params);
|
|
796
|
-
if (v7.is(rpcErrorResponseMessageSchema, response)) {
|
|
797
|
-
return {
|
|
798
|
-
status: "error",
|
|
799
|
-
error: response.error
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
if (v7.is(rpcSuccessResponseMessageSchema, response)) {
|
|
803
|
-
return {
|
|
804
|
-
status: "success",
|
|
805
|
-
result: response.result
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
return {
|
|
809
|
-
status: "error",
|
|
810
|
-
error: {
|
|
811
|
-
code: -32603 /* INTERNAL_ERROR */,
|
|
812
|
-
message: "Received unknown response from provider.",
|
|
813
|
-
data: response
|
|
814
|
-
}
|
|
815
|
-
};
|
|
816
|
-
};
|
|
817
|
-
|
|
818
|
-
// src/adapters/xverse.ts
|
|
819
|
-
var XverseAdapter = class extends SatsConnectAdapter {
|
|
820
|
-
id = DefaultAdaptersInfo.xverse.id;
|
|
821
|
-
requestInternal = async (method, params) => {
|
|
822
|
-
return request(method, params, this.id);
|
|
823
|
-
};
|
|
824
|
-
};
|
|
825
|
-
|
|
826
592
|
// src/adapters/unisat.ts
|
|
827
|
-
import { Buffer } from "buffer";
|
|
828
|
-
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
829
593
|
function convertSignInputsToInputType(signInputs, allowedSignHash) {
|
|
830
594
|
let result = [];
|
|
831
595
|
for (let address in signInputs) {
|
|
@@ -1229,65 +993,23 @@ export {
|
|
|
1229
993
|
BitcoinNetworkType,
|
|
1230
994
|
DefaultAdaptersInfo,
|
|
1231
995
|
RpcErrorCode,
|
|
1232
|
-
RpcIdSchema,
|
|
1233
996
|
SatsConnectAdapter,
|
|
1234
|
-
addressSchema,
|
|
1235
997
|
createInscription,
|
|
1236
998
|
createRepeatInscriptions,
|
|
1237
999
|
defaultAdapters,
|
|
1238
|
-
getAccountsMethodName,
|
|
1239
|
-
getAccountsParamsSchema,
|
|
1240
|
-
getAccountsRequestMessageSchema,
|
|
1241
|
-
getAccountsResultSchema,
|
|
1242
1000
|
getAddress,
|
|
1243
|
-
getAddressesMethodName,
|
|
1244
|
-
getAddressesParamsSchema,
|
|
1245
|
-
getAddressesRequestMessageSchema,
|
|
1246
|
-
getAddressesResultSchema,
|
|
1247
|
-
getBalanceMethodName,
|
|
1248
|
-
getBalanceParamsSchema,
|
|
1249
|
-
getBalanceRequestMessageSchema,
|
|
1250
|
-
getBalanceResultSchema,
|
|
1251
1001
|
getCapabilities,
|
|
1252
1002
|
getDefaultProvider,
|
|
1253
|
-
getInfoMethodName,
|
|
1254
|
-
getInfoParamsSchema,
|
|
1255
|
-
getInfoResultSchema,
|
|
1256
|
-
getInfoSchema,
|
|
1257
|
-
getInscriptionsMethodName,
|
|
1258
|
-
getInscriptionsParamsSchema,
|
|
1259
|
-
getInscriptionsResultSchema,
|
|
1260
|
-
getInscriptionsSchema,
|
|
1261
1003
|
getProviderById,
|
|
1262
1004
|
getProviderOrThrow,
|
|
1263
1005
|
getProviders,
|
|
1264
|
-
getRunesBalanceMethodName,
|
|
1265
|
-
getRunesBalanceParamsSchema,
|
|
1266
|
-
getRunesBalanceRequestMessageSchema,
|
|
1267
|
-
getRunesBalanceResultSchema,
|
|
1268
1006
|
getSupportedWallets,
|
|
1269
1007
|
isProviderInstalled,
|
|
1270
1008
|
removeDefaultProvider,
|
|
1271
|
-
renouncePermissionsMethodName,
|
|
1272
|
-
renouncePermissionsParamsSchema,
|
|
1273
|
-
renouncePermissionsRequestMessageSchema,
|
|
1274
|
-
renouncePermissionsResultSchema,
|
|
1275
1009
|
request,
|
|
1276
|
-
requestPermissionsMethodName,
|
|
1277
|
-
requestPermissionsParamsSchema,
|
|
1278
|
-
requestPermissionsRequestMessageSchema,
|
|
1279
|
-
requestPermissionsResultSchema,
|
|
1280
|
-
rpcErrorResponseMessageSchema,
|
|
1281
|
-
rpcRequestMessageSchema,
|
|
1282
|
-
rpcResponseMessageSchema,
|
|
1283
|
-
rpcSuccessResponseMessageSchema,
|
|
1284
1010
|
sendBtcTransaction,
|
|
1285
1011
|
setDefaultProvider,
|
|
1286
1012
|
signMessage,
|
|
1287
|
-
signMessageMethodName,
|
|
1288
|
-
signMessageParamsSchema,
|
|
1289
|
-
signMessageRequestMessageSchema,
|
|
1290
|
-
signMessageResultSchema,
|
|
1291
1013
|
signMultipleTransactions,
|
|
1292
1014
|
signTransaction
|
|
1293
1015
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.0.11-
|
|
3
|
+
"version": "0.0.11-da5cf6b",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -11,7 +11,6 @@
|
|
|
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",
|
|
15
14
|
"clean": "rimraf dist",
|
|
16
15
|
"lint": "prettier --write .",
|
|
17
16
|
"prepare": "husky install"
|
|
@@ -31,9 +30,6 @@
|
|
|
31
30
|
"jsontokens": "4.0.1",
|
|
32
31
|
"lodash.omit": "4.5.0"
|
|
33
32
|
},
|
|
34
|
-
"peerDependencies": {
|
|
35
|
-
"valibot": "0.33.2"
|
|
36
|
-
},
|
|
37
33
|
"devDependencies": {
|
|
38
34
|
"@types/jest": "^29.2.6",
|
|
39
35
|
"@types/lodash.omit": "4.5.9",
|
|
@@ -46,7 +42,7 @@
|
|
|
46
42
|
"ts-jest": "^29.0.5",
|
|
47
43
|
"ts-loader": "^9.4.1",
|
|
48
44
|
"tsup": "^8.0.2",
|
|
49
|
-
"typescript": "
|
|
45
|
+
"typescript": "^4.9.4",
|
|
50
46
|
"util": "^0.12.4",
|
|
51
47
|
"vm-browserify": "^1.1.2",
|
|
52
48
|
"webpack": "^5.74.0",
|