@sats-connect/core 0.0.10 → 0.0.11-1692148
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 +249 -79
- package/dist/index.mjs +317 -46
- package/package.json +6 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
1
3
|
interface GetCapabilitiesPayload extends RequestPayload {
|
|
2
4
|
}
|
|
3
5
|
type GetCapabilitiesResponse = Capability[];
|
|
@@ -141,7 +143,8 @@ declare function getSupportedWallets(): SupportedWallet[];
|
|
|
141
143
|
|
|
142
144
|
declare enum BitcoinNetworkType {
|
|
143
145
|
Mainnet = "Mainnet",
|
|
144
|
-
Testnet = "Testnet"
|
|
146
|
+
Testnet = "Testnet",
|
|
147
|
+
Signet = "Signet"
|
|
145
148
|
}
|
|
146
149
|
interface BitcoinNetwork {
|
|
147
150
|
type: BitcoinNetworkType;
|
|
@@ -156,7 +159,15 @@ interface RequestOptions<Payload extends RequestPayload, Response> {
|
|
|
156
159
|
payload: Payload;
|
|
157
160
|
getProvider?: () => Promise<BitcoinProvider | undefined>;
|
|
158
161
|
}
|
|
159
|
-
|
|
162
|
+
declare const RpcIdSchema: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
163
|
+
type RpcId = v.InferOutput<typeof RpcIdSchema>;
|
|
164
|
+
declare const rpcRequestMessageSchema: v.ObjectSchema<{
|
|
165
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
166
|
+
readonly method: v.StringSchema<undefined>;
|
|
167
|
+
readonly params: v.OptionalSchema<v.UnionSchema<[v.ArraySchema<v.UnknownSchema, undefined>, v.LooseObjectSchema<{}, undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
168
|
+
readonly id: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.NullSchema<undefined>], undefined>, never>;
|
|
169
|
+
}, undefined>;
|
|
170
|
+
type RpcRequestMessage = v.InferOutput<typeof rpcRequestMessageSchema>;
|
|
160
171
|
interface RpcBase {
|
|
161
172
|
jsonrpc: '2.0';
|
|
162
173
|
id: RpcId;
|
|
@@ -203,8 +214,34 @@ declare enum RpcErrorCode {
|
|
|
203
214
|
/**
|
|
204
215
|
* method is not supported for the address provided
|
|
205
216
|
*/
|
|
206
|
-
METHOD_NOT_SUPPORTED = -32001
|
|
207
|
-
|
|
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>;
|
|
208
245
|
interface RpcError {
|
|
209
246
|
code: number | RpcErrorCode;
|
|
210
247
|
message: string;
|
|
@@ -242,12 +279,13 @@ declare enum AddressType {
|
|
|
242
279
|
p2tr = "p2tr",
|
|
243
280
|
stacks = "stacks"
|
|
244
281
|
}
|
|
245
|
-
|
|
246
|
-
address:
|
|
247
|
-
publicKey:
|
|
248
|
-
purpose
|
|
249
|
-
addressType
|
|
250
|
-
}
|
|
282
|
+
declare const addressSchema: v.ObjectSchema<{
|
|
283
|
+
readonly address: v.StringSchema<undefined>;
|
|
284
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
285
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
286
|
+
readonly addressType: v.EnumSchema<typeof AddressType, undefined>;
|
|
287
|
+
}, undefined>;
|
|
288
|
+
type Address$1 = v.InferOutput<typeof addressSchema>;
|
|
251
289
|
interface GetAddressResponse {
|
|
252
290
|
addresses: Address$1[];
|
|
253
291
|
}
|
|
@@ -255,59 +293,110 @@ type GetAddressOptions = RequestOptions<GetAddressPayload, GetAddressResponse>;
|
|
|
255
293
|
|
|
256
294
|
declare const getAddress: (options: GetAddressOptions) => Promise<void>;
|
|
257
295
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
*
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
296
|
+
declare const getInfoMethodName = "getInfo";
|
|
297
|
+
declare const getInfoParamsSchema: v.NullSchema<undefined>;
|
|
298
|
+
declare const getInfoResultSchema: v.ObjectSchema<{
|
|
299
|
+
/**
|
|
300
|
+
* Version of the wallet.
|
|
301
|
+
*/
|
|
302
|
+
readonly version: v.StringSchema<undefined>;
|
|
303
|
+
/**
|
|
304
|
+
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
305
|
+
*/
|
|
306
|
+
readonly methods: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, never>;
|
|
307
|
+
/**
|
|
308
|
+
* List of WBIP standards supported by the wallet. Not currently used.
|
|
309
|
+
*/
|
|
310
|
+
readonly supports: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
311
|
+
}, undefined>;
|
|
312
|
+
declare const getInfoSchema: v.ObjectSchema<{
|
|
313
|
+
readonly method: v.LiteralSchema<"getInfo", undefined>;
|
|
314
|
+
readonly params: v.NullSchema<undefined>;
|
|
315
|
+
readonly id: v.StringSchema<undefined>;
|
|
316
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
317
|
+
}, undefined>;
|
|
318
|
+
type GetInfo = MethodParamsAndResult<v.InferOutput<typeof getInfoParamsSchema>, v.InferOutput<typeof getInfoResultSchema>>;
|
|
319
|
+
declare const getAddressesMethodName = "getAddresses";
|
|
320
|
+
declare const getAddressesParamsSchema: v.ObjectSchema<{
|
|
321
|
+
/**
|
|
322
|
+
* The purposes for which to generate addresses. See
|
|
323
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
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<{
|
|
287
361
|
/**
|
|
288
362
|
* The address used for signing.
|
|
289
363
|
**/
|
|
290
|
-
address:
|
|
364
|
+
readonly address: v.StringSchema<undefined>;
|
|
291
365
|
/**
|
|
292
366
|
* The message to sign.
|
|
293
367
|
**/
|
|
294
|
-
message:
|
|
295
|
-
}
|
|
296
|
-
|
|
368
|
+
readonly message: v.StringSchema<undefined>;
|
|
369
|
+
}, undefined>;
|
|
370
|
+
declare const signMessageResultSchema: v.ObjectSchema<{
|
|
297
371
|
/**
|
|
298
372
|
* The signature of the message.
|
|
299
373
|
*/
|
|
300
|
-
signature:
|
|
374
|
+
readonly signature: v.StringSchema<undefined>;
|
|
301
375
|
/**
|
|
302
376
|
* hash of the message.
|
|
303
377
|
*/
|
|
304
|
-
messageHash:
|
|
378
|
+
readonly messageHash: v.StringSchema<undefined>;
|
|
305
379
|
/**
|
|
306
380
|
* The address used for signing.
|
|
307
381
|
*/
|
|
308
|
-
address:
|
|
309
|
-
}
|
|
310
|
-
|
|
382
|
+
readonly address: v.StringSchema<undefined>;
|
|
383
|
+
}, undefined>;
|
|
384
|
+
declare const signMessageRequestMessageSchema: v.ObjectSchema<{
|
|
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>>;
|
|
311
400
|
type Recipient$1 = {
|
|
312
401
|
/**
|
|
313
402
|
* The recipient's address.
|
|
@@ -364,22 +453,70 @@ type SignPsbtResult = {
|
|
|
364
453
|
txid?: string;
|
|
365
454
|
};
|
|
366
455
|
type SignPsbt = MethodParamsAndResult<SignPsbtParams, SignPsbtResult>;
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
*
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
456
|
+
declare const getAccountsMethodName = "getAccounts";
|
|
457
|
+
declare const getAccountsParamsSchema: v.ObjectSchema<{
|
|
458
|
+
/**
|
|
459
|
+
* The purposes for which to generate addresses. See
|
|
460
|
+
* {@linkcode AddressPurpose} for available purposes.
|
|
461
|
+
*/
|
|
462
|
+
readonly purposes: v.ArraySchema<v.EnumSchema<typeof AddressPurpose, undefined>, undefined>;
|
|
463
|
+
/**
|
|
464
|
+
* A message to be displayed to the user in the request prompt.
|
|
465
|
+
*/
|
|
466
|
+
readonly message: v.OptionalSchema<v.StringSchema<undefined>, never>;
|
|
467
|
+
}, undefined>;
|
|
468
|
+
declare const getAccountsResultSchema: v.ArraySchema<v.ObjectSchema<{
|
|
469
|
+
readonly address: v.StringSchema<undefined>;
|
|
470
|
+
readonly publicKey: v.StringSchema<undefined>;
|
|
471
|
+
readonly purpose: v.EnumSchema<typeof AddressPurpose, undefined>;
|
|
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>>;
|
|
383
520
|
|
|
384
521
|
type CreateMintOrderRequest = {
|
|
385
522
|
runeName: string;
|
|
@@ -492,17 +629,24 @@ interface RbfOrderResult {
|
|
|
492
629
|
fundingAddress: string;
|
|
493
630
|
}
|
|
494
631
|
type RbfOrder = MethodParamsAndResult<RbfOrderParams, RbfOrderResult>;
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
|
|
632
|
+
declare const getRunesBalanceMethodName = "getRunesBalance";
|
|
633
|
+
declare const getRunesBalanceParamsSchema: v.NullSchema<undefined>;
|
|
634
|
+
declare const getRunesBalanceResultSchema: v.ObjectSchema<{
|
|
635
|
+
readonly balances: v.ArraySchema<v.ObjectSchema<{
|
|
636
|
+
readonly runeName: v.StringSchema<undefined>;
|
|
637
|
+
readonly amount: v.StringSchema<undefined>;
|
|
638
|
+
readonly divisibility: v.NumberSchema<undefined>;
|
|
639
|
+
readonly symbol: v.StringSchema<undefined>;
|
|
640
|
+
readonly inscriptionId: v.NullishSchema<v.StringSchema<undefined>, never>;
|
|
641
|
+
}, undefined>, undefined>;
|
|
642
|
+
}, undefined>;
|
|
643
|
+
declare const getRunesBalanceRequestMessageSchema: v.ObjectSchema<{
|
|
644
|
+
readonly method: v.LiteralSchema<"getRunesBalance", undefined>;
|
|
645
|
+
readonly params: v.NullSchema<undefined>;
|
|
646
|
+
readonly id: v.StringSchema<undefined>;
|
|
647
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
648
|
+
}, undefined>;
|
|
649
|
+
type GetRunesBalance = MethodParamsAndResult<v.InferOutput<typeof getRunesBalanceParamsSchema>, v.InferOutput<typeof getRunesBalanceResultSchema>>;
|
|
506
650
|
|
|
507
651
|
interface Pubkey {
|
|
508
652
|
/**
|
|
@@ -684,6 +828,27 @@ type SignTransactionParams = Transaction & Partial<Pubkey>;
|
|
|
684
828
|
type SignTransactionResult = Transaction;
|
|
685
829
|
type StxSignTransaction = MethodParamsAndResult<SignTransactionParams, SignTransactionResult>;
|
|
686
830
|
|
|
831
|
+
declare const requestPermissionsMethodName = "wallet_requestPermissions";
|
|
832
|
+
declare const requestPermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
833
|
+
declare const requestPermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
834
|
+
declare const requestPermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
835
|
+
readonly method: v.LiteralSchema<"wallet_requestPermissions", undefined>;
|
|
836
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
837
|
+
readonly id: v.StringSchema<undefined>;
|
|
838
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
839
|
+
}, undefined>;
|
|
840
|
+
type RequestPermissions = MethodParamsAndResult<v.InferOutput<typeof requestPermissionsParamsSchema>, v.InferOutput<typeof requestPermissionsResultSchema>>;
|
|
841
|
+
declare const renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
842
|
+
declare const renouncePermissionsParamsSchema: v.UndefinedSchema<undefined>;
|
|
843
|
+
declare const renouncePermissionsResultSchema: v.LiteralSchema<true, undefined>;
|
|
844
|
+
declare const renouncePermissionsRequestMessageSchema: v.ObjectSchema<{
|
|
845
|
+
readonly method: v.LiteralSchema<"wallet_renouncePermissions", undefined>;
|
|
846
|
+
readonly params: v.UndefinedSchema<undefined>;
|
|
847
|
+
readonly id: v.StringSchema<undefined>;
|
|
848
|
+
readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
|
|
849
|
+
}, undefined>;
|
|
850
|
+
type RenouncePermissions = MethodParamsAndResult<v.InferOutput<typeof renouncePermissionsParamsSchema>, v.InferOutput<typeof renouncePermissionsResultSchema>>;
|
|
851
|
+
|
|
687
852
|
interface StxRequests {
|
|
688
853
|
stx_callContract: StxCallContract;
|
|
689
854
|
stx_deployContract: StxDeployContract;
|
|
@@ -699,6 +864,7 @@ interface BtcRequests {
|
|
|
699
864
|
getInfo: GetInfo;
|
|
700
865
|
getAddresses: GetAddresses;
|
|
701
866
|
getAccounts: GetAccounts;
|
|
867
|
+
getBalance: GetBalance;
|
|
702
868
|
signMessage: SignMessage;
|
|
703
869
|
sendTransfer: SendTransfer;
|
|
704
870
|
signPsbt: SignPsbt;
|
|
@@ -715,11 +881,15 @@ interface RunesRequests {
|
|
|
715
881
|
runes_getBalance: GetRunesBalance;
|
|
716
882
|
}
|
|
717
883
|
type RunesRequestMethod = keyof RunesRequests;
|
|
718
|
-
|
|
884
|
+
interface WalletMethods {
|
|
885
|
+
wallet_requestPermissions: RequestPermissions;
|
|
886
|
+
wallet_renouncePermissions: RenouncePermissions;
|
|
887
|
+
}
|
|
888
|
+
type Requests = BtcRequests & StxRequests & RunesRequests & WalletMethods;
|
|
719
889
|
type Return<Method> = Method extends keyof Requests ? Requests[Method]['result'] : never;
|
|
720
890
|
type Params<Method> = Method extends keyof Requests ? Requests[Method]['params'] : never;
|
|
721
891
|
|
|
722
|
-
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
892
|
+
declare const request: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>, providerId?: string) => Promise<RpcResult<Method>>;
|
|
723
893
|
|
|
724
894
|
declare abstract class SatsConnectAdapter {
|
|
725
895
|
abstract readonly id: string;
|
|
@@ -737,10 +907,10 @@ declare abstract class SatsConnectAdapter {
|
|
|
737
907
|
declare class BaseAdapter extends SatsConnectAdapter {
|
|
738
908
|
id: string;
|
|
739
909
|
constructor(providerId: string);
|
|
740
|
-
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
910
|
+
requestInternal: <Method extends keyof BtcRequests | keyof StxRequests | keyof RunesRequests | keyof WalletMethods>(method: Method, params: Params<Method>) => Promise<RpcResult<Method>>;
|
|
741
911
|
}
|
|
742
912
|
|
|
743
913
|
declare const DefaultAdaptersInfo: Record<string, Provider>;
|
|
744
914
|
declare const defaultAdapters: Record<string, new () => SatsConnectAdapter>;
|
|
745
915
|
|
|
746
|
-
export { type Address$1 as Address, AddressPurpose, AddressType, BaseAdapter, type BitcoinNetwork, BitcoinNetworkType, type BitcoinProvider, type BtcRequestMethod, type BtcRequests, type CallContractParams, type CallContractResult, type Capability, type CreateInscriptionOptions, type CreateInscriptionPayload, type CreateInscriptionResponse, type CreateRepeatInscriptionsOptions, type CreateRepeatInscriptionsPayload, type CreateRepeatInscriptionsResponse, DefaultAdaptersInfo, type DeployContractParams, type DeployContractResult, type
|
|
916
|
+
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 GetAccountsResult, type GetAddressOptions, type GetAddressPayload, type GetAddressResponse, type GetAddresses, type GetAddressesParams, type GetAddressesResult, type GetBalance, type GetCapabilitiesOptions, type GetCapabilitiesPayload, type GetCapabilitiesResponse, type GetInfo, type GetOrder, type GetRunesBalance, type InputToSign, type MethodParamsAndResult, type MintRunes, type MintRunesParams, type MintRunesResult, 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 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, type WalletMethods, addressSchema, createInscription, createRepeatInscriptions, defaultAdapters, getAccountsMethodName, getAccountsParamsSchema, getAccountsRequestMessageSchema, getAccountsResultSchema, getAddress, getAddressesMethodName, getAddressesParamsSchema, getAddressesRequestMessageSchema, getAddressesResultSchema, getBalanceMethodName, getBalanceParamsSchema, getBalanceRequestMessageSchema, getBalanceResultSchema, getCapabilities, getDefaultProvider, getInfoMethodName, getInfoParamsSchema, getInfoResultSchema, getInfoSchema, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
// src/types.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType3) => {
|
|
4
|
+
BitcoinNetworkType3["Mainnet"] = "Mainnet";
|
|
5
|
+
BitcoinNetworkType3["Testnet"] = "Testnet";
|
|
6
|
+
BitcoinNetworkType3["Signet"] = "Signet";
|
|
7
|
+
return BitcoinNetworkType3;
|
|
6
8
|
})(BitcoinNetworkType || {});
|
|
9
|
+
var RpcIdSchema = v.optional(v.union([v.string(), v.number(), v.null()]));
|
|
10
|
+
var rpcRequestMessageSchema = v.object({
|
|
11
|
+
jsonrpc: v.literal("2.0"),
|
|
12
|
+
method: v.string(),
|
|
13
|
+
params: v.optional(
|
|
14
|
+
v.union([
|
|
15
|
+
v.array(v.unknown()),
|
|
16
|
+
v.looseObject({}),
|
|
17
|
+
// Note: This is to support current incorrect usage of RPC 2.0. Params need
|
|
18
|
+
// to be either an array or an object when provided. Changing this now would
|
|
19
|
+
// be a breaking change, so accepting null values for now. Tracking in
|
|
20
|
+
// https://linear.app/xverseapp/issue/ENG-4538.
|
|
21
|
+
v.null()
|
|
22
|
+
])
|
|
23
|
+
),
|
|
24
|
+
id: RpcIdSchema
|
|
25
|
+
});
|
|
7
26
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
8
27
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
9
28
|
RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
@@ -12,12 +31,32 @@ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
|
12
31
|
RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
13
32
|
RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
|
|
14
33
|
RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
|
|
34
|
+
RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
|
|
15
35
|
return RpcErrorCode2;
|
|
16
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
|
+
]);
|
|
17
51
|
|
|
18
52
|
// src/runes/api.ts
|
|
19
53
|
import axios from "axios";
|
|
20
|
-
var
|
|
54
|
+
var urlNetworkSuffix = {
|
|
55
|
+
["Mainnet" /* Mainnet */]: "",
|
|
56
|
+
["Testnet" /* Testnet */]: "-testnet",
|
|
57
|
+
["Signet" /* Signet */]: "-signet"
|
|
58
|
+
};
|
|
59
|
+
var ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
|
|
21
60
|
var RunesApi = class {
|
|
22
61
|
client;
|
|
23
62
|
constructor(network) {
|
|
@@ -151,9 +190,13 @@ var RunesApi = class {
|
|
|
151
190
|
}
|
|
152
191
|
};
|
|
153
192
|
};
|
|
154
|
-
var
|
|
155
|
-
var
|
|
156
|
-
|
|
193
|
+
var clients = {};
|
|
194
|
+
var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
|
|
195
|
+
if (!clients[network]) {
|
|
196
|
+
clients[network] = new RunesApi(network);
|
|
197
|
+
}
|
|
198
|
+
return clients[network];
|
|
199
|
+
};
|
|
157
200
|
|
|
158
201
|
// src/adapters/satsConnectAdapter.ts
|
|
159
202
|
var SatsConnectAdapter = class {
|
|
@@ -483,49 +526,13 @@ function getSupportedWallets() {
|
|
|
483
526
|
}
|
|
484
527
|
|
|
485
528
|
// src/request/index.ts
|
|
486
|
-
|
|
487
|
-
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
488
|
-
if (providerId) {
|
|
489
|
-
provider = await getProviderById(providerId);
|
|
490
|
-
}
|
|
491
|
-
if (!provider) {
|
|
492
|
-
throw new Error("no wallet provider was found");
|
|
493
|
-
}
|
|
494
|
-
if (!method) {
|
|
495
|
-
throw new Error("A wallet method is required");
|
|
496
|
-
}
|
|
497
|
-
const response = await provider.request(method, params);
|
|
498
|
-
if (isRpcSuccessResponse(response)) {
|
|
499
|
-
return {
|
|
500
|
-
status: "success",
|
|
501
|
-
result: response.result
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
return {
|
|
505
|
-
status: "error",
|
|
506
|
-
error: response.error
|
|
507
|
-
};
|
|
508
|
-
};
|
|
509
|
-
var isRpcSuccessResponse = (response) => {
|
|
510
|
-
return Object.hasOwn(response, "result") && !!response.result;
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
// src/adapters/xverse.ts
|
|
514
|
-
var XverseAdapter = class extends SatsConnectAdapter {
|
|
515
|
-
id = DefaultAdaptersInfo.xverse.id;
|
|
516
|
-
requestInternal = async (method, params) => {
|
|
517
|
-
return request(method, params, this.id);
|
|
518
|
-
};
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
// src/adapters/unisat.ts
|
|
522
|
-
import { Buffer } from "buffer";
|
|
523
|
-
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
529
|
+
import * as v6 from "valibot";
|
|
524
530
|
|
|
525
531
|
// src/addresses/index.ts
|
|
526
532
|
import { createUnsecuredToken } from "jsontokens";
|
|
527
533
|
|
|
528
534
|
// src/addresses/types.ts
|
|
535
|
+
import * as v2 from "valibot";
|
|
529
536
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
530
537
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
531
538
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -541,6 +548,12 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
541
548
|
AddressType3["stacks"] = "stacks";
|
|
542
549
|
return AddressType3;
|
|
543
550
|
})(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
|
+
});
|
|
544
557
|
|
|
545
558
|
// src/addresses/index.ts
|
|
546
559
|
var getAddress = async (options) => {
|
|
@@ -559,7 +572,227 @@ var getAddress = async (options) => {
|
|
|
559
572
|
}
|
|
560
573
|
};
|
|
561
574
|
|
|
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 = "getRunesBalance";
|
|
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/index.ts
|
|
751
|
+
var request = async (method, params, providerId) => {
|
|
752
|
+
let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
|
|
753
|
+
if (providerId) {
|
|
754
|
+
provider = await getProviderById(providerId);
|
|
755
|
+
}
|
|
756
|
+
if (!provider) {
|
|
757
|
+
throw new Error("no wallet provider was found");
|
|
758
|
+
}
|
|
759
|
+
if (!method) {
|
|
760
|
+
throw new Error("A wallet method is required");
|
|
761
|
+
}
|
|
762
|
+
const response = await provider.request(method, params);
|
|
763
|
+
if (v6.is(rpcErrorResponseMessageSchema, response)) {
|
|
764
|
+
return {
|
|
765
|
+
status: "error",
|
|
766
|
+
error: response.error
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
if (v6.is(rpcSuccessResponseMessageSchema, response)) {
|
|
770
|
+
return {
|
|
771
|
+
status: "success",
|
|
772
|
+
result: response.result
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
return {
|
|
776
|
+
status: "error",
|
|
777
|
+
error: {
|
|
778
|
+
code: -32603 /* INTERNAL_ERROR */,
|
|
779
|
+
message: "Received unknown response from provider.",
|
|
780
|
+
data: response
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
// src/adapters/xverse.ts
|
|
786
|
+
var XverseAdapter = class extends SatsConnectAdapter {
|
|
787
|
+
id = DefaultAdaptersInfo.xverse.id;
|
|
788
|
+
requestInternal = async (method, params) => {
|
|
789
|
+
return request(method, params, this.id);
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
|
|
562
793
|
// src/adapters/unisat.ts
|
|
794
|
+
import { Buffer } from "buffer";
|
|
795
|
+
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
563
796
|
function convertSignInputsToInputType(signInputs, allowedSignHash) {
|
|
564
797
|
let result = [];
|
|
565
798
|
for (let address in signInputs) {
|
|
@@ -963,23 +1196,61 @@ export {
|
|
|
963
1196
|
BitcoinNetworkType,
|
|
964
1197
|
DefaultAdaptersInfo,
|
|
965
1198
|
RpcErrorCode,
|
|
1199
|
+
RpcIdSchema,
|
|
966
1200
|
SatsConnectAdapter,
|
|
1201
|
+
addressSchema,
|
|
967
1202
|
createInscription,
|
|
968
1203
|
createRepeatInscriptions,
|
|
969
1204
|
defaultAdapters,
|
|
1205
|
+
getAccountsMethodName,
|
|
1206
|
+
getAccountsParamsSchema,
|
|
1207
|
+
getAccountsRequestMessageSchema,
|
|
1208
|
+
getAccountsResultSchema,
|
|
970
1209
|
getAddress,
|
|
1210
|
+
getAddressesMethodName,
|
|
1211
|
+
getAddressesParamsSchema,
|
|
1212
|
+
getAddressesRequestMessageSchema,
|
|
1213
|
+
getAddressesResultSchema,
|
|
1214
|
+
getBalanceMethodName,
|
|
1215
|
+
getBalanceParamsSchema,
|
|
1216
|
+
getBalanceRequestMessageSchema,
|
|
1217
|
+
getBalanceResultSchema,
|
|
971
1218
|
getCapabilities,
|
|
972
1219
|
getDefaultProvider,
|
|
1220
|
+
getInfoMethodName,
|
|
1221
|
+
getInfoParamsSchema,
|
|
1222
|
+
getInfoResultSchema,
|
|
1223
|
+
getInfoSchema,
|
|
973
1224
|
getProviderById,
|
|
974
1225
|
getProviderOrThrow,
|
|
975
1226
|
getProviders,
|
|
1227
|
+
getRunesBalanceMethodName,
|
|
1228
|
+
getRunesBalanceParamsSchema,
|
|
1229
|
+
getRunesBalanceRequestMessageSchema,
|
|
1230
|
+
getRunesBalanceResultSchema,
|
|
976
1231
|
getSupportedWallets,
|
|
977
1232
|
isProviderInstalled,
|
|
978
1233
|
removeDefaultProvider,
|
|
1234
|
+
renouncePermissionsMethodName,
|
|
1235
|
+
renouncePermissionsParamsSchema,
|
|
1236
|
+
renouncePermissionsRequestMessageSchema,
|
|
1237
|
+
renouncePermissionsResultSchema,
|
|
979
1238
|
request,
|
|
1239
|
+
requestPermissionsMethodName,
|
|
1240
|
+
requestPermissionsParamsSchema,
|
|
1241
|
+
requestPermissionsRequestMessageSchema,
|
|
1242
|
+
requestPermissionsResultSchema,
|
|
1243
|
+
rpcErrorResponseMessageSchema,
|
|
1244
|
+
rpcRequestMessageSchema,
|
|
1245
|
+
rpcResponseMessageSchema,
|
|
1246
|
+
rpcSuccessResponseMessageSchema,
|
|
980
1247
|
sendBtcTransaction,
|
|
981
1248
|
setDefaultProvider,
|
|
982
1249
|
signMessage,
|
|
1250
|
+
signMessageMethodName,
|
|
1251
|
+
signMessageParamsSchema,
|
|
1252
|
+
signMessageRequestMessageSchema,
|
|
1253
|
+
signMessageResultSchema,
|
|
983
1254
|
signMultipleTransactions,
|
|
984
1255
|
signTransaction
|
|
985
1256
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sats-connect/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11-1692148",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.mts",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"test": "jest",
|
|
12
12
|
"build-debug": "webpack --mode development",
|
|
13
13
|
"build": "npm run clean && tsup src/index.ts --format esm --dts",
|
|
14
|
+
"build:watch": "npm run clean && tsup src/index.ts --format esm --dts --watch",
|
|
14
15
|
"clean": "rimraf dist",
|
|
15
16
|
"lint": "prettier --write .",
|
|
16
17
|
"prepare": "husky install"
|
|
@@ -30,6 +31,9 @@
|
|
|
30
31
|
"jsontokens": "4.0.1",
|
|
31
32
|
"lodash.omit": "4.5.0"
|
|
32
33
|
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"valibot": "0.33.2"
|
|
36
|
+
},
|
|
33
37
|
"devDependencies": {
|
|
34
38
|
"@types/jest": "^29.2.6",
|
|
35
39
|
"@types/lodash.omit": "4.5.9",
|
|
@@ -42,7 +46,7 @@
|
|
|
42
46
|
"ts-jest": "^29.0.5",
|
|
43
47
|
"ts-loader": "^9.4.1",
|
|
44
48
|
"tsup": "^8.0.2",
|
|
45
|
-
"typescript": "
|
|
49
|
+
"typescript": "5.4.5",
|
|
46
50
|
"util": "^0.12.4",
|
|
47
51
|
"vm-browserify": "^1.1.2",
|
|
48
52
|
"webpack": "^5.74.0",
|