@sats-connect/core 0.4.0-8f3e1e5 → 0.4.0-8f77109

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.js ADDED
@@ -0,0 +1,2311 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ AddressPurpose: () => AddressPurpose,
34
+ AddressType: () => AddressType,
35
+ BaseAdapter: () => BaseAdapter,
36
+ BitcoinNetworkType: () => BitcoinNetworkType,
37
+ DefaultAdaptersInfo: () => DefaultAdaptersInfo,
38
+ MessageSigningProtocols: () => MessageSigningProtocols,
39
+ PermissionRequestParams: () => PermissionRequestParams,
40
+ RpcErrorCode: () => RpcErrorCode,
41
+ RpcIdSchema: () => RpcIdSchema,
42
+ SatsConnectAdapter: () => SatsConnectAdapter,
43
+ accountActionsSchema: () => accountActionsSchema,
44
+ accountChangeEventName: () => accountChangeEventName,
45
+ accountChangeSchema: () => accountChangeSchema,
46
+ accountPermissionSchema: () => accountPermissionSchema,
47
+ addListener: () => addListener,
48
+ addressSchema: () => addressSchema,
49
+ connectMethodName: () => connectMethodName,
50
+ connectParamsSchema: () => connectParamsSchema,
51
+ connectRequestMessageSchema: () => connectRequestMessageSchema,
52
+ connectResultSchema: () => connectResultSchema,
53
+ createInscription: () => createInscription,
54
+ createRepeatInscriptions: () => createRepeatInscriptions,
55
+ defaultAdapters: () => defaultAdapters,
56
+ disconnectEventName: () => disconnectEventName,
57
+ disconnectMethodName: () => disconnectMethodName,
58
+ disconnectParamsSchema: () => disconnectParamsSchema,
59
+ disconnectRequestMessageSchema: () => disconnectRequestMessageSchema,
60
+ disconnectResultSchema: () => disconnectResultSchema,
61
+ disconnectSchema: () => disconnectSchema,
62
+ getAccountMethodName: () => getAccountMethodName,
63
+ getAccountParamsSchema: () => getAccountParamsSchema,
64
+ getAccountRequestMessageSchema: () => getAccountRequestMessageSchema,
65
+ getAccountResultSchema: () => getAccountResultSchema,
66
+ getAccountsMethodName: () => getAccountsMethodName,
67
+ getAccountsParamsSchema: () => getAccountsParamsSchema,
68
+ getAccountsRequestMessageSchema: () => getAccountsRequestMessageSchema,
69
+ getAccountsResultSchema: () => getAccountsResultSchema,
70
+ getAddress: () => getAddress,
71
+ getAddressesMethodName: () => getAddressesMethodName,
72
+ getAddressesParamsSchema: () => getAddressesParamsSchema,
73
+ getAddressesRequestMessageSchema: () => getAddressesRequestMessageSchema,
74
+ getAddressesResultSchema: () => getAddressesResultSchema,
75
+ getBalanceMethodName: () => getBalanceMethodName,
76
+ getBalanceParamsSchema: () => getBalanceParamsSchema,
77
+ getBalanceRequestMessageSchema: () => getBalanceRequestMessageSchema,
78
+ getBalanceResultSchema: () => getBalanceResultSchema,
79
+ getCapabilities: () => getCapabilities,
80
+ getCurrentPermissionsMethodName: () => getCurrentPermissionsMethodName,
81
+ getCurrentPermissionsParamsSchema: () => getCurrentPermissionsParamsSchema,
82
+ getCurrentPermissionsRequestMessageSchema: () => getCurrentPermissionsRequestMessageSchema,
83
+ getCurrentPermissionsResultSchema: () => getCurrentPermissionsResultSchema,
84
+ getDefaultProvider: () => getDefaultProvider,
85
+ getInfoMethodName: () => getInfoMethodName,
86
+ getInfoParamsSchema: () => getInfoParamsSchema,
87
+ getInfoRequestMessageSchema: () => getInfoRequestMessageSchema,
88
+ getInfoResultSchema: () => getInfoResultSchema,
89
+ getInscriptionsMethodName: () => getInscriptionsMethodName,
90
+ getInscriptionsParamsSchema: () => getInscriptionsParamsSchema,
91
+ getInscriptionsRequestMessageSchema: () => getInscriptionsRequestMessageSchema,
92
+ getInscriptionsResultSchema: () => getInscriptionsResultSchema,
93
+ getProviderById: () => getProviderById,
94
+ getProviderOrThrow: () => getProviderOrThrow,
95
+ getProviders: () => getProviders,
96
+ getSupportedWallets: () => getSupportedWallets,
97
+ getWalletTypeMethodName: () => getWalletTypeMethodName,
98
+ getWalletTypeParamsSchema: () => getWalletTypeParamsSchema,
99
+ getWalletTypeRequestMessageSchema: () => getWalletTypeRequestMessageSchema,
100
+ getWalletTypeResultSchema: () => getWalletTypeResultSchema,
101
+ isProviderInstalled: () => isProviderInstalled,
102
+ networkChangeEventName: () => networkChangeEventName,
103
+ networkChangeSchema: () => networkChangeSchema,
104
+ permission: () => permission,
105
+ removeDefaultProvider: () => removeDefaultProvider,
106
+ renouncePermissionsMethodName: () => renouncePermissionsMethodName,
107
+ renouncePermissionsParamsSchema: () => renouncePermissionsParamsSchema,
108
+ renouncePermissionsRequestMessageSchema: () => renouncePermissionsRequestMessageSchema,
109
+ renouncePermissionsResultSchema: () => renouncePermissionsResultSchema,
110
+ request: () => request,
111
+ requestPermissionsMethodName: () => requestPermissionsMethodName,
112
+ requestPermissionsParamsSchema: () => requestPermissionsParamsSchema,
113
+ requestPermissionsRequestMessageSchema: () => requestPermissionsRequestMessageSchema,
114
+ requestPermissionsResultSchema: () => requestPermissionsResultSchema,
115
+ rpcErrorResponseMessageSchema: () => rpcErrorResponseMessageSchema,
116
+ rpcRequestMessageSchema: () => rpcRequestMessageSchema,
117
+ rpcResponseMessageSchema: () => rpcResponseMessageSchema,
118
+ rpcSuccessResponseMessageSchema: () => rpcSuccessResponseMessageSchema,
119
+ runesEtchMethodName: () => runesEtchMethodName,
120
+ runesEtchParamsSchema: () => runesEtchParamsSchema,
121
+ runesEtchRequestMessageSchema: () => runesEtchRequestMessageSchema,
122
+ runesEtchResultSchema: () => runesEtchResultSchema,
123
+ runesGetBalanceMethodName: () => runesGetBalanceMethodName,
124
+ runesGetBalanceParamsSchema: () => runesGetBalanceParamsSchema,
125
+ runesGetBalanceRequestMessageSchema: () => runesGetBalanceRequestMessageSchema,
126
+ runesGetBalanceResultSchema: () => runesGetBalanceResultSchema,
127
+ runesMintMethodName: () => runesMintMethodName,
128
+ runesMintParamsSchema: () => runesMintParamsSchema,
129
+ runesMintRequestMessageSchema: () => runesMintRequestMessageSchema,
130
+ runesMintResultSchema: () => runesMintResultSchema,
131
+ runesTransferMethodName: () => runesTransferMethodName,
132
+ runesTransferParamsSchema: () => runesTransferParamsSchema,
133
+ runesTransferRequestMessageSchema: () => runesTransferRequestMessageSchema,
134
+ runesTransferResultSchema: () => runesTransferResultSchema,
135
+ sendBtcTransaction: () => sendBtcTransaction,
136
+ sendInscriptionsMethodName: () => sendInscriptionsMethodName,
137
+ sendInscriptionsParamsSchema: () => sendInscriptionsParamsSchema,
138
+ sendInscriptionsRequestMessageSchema: () => sendInscriptionsRequestMessageSchema,
139
+ sendInscriptionsResultSchema: () => sendInscriptionsResultSchema,
140
+ sendTransferMethodName: () => sendTransferMethodName,
141
+ sendTransferParamsSchema: () => sendTransferParamsSchema,
142
+ sendTransferRequestMessageSchema: () => sendTransferRequestMessageSchema,
143
+ sendTransferResultSchema: () => sendTransferResultSchema,
144
+ setDefaultProvider: () => setDefaultProvider,
145
+ signMessage: () => signMessage,
146
+ signMessageMethodName: () => signMessageMethodName,
147
+ signMessageParamsSchema: () => signMessageParamsSchema,
148
+ signMessageRequestMessageSchema: () => signMessageRequestMessageSchema,
149
+ signMessageResultSchema: () => signMessageResultSchema,
150
+ signMultipleTransactions: () => signMultipleTransactions,
151
+ signPsbtMethodName: () => signPsbtMethodName,
152
+ signPsbtParamsSchema: () => signPsbtParamsSchema,
153
+ signPsbtRequestMessageSchema: () => signPsbtRequestMessageSchema,
154
+ signPsbtResultSchema: () => signPsbtResultSchema,
155
+ signTransaction: () => signTransaction,
156
+ stxCallContractMethodName: () => stxCallContractMethodName,
157
+ stxCallContractParamsSchema: () => stxCallContractParamsSchema,
158
+ stxCallContractRequestMessageSchema: () => stxCallContractRequestMessageSchema,
159
+ stxCallContractResultSchema: () => stxCallContractResultSchema,
160
+ stxDeployContractMethodName: () => stxDeployContractMethodName,
161
+ stxDeployContractParamsSchema: () => stxDeployContractParamsSchema,
162
+ stxDeployContractRequestMessageSchema: () => stxDeployContractRequestMessageSchema,
163
+ stxDeployContractResultSchema: () => stxDeployContractResultSchema,
164
+ stxGetAccountsMethodName: () => stxGetAccountsMethodName,
165
+ stxGetAccountsParamsSchema: () => stxGetAccountsParamsSchema,
166
+ stxGetAccountsRequestMessageSchema: () => stxGetAccountsRequestMessageSchema,
167
+ stxGetAccountsResultSchema: () => stxGetAccountsResultSchema,
168
+ stxGetAddressesMethodName: () => stxGetAddressesMethodName,
169
+ stxGetAddressesParamsSchema: () => stxGetAddressesParamsSchema,
170
+ stxGetAddressesRequestMessageSchema: () => stxGetAddressesRequestMessageSchema,
171
+ stxGetAddressesResultSchema: () => stxGetAddressesResultSchema,
172
+ stxSignMessageMethodName: () => stxSignMessageMethodName,
173
+ stxSignMessageParamsSchema: () => stxSignMessageParamsSchema,
174
+ stxSignMessageRequestMessageSchema: () => stxSignMessageRequestMessageSchema,
175
+ stxSignMessageResultSchema: () => stxSignMessageResultSchema,
176
+ stxSignStructuredMessageMethodName: () => stxSignStructuredMessageMethodName,
177
+ stxSignStructuredMessageParamsSchema: () => stxSignStructuredMessageParamsSchema,
178
+ stxSignStructuredMessageRequestMessageSchema: () => stxSignStructuredMessageRequestMessageSchema,
179
+ stxSignStructuredMessageResultSchema: () => stxSignStructuredMessageResultSchema,
180
+ stxSignTransactionMethodName: () => stxSignTransactionMethodName,
181
+ stxSignTransactionParamsSchema: () => stxSignTransactionParamsSchema,
182
+ stxSignTransactionRequestMessageSchema: () => stxSignTransactionRequestMessageSchema,
183
+ stxSignTransactionResultSchema: () => stxSignTransactionResultSchema,
184
+ stxTransferStxMethodName: () => stxTransferStxMethodName,
185
+ stxTransferStxParamsSchema: () => stxTransferStxParamsSchema,
186
+ stxTransferStxRequestMessageSchema: () => stxTransferStxRequestMessageSchema,
187
+ stxTransferStxResultSchema: () => stxTransferStxResultSchema,
188
+ walletActionsSchema: () => walletActionsSchema,
189
+ walletEventSchema: () => walletEventSchema,
190
+ walletPermissionSchema: () => walletPermissionSchema,
191
+ walletTypeSchema: () => walletTypeSchema,
192
+ walletTypes: () => walletTypes
193
+ });
194
+ module.exports = __toCommonJS(src_exports);
195
+
196
+ // src/provider/types.ts
197
+ var v = __toESM(require("valibot"));
198
+ var accountChangeEventName = "accountChange";
199
+ var accountChangeSchema = v.object({
200
+ type: v.literal(accountChangeEventName)
201
+ });
202
+ var networkChangeEventName = "networkChange";
203
+ var networkChangeSchema = v.object({
204
+ type: v.literal(networkChangeEventName)
205
+ });
206
+ var disconnectEventName = "disconnect";
207
+ var disconnectSchema = v.object({
208
+ type: v.literal(disconnectEventName)
209
+ });
210
+ var walletEventSchema = v.variant("type", [
211
+ accountChangeSchema,
212
+ networkChangeSchema,
213
+ disconnectSchema
214
+ ]);
215
+
216
+ // src/provider/index.ts
217
+ async function getProviderOrThrow(getProvider) {
218
+ const provider = await getProvider?.() || window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
219
+ if (!provider) {
220
+ throw new Error("No Bitcoin wallet installed");
221
+ }
222
+ return provider;
223
+ }
224
+ function getProviders() {
225
+ if (!window.btc_providers) window.btc_providers = [];
226
+ return window.btc_providers;
227
+ }
228
+ function getProviderById(providerId) {
229
+ return providerId?.split(".").reduce((acc, part) => acc?.[part], window);
230
+ }
231
+ function isProviderInstalled(providerId) {
232
+ return !!getProviderById(providerId);
233
+ }
234
+ function setDefaultProvider(providerId) {
235
+ localStorage.setItem("sats-connect_defaultProvider", providerId);
236
+ }
237
+ function getDefaultProvider() {
238
+ return localStorage.getItem("sats-connect_defaultProvider");
239
+ }
240
+ function removeDefaultProvider() {
241
+ localStorage.removeItem("sats-connect_defaultProvider");
242
+ }
243
+ function getSupportedWallets() {
244
+ const wallets = Object.values(DefaultAdaptersInfo).map((provider) => {
245
+ {
246
+ return {
247
+ ...provider,
248
+ isInstalled: isProviderInstalled(provider.id)
249
+ };
250
+ }
251
+ });
252
+ return wallets;
253
+ }
254
+
255
+ // src/types.ts
256
+ var v2 = __toESM(require("valibot"));
257
+ var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
258
+ BitcoinNetworkType2["Mainnet"] = "Mainnet";
259
+ BitcoinNetworkType2["Testnet"] = "Testnet";
260
+ BitcoinNetworkType2["Signet"] = "Signet";
261
+ return BitcoinNetworkType2;
262
+ })(BitcoinNetworkType || {});
263
+ var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
264
+ var rpcRequestMessageSchema = v2.object({
265
+ jsonrpc: v2.literal("2.0"),
266
+ method: v2.string(),
267
+ params: v2.optional(
268
+ v2.union([
269
+ v2.array(v2.unknown()),
270
+ v2.looseObject({}),
271
+ // Note: This is to support current incorrect usage of RPC 2.0. Params need
272
+ // to be either an array or an object when provided. Changing this now would
273
+ // be a breaking change, so accepting null values for now. Tracking in
274
+ // https://linear.app/xverseapp/issue/ENG-4538.
275
+ v2.null()
276
+ ])
277
+ ),
278
+ id: v2.unwrap(RpcIdSchema)
279
+ });
280
+ var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
281
+ RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
282
+ RpcErrorCode2[RpcErrorCode2["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
283
+ RpcErrorCode2[RpcErrorCode2["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
284
+ RpcErrorCode2[RpcErrorCode2["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
285
+ RpcErrorCode2[RpcErrorCode2["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
286
+ RpcErrorCode2[RpcErrorCode2["USER_REJECTION"] = -32e3] = "USER_REJECTION";
287
+ RpcErrorCode2[RpcErrorCode2["METHOD_NOT_SUPPORTED"] = -32001] = "METHOD_NOT_SUPPORTED";
288
+ RpcErrorCode2[RpcErrorCode2["ACCESS_DENIED"] = -32002] = "ACCESS_DENIED";
289
+ return RpcErrorCode2;
290
+ })(RpcErrorCode || {});
291
+ var rpcSuccessResponseMessageSchema = v2.object({
292
+ jsonrpc: v2.literal("2.0"),
293
+ result: v2.nonOptional(v2.unknown()),
294
+ id: RpcIdSchema
295
+ });
296
+ var rpcErrorResponseMessageSchema = v2.object({
297
+ jsonrpc: v2.literal("2.0"),
298
+ error: v2.nonOptional(v2.unknown()),
299
+ id: RpcIdSchema
300
+ });
301
+ var rpcResponseMessageSchema = v2.union([
302
+ rpcSuccessResponseMessageSchema,
303
+ rpcErrorResponseMessageSchema
304
+ ]);
305
+
306
+ // src/request/index.ts
307
+ var v20 = __toESM(require("valibot"));
308
+
309
+ // src/request/types/stxMethods/callContract.ts
310
+ var v3 = __toESM(require("valibot"));
311
+ var stxCallContractMethodName = "stx_callContract";
312
+ var stxCallContractParamsSchema = v3.object({
313
+ /**
314
+ * The contract principal.
315
+ *
316
+ * E.g. `"SPKE...GD5C.my-contract"`
317
+ */
318
+ contract: v3.string(),
319
+ /**
320
+ * The name of the function to call.
321
+ *
322
+ * Note: spec changes ongoing,
323
+ * https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
324
+ */
325
+ functionName: v3.string(),
326
+ /**
327
+ * The function's arguments. The arguments are expected to be hex-encoded
328
+ * strings of Clarity values.
329
+ *
330
+ * To convert Clarity values to their hex representation, the `cvToString`
331
+ * helper from the `@stacks/transactions` package may be helpful.
332
+ *
333
+ * ```js
334
+ * import { cvToString } from '@stacks/transactions';
335
+ *
336
+ * const functionArgs = [someClarityValue1, someClarityValue2];
337
+ * const hexArgs = functionArgs.map(cvToString);
338
+ * ```
339
+ */
340
+ arguments: v3.optional(v3.array(v3.string()))
341
+ });
342
+ var stxCallContractResultSchema = v3.object({
343
+ /**
344
+ * The ID of the transaction.
345
+ */
346
+ txid: v3.string(),
347
+ /**
348
+ * A Stacks transaction as a hex-encoded string.
349
+ */
350
+ transaction: v3.string()
351
+ });
352
+ var stxCallContractRequestMessageSchema = v3.object({
353
+ ...rpcRequestMessageSchema.entries,
354
+ ...v3.object({
355
+ method: v3.literal(stxCallContractMethodName),
356
+ params: stxCallContractParamsSchema,
357
+ id: v3.string()
358
+ }).entries
359
+ });
360
+
361
+ // src/request/types/stxMethods/deployContract.ts
362
+ var v4 = __toESM(require("valibot"));
363
+ var stxDeployContractMethodName = "stx_deployContract";
364
+ var stxDeployContractParamsSchema = v4.object({
365
+ /**
366
+ * Name of the contract.
367
+ */
368
+ name: v4.string(),
369
+ /**
370
+ * The source code of the Clarity contract.
371
+ */
372
+ clarityCode: v4.string(),
373
+ /**
374
+ * The version of the Clarity contract.
375
+ */
376
+ clarityVersion: v4.optional(v4.string())
377
+ });
378
+ var stxDeployContractResultSchema = v4.object({
379
+ /**
380
+ * The ID of the transaction.
381
+ */
382
+ txid: v4.string(),
383
+ /**
384
+ * A Stacks transaction as a hex-encoded string.
385
+ */
386
+ transaction: v4.string()
387
+ });
388
+ var stxDeployContractRequestMessageSchema = v4.object({
389
+ ...rpcRequestMessageSchema.entries,
390
+ ...v4.object({
391
+ method: v4.literal(stxDeployContractMethodName),
392
+ params: stxDeployContractParamsSchema,
393
+ id: v4.string()
394
+ }).entries
395
+ });
396
+
397
+ // src/request/types/stxMethods/getAccounts.ts
398
+ var v5 = __toESM(require("valibot"));
399
+ var stxGetAccountsMethodName = "stx_getAccounts";
400
+ var stxGetAccountsParamsSchema = v5.nullish(v5.null());
401
+ var stxGetAccountsResultSchema = v5.object({
402
+ /**
403
+ * The addresses generated for the given purposes.
404
+ */
405
+ addresses: v5.array(
406
+ v5.object({
407
+ address: v5.string(),
408
+ publicKey: v5.string(),
409
+ gaiaHubUrl: v5.string(),
410
+ gaiaAppKey: v5.string()
411
+ })
412
+ )
413
+ });
414
+ var stxGetAccountsRequestMessageSchema = v5.object({
415
+ ...rpcRequestMessageSchema.entries,
416
+ ...v5.object({
417
+ method: v5.literal(stxGetAccountsMethodName),
418
+ params: stxGetAccountsParamsSchema,
419
+ id: v5.string()
420
+ }).entries
421
+ });
422
+
423
+ // src/addresses/index.ts
424
+ var import_jsontokens = require("jsontokens");
425
+
426
+ // src/addresses/types.ts
427
+ var v6 = __toESM(require("valibot"));
428
+ var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
429
+ AddressPurpose2["Ordinals"] = "ordinals";
430
+ AddressPurpose2["Payment"] = "payment";
431
+ AddressPurpose2["Stacks"] = "stacks";
432
+ return AddressPurpose2;
433
+ })(AddressPurpose || {});
434
+ var AddressType = /* @__PURE__ */ ((AddressType3) => {
435
+ AddressType3["p2pkh"] = "p2pkh";
436
+ AddressType3["p2sh"] = "p2sh";
437
+ AddressType3["p2wpkh"] = "p2wpkh";
438
+ AddressType3["p2wsh"] = "p2wsh";
439
+ AddressType3["p2tr"] = "p2tr";
440
+ AddressType3["stacks"] = "stacks";
441
+ return AddressType3;
442
+ })(AddressType || {});
443
+ var addressSchema = v6.object({
444
+ address: v6.string(),
445
+ publicKey: v6.string(),
446
+ purpose: v6.enum(AddressPurpose),
447
+ addressType: v6.enum(AddressType)
448
+ });
449
+
450
+ // src/addresses/index.ts
451
+ var getAddress = async (options) => {
452
+ const provider = await getProviderOrThrow(options.getProvider);
453
+ const { purposes } = options.payload;
454
+ if (!purposes) {
455
+ throw new Error("Address purposes are required");
456
+ }
457
+ try {
458
+ const request2 = (0, import_jsontokens.createUnsecuredToken)(options.payload);
459
+ const response = await provider.connect(request2);
460
+ options.onFinish?.(response);
461
+ } catch (error) {
462
+ console.error("[Connect] Error during address request", error);
463
+ options.onCancel?.();
464
+ }
465
+ };
466
+
467
+ // src/request/types/stxMethods/getAddresses.ts
468
+ var v7 = __toESM(require("valibot"));
469
+ var stxGetAddressesMethodName = "stx_getAddresses";
470
+ var stxGetAddressesParamsSchema = v7.nullish(
471
+ v7.object({
472
+ /**
473
+ * A message to be displayed to the user in the request prompt.
474
+ */
475
+ message: v7.optional(v7.string())
476
+ })
477
+ );
478
+ var stxGetAddressesResultSchema = v7.object({
479
+ /**
480
+ * The addresses generated for the given purposes.
481
+ */
482
+ addresses: v7.array(addressSchema)
483
+ });
484
+ var stxGetAddressesRequestMessageSchema = v7.object({
485
+ ...rpcRequestMessageSchema.entries,
486
+ ...v7.object({
487
+ method: v7.literal(stxGetAddressesMethodName),
488
+ params: stxGetAddressesParamsSchema,
489
+ id: v7.string()
490
+ }).entries
491
+ });
492
+
493
+ // src/request/types/stxMethods/signMessage.ts
494
+ var v8 = __toESM(require("valibot"));
495
+ var stxSignMessageMethodName = "stx_signMessage";
496
+ var stxSignMessageParamsSchema = v8.object({
497
+ /**
498
+ * The message to sign.
499
+ */
500
+ message: v8.string(),
501
+ /**
502
+ * The public key to sign the message with.
503
+ */
504
+ publicKey: v8.string(),
505
+ /**
506
+ * The format version of the parameter.
507
+ */
508
+ parameterFormatVersion: v8.optional(v8.number())
509
+ });
510
+ var stxSignMessageResultSchema = v8.object({
511
+ /**
512
+ * The signature of the message.
513
+ */
514
+ signature: v8.string(),
515
+ /**
516
+ * The public key used to sign the message.
517
+ */
518
+ publicKey: v8.string()
519
+ });
520
+ var stxSignMessageRequestMessageSchema = v8.object({
521
+ ...rpcRequestMessageSchema.entries,
522
+ ...v8.object({
523
+ method: v8.literal(stxSignMessageMethodName),
524
+ params: stxSignMessageParamsSchema,
525
+ id: v8.string()
526
+ }).entries
527
+ });
528
+
529
+ // src/request/types/stxMethods/signStructuredMessage.ts
530
+ var v9 = __toESM(require("valibot"));
531
+ var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
532
+ var stxSignStructuredMessageParamsSchema = v9.object({
533
+ /**
534
+ * The domain to be signed.
535
+ */
536
+ domain: v9.string(),
537
+ /**
538
+ * Message payload to be signed.
539
+ */
540
+ message: v9.string(),
541
+ /**
542
+ * The format version of the parameter.
543
+ */
544
+ parameterFormatVersion: v9.optional(v9.number()),
545
+ /**
546
+ * The public key to sign the message with.
547
+ */
548
+ publicKey: v9.optional(v9.string())
549
+ });
550
+ var stxSignStructuredMessageResultSchema = v9.object({
551
+ /**
552
+ * Signature of the message.
553
+ */
554
+ signature: v9.string(),
555
+ /**
556
+ * Public key as hex-encoded string.
557
+ */
558
+ publicKey: v9.string()
559
+ });
560
+ var stxSignStructuredMessageRequestMessageSchema = v9.object({
561
+ ...rpcRequestMessageSchema.entries,
562
+ ...v9.object({
563
+ method: v9.literal(stxSignStructuredMessageMethodName),
564
+ params: stxSignStructuredMessageParamsSchema,
565
+ id: v9.string()
566
+ }).entries
567
+ });
568
+
569
+ // src/request/types/stxMethods/signTransaction.ts
570
+ var v10 = __toESM(require("valibot"));
571
+ var stxSignTransactionMethodName = "stx_signTransaction";
572
+ var stxSignTransactionParamsSchema = v10.object({
573
+ /**
574
+ * The transaction to sign as a hex-encoded string.
575
+ */
576
+ transaction: v10.string(),
577
+ /**
578
+ * The public key to sign the transaction with. The wallet may use any key
579
+ * when not provided.
580
+ */
581
+ pubkey: v10.optional(v10.string()),
582
+ /**
583
+ * Whether to broadcast the transaction after signing. Defaults to `true`.
584
+ */
585
+ broadcast: v10.optional(v10.boolean())
586
+ });
587
+ var stxSignTransactionResultSchema = v10.object({
588
+ /**
589
+ * The signed transaction as a hex-encoded string.
590
+ */
591
+ transaction: v10.string()
592
+ });
593
+ var stxSignTransactionRequestMessageSchema = v10.object({
594
+ ...rpcRequestMessageSchema.entries,
595
+ ...v10.object({
596
+ method: v10.literal(stxSignTransactionMethodName),
597
+ params: stxSignTransactionParamsSchema,
598
+ id: v10.string()
599
+ }).entries
600
+ });
601
+
602
+ // src/request/types/stxMethods/transferStx.ts
603
+ var v11 = __toESM(require("valibot"));
604
+ var stxTransferStxMethodName = "stx_transferStx";
605
+ var stxTransferStxParamsSchema = v11.object({
606
+ /**
607
+ * Amount of STX tokens to transfer in microstacks as a string. Anything
608
+ * parseable by `BigInt` is acceptable.
609
+ *
610
+ * Example,
611
+ *
612
+ * ```js
613
+ * const amount1 = 1234;
614
+ * const amount2 = 1234n;
615
+ * const amount3 = '1234';
616
+ * ```
617
+ */
618
+ amount: v11.union([v11.number(), v11.string()]),
619
+ /**
620
+ * The recipeint's principal.
621
+ */
622
+ recipient: v11.string(),
623
+ /**
624
+ * A string representing the memo.
625
+ */
626
+ memo: v11.optional(v11.string()),
627
+ /**
628
+ * Version of parameter format.
629
+ */
630
+ version: v11.optional(v11.string()),
631
+ /**
632
+ * The mode of the post conditions.
633
+ */
634
+ postConditionMode: v11.optional(v11.number()),
635
+ /**
636
+ * A hex-encoded string representing the post conditions.
637
+ *
638
+ * A post condition may be converted to it's hex representation using the `serializePostCondition` helper from the `@stacks/transactions` package,
639
+ *
640
+ * ```js
641
+ * import { serializePostCondition } from '@stacks/transactions';
642
+ *
643
+ * const postCondition = somePostCondition;
644
+ * const hexPostCondition = serializePostCondition(postCondition).toString('hex');
645
+ * ```
646
+ */
647
+ postConditions: v11.optional(v11.array(v11.string())),
648
+ /**
649
+ * The public key to sign the transaction with. The wallet may use any key
650
+ * when not provided.
651
+ */
652
+ pubkey: v11.optional(v11.string())
653
+ });
654
+ var stxTransferStxResultSchema = v11.object({
655
+ /**
656
+ * The ID of the transaction.
657
+ */
658
+ txid: v11.string(),
659
+ /**
660
+ * A Stacks transaction as a hex-encoded string.
661
+ */
662
+ transaction: v11.string()
663
+ });
664
+ var stxTransferStxRequestMessageSchema = v11.object({
665
+ ...rpcRequestMessageSchema.entries,
666
+ ...v11.object({
667
+ method: v11.literal(stxTransferStxMethodName),
668
+ params: stxTransferStxParamsSchema,
669
+ id: v11.string()
670
+ }).entries
671
+ });
672
+
673
+ // src/request/types/btcMethods.ts
674
+ var v13 = __toESM(require("valibot"));
675
+
676
+ // src/request/types/common.ts
677
+ var v12 = __toESM(require("valibot"));
678
+ var walletTypes = ["software", "ledger"];
679
+ var walletTypeSchema = v12.picklist(walletTypes);
680
+
681
+ // src/request/types/btcMethods.ts
682
+ var getInfoMethodName = "getInfo";
683
+ var getInfoParamsSchema = v13.nullish(v13.null());
684
+ var getInfoResultSchema = v13.object({
685
+ /**
686
+ * Version of the wallet.
687
+ */
688
+ version: v13.string(),
689
+ /**
690
+ * [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
691
+ */
692
+ methods: v13.optional(v13.array(v13.string())),
693
+ /**
694
+ * List of WBIP standards supported by the wallet. Not currently used.
695
+ */
696
+ supports: v13.array(v13.string())
697
+ });
698
+ var getInfoRequestMessageSchema = v13.object({
699
+ ...rpcRequestMessageSchema.entries,
700
+ ...v13.object({
701
+ method: v13.literal(getInfoMethodName),
702
+ params: getInfoParamsSchema,
703
+ id: v13.string()
704
+ }).entries
705
+ });
706
+ var getAddressesMethodName = "getAddresses";
707
+ var getAddressesParamsSchema = v13.object({
708
+ /**
709
+ * The purposes for which to generate addresses. See
710
+ * {@linkcode AddressPurpose} for available purposes.
711
+ */
712
+ purposes: v13.array(v13.enum(AddressPurpose)),
713
+ /**
714
+ * A message to be displayed to the user in the request prompt.
715
+ */
716
+ message: v13.optional(v13.string())
717
+ });
718
+ var getAddressesResultSchema = v13.object({
719
+ /**
720
+ * The addresses generated for the given purposes.
721
+ */
722
+ addresses: v13.array(addressSchema)
723
+ });
724
+ var getAddressesRequestMessageSchema = v13.object({
725
+ ...rpcRequestMessageSchema.entries,
726
+ ...v13.object({
727
+ method: v13.literal(getAddressesMethodName),
728
+ params: getAddressesParamsSchema,
729
+ id: v13.string()
730
+ }).entries
731
+ });
732
+ var signMessageMethodName = "signMessage";
733
+ var MessageSigningProtocols = /* @__PURE__ */ ((MessageSigningProtocols2) => {
734
+ MessageSigningProtocols2["ECDSA"] = "ECDSA";
735
+ MessageSigningProtocols2["BIP322"] = "BIP322";
736
+ return MessageSigningProtocols2;
737
+ })(MessageSigningProtocols || {});
738
+ var signMessageParamsSchema = v13.object({
739
+ /**
740
+ * The address used for signing.
741
+ **/
742
+ address: v13.string(),
743
+ /**
744
+ * The message to sign.
745
+ **/
746
+ message: v13.string(),
747
+ /**
748
+ * The protocol to use for signing the message.
749
+ */
750
+ protocol: v13.optional(v13.enum(MessageSigningProtocols))
751
+ });
752
+ var signMessageResultSchema = v13.object({
753
+ /**
754
+ * The signature of the message.
755
+ */
756
+ signature: v13.string(),
757
+ /**
758
+ * hash of the message.
759
+ */
760
+ messageHash: v13.string(),
761
+ /**
762
+ * The address used for signing.
763
+ */
764
+ address: v13.string(),
765
+ /**
766
+ * The protocol to use for signing the message.
767
+ */
768
+ protocol: v13.enum(MessageSigningProtocols)
769
+ });
770
+ var signMessageRequestMessageSchema = v13.object({
771
+ ...rpcRequestMessageSchema.entries,
772
+ ...v13.object({
773
+ method: v13.literal(signMessageMethodName),
774
+ params: signMessageParamsSchema,
775
+ id: v13.string()
776
+ }).entries
777
+ });
778
+ var sendTransferMethodName = "sendTransfer";
779
+ var sendTransferParamsSchema = v13.object({
780
+ /**
781
+ * Array of recipients to send to.
782
+ * The amount to send to each recipient is in satoshis.
783
+ */
784
+ recipients: v13.array(
785
+ v13.object({
786
+ address: v13.string(),
787
+ amount: v13.number()
788
+ })
789
+ )
790
+ });
791
+ var sendTransferResultSchema = v13.object({
792
+ /**
793
+ * The transaction id as a hex-encoded string.
794
+ */
795
+ txid: v13.string()
796
+ });
797
+ var sendTransferRequestMessageSchema = v13.object({
798
+ ...rpcRequestMessageSchema.entries,
799
+ ...v13.object({
800
+ method: v13.literal(sendTransferMethodName),
801
+ params: sendTransferParamsSchema,
802
+ id: v13.string()
803
+ }).entries
804
+ });
805
+ var signPsbtMethodName = "signPsbt";
806
+ var signPsbtParamsSchema = v13.object({
807
+ /**
808
+ * The base64 encoded PSBT to sign.
809
+ */
810
+ psbt: v13.string(),
811
+ /**
812
+ * The inputs to sign.
813
+ * The key is the address and the value is an array of indexes of the inputs to sign.
814
+ */
815
+ signInputs: v13.record(v13.string(), v13.array(v13.number())),
816
+ /**
817
+ * Whether to broadcast the transaction after signing.
818
+ **/
819
+ broadcast: v13.optional(v13.boolean())
820
+ });
821
+ var signPsbtResultSchema = v13.object({
822
+ /**
823
+ * The base64 encoded PSBT after signing.
824
+ */
825
+ psbt: v13.string(),
826
+ /**
827
+ * The transaction id as a hex-encoded string.
828
+ * This is only returned if the transaction was broadcast.
829
+ **/
830
+ txid: v13.optional(v13.string())
831
+ });
832
+ var signPsbtRequestMessageSchema = v13.object({
833
+ ...rpcRequestMessageSchema.entries,
834
+ ...v13.object({
835
+ method: v13.literal(signPsbtMethodName),
836
+ params: signPsbtParamsSchema,
837
+ id: v13.string()
838
+ }).entries
839
+ });
840
+ var getAccountsMethodName = "getAccounts";
841
+ var getAccountsParamsSchema = v13.object({
842
+ /**
843
+ * The purposes for which to generate addresses. See
844
+ * {@linkcode AddressPurpose} for available purposes.
845
+ */
846
+ purposes: v13.array(v13.enum(AddressPurpose)),
847
+ /**
848
+ * A message to be displayed to the user in the request prompt.
849
+ */
850
+ message: v13.optional(v13.string())
851
+ });
852
+ var getAccountsResultSchema = v13.array(
853
+ v13.object({
854
+ ...addressSchema.entries,
855
+ ...v13.object({
856
+ walletType: walletTypeSchema
857
+ }).entries
858
+ })
859
+ );
860
+ var getAccountsRequestMessageSchema = v13.object({
861
+ ...rpcRequestMessageSchema.entries,
862
+ ...v13.object({
863
+ method: v13.literal(getAccountsMethodName),
864
+ params: getAccountsParamsSchema,
865
+ id: v13.string()
866
+ }).entries
867
+ });
868
+ var getBalanceMethodName = "getBalance";
869
+ var getBalanceParamsSchema = v13.nullish(v13.null());
870
+ var getBalanceResultSchema = v13.object({
871
+ /**
872
+ * The confirmed balance of the wallet in sats. Using a string due to chrome
873
+ * messages not supporting bigint
874
+ * (https://issues.chromium.org/issues/40116184).
875
+ */
876
+ confirmed: v13.string(),
877
+ /**
878
+ * The unconfirmed balance of the wallet in sats. Using a string due to chrome
879
+ * messages not supporting bigint
880
+ * (https://issues.chromium.org/issues/40116184).
881
+ */
882
+ unconfirmed: v13.string(),
883
+ /**
884
+ * The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
885
+ * sats. Using a string due to chrome messages not supporting bigint
886
+ * (https://issues.chromium.org/issues/40116184).
887
+ */
888
+ total: v13.string()
889
+ });
890
+ var getBalanceRequestMessageSchema = v13.object({
891
+ ...rpcRequestMessageSchema.entries,
892
+ ...v13.object({
893
+ method: v13.literal(getBalanceMethodName),
894
+ id: v13.string()
895
+ }).entries
896
+ });
897
+
898
+ // src/request/types/walletMethods.ts
899
+ var v14 = __toESM(require("valibot"));
900
+ var accountActionsSchema = v14.object({
901
+ read: v14.optional(v14.boolean())
902
+ });
903
+ var walletActionsSchema = v14.object({});
904
+ var accountPermissionSchema = v14.object({
905
+ type: v14.literal("account"),
906
+ resourceId: v14.string(),
907
+ clientId: v14.string(),
908
+ actions: accountActionsSchema
909
+ });
910
+ var walletPermissionSchema = v14.object({
911
+ type: v14.literal("wallet"),
912
+ resourceId: v14.string(),
913
+ clientId: v14.string(),
914
+ actions: walletActionsSchema
915
+ });
916
+ var PermissionRequestParams = v14.variant("type", [
917
+ v14.object({
918
+ ...v14.omit(accountPermissionSchema, ["clientId"]).entries
919
+ }),
920
+ v14.object({
921
+ ...v14.omit(walletPermissionSchema, ["clientId"]).entries
922
+ })
923
+ ]);
924
+ var permission = v14.variant("type", [accountPermissionSchema, walletPermissionSchema]);
925
+ var requestPermissionsMethodName = "wallet_requestPermissions";
926
+ var requestPermissionsParamsSchema = v14.nullish(v14.array(PermissionRequestParams));
927
+ var requestPermissionsResultSchema = v14.literal(true);
928
+ var requestPermissionsRequestMessageSchema = v14.object({
929
+ ...rpcRequestMessageSchema.entries,
930
+ ...v14.object({
931
+ method: v14.literal(requestPermissionsMethodName),
932
+ params: requestPermissionsParamsSchema,
933
+ id: v14.string()
934
+ }).entries
935
+ });
936
+ var renouncePermissionsMethodName = "wallet_renouncePermissions";
937
+ var renouncePermissionsParamsSchema = v14.nullish(v14.null());
938
+ var renouncePermissionsResultSchema = v14.nullish(v14.null());
939
+ var renouncePermissionsRequestMessageSchema = v14.object({
940
+ ...rpcRequestMessageSchema.entries,
941
+ ...v14.object({
942
+ method: v14.literal(renouncePermissionsMethodName),
943
+ params: renouncePermissionsParamsSchema,
944
+ id: v14.string()
945
+ }).entries
946
+ });
947
+ var disconnectMethodName = "wallet_disconnect";
948
+ var disconnectParamsSchema = v14.nullish(v14.null());
949
+ var disconnectResultSchema = v14.nullish(v14.null());
950
+ var disconnectRequestMessageSchema = v14.object({
951
+ ...rpcRequestMessageSchema.entries,
952
+ ...v14.object({
953
+ method: v14.literal(disconnectMethodName),
954
+ params: disconnectParamsSchema,
955
+ id: v14.string()
956
+ }).entries
957
+ });
958
+ var getWalletTypeMethodName = "wallet_getWalletType";
959
+ var getWalletTypeParamsSchema = v14.nullish(v14.null());
960
+ var getWalletTypeResultSchema = walletTypeSchema;
961
+ var getWalletTypeRequestMessageSchema = v14.object({
962
+ ...rpcRequestMessageSchema.entries,
963
+ ...v14.object({
964
+ method: v14.literal(getWalletTypeMethodName),
965
+ params: getWalletTypeParamsSchema,
966
+ id: v14.string()
967
+ }).entries
968
+ });
969
+ var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
970
+ var getCurrentPermissionsParamsSchema = v14.nullish(v14.null());
971
+ var getCurrentPermissionsResultSchema = v14.array(permission);
972
+ var getCurrentPermissionsRequestMessageSchema = v14.object({
973
+ ...rpcRequestMessageSchema.entries,
974
+ ...v14.object({
975
+ method: v14.literal(getCurrentPermissionsMethodName),
976
+ params: getCurrentPermissionsParamsSchema,
977
+ id: v14.string()
978
+ }).entries
979
+ });
980
+ var getAccountMethodName = "wallet_getAccount";
981
+ var getAccountParamsSchema = v14.nullish(v14.null());
982
+ var getAccountResultSchema = v14.object({
983
+ id: v14.string(),
984
+ addresses: v14.array(addressSchema),
985
+ walletType: walletTypeSchema
986
+ });
987
+ var getAccountRequestMessageSchema = v14.object({
988
+ ...rpcRequestMessageSchema.entries,
989
+ ...v14.object({
990
+ method: v14.literal(getAccountMethodName),
991
+ params: getAccountParamsSchema,
992
+ id: v14.string()
993
+ }).entries
994
+ });
995
+ var connectMethodName = "wallet_connect";
996
+ var connectParamsSchema = v14.nullish(
997
+ v14.object({
998
+ permissions: v14.optional(v14.array(PermissionRequestParams)),
999
+ addresses: v14.optional(v14.array(v14.enum(AddressPurpose))),
1000
+ message: v14.optional(
1001
+ v14.pipe(v14.string(), v14.maxLength(80, "The message must not exceed 80 characters."))
1002
+ )
1003
+ })
1004
+ );
1005
+ var connectResultSchema = getAccountResultSchema;
1006
+ var connectRequestMessageSchema = v14.object({
1007
+ ...rpcRequestMessageSchema.entries,
1008
+ ...v14.object({
1009
+ method: v14.literal(connectMethodName),
1010
+ params: connectParamsSchema,
1011
+ id: v14.string()
1012
+ }).entries
1013
+ });
1014
+
1015
+ // src/request/types/runesMethods/etch.ts
1016
+ var v15 = __toESM(require("valibot"));
1017
+ var runesEtchMethodName = "runes_etch";
1018
+ var etchTermsSchema = v15.object({
1019
+ amount: v15.string(),
1020
+ cap: v15.string(),
1021
+ heightStart: v15.optional(v15.string()),
1022
+ heightEnd: v15.optional(v15.string()),
1023
+ offsetStart: v15.optional(v15.string()),
1024
+ offsetEnd: v15.optional(v15.string())
1025
+ });
1026
+ var inscriptionDetailsSchema = v15.object({
1027
+ contentType: v15.string(),
1028
+ contentBase64: v15.string()
1029
+ });
1030
+ var runesEtchParamsSchema = v15.object({
1031
+ runeName: v15.string(),
1032
+ divisibility: v15.optional(v15.number()),
1033
+ symbol: v15.optional(v15.string()),
1034
+ premine: v15.optional(v15.string()),
1035
+ isMintable: v15.boolean(),
1036
+ delegateInscriptionId: v15.optional(v15.string()),
1037
+ destinationAddress: v15.string(),
1038
+ refundAddress: v15.string(),
1039
+ feeRate: v15.number(),
1040
+ appServiceFee: v15.optional(v15.number()),
1041
+ appServiceFeeAddress: v15.optional(v15.string()),
1042
+ terms: v15.optional(etchTermsSchema),
1043
+ inscriptionDetails: v15.optional(inscriptionDetailsSchema),
1044
+ network: v15.optional(v15.enum(BitcoinNetworkType))
1045
+ });
1046
+ var runesEtchResultSchema = v15.object({
1047
+ orderId: v15.string(),
1048
+ fundTransactionId: v15.string(),
1049
+ fundingAddress: v15.string()
1050
+ });
1051
+ var runesEtchRequestMessageSchema = v15.object({
1052
+ ...rpcRequestMessageSchema.entries,
1053
+ ...v15.object({
1054
+ method: v15.literal(runesEtchMethodName),
1055
+ params: runesEtchParamsSchema,
1056
+ id: v15.string()
1057
+ }).entries
1058
+ });
1059
+
1060
+ // src/request/types/runesMethods/getBalance.ts
1061
+ var v16 = __toESM(require("valibot"));
1062
+ var runesGetBalanceMethodName = "runes_getBalance";
1063
+ var runesGetBalanceParamsSchema = v16.nullish(v16.null());
1064
+ var runesGetBalanceResultSchema = v16.object({
1065
+ balances: v16.array(
1066
+ v16.object({
1067
+ runeName: v16.string(),
1068
+ amount: v16.string(),
1069
+ divisibility: v16.number(),
1070
+ symbol: v16.string(),
1071
+ inscriptionId: v16.nullish(v16.string())
1072
+ })
1073
+ )
1074
+ });
1075
+ var runesGetBalanceRequestMessageSchema = v16.object({
1076
+ ...rpcRequestMessageSchema.entries,
1077
+ ...v16.object({
1078
+ method: v16.literal(runesGetBalanceMethodName),
1079
+ params: runesGetBalanceParamsSchema,
1080
+ id: v16.string()
1081
+ }).entries
1082
+ });
1083
+
1084
+ // src/request/types/runesMethods/mint.ts
1085
+ var v17 = __toESM(require("valibot"));
1086
+ var runesMintMethodName = "runes_mint";
1087
+ var runesMintParamsSchema = v17.object({
1088
+ appServiceFee: v17.optional(v17.number()),
1089
+ appServiceFeeAddress: v17.optional(v17.string()),
1090
+ destinationAddress: v17.string(),
1091
+ feeRate: v17.number(),
1092
+ refundAddress: v17.string(),
1093
+ repeats: v17.number(),
1094
+ runeName: v17.string(),
1095
+ network: v17.optional(v17.enum(BitcoinNetworkType))
1096
+ });
1097
+ var runesMintResultSchema = v17.object({
1098
+ orderId: v17.string(),
1099
+ fundTransactionId: v17.string(),
1100
+ fundingAddress: v17.string()
1101
+ });
1102
+ var runesMintRequestMessageSchema = v17.object({
1103
+ ...rpcRequestMessageSchema.entries,
1104
+ ...v17.object({
1105
+ method: v17.literal(runesMintMethodName),
1106
+ params: runesMintParamsSchema,
1107
+ id: v17.string()
1108
+ }).entries
1109
+ });
1110
+
1111
+ // src/request/types/runesMethods/transfer.ts
1112
+ var v18 = __toESM(require("valibot"));
1113
+ var runesTransferMethodName = "runes_transfer";
1114
+ var runesTransferParamsSchema = v18.object({
1115
+ recipients: v18.array(
1116
+ v18.object({
1117
+ runeName: v18.string(),
1118
+ amount: v18.string(),
1119
+ address: v18.string()
1120
+ })
1121
+ )
1122
+ });
1123
+ var runesTransferResultSchema = v18.object({
1124
+ txid: v18.string()
1125
+ });
1126
+ var runesTransferRequestMessageSchema = v18.object({
1127
+ ...rpcRequestMessageSchema.entries,
1128
+ ...v18.object({
1129
+ method: v18.literal(runesTransferMethodName),
1130
+ params: runesTransferParamsSchema,
1131
+ id: v18.string()
1132
+ }).entries
1133
+ });
1134
+
1135
+ // src/request/types/ordinalsMethods.ts
1136
+ var v19 = __toESM(require("valibot"));
1137
+ var getInscriptionsMethodName = "ord_getInscriptions";
1138
+ var getInscriptionsParamsSchema = v19.object({
1139
+ offset: v19.number(),
1140
+ limit: v19.number()
1141
+ });
1142
+ var getInscriptionsResultSchema = v19.object({
1143
+ total: v19.number(),
1144
+ limit: v19.number(),
1145
+ offset: v19.number(),
1146
+ inscriptions: v19.array(
1147
+ v19.object({
1148
+ inscriptionId: v19.string(),
1149
+ inscriptionNumber: v19.string(),
1150
+ address: v19.string(),
1151
+ collectionName: v19.optional(v19.string()),
1152
+ postage: v19.string(),
1153
+ contentLength: v19.string(),
1154
+ contentType: v19.string(),
1155
+ timestamp: v19.number(),
1156
+ offset: v19.number(),
1157
+ genesisTransaction: v19.string(),
1158
+ output: v19.string()
1159
+ })
1160
+ )
1161
+ });
1162
+ var getInscriptionsRequestMessageSchema = v19.object({
1163
+ ...rpcRequestMessageSchema.entries,
1164
+ ...v19.object({
1165
+ method: v19.literal(getInscriptionsMethodName),
1166
+ params: getInscriptionsParamsSchema,
1167
+ id: v19.string()
1168
+ }).entries
1169
+ });
1170
+ var sendInscriptionsMethodName = "ord_sendInscriptions";
1171
+ var sendInscriptionsParamsSchema = v19.object({
1172
+ transfers: v19.array(
1173
+ v19.object({
1174
+ address: v19.string(),
1175
+ inscriptionId: v19.string()
1176
+ })
1177
+ )
1178
+ });
1179
+ var sendInscriptionsResultSchema = v19.object({
1180
+ txid: v19.string()
1181
+ });
1182
+ var sendInscriptionsRequestMessageSchema = v19.object({
1183
+ ...rpcRequestMessageSchema.entries,
1184
+ ...v19.object({
1185
+ method: v19.literal(sendInscriptionsMethodName),
1186
+ params: sendInscriptionsParamsSchema,
1187
+ id: v19.string()
1188
+ }).entries
1189
+ });
1190
+
1191
+ // src/request/index.ts
1192
+ var request = async (method, params, providerId) => {
1193
+ let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
1194
+ if (providerId) {
1195
+ provider = await getProviderById(providerId);
1196
+ }
1197
+ if (!provider) {
1198
+ throw new Error("no wallet provider was found");
1199
+ }
1200
+ if (!method) {
1201
+ throw new Error("A wallet method is required");
1202
+ }
1203
+ const response = await provider.request(method, params);
1204
+ if (v20.is(rpcErrorResponseMessageSchema, response)) {
1205
+ return {
1206
+ status: "error",
1207
+ error: response.error
1208
+ };
1209
+ }
1210
+ if (v20.is(rpcSuccessResponseMessageSchema, response)) {
1211
+ return {
1212
+ status: "success",
1213
+ result: response.result
1214
+ };
1215
+ }
1216
+ return {
1217
+ status: "error",
1218
+ error: {
1219
+ code: -32603 /* INTERNAL_ERROR */,
1220
+ message: "Received unknown response from provider.",
1221
+ data: response
1222
+ }
1223
+ };
1224
+ };
1225
+ var addListener = (event, cb, providerId) => {
1226
+ let provider = window.XverseProviders?.BitcoinProvider || window.BitcoinProvider;
1227
+ if (providerId) {
1228
+ provider = getProviderById(providerId);
1229
+ }
1230
+ if (!provider) {
1231
+ throw new Error("no wallet provider was found");
1232
+ }
1233
+ if (!provider.addListener) {
1234
+ console.error(
1235
+ `The wallet provider you are using does not support the addListener method. Please update your wallet provider.`
1236
+ );
1237
+ return () => {
1238
+ };
1239
+ }
1240
+ return provider.addListener(event, cb);
1241
+ };
1242
+
1243
+ // src/runes/api.ts
1244
+ var import_axios = __toESM(require("axios"));
1245
+ var urlNetworkSuffix = {
1246
+ ["Mainnet" /* Mainnet */]: "",
1247
+ ["Testnet" /* Testnet */]: "-testnet",
1248
+ ["Signet" /* Signet */]: "-signet"
1249
+ };
1250
+ var ORDINALS_API_BASE_URL = (network = "Mainnet" /* Mainnet */) => `https://ordinals${urlNetworkSuffix[network]}.xverse.app/v1`;
1251
+ var RunesApi = class {
1252
+ client;
1253
+ constructor(network) {
1254
+ this.client = import_axios.default.create({
1255
+ baseURL: ORDINALS_API_BASE_URL(network)
1256
+ });
1257
+ }
1258
+ parseError = (error) => {
1259
+ return {
1260
+ code: error.response?.status,
1261
+ message: JSON.stringify(error.response?.data)
1262
+ };
1263
+ };
1264
+ estimateMintCost = async (mintParams) => {
1265
+ try {
1266
+ const response = await this.client.post("/runes/mint/estimate", {
1267
+ ...mintParams
1268
+ });
1269
+ return {
1270
+ data: response.data
1271
+ };
1272
+ } catch (error) {
1273
+ const err = error;
1274
+ return {
1275
+ error: this.parseError(err)
1276
+ };
1277
+ }
1278
+ };
1279
+ estimateEtchCost = async (etchParams) => {
1280
+ try {
1281
+ const response = await this.client.post("/runes/etch/estimate", {
1282
+ ...etchParams
1283
+ });
1284
+ return {
1285
+ data: response.data
1286
+ };
1287
+ } catch (error) {
1288
+ const err = error;
1289
+ return {
1290
+ error: this.parseError(err)
1291
+ };
1292
+ }
1293
+ };
1294
+ createMintOrder = async (mintOrderParams) => {
1295
+ try {
1296
+ const response = await this.client.post("/runes/mint/orders", {
1297
+ ...mintOrderParams
1298
+ });
1299
+ return {
1300
+ data: response.data
1301
+ };
1302
+ } catch (error) {
1303
+ const err = error;
1304
+ return {
1305
+ error: this.parseError(err)
1306
+ };
1307
+ }
1308
+ };
1309
+ createEtchOrder = async (etchOrderParams) => {
1310
+ try {
1311
+ const response = await this.client.post("/runes/etch/orders", {
1312
+ ...etchOrderParams
1313
+ });
1314
+ return {
1315
+ data: response.data
1316
+ };
1317
+ } catch (error) {
1318
+ const err = error;
1319
+ return {
1320
+ error: this.parseError(err)
1321
+ };
1322
+ }
1323
+ };
1324
+ executeMint = async (orderId, fundTransactionId) => {
1325
+ try {
1326
+ const response = await this.client.post(`/runes/mint/orders/${orderId}/execute`, {
1327
+ fundTransactionId
1328
+ });
1329
+ return {
1330
+ data: response.data
1331
+ };
1332
+ } catch (error) {
1333
+ const err = error;
1334
+ return {
1335
+ error: this.parseError(err)
1336
+ };
1337
+ }
1338
+ };
1339
+ executeEtch = async (orderId, fundTransactionId) => {
1340
+ try {
1341
+ const response = await this.client.post(`/runes/etch/orders/${orderId}/execute`, {
1342
+ fundTransactionId
1343
+ });
1344
+ return {
1345
+ data: response.data
1346
+ };
1347
+ } catch (error) {
1348
+ const err = error;
1349
+ return {
1350
+ error: this.parseError(err)
1351
+ };
1352
+ }
1353
+ };
1354
+ getOrder = async (orderId) => {
1355
+ try {
1356
+ const response = await this.client.get(`/orders/${orderId}`);
1357
+ return {
1358
+ data: response.data
1359
+ };
1360
+ } catch (error) {
1361
+ const err = error;
1362
+ return {
1363
+ error: this.parseError(err)
1364
+ };
1365
+ }
1366
+ };
1367
+ rbfOrder = async (rbfRequest) => {
1368
+ const { orderId, newFeeRate } = rbfRequest;
1369
+ try {
1370
+ const response = await this.client.post(`/orders/${orderId}/rbf-estimate`, {
1371
+ newFeeRate
1372
+ });
1373
+ return {
1374
+ data: response.data
1375
+ };
1376
+ } catch (error) {
1377
+ const err = error;
1378
+ return {
1379
+ error: this.parseError(err)
1380
+ };
1381
+ }
1382
+ };
1383
+ };
1384
+ var clients = {};
1385
+ var getRunesApiClient = (network = "Mainnet" /* Mainnet */) => {
1386
+ if (!clients[network]) {
1387
+ clients[network] = new RunesApi(network);
1388
+ }
1389
+ return clients[network];
1390
+ };
1391
+
1392
+ // src/adapters/satsConnectAdapter.ts
1393
+ var SatsConnectAdapter = class {
1394
+ async mintRunes(params) {
1395
+ try {
1396
+ const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
1397
+ if (walletInfo && walletInfo.status === "success") {
1398
+ const isMintSupported = walletInfo.result.methods?.includes("runes_mint");
1399
+ if (isMintSupported) {
1400
+ const response = await this.requestInternal("runes_mint", params);
1401
+ if (response) {
1402
+ if (response.status === "success") {
1403
+ return response;
1404
+ }
1405
+ if (response.status === "error" && response.error.code !== -32601 /* METHOD_NOT_FOUND */) {
1406
+ return response;
1407
+ }
1408
+ }
1409
+ }
1410
+ }
1411
+ const mintRequest = {
1412
+ destinationAddress: params.destinationAddress,
1413
+ feeRate: params.feeRate,
1414
+ refundAddress: params.refundAddress,
1415
+ repeats: params.repeats,
1416
+ runeName: params.runeName,
1417
+ appServiceFee: params.appServiceFee,
1418
+ appServiceFeeAddress: params.appServiceFeeAddress
1419
+ };
1420
+ const orderResponse = await new RunesApi(params.network).createMintOrder(mintRequest);
1421
+ if (!orderResponse.data) {
1422
+ return {
1423
+ status: "error",
1424
+ error: {
1425
+ code: orderResponse.error.code === 400 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
1426
+ message: orderResponse.error.message
1427
+ }
1428
+ };
1429
+ }
1430
+ const paymentResponse = await this.requestInternal("sendTransfer", {
1431
+ recipients: [
1432
+ {
1433
+ address: orderResponse.data.fundAddress,
1434
+ amount: orderResponse.data.fundAmount
1435
+ }
1436
+ ]
1437
+ });
1438
+ if (paymentResponse.status !== "success") {
1439
+ return paymentResponse;
1440
+ }
1441
+ await new RunesApi(params.network).executeMint(
1442
+ orderResponse.data.orderId,
1443
+ paymentResponse.result.txid
1444
+ );
1445
+ return {
1446
+ status: "success",
1447
+ result: {
1448
+ orderId: orderResponse.data.orderId,
1449
+ fundTransactionId: paymentResponse.result.txid,
1450
+ fundingAddress: orderResponse.data.fundAddress
1451
+ }
1452
+ };
1453
+ } catch (error) {
1454
+ return {
1455
+ status: "error",
1456
+ error: {
1457
+ code: -32603 /* INTERNAL_ERROR */,
1458
+ message: error.message
1459
+ }
1460
+ };
1461
+ }
1462
+ }
1463
+ async etchRunes(params) {
1464
+ const etchRequest = {
1465
+ destinationAddress: params.destinationAddress,
1466
+ refundAddress: params.refundAddress,
1467
+ feeRate: params.feeRate,
1468
+ runeName: params.runeName,
1469
+ divisibility: params.divisibility,
1470
+ symbol: params.symbol,
1471
+ premine: params.premine,
1472
+ isMintable: params.isMintable,
1473
+ terms: params.terms,
1474
+ inscriptionDetails: params.inscriptionDetails,
1475
+ delegateInscriptionId: params.delegateInscriptionId,
1476
+ appServiceFee: params.appServiceFee,
1477
+ appServiceFeeAddress: params.appServiceFeeAddress
1478
+ };
1479
+ try {
1480
+ const walletInfo = await this.requestInternal("getInfo", null).catch(() => null);
1481
+ if (walletInfo && walletInfo.status === "success") {
1482
+ const isEtchSupported = walletInfo.result.methods?.includes("runes_etch");
1483
+ if (isEtchSupported) {
1484
+ const response = await this.requestInternal("runes_etch", params);
1485
+ if (response) {
1486
+ if (response.status === "success") {
1487
+ return response;
1488
+ }
1489
+ if (response.status === "error" && response.error.code !== -32601 /* METHOD_NOT_FOUND */) {
1490
+ return response;
1491
+ }
1492
+ }
1493
+ }
1494
+ }
1495
+ const orderResponse = await new RunesApi(params.network).createEtchOrder(etchRequest);
1496
+ if (!orderResponse.data) {
1497
+ return {
1498
+ status: "error",
1499
+ error: {
1500
+ code: orderResponse.error.code === 400 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
1501
+ message: orderResponse.error.message
1502
+ }
1503
+ };
1504
+ }
1505
+ const paymentResponse = await this.requestInternal("sendTransfer", {
1506
+ recipients: [
1507
+ {
1508
+ address: orderResponse.data.fundAddress,
1509
+ amount: orderResponse.data.fundAmount
1510
+ }
1511
+ ]
1512
+ });
1513
+ if (paymentResponse.status !== "success") {
1514
+ return paymentResponse;
1515
+ }
1516
+ await new RunesApi(params.network).executeEtch(
1517
+ orderResponse.data.orderId,
1518
+ paymentResponse.result.txid
1519
+ );
1520
+ return {
1521
+ status: "success",
1522
+ result: {
1523
+ orderId: orderResponse.data.orderId,
1524
+ fundTransactionId: paymentResponse.result.txid,
1525
+ fundingAddress: orderResponse.data.fundAddress
1526
+ }
1527
+ };
1528
+ } catch (error) {
1529
+ return {
1530
+ status: "error",
1531
+ error: {
1532
+ code: -32603 /* INTERNAL_ERROR */,
1533
+ message: error.message
1534
+ }
1535
+ };
1536
+ }
1537
+ }
1538
+ async estimateMint(params) {
1539
+ const estimateMintRequest = {
1540
+ destinationAddress: params.destinationAddress,
1541
+ feeRate: params.feeRate,
1542
+ repeats: params.repeats,
1543
+ runeName: params.runeName,
1544
+ appServiceFee: params.appServiceFee,
1545
+ appServiceFeeAddress: params.appServiceFeeAddress
1546
+ };
1547
+ const response = await getRunesApiClient(
1548
+ params.network
1549
+ ).estimateMintCost(estimateMintRequest);
1550
+ if (response.data) {
1551
+ return {
1552
+ status: "success",
1553
+ result: response.data
1554
+ };
1555
+ }
1556
+ return {
1557
+ status: "error",
1558
+ error: {
1559
+ code: response.error.code === 400 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
1560
+ message: response.error.message
1561
+ }
1562
+ };
1563
+ }
1564
+ async estimateEtch(params) {
1565
+ const estimateEtchRequest = {
1566
+ destinationAddress: params.destinationAddress,
1567
+ feeRate: params.feeRate,
1568
+ runeName: params.runeName,
1569
+ divisibility: params.divisibility,
1570
+ symbol: params.symbol,
1571
+ premine: params.premine,
1572
+ isMintable: params.isMintable,
1573
+ terms: params.terms,
1574
+ inscriptionDetails: params.inscriptionDetails,
1575
+ delegateInscriptionId: params.delegateInscriptionId,
1576
+ appServiceFee: params.appServiceFee,
1577
+ appServiceFeeAddress: params.appServiceFeeAddress
1578
+ };
1579
+ const response = await getRunesApiClient(params.network).estimateEtchCost(estimateEtchRequest);
1580
+ if (response.data) {
1581
+ return {
1582
+ status: "success",
1583
+ result: response.data
1584
+ };
1585
+ }
1586
+ return {
1587
+ status: "error",
1588
+ error: {
1589
+ code: response.error.code === 400 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
1590
+ message: response.error.message
1591
+ }
1592
+ };
1593
+ }
1594
+ async getOrder(params) {
1595
+ const response = await getRunesApiClient(params.network).getOrder(params.id);
1596
+ if (response.data) {
1597
+ return {
1598
+ status: "success",
1599
+ result: response.data
1600
+ };
1601
+ }
1602
+ return {
1603
+ status: "error",
1604
+ error: {
1605
+ code: response.error.code === 400 || response.error.code === 404 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
1606
+ message: response.error.message
1607
+ }
1608
+ };
1609
+ }
1610
+ async estimateRbfOrder(params) {
1611
+ const rbfOrderRequest = {
1612
+ newFeeRate: params.newFeeRate,
1613
+ orderId: params.orderId
1614
+ };
1615
+ const response = await getRunesApiClient(params.network).rbfOrder(rbfOrderRequest);
1616
+ if (response.data) {
1617
+ return {
1618
+ status: "success",
1619
+ result: {
1620
+ fundingAddress: response.data.fundingAddress,
1621
+ rbfCost: response.data.rbfCost
1622
+ }
1623
+ };
1624
+ }
1625
+ return {
1626
+ status: "error",
1627
+ error: {
1628
+ code: response.error.code === 400 || response.error.code === 404 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
1629
+ message: response.error.message
1630
+ }
1631
+ };
1632
+ }
1633
+ async rbfOrder(params) {
1634
+ try {
1635
+ const rbfOrderRequest = {
1636
+ newFeeRate: params.newFeeRate,
1637
+ orderId: params.orderId
1638
+ };
1639
+ const orderResponse = await getRunesApiClient(params.network).rbfOrder(rbfOrderRequest);
1640
+ if (!orderResponse.data) {
1641
+ return {
1642
+ status: "error",
1643
+ error: {
1644
+ code: orderResponse.error.code === 400 || orderResponse.error.code === 404 ? -32600 /* INVALID_REQUEST */ : -32603 /* INTERNAL_ERROR */,
1645
+ message: orderResponse.error.message
1646
+ }
1647
+ };
1648
+ }
1649
+ const paymentResponse = await this.requestInternal("sendTransfer", {
1650
+ recipients: [
1651
+ {
1652
+ address: orderResponse.data.fundingAddress,
1653
+ amount: orderResponse.data.rbfCost
1654
+ }
1655
+ ]
1656
+ });
1657
+ if (paymentResponse.status !== "success") {
1658
+ return paymentResponse;
1659
+ }
1660
+ return {
1661
+ status: "success",
1662
+ result: {
1663
+ fundingAddress: orderResponse.data.fundingAddress,
1664
+ orderId: rbfOrderRequest.orderId,
1665
+ fundRBFTransactionId: paymentResponse.result.txid
1666
+ }
1667
+ };
1668
+ } catch (error) {
1669
+ return {
1670
+ status: "error",
1671
+ error: {
1672
+ code: -32603 /* INTERNAL_ERROR */,
1673
+ message: error.message
1674
+ }
1675
+ };
1676
+ }
1677
+ }
1678
+ async request(method, params) {
1679
+ switch (method) {
1680
+ case "runes_mint":
1681
+ return this.mintRunes(params);
1682
+ case "runes_etch":
1683
+ return this.etchRunes(params);
1684
+ case "runes_estimateMint":
1685
+ return this.estimateMint(params);
1686
+ case "runes_estimateEtch":
1687
+ return this.estimateEtch(params);
1688
+ case "runes_getOrder": {
1689
+ return this.getOrder(params);
1690
+ }
1691
+ case "runes_estimateRbfOrder": {
1692
+ return this.estimateRbfOrder(params);
1693
+ }
1694
+ case "runes_rbfOrder": {
1695
+ return this.rbfOrder(params);
1696
+ }
1697
+ default:
1698
+ return this.requestInternal(method, params);
1699
+ }
1700
+ }
1701
+ };
1702
+
1703
+ // src/adapters/xverse.ts
1704
+ var XverseAdapter = class extends SatsConnectAdapter {
1705
+ id = DefaultAdaptersInfo.xverse.id;
1706
+ requestInternal = async (method, params) => {
1707
+ return request(method, params, this.id);
1708
+ };
1709
+ addListener = (event, cb) => {
1710
+ return addListener(
1711
+ event,
1712
+ // The types of the `addListener` function being called here are not
1713
+ // entirely accurate.
1714
+ cb,
1715
+ this.id
1716
+ );
1717
+ };
1718
+ };
1719
+
1720
+ // src/adapters/unisat.ts
1721
+ var import_bitcoin_address_validation = require("bitcoin-address-validation");
1722
+ var import_buffer = require("buffer");
1723
+ function convertSignInputsToInputType(signInputs) {
1724
+ let result = [];
1725
+ for (let address in signInputs) {
1726
+ let indexes = signInputs[address];
1727
+ for (let index of indexes) {
1728
+ result.push({
1729
+ index,
1730
+ address
1731
+ });
1732
+ }
1733
+ }
1734
+ return result;
1735
+ }
1736
+ var UnisatAdapter = class extends SatsConnectAdapter {
1737
+ id = DefaultAdaptersInfo.unisat.id;
1738
+ async getAccounts(params) {
1739
+ const { purposes } = params;
1740
+ if (purposes.includes("stacks" /* Stacks */)) {
1741
+ throw new Error("Only bitcoin addresses are supported");
1742
+ }
1743
+ const accounts = await window.unisat.requestAccounts();
1744
+ const publicKey = await window.unisat.getPublicKey();
1745
+ const address = accounts[0];
1746
+ const addressType = (0, import_bitcoin_address_validation.getAddressInfo)(accounts[0]).type;
1747
+ const pk = addressType === import_bitcoin_address_validation.AddressType.p2tr ? publicKey.slice(2) : publicKey;
1748
+ const paymentAddress = {
1749
+ address,
1750
+ publicKey: pk,
1751
+ addressType,
1752
+ purpose: "payment" /* Payment */
1753
+ };
1754
+ const ordinalsAddress = {
1755
+ address,
1756
+ publicKey: pk,
1757
+ addressType,
1758
+ purpose: "ordinals" /* Ordinals */
1759
+ };
1760
+ const response = [];
1761
+ if (purposes.includes("payment" /* Payment */)) {
1762
+ response.push({ ...paymentAddress, walletType: "software" });
1763
+ }
1764
+ if (purposes.includes("ordinals" /* Ordinals */)) {
1765
+ response.push({ ...ordinalsAddress, walletType: "software" });
1766
+ }
1767
+ return response;
1768
+ }
1769
+ async signMessage(params) {
1770
+ const { message, address } = params;
1771
+ const addressType = (0, import_bitcoin_address_validation.getAddressInfo)(address).type;
1772
+ const Bip322supportedTypes = [import_bitcoin_address_validation.AddressType.p2wpkh, import_bitcoin_address_validation.AddressType.p2tr];
1773
+ if (Bip322supportedTypes.includes(addressType)) {
1774
+ const response2 = await window.unisat.signMessage(message, "bip322-simple");
1775
+ return {
1776
+ address,
1777
+ messageHash: "",
1778
+ signature: response2,
1779
+ protocol: "BIP322" /* BIP322 */
1780
+ };
1781
+ }
1782
+ const response = await window.unisat.signMessage(message, "ecdsa");
1783
+ return {
1784
+ address,
1785
+ messageHash: "",
1786
+ signature: response,
1787
+ protocol: "ECDSA" /* ECDSA */
1788
+ };
1789
+ }
1790
+ async sendTransfer(params) {
1791
+ const { recipients } = params;
1792
+ if (recipients.length > 1) {
1793
+ throw new Error("Only one recipient is supported by this wallet provider");
1794
+ }
1795
+ const txid = await window.unisat.sendBitcoin(recipients[0].address, recipients[0].amount);
1796
+ return {
1797
+ txid
1798
+ };
1799
+ }
1800
+ async signPsbt(params) {
1801
+ const { psbt, signInputs, broadcast } = params;
1802
+ const psbtHex = import_buffer.Buffer.from(psbt, "base64").toString("hex");
1803
+ const signedPsbt = await window.unisat.signPsbt(psbtHex, {
1804
+ autoFinalized: broadcast,
1805
+ toSignInputs: convertSignInputsToInputType(signInputs)
1806
+ });
1807
+ const signedPsbtBase64 = import_buffer.Buffer.from(signedPsbt, "hex").toString("base64");
1808
+ let txid;
1809
+ if (broadcast) {
1810
+ txid = await window.unisat.pushPsbt(signedPsbt);
1811
+ }
1812
+ return {
1813
+ psbt: signedPsbtBase64,
1814
+ txid
1815
+ };
1816
+ }
1817
+ requestInternal = async (method, params) => {
1818
+ try {
1819
+ switch (method) {
1820
+ case "getAccounts": {
1821
+ const response = await this.getAccounts(
1822
+ params
1823
+ );
1824
+ return {
1825
+ status: "success",
1826
+ result: response
1827
+ };
1828
+ }
1829
+ case "sendTransfer": {
1830
+ const response = await this.sendTransfer(params);
1831
+ return {
1832
+ status: "success",
1833
+ result: response
1834
+ };
1835
+ }
1836
+ case "signMessage": {
1837
+ const response = await this.signMessage(params);
1838
+ return {
1839
+ status: "success",
1840
+ result: response
1841
+ };
1842
+ }
1843
+ case "signPsbt": {
1844
+ const response = await this.signPsbt(params);
1845
+ return {
1846
+ status: "success",
1847
+ result: response
1848
+ };
1849
+ }
1850
+ default: {
1851
+ const error = {
1852
+ code: -32001 /* METHOD_NOT_SUPPORTED */,
1853
+ message: "Method not supported by the selected wallet"
1854
+ };
1855
+ console.error("Error calling the method", error);
1856
+ return {
1857
+ status: "error",
1858
+ error
1859
+ };
1860
+ }
1861
+ }
1862
+ } catch (error) {
1863
+ console.error("Error calling the method", error);
1864
+ return {
1865
+ status: "error",
1866
+ error: {
1867
+ code: error.code === 4001 ? -32e3 /* USER_REJECTION */ : -32603 /* INTERNAL_ERROR */,
1868
+ message: error.message ? error.message : "Wallet method call error",
1869
+ data: error
1870
+ }
1871
+ };
1872
+ }
1873
+ };
1874
+ addListener = (eventName, cb) => {
1875
+ switch (eventName) {
1876
+ case "accountChange": {
1877
+ const handler = () => {
1878
+ cb({ type: "accountChange" });
1879
+ };
1880
+ window.unisat.on("accountsChanged", handler);
1881
+ return () => {
1882
+ window.unisat.removeListener("accountsChanged", handler);
1883
+ };
1884
+ }
1885
+ case "networkChange": {
1886
+ const handler = () => {
1887
+ cb({ type: "networkChange" });
1888
+ };
1889
+ window.unisat.on("networkChanged", handler);
1890
+ return () => {
1891
+ window.unisat.removeListener("networkChanged", handler);
1892
+ };
1893
+ }
1894
+ default: {
1895
+ console.error("Event not supported by the selected wallet");
1896
+ return () => {
1897
+ };
1898
+ }
1899
+ }
1900
+ };
1901
+ };
1902
+
1903
+ // src/adapters/BaseAdapter.ts
1904
+ var BaseAdapter = class extends SatsConnectAdapter {
1905
+ id = "";
1906
+ constructor(providerId) {
1907
+ super();
1908
+ this.id = providerId;
1909
+ }
1910
+ requestInternal = async (method, params) => {
1911
+ return request(method, params, this.id);
1912
+ };
1913
+ addListener = (..._args) => {
1914
+ throw new Error("Method not supported for `BaseAdapter`.");
1915
+ };
1916
+ };
1917
+
1918
+ // src/adapters/index.ts
1919
+ var DefaultAdaptersInfo = {
1920
+ xverse: {
1921
+ id: "XverseProviders.BitcoinProvider",
1922
+ name: "Xverse",
1923
+ webUrl: "https://www.xverse.app/",
1924
+ googlePlayStoreUrl: "https://play.google.com/store/apps/details?id=com.secretkeylabs.xverse",
1925
+ iOSAppStoreUrl: "https://apps.apple.com/app/xverse-bitcoin-web3-wallet/id1552272513",
1926
+ chromeWebStoreUrl: "https://chromewebstore.google.com/detail/xverse-wallet/idnnbdplmphpflfnlkomgpfbpcgelopg",
1927
+ icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgdmlld0JveD0iMCAwIDEwMiAxMDIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGlkPSJJY29uX0FydCAoRWRpdCBNZSkiPgo8cmVjdCB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgZmlsbD0iIzE4MTgxOCIvPgo8ZyBpZD0iTG9nby9FbWJsZW0iIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8yMF8xMjIzKSI+CjxwYXRoIGlkPSJWZW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iIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiBncmFkaWVudFRyYW5zZm9ybT0idHJhbnNsYXRlKDg1LjAwOTkgNjEuODM5Mikgc2NhbGUoMTEuMTMpIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0Y0Qjg1MiIvPgo8c3RvcCBvZmZzZXQ9IjAuMzMiIHN0b3AtY29sb3I9IiNFQTgxMDEiLz4KPHN0b3Agb2Zmc2V0PSIwLjY0IiBzdG9wLWNvbG9yPSIjNzczOTBEIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzIxMUMxRCIvPgo8L3JhZGlhbEdyYWRpZW50Pgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEwMDUwXzQxNzEiPgo8cmVjdCB3aWR0aD0iMTE1Ljc3IiBoZWlnaHQ9IjE0Ny43IiBmaWxsPSJ3aGl0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMzIgMTYpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg=="
1934
+ }
1935
+ };
1936
+ var defaultAdapters = {
1937
+ [DefaultAdaptersInfo.xverse.id]: XverseAdapter,
1938
+ [DefaultAdaptersInfo.unisat.id]: UnisatAdapter
1939
+ };
1940
+
1941
+ // src/capabilities/index.ts
1942
+ var import_jsontokens2 = require("jsontokens");
1943
+ var extractOrValidateCapabilities = (provider, reportedCapabilities) => {
1944
+ const validateCapability = (capability) => {
1945
+ if (!provider[capability]) {
1946
+ return false;
1947
+ }
1948
+ if (reportedCapabilities && !reportedCapabilities.has(capability)) {
1949
+ return false;
1950
+ }
1951
+ return true;
1952
+ };
1953
+ const capabilityMap = {
1954
+ request: validateCapability("request"),
1955
+ connect: validateCapability("connect"),
1956
+ signMessage: validateCapability("signMessage"),
1957
+ signTransaction: validateCapability("signTransaction"),
1958
+ sendBtcTransaction: validateCapability("sendBtcTransaction"),
1959
+ createInscription: validateCapability("createInscription"),
1960
+ createRepeatInscriptions: validateCapability("createRepeatInscriptions"),
1961
+ signMultipleTransactions: validateCapability("signMultipleTransactions"),
1962
+ addListener: validateCapability("addListener")
1963
+ };
1964
+ return Object.entries(capabilityMap).reduce((acc, [capability, value]) => {
1965
+ if (value) return [...acc, capability];
1966
+ return acc;
1967
+ }, []);
1968
+ };
1969
+ var getCapabilities = async (options) => {
1970
+ const provider = await getProviderOrThrow(options.getProvider);
1971
+ const request2 = (0, import_jsontokens2.createUnsecuredToken)(options.payload);
1972
+ if (provider.getCapabilities) {
1973
+ try {
1974
+ const response = await provider.getCapabilities(request2);
1975
+ options.onFinish?.(extractOrValidateCapabilities(provider, new Set(response)));
1976
+ } catch (error) {
1977
+ console.error("[Connect] Error during capabilities request", error);
1978
+ }
1979
+ }
1980
+ try {
1981
+ const inferredCapabilities = extractOrValidateCapabilities(provider);
1982
+ options.onFinish?.(inferredCapabilities);
1983
+ } catch (error) {
1984
+ console.error("[Connect] Error during capabilities request", error);
1985
+ options.onCancel?.();
1986
+ }
1987
+ };
1988
+
1989
+ // src/inscriptions/createInscription.ts
1990
+ var import_jsontokens3 = require("jsontokens");
1991
+
1992
+ // src/inscriptions/utils.ts
1993
+ var MAX_CONTENT_LENGTH_MAINNET = 4e5;
1994
+ var MAX_CONTENT_LENGTH_TESTNET = 6e4;
1995
+ var validateInscriptionPayload = (payload) => {
1996
+ const { contentType, content, payloadType, network, appFeeAddress, appFee } = payload;
1997
+ if (!/^[a-z]+\/[a-z0-9\-\.\+]+(?=;.*|$)/.test(contentType)) {
1998
+ throw new Error("Invalid content type detected");
1999
+ }
2000
+ if (!content || content.length === 0) {
2001
+ throw new Error("Empty content not allowed");
2002
+ }
2003
+ if (!payloadType || payloadType !== "BASE_64" && payloadType !== "PLAIN_TEXT") {
2004
+ throw new Error("Empty invalid payloadType specified");
2005
+ }
2006
+ if (content.length > (network.type === "Mainnet" ? MAX_CONTENT_LENGTH_MAINNET : MAX_CONTENT_LENGTH_TESTNET)) {
2007
+ throw new Error("Content too large");
2008
+ }
2009
+ if ((appFeeAddress?.length ?? 0) > 0 && (appFee ?? 0) <= 0) {
2010
+ throw new Error("Invalid combination of app fee address and fee provided");
2011
+ }
2012
+ };
2013
+
2014
+ // src/inscriptions/createInscription.ts
2015
+ var createInscription = async (options) => {
2016
+ const { getProvider } = options;
2017
+ const provider = await getProviderOrThrow(getProvider);
2018
+ validateInscriptionPayload(options.payload);
2019
+ try {
2020
+ const request2 = (0, import_jsontokens3.createUnsecuredToken)(options.payload);
2021
+ const response = await provider.createInscription(request2);
2022
+ options.onFinish?.(response);
2023
+ } catch (error) {
2024
+ console.error("[Connect] Error during create inscription", error);
2025
+ options.onCancel?.();
2026
+ }
2027
+ };
2028
+
2029
+ // src/inscriptions/createRepeatInscriptions.ts
2030
+ var import_jsontokens4 = require("jsontokens");
2031
+ var createRepeatInscriptions = async (options) => {
2032
+ const { getProvider } = options;
2033
+ const provider = await getProviderOrThrow(getProvider);
2034
+ validateInscriptionPayload(options.payload);
2035
+ try {
2036
+ const request2 = (0, import_jsontokens4.createUnsecuredToken)(options.payload);
2037
+ const response = await provider.createRepeatInscriptions(request2);
2038
+ options.onFinish?.(response);
2039
+ } catch (error) {
2040
+ console.error("[Connect] Error during create repeat inscriptions", error);
2041
+ options.onCancel?.();
2042
+ }
2043
+ };
2044
+
2045
+ // src/messages/index.ts
2046
+ var import_jsontokens5 = require("jsontokens");
2047
+ var signMessage = async (options) => {
2048
+ const provider = await getProviderOrThrow(options.getProvider);
2049
+ const { address, message } = options.payload;
2050
+ if (!address) {
2051
+ throw new Error("An address is required to sign a message");
2052
+ }
2053
+ if (!message) {
2054
+ throw new Error("A message to be signed is required");
2055
+ }
2056
+ try {
2057
+ const request2 = (0, import_jsontokens5.createUnsecuredToken)(options.payload);
2058
+ const response = await provider.signMessage(request2);
2059
+ options.onFinish?.(response);
2060
+ } catch (error) {
2061
+ console.error("[Connect] Error during sign message request", error);
2062
+ options.onCancel?.();
2063
+ }
2064
+ };
2065
+
2066
+ // src/transactions/sendBtcTransaction.ts
2067
+ var import_jsontokens6 = require("jsontokens");
2068
+ var serializer = (recipient) => {
2069
+ return recipient.map((value) => {
2070
+ const { address, amountSats } = value;
2071
+ return {
2072
+ address,
2073
+ amountSats: amountSats.toString()
2074
+ };
2075
+ });
2076
+ };
2077
+ var sendBtcTransaction = async (options) => {
2078
+ const provider = await getProviderOrThrow(options.getProvider);
2079
+ const { recipients, senderAddress, network, message } = options.payload;
2080
+ if (!recipients || recipients.length === 0) {
2081
+ throw new Error("At least one recipient is required");
2082
+ }
2083
+ if (recipients.some(
2084
+ (item) => typeof item.address !== "string" || typeof item.amountSats !== "bigint"
2085
+ )) {
2086
+ throw new Error("Incorrect recipient format");
2087
+ }
2088
+ if (!senderAddress) {
2089
+ throw new Error("The sender address is required");
2090
+ }
2091
+ try {
2092
+ const serializedRecipients = serializer(recipients);
2093
+ const serializedPayload = {
2094
+ network,
2095
+ senderAddress,
2096
+ message,
2097
+ recipients: serializedRecipients
2098
+ };
2099
+ const request2 = (0, import_jsontokens6.createUnsecuredToken)(serializedPayload);
2100
+ const response = await provider.sendBtcTransaction(request2);
2101
+ options.onFinish?.(response);
2102
+ } catch (error) {
2103
+ console.error("[Connect] Error during send BTC transaction request", error);
2104
+ options.onCancel?.();
2105
+ }
2106
+ };
2107
+
2108
+ // src/transactions/signTransaction.ts
2109
+ var import_jsontokens7 = require("jsontokens");
2110
+ var signTransaction = async (options) => {
2111
+ const provider = await getProviderOrThrow(options.getProvider);
2112
+ const { psbtBase64, inputsToSign } = options.payload;
2113
+ if (!psbtBase64) {
2114
+ throw new Error("A value for psbtBase64 representing the tx hash is required");
2115
+ }
2116
+ if (!inputsToSign) {
2117
+ throw new Error("An array specifying the inputs to be signed by the wallet is required");
2118
+ }
2119
+ try {
2120
+ const request2 = (0, import_jsontokens7.createUnsecuredToken)(options.payload);
2121
+ const response = await provider.signTransaction(request2);
2122
+ options.onFinish?.(response);
2123
+ } catch (error) {
2124
+ console.error("[Connect] Error during sign transaction request", error);
2125
+ options.onCancel?.();
2126
+ }
2127
+ };
2128
+
2129
+ // src/transactions/signMultipleTransactions.ts
2130
+ var import_jsontokens8 = require("jsontokens");
2131
+ var signMultipleTransactions = async (options) => {
2132
+ const provider = await getProviderOrThrow(options.getProvider);
2133
+ const { psbts } = options.payload;
2134
+ if (!psbts || !psbts.length) {
2135
+ throw new Error("psbts array is required");
2136
+ }
2137
+ if (psbts.length > 100) {
2138
+ throw new Error("psbts array must contain less than 100 psbts");
2139
+ }
2140
+ try {
2141
+ const request2 = (0, import_jsontokens8.createUnsecuredToken)(options.payload);
2142
+ const response = await provider.signMultipleTransactions(request2);
2143
+ options.onFinish?.(response);
2144
+ } catch (error) {
2145
+ console.error("[Connect] Error during sign Multiple transactions request", error);
2146
+ options.onCancel?.();
2147
+ }
2148
+ };
2149
+ // Annotate the CommonJS export names for ESM import in node:
2150
+ 0 && (module.exports = {
2151
+ AddressPurpose,
2152
+ AddressType,
2153
+ BaseAdapter,
2154
+ BitcoinNetworkType,
2155
+ DefaultAdaptersInfo,
2156
+ MessageSigningProtocols,
2157
+ PermissionRequestParams,
2158
+ RpcErrorCode,
2159
+ RpcIdSchema,
2160
+ SatsConnectAdapter,
2161
+ accountActionsSchema,
2162
+ accountChangeEventName,
2163
+ accountChangeSchema,
2164
+ accountPermissionSchema,
2165
+ addListener,
2166
+ addressSchema,
2167
+ connectMethodName,
2168
+ connectParamsSchema,
2169
+ connectRequestMessageSchema,
2170
+ connectResultSchema,
2171
+ createInscription,
2172
+ createRepeatInscriptions,
2173
+ defaultAdapters,
2174
+ disconnectEventName,
2175
+ disconnectMethodName,
2176
+ disconnectParamsSchema,
2177
+ disconnectRequestMessageSchema,
2178
+ disconnectResultSchema,
2179
+ disconnectSchema,
2180
+ getAccountMethodName,
2181
+ getAccountParamsSchema,
2182
+ getAccountRequestMessageSchema,
2183
+ getAccountResultSchema,
2184
+ getAccountsMethodName,
2185
+ getAccountsParamsSchema,
2186
+ getAccountsRequestMessageSchema,
2187
+ getAccountsResultSchema,
2188
+ getAddress,
2189
+ getAddressesMethodName,
2190
+ getAddressesParamsSchema,
2191
+ getAddressesRequestMessageSchema,
2192
+ getAddressesResultSchema,
2193
+ getBalanceMethodName,
2194
+ getBalanceParamsSchema,
2195
+ getBalanceRequestMessageSchema,
2196
+ getBalanceResultSchema,
2197
+ getCapabilities,
2198
+ getCurrentPermissionsMethodName,
2199
+ getCurrentPermissionsParamsSchema,
2200
+ getCurrentPermissionsRequestMessageSchema,
2201
+ getCurrentPermissionsResultSchema,
2202
+ getDefaultProvider,
2203
+ getInfoMethodName,
2204
+ getInfoParamsSchema,
2205
+ getInfoRequestMessageSchema,
2206
+ getInfoResultSchema,
2207
+ getInscriptionsMethodName,
2208
+ getInscriptionsParamsSchema,
2209
+ getInscriptionsRequestMessageSchema,
2210
+ getInscriptionsResultSchema,
2211
+ getProviderById,
2212
+ getProviderOrThrow,
2213
+ getProviders,
2214
+ getSupportedWallets,
2215
+ getWalletTypeMethodName,
2216
+ getWalletTypeParamsSchema,
2217
+ getWalletTypeRequestMessageSchema,
2218
+ getWalletTypeResultSchema,
2219
+ isProviderInstalled,
2220
+ networkChangeEventName,
2221
+ networkChangeSchema,
2222
+ permission,
2223
+ removeDefaultProvider,
2224
+ renouncePermissionsMethodName,
2225
+ renouncePermissionsParamsSchema,
2226
+ renouncePermissionsRequestMessageSchema,
2227
+ renouncePermissionsResultSchema,
2228
+ request,
2229
+ requestPermissionsMethodName,
2230
+ requestPermissionsParamsSchema,
2231
+ requestPermissionsRequestMessageSchema,
2232
+ requestPermissionsResultSchema,
2233
+ rpcErrorResponseMessageSchema,
2234
+ rpcRequestMessageSchema,
2235
+ rpcResponseMessageSchema,
2236
+ rpcSuccessResponseMessageSchema,
2237
+ runesEtchMethodName,
2238
+ runesEtchParamsSchema,
2239
+ runesEtchRequestMessageSchema,
2240
+ runesEtchResultSchema,
2241
+ runesGetBalanceMethodName,
2242
+ runesGetBalanceParamsSchema,
2243
+ runesGetBalanceRequestMessageSchema,
2244
+ runesGetBalanceResultSchema,
2245
+ runesMintMethodName,
2246
+ runesMintParamsSchema,
2247
+ runesMintRequestMessageSchema,
2248
+ runesMintResultSchema,
2249
+ runesTransferMethodName,
2250
+ runesTransferParamsSchema,
2251
+ runesTransferRequestMessageSchema,
2252
+ runesTransferResultSchema,
2253
+ sendBtcTransaction,
2254
+ sendInscriptionsMethodName,
2255
+ sendInscriptionsParamsSchema,
2256
+ sendInscriptionsRequestMessageSchema,
2257
+ sendInscriptionsResultSchema,
2258
+ sendTransferMethodName,
2259
+ sendTransferParamsSchema,
2260
+ sendTransferRequestMessageSchema,
2261
+ sendTransferResultSchema,
2262
+ setDefaultProvider,
2263
+ signMessage,
2264
+ signMessageMethodName,
2265
+ signMessageParamsSchema,
2266
+ signMessageRequestMessageSchema,
2267
+ signMessageResultSchema,
2268
+ signMultipleTransactions,
2269
+ signPsbtMethodName,
2270
+ signPsbtParamsSchema,
2271
+ signPsbtRequestMessageSchema,
2272
+ signPsbtResultSchema,
2273
+ signTransaction,
2274
+ stxCallContractMethodName,
2275
+ stxCallContractParamsSchema,
2276
+ stxCallContractRequestMessageSchema,
2277
+ stxCallContractResultSchema,
2278
+ stxDeployContractMethodName,
2279
+ stxDeployContractParamsSchema,
2280
+ stxDeployContractRequestMessageSchema,
2281
+ stxDeployContractResultSchema,
2282
+ stxGetAccountsMethodName,
2283
+ stxGetAccountsParamsSchema,
2284
+ stxGetAccountsRequestMessageSchema,
2285
+ stxGetAccountsResultSchema,
2286
+ stxGetAddressesMethodName,
2287
+ stxGetAddressesParamsSchema,
2288
+ stxGetAddressesRequestMessageSchema,
2289
+ stxGetAddressesResultSchema,
2290
+ stxSignMessageMethodName,
2291
+ stxSignMessageParamsSchema,
2292
+ stxSignMessageRequestMessageSchema,
2293
+ stxSignMessageResultSchema,
2294
+ stxSignStructuredMessageMethodName,
2295
+ stxSignStructuredMessageParamsSchema,
2296
+ stxSignStructuredMessageRequestMessageSchema,
2297
+ stxSignStructuredMessageResultSchema,
2298
+ stxSignTransactionMethodName,
2299
+ stxSignTransactionParamsSchema,
2300
+ stxSignTransactionRequestMessageSchema,
2301
+ stxSignTransactionResultSchema,
2302
+ stxTransferStxMethodName,
2303
+ stxTransferStxParamsSchema,
2304
+ stxTransferStxRequestMessageSchema,
2305
+ stxTransferStxResultSchema,
2306
+ walletActionsSchema,
2307
+ walletEventSchema,
2308
+ walletPermissionSchema,
2309
+ walletTypeSchema,
2310
+ walletTypes
2311
+ });