@sats-connect/core 0.4.0-791813d → 0.4.0-80a221a
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 +796 -274
- package/dist/index.d.ts +1705 -0
- package/dist/index.js +2786 -0
- package/dist/index.mjs +1242 -217
- package/package.json +9 -13
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/provider/index.ts
|
|
2
|
-
import omit from "lodash.omit";
|
|
3
|
-
|
|
4
1
|
// src/provider/types.ts
|
|
5
2
|
import * as v from "valibot";
|
|
6
3
|
var accountChangeEventName = "accountChange";
|
|
@@ -30,8 +27,7 @@ async function getProviderOrThrow(getProvider) {
|
|
|
30
27
|
return provider;
|
|
31
28
|
}
|
|
32
29
|
function getProviders() {
|
|
33
|
-
if (!window.btc_providers)
|
|
34
|
-
window.btc_providers = [];
|
|
30
|
+
if (!window.btc_providers) window.btc_providers = [];
|
|
35
31
|
return window.btc_providers;
|
|
36
32
|
}
|
|
37
33
|
function getProviderById(providerId) {
|
|
@@ -50,12 +46,7 @@ function removeDefaultProvider() {
|
|
|
50
46
|
localStorage.removeItem("sats-connect_defaultProvider");
|
|
51
47
|
}
|
|
52
48
|
function getSupportedWallets() {
|
|
53
|
-
const
|
|
54
|
-
const allProviders = [...btc_providers];
|
|
55
|
-
for (const key in omit(DefaultAdaptersInfo, ["xverse"])) {
|
|
56
|
-
allProviders.push(DefaultAdaptersInfo[key]);
|
|
57
|
-
}
|
|
58
|
-
const wallets = allProviders.map((provider) => {
|
|
49
|
+
const wallets = Object.values(DefaultAdaptersInfo).map((provider) => {
|
|
59
50
|
{
|
|
60
51
|
return {
|
|
61
52
|
...provider,
|
|
@@ -68,11 +59,11 @@ function getSupportedWallets() {
|
|
|
68
59
|
|
|
69
60
|
// src/types.ts
|
|
70
61
|
import * as v2 from "valibot";
|
|
71
|
-
var BitcoinNetworkType = /* @__PURE__ */ ((
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return
|
|
62
|
+
var BitcoinNetworkType = /* @__PURE__ */ ((BitcoinNetworkType2) => {
|
|
63
|
+
BitcoinNetworkType2["Mainnet"] = "Mainnet";
|
|
64
|
+
BitcoinNetworkType2["Testnet"] = "Testnet";
|
|
65
|
+
BitcoinNetworkType2["Signet"] = "Signet";
|
|
66
|
+
return BitcoinNetworkType2;
|
|
76
67
|
})(BitcoinNetworkType || {});
|
|
77
68
|
var RpcIdSchema = v2.optional(v2.union([v2.string(), v2.number(), v2.null()]));
|
|
78
69
|
var rpcRequestMessageSchema = v2.object({
|
|
@@ -89,7 +80,7 @@ var rpcRequestMessageSchema = v2.object({
|
|
|
89
80
|
v2.null()
|
|
90
81
|
])
|
|
91
82
|
),
|
|
92
|
-
id: RpcIdSchema
|
|
83
|
+
id: v2.unwrap(RpcIdSchema)
|
|
93
84
|
});
|
|
94
85
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
95
86
|
RpcErrorCode2[RpcErrorCode2["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
@@ -118,13 +109,127 @@ var rpcResponseMessageSchema = v2.union([
|
|
|
118
109
|
]);
|
|
119
110
|
|
|
120
111
|
// src/request/index.ts
|
|
121
|
-
import * as
|
|
112
|
+
import * as v25 from "valibot";
|
|
113
|
+
|
|
114
|
+
// src/request/types/stxMethods/callContract.ts
|
|
115
|
+
import * as v3 from "valibot";
|
|
116
|
+
var stxCallContractMethodName = "stx_callContract";
|
|
117
|
+
var stxCallContractParamsSchema = v3.object({
|
|
118
|
+
/**
|
|
119
|
+
* The contract principal.
|
|
120
|
+
*
|
|
121
|
+
* E.g. `"SPKE...GD5C.my-contract"`
|
|
122
|
+
*/
|
|
123
|
+
contract: v3.string(),
|
|
124
|
+
/**
|
|
125
|
+
* The name of the function to call.
|
|
126
|
+
*
|
|
127
|
+
* Note: spec changes ongoing,
|
|
128
|
+
* https://github.com/stacksgov/sips/pull/166#pullrequestreview-1914236999
|
|
129
|
+
*/
|
|
130
|
+
functionName: v3.string(),
|
|
131
|
+
/**
|
|
132
|
+
* The function's arguments. The arguments are expected to be hex-encoded
|
|
133
|
+
* strings of Clarity values.
|
|
134
|
+
*
|
|
135
|
+
* To convert Clarity values to their hex representation, the `cvToString`
|
|
136
|
+
* helper from the `@stacks/transactions` package may be helpful.
|
|
137
|
+
*
|
|
138
|
+
* ```js
|
|
139
|
+
* import { cvToString } from '@stacks/transactions';
|
|
140
|
+
*
|
|
141
|
+
* const functionArgs = [someClarityValue1, someClarityValue2];
|
|
142
|
+
* const hexArgs = functionArgs.map(cvToString);
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
arguments: v3.optional(v3.array(v3.string()))
|
|
146
|
+
});
|
|
147
|
+
var stxCallContractResultSchema = v3.object({
|
|
148
|
+
/**
|
|
149
|
+
* The ID of the transaction.
|
|
150
|
+
*/
|
|
151
|
+
txid: v3.string(),
|
|
152
|
+
/**
|
|
153
|
+
* A Stacks transaction as a hex-encoded string.
|
|
154
|
+
*/
|
|
155
|
+
transaction: v3.string()
|
|
156
|
+
});
|
|
157
|
+
var stxCallContractRequestMessageSchema = v3.object({
|
|
158
|
+
...rpcRequestMessageSchema.entries,
|
|
159
|
+
...v3.object({
|
|
160
|
+
method: v3.literal(stxCallContractMethodName),
|
|
161
|
+
params: stxCallContractParamsSchema,
|
|
162
|
+
id: v3.string()
|
|
163
|
+
}).entries
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// src/request/types/stxMethods/deployContract.ts
|
|
167
|
+
import * as v4 from "valibot";
|
|
168
|
+
var stxDeployContractMethodName = "stx_deployContract";
|
|
169
|
+
var stxDeployContractParamsSchema = v4.object({
|
|
170
|
+
/**
|
|
171
|
+
* Name of the contract.
|
|
172
|
+
*/
|
|
173
|
+
name: v4.string(),
|
|
174
|
+
/**
|
|
175
|
+
* The source code of the Clarity contract.
|
|
176
|
+
*/
|
|
177
|
+
clarityCode: v4.string(),
|
|
178
|
+
/**
|
|
179
|
+
* The version of the Clarity contract.
|
|
180
|
+
*/
|
|
181
|
+
clarityVersion: v4.optional(v4.string())
|
|
182
|
+
});
|
|
183
|
+
var stxDeployContractResultSchema = v4.object({
|
|
184
|
+
/**
|
|
185
|
+
* The ID of the transaction.
|
|
186
|
+
*/
|
|
187
|
+
txid: v4.string(),
|
|
188
|
+
/**
|
|
189
|
+
* A Stacks transaction as a hex-encoded string.
|
|
190
|
+
*/
|
|
191
|
+
transaction: v4.string()
|
|
192
|
+
});
|
|
193
|
+
var stxDeployContractRequestMessageSchema = v4.object({
|
|
194
|
+
...rpcRequestMessageSchema.entries,
|
|
195
|
+
...v4.object({
|
|
196
|
+
method: v4.literal(stxDeployContractMethodName),
|
|
197
|
+
params: stxDeployContractParamsSchema,
|
|
198
|
+
id: v4.string()
|
|
199
|
+
}).entries
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// src/request/types/stxMethods/getAccounts.ts
|
|
203
|
+
import * as v5 from "valibot";
|
|
204
|
+
var stxGetAccountsMethodName = "stx_getAccounts";
|
|
205
|
+
var stxGetAccountsParamsSchema = v5.nullish(v5.null());
|
|
206
|
+
var stxGetAccountsResultSchema = v5.object({
|
|
207
|
+
/**
|
|
208
|
+
* The addresses generated for the given purposes.
|
|
209
|
+
*/
|
|
210
|
+
addresses: v5.array(
|
|
211
|
+
v5.object({
|
|
212
|
+
address: v5.string(),
|
|
213
|
+
publicKey: v5.string(),
|
|
214
|
+
gaiaHubUrl: v5.string(),
|
|
215
|
+
gaiaAppKey: v5.string()
|
|
216
|
+
})
|
|
217
|
+
)
|
|
218
|
+
});
|
|
219
|
+
var stxGetAccountsRequestMessageSchema = v5.object({
|
|
220
|
+
...rpcRequestMessageSchema.entries,
|
|
221
|
+
...v5.object({
|
|
222
|
+
method: v5.literal(stxGetAccountsMethodName),
|
|
223
|
+
params: stxGetAccountsParamsSchema,
|
|
224
|
+
id: v5.string()
|
|
225
|
+
}).entries
|
|
226
|
+
});
|
|
122
227
|
|
|
123
228
|
// src/addresses/index.ts
|
|
124
229
|
import { createUnsecuredToken } from "jsontokens";
|
|
125
230
|
|
|
126
231
|
// src/addresses/types.ts
|
|
127
|
-
import * as
|
|
232
|
+
import * as v6 from "valibot";
|
|
128
233
|
var AddressPurpose = /* @__PURE__ */ ((AddressPurpose2) => {
|
|
129
234
|
AddressPurpose2["Ordinals"] = "ordinals";
|
|
130
235
|
AddressPurpose2["Payment"] = "payment";
|
|
@@ -140,11 +245,11 @@ var AddressType = /* @__PURE__ */ ((AddressType3) => {
|
|
|
140
245
|
AddressType3["stacks"] = "stacks";
|
|
141
246
|
return AddressType3;
|
|
142
247
|
})(AddressType || {});
|
|
143
|
-
var addressSchema =
|
|
144
|
-
address:
|
|
145
|
-
publicKey:
|
|
146
|
-
purpose:
|
|
147
|
-
addressType:
|
|
248
|
+
var addressSchema = v6.object({
|
|
249
|
+
address: v6.string(),
|
|
250
|
+
publicKey: v6.string(),
|
|
251
|
+
purpose: v6.enum(AddressPurpose),
|
|
252
|
+
addressType: v6.enum(AddressType)
|
|
148
253
|
});
|
|
149
254
|
|
|
150
255
|
// src/addresses/index.ts
|
|
@@ -164,119 +269,269 @@ var getAddress = async (options) => {
|
|
|
164
269
|
}
|
|
165
270
|
};
|
|
166
271
|
|
|
167
|
-
// src/request/types/stxMethods.ts
|
|
168
|
-
import * as
|
|
272
|
+
// src/request/types/stxMethods/getAddresses.ts
|
|
273
|
+
import * as v7 from "valibot";
|
|
169
274
|
var stxGetAddressesMethodName = "stx_getAddresses";
|
|
170
|
-
var stxGetAddressesParamsSchema =
|
|
171
|
-
|
|
275
|
+
var stxGetAddressesParamsSchema = v7.nullish(
|
|
276
|
+
v7.object({
|
|
172
277
|
/**
|
|
173
278
|
* A message to be displayed to the user in the request prompt.
|
|
174
279
|
*/
|
|
175
|
-
message:
|
|
280
|
+
message: v7.optional(v7.string())
|
|
176
281
|
})
|
|
177
282
|
);
|
|
178
|
-
var stxGetAddressesResultSchema =
|
|
283
|
+
var stxGetAddressesResultSchema = v7.object({
|
|
179
284
|
/**
|
|
180
285
|
* The addresses generated for the given purposes.
|
|
181
286
|
*/
|
|
182
|
-
addresses:
|
|
287
|
+
addresses: v7.array(addressSchema)
|
|
183
288
|
});
|
|
184
|
-
var stxGetAddressesRequestMessageSchema =
|
|
289
|
+
var stxGetAddressesRequestMessageSchema = v7.object({
|
|
185
290
|
...rpcRequestMessageSchema.entries,
|
|
186
|
-
...
|
|
187
|
-
method:
|
|
291
|
+
...v7.object({
|
|
292
|
+
method: v7.literal(stxGetAddressesMethodName),
|
|
188
293
|
params: stxGetAddressesParamsSchema,
|
|
189
|
-
id:
|
|
294
|
+
id: v7.string()
|
|
190
295
|
}).entries
|
|
191
296
|
});
|
|
297
|
+
|
|
298
|
+
// src/request/types/stxMethods/signMessage.ts
|
|
299
|
+
import * as v8 from "valibot";
|
|
300
|
+
var stxSignMessageMethodName = "stx_signMessage";
|
|
301
|
+
var stxSignMessageParamsSchema = v8.object({
|
|
302
|
+
/**
|
|
303
|
+
* The message to sign.
|
|
304
|
+
*/
|
|
305
|
+
message: v8.string(),
|
|
306
|
+
/**
|
|
307
|
+
* The public key to sign the message with.
|
|
308
|
+
*/
|
|
309
|
+
publicKey: v8.string(),
|
|
310
|
+
/**
|
|
311
|
+
* The format version of the parameter.
|
|
312
|
+
*/
|
|
313
|
+
parameterFormatVersion: v8.optional(v8.number())
|
|
314
|
+
});
|
|
315
|
+
var stxSignMessageResultSchema = v8.object({
|
|
316
|
+
/**
|
|
317
|
+
* The signature of the message.
|
|
318
|
+
*/
|
|
319
|
+
signature: v8.string(),
|
|
320
|
+
/**
|
|
321
|
+
* The public key used to sign the message.
|
|
322
|
+
*/
|
|
323
|
+
publicKey: v8.string()
|
|
324
|
+
});
|
|
325
|
+
var stxSignMessageRequestMessageSchema = v8.object({
|
|
326
|
+
...rpcRequestMessageSchema.entries,
|
|
327
|
+
...v8.object({
|
|
328
|
+
method: v8.literal(stxSignMessageMethodName),
|
|
329
|
+
params: stxSignMessageParamsSchema,
|
|
330
|
+
id: v8.string()
|
|
331
|
+
}).entries
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// src/request/types/stxMethods/signStructuredMessage.ts
|
|
335
|
+
import * as v9 from "valibot";
|
|
336
|
+
var stxSignStructuredMessageMethodName = "stx_signStructuredMessage";
|
|
337
|
+
var stxSignStructuredMessageParamsSchema = v9.object({
|
|
338
|
+
/**
|
|
339
|
+
* The domain to be signed.
|
|
340
|
+
*/
|
|
341
|
+
domain: v9.string(),
|
|
342
|
+
/**
|
|
343
|
+
* Message payload to be signed.
|
|
344
|
+
*/
|
|
345
|
+
message: v9.string(),
|
|
346
|
+
/**
|
|
347
|
+
* The format version of the parameter.
|
|
348
|
+
*/
|
|
349
|
+
parameterFormatVersion: v9.optional(v9.number()),
|
|
350
|
+
/**
|
|
351
|
+
* The public key to sign the message with.
|
|
352
|
+
*/
|
|
353
|
+
publicKey: v9.optional(v9.string())
|
|
354
|
+
});
|
|
355
|
+
var stxSignStructuredMessageResultSchema = v9.object({
|
|
356
|
+
/**
|
|
357
|
+
* Signature of the message.
|
|
358
|
+
*/
|
|
359
|
+
signature: v9.string(),
|
|
360
|
+
/**
|
|
361
|
+
* Public key as hex-encoded string.
|
|
362
|
+
*/
|
|
363
|
+
publicKey: v9.string()
|
|
364
|
+
});
|
|
365
|
+
var stxSignStructuredMessageRequestMessageSchema = v9.object({
|
|
366
|
+
...rpcRequestMessageSchema.entries,
|
|
367
|
+
...v9.object({
|
|
368
|
+
method: v9.literal(stxSignStructuredMessageMethodName),
|
|
369
|
+
params: stxSignStructuredMessageParamsSchema,
|
|
370
|
+
id: v9.string()
|
|
371
|
+
}).entries
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
// src/request/types/stxMethods/signTransaction.ts
|
|
375
|
+
import * as v10 from "valibot";
|
|
192
376
|
var stxSignTransactionMethodName = "stx_signTransaction";
|
|
193
|
-
var stxSignTransactionParamsSchema =
|
|
377
|
+
var stxSignTransactionParamsSchema = v10.object({
|
|
194
378
|
/**
|
|
195
379
|
* The transaction to sign as a hex-encoded string.
|
|
196
380
|
*/
|
|
197
|
-
transaction:
|
|
381
|
+
transaction: v10.string(),
|
|
198
382
|
/**
|
|
199
383
|
* The public key to sign the transaction with. The wallet may use any key
|
|
200
384
|
* when not provided.
|
|
201
385
|
*/
|
|
202
|
-
pubkey:
|
|
386
|
+
pubkey: v10.optional(v10.string()),
|
|
203
387
|
/**
|
|
204
388
|
* Whether to broadcast the transaction after signing. Defaults to `true`.
|
|
205
389
|
*/
|
|
206
|
-
broadcast:
|
|
390
|
+
broadcast: v10.optional(v10.boolean())
|
|
207
391
|
});
|
|
208
|
-
var stxSignTransactionResultSchema =
|
|
392
|
+
var stxSignTransactionResultSchema = v10.object({
|
|
209
393
|
/**
|
|
210
394
|
* The signed transaction as a hex-encoded string.
|
|
211
395
|
*/
|
|
212
|
-
transaction:
|
|
396
|
+
transaction: v10.string()
|
|
213
397
|
});
|
|
214
|
-
var stxSignTransactionRequestMessageSchema =
|
|
398
|
+
var stxSignTransactionRequestMessageSchema = v10.object({
|
|
215
399
|
...rpcRequestMessageSchema.entries,
|
|
216
|
-
...
|
|
217
|
-
method:
|
|
400
|
+
...v10.object({
|
|
401
|
+
method: v10.literal(stxSignTransactionMethodName),
|
|
218
402
|
params: stxSignTransactionParamsSchema,
|
|
219
|
-
id:
|
|
403
|
+
id: v10.string()
|
|
404
|
+
}).entries
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// src/request/types/stxMethods/transferStx.ts
|
|
408
|
+
import * as v11 from "valibot";
|
|
409
|
+
var stxTransferStxMethodName = "stx_transferStx";
|
|
410
|
+
var stxTransferStxParamsSchema = v11.object({
|
|
411
|
+
/**
|
|
412
|
+
* Amount of STX tokens to transfer in microstacks as a string. Anything
|
|
413
|
+
* parseable by `BigInt` is acceptable.
|
|
414
|
+
*
|
|
415
|
+
* Example,
|
|
416
|
+
*
|
|
417
|
+
* ```js
|
|
418
|
+
* const amount1 = 1234;
|
|
419
|
+
* const amount2 = 1234n;
|
|
420
|
+
* const amount3 = '1234';
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
amount: v11.union([v11.number(), v11.string()]),
|
|
424
|
+
/**
|
|
425
|
+
* The recipeint's principal.
|
|
426
|
+
*/
|
|
427
|
+
recipient: v11.string(),
|
|
428
|
+
/**
|
|
429
|
+
* A string representing the memo.
|
|
430
|
+
*/
|
|
431
|
+
memo: v11.optional(v11.string()),
|
|
432
|
+
/**
|
|
433
|
+
* Version of parameter format.
|
|
434
|
+
*/
|
|
435
|
+
version: v11.optional(v11.string()),
|
|
436
|
+
/**
|
|
437
|
+
* The mode of the post conditions.
|
|
438
|
+
*/
|
|
439
|
+
postConditionMode: v11.optional(v11.number()),
|
|
440
|
+
/**
|
|
441
|
+
* A hex-encoded string representing the post conditions.
|
|
442
|
+
*
|
|
443
|
+
* A post condition may be converted to it's hex representation using the `serializePostCondition` helper from the `@stacks/transactions` package,
|
|
444
|
+
*
|
|
445
|
+
* ```js
|
|
446
|
+
* import { serializePostCondition } from '@stacks/transactions';
|
|
447
|
+
*
|
|
448
|
+
* const postCondition = somePostCondition;
|
|
449
|
+
* const hexPostCondition = serializePostCondition(postCondition).toString('hex');
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
postConditions: v11.optional(v11.array(v11.string())),
|
|
453
|
+
/**
|
|
454
|
+
* The public key to sign the transaction with. The wallet may use any key
|
|
455
|
+
* when not provided.
|
|
456
|
+
*/
|
|
457
|
+
pubkey: v11.optional(v11.string())
|
|
458
|
+
});
|
|
459
|
+
var stxTransferStxResultSchema = v11.object({
|
|
460
|
+
/**
|
|
461
|
+
* The ID of the transaction.
|
|
462
|
+
*/
|
|
463
|
+
txid: v11.string(),
|
|
464
|
+
/**
|
|
465
|
+
* A Stacks transaction as a hex-encoded string.
|
|
466
|
+
*/
|
|
467
|
+
transaction: v11.string()
|
|
468
|
+
});
|
|
469
|
+
var stxTransferStxRequestMessageSchema = v11.object({
|
|
470
|
+
...rpcRequestMessageSchema.entries,
|
|
471
|
+
...v11.object({
|
|
472
|
+
method: v11.literal(stxTransferStxMethodName),
|
|
473
|
+
params: stxTransferStxParamsSchema,
|
|
474
|
+
id: v11.string()
|
|
220
475
|
}).entries
|
|
221
476
|
});
|
|
222
477
|
|
|
223
478
|
// src/request/types/btcMethods.ts
|
|
224
|
-
import * as
|
|
479
|
+
import * as v13 from "valibot";
|
|
225
480
|
|
|
226
481
|
// src/request/types/common.ts
|
|
227
|
-
import * as
|
|
482
|
+
import * as v12 from "valibot";
|
|
228
483
|
var walletTypes = ["software", "ledger"];
|
|
229
|
-
var walletTypeSchema =
|
|
484
|
+
var walletTypeSchema = v12.picklist(walletTypes);
|
|
230
485
|
|
|
231
486
|
// src/request/types/btcMethods.ts
|
|
232
487
|
var getInfoMethodName = "getInfo";
|
|
233
|
-
var getInfoParamsSchema =
|
|
234
|
-
var getInfoResultSchema =
|
|
488
|
+
var getInfoParamsSchema = v13.nullish(v13.null());
|
|
489
|
+
var getInfoResultSchema = v13.object({
|
|
235
490
|
/**
|
|
236
491
|
* Version of the wallet.
|
|
237
492
|
*/
|
|
238
|
-
version:
|
|
493
|
+
version: v13.string(),
|
|
239
494
|
/**
|
|
240
495
|
* [WBIP](https://wbips.netlify.app/wbips/WBIP002) methods supported by the wallet.
|
|
241
496
|
*/
|
|
242
|
-
methods:
|
|
497
|
+
methods: v13.optional(v13.array(v13.string())),
|
|
243
498
|
/**
|
|
244
499
|
* List of WBIP standards supported by the wallet. Not currently used.
|
|
245
500
|
*/
|
|
246
|
-
supports:
|
|
501
|
+
supports: v13.array(v13.string())
|
|
247
502
|
});
|
|
248
|
-
var getInfoRequestMessageSchema =
|
|
503
|
+
var getInfoRequestMessageSchema = v13.object({
|
|
249
504
|
...rpcRequestMessageSchema.entries,
|
|
250
|
-
...
|
|
251
|
-
method:
|
|
505
|
+
...v13.object({
|
|
506
|
+
method: v13.literal(getInfoMethodName),
|
|
252
507
|
params: getInfoParamsSchema,
|
|
253
|
-
id:
|
|
508
|
+
id: v13.string()
|
|
254
509
|
}).entries
|
|
255
510
|
});
|
|
256
511
|
var getAddressesMethodName = "getAddresses";
|
|
257
|
-
var getAddressesParamsSchema =
|
|
512
|
+
var getAddressesParamsSchema = v13.object({
|
|
258
513
|
/**
|
|
259
514
|
* The purposes for which to generate addresses. See
|
|
260
515
|
* {@linkcode AddressPurpose} for available purposes.
|
|
261
516
|
*/
|
|
262
|
-
purposes:
|
|
517
|
+
purposes: v13.array(v13.enum(AddressPurpose)),
|
|
263
518
|
/**
|
|
264
519
|
* A message to be displayed to the user in the request prompt.
|
|
265
520
|
*/
|
|
266
|
-
message:
|
|
521
|
+
message: v13.optional(v13.string())
|
|
267
522
|
});
|
|
268
|
-
var getAddressesResultSchema =
|
|
523
|
+
var getAddressesResultSchema = v13.object({
|
|
269
524
|
/**
|
|
270
525
|
* The addresses generated for the given purposes.
|
|
271
526
|
*/
|
|
272
|
-
addresses:
|
|
527
|
+
addresses: v13.array(addressSchema)
|
|
273
528
|
});
|
|
274
|
-
var getAddressesRequestMessageSchema =
|
|
529
|
+
var getAddressesRequestMessageSchema = v13.object({
|
|
275
530
|
...rpcRequestMessageSchema.entries,
|
|
276
|
-
...
|
|
277
|
-
method:
|
|
531
|
+
...v13.object({
|
|
532
|
+
method: v13.literal(getAddressesMethodName),
|
|
278
533
|
params: getAddressesParamsSchema,
|
|
279
|
-
id:
|
|
534
|
+
id: v13.string()
|
|
280
535
|
}).entries
|
|
281
536
|
});
|
|
282
537
|
var signMessageMethodName = "signMessage";
|
|
@@ -285,250 +540,935 @@ var MessageSigningProtocols = /* @__PURE__ */ ((MessageSigningProtocols2) => {
|
|
|
285
540
|
MessageSigningProtocols2["BIP322"] = "BIP322";
|
|
286
541
|
return MessageSigningProtocols2;
|
|
287
542
|
})(MessageSigningProtocols || {});
|
|
288
|
-
var signMessageParamsSchema =
|
|
543
|
+
var signMessageParamsSchema = v13.object({
|
|
289
544
|
/**
|
|
290
545
|
* The address used for signing.
|
|
291
546
|
**/
|
|
292
|
-
address:
|
|
547
|
+
address: v13.string(),
|
|
293
548
|
/**
|
|
294
549
|
* The message to sign.
|
|
295
550
|
**/
|
|
296
|
-
message:
|
|
551
|
+
message: v13.string(),
|
|
297
552
|
/**
|
|
298
553
|
* The protocol to use for signing the message.
|
|
299
554
|
*/
|
|
300
|
-
protocol:
|
|
555
|
+
protocol: v13.optional(v13.enum(MessageSigningProtocols))
|
|
301
556
|
});
|
|
302
|
-
var signMessageResultSchema =
|
|
557
|
+
var signMessageResultSchema = v13.object({
|
|
303
558
|
/**
|
|
304
559
|
* The signature of the message.
|
|
305
560
|
*/
|
|
306
|
-
signature:
|
|
561
|
+
signature: v13.string(),
|
|
307
562
|
/**
|
|
308
563
|
* hash of the message.
|
|
309
564
|
*/
|
|
310
|
-
messageHash:
|
|
565
|
+
messageHash: v13.string(),
|
|
311
566
|
/**
|
|
312
567
|
* The address used for signing.
|
|
313
568
|
*/
|
|
314
|
-
address:
|
|
569
|
+
address: v13.string(),
|
|
315
570
|
/**
|
|
316
571
|
* The protocol to use for signing the message.
|
|
317
572
|
*/
|
|
318
|
-
protocol:
|
|
573
|
+
protocol: v13.enum(MessageSigningProtocols)
|
|
319
574
|
});
|
|
320
|
-
var signMessageRequestMessageSchema =
|
|
575
|
+
var signMessageRequestMessageSchema = v13.object({
|
|
321
576
|
...rpcRequestMessageSchema.entries,
|
|
322
|
-
...
|
|
323
|
-
method:
|
|
577
|
+
...v13.object({
|
|
578
|
+
method: v13.literal(signMessageMethodName),
|
|
324
579
|
params: signMessageParamsSchema,
|
|
325
|
-
id:
|
|
580
|
+
id: v13.string()
|
|
581
|
+
}).entries
|
|
582
|
+
});
|
|
583
|
+
var sendTransferMethodName = "sendTransfer";
|
|
584
|
+
var sendTransferParamsSchema = v13.object({
|
|
585
|
+
/**
|
|
586
|
+
* Array of recipients to send to.
|
|
587
|
+
* The amount to send to each recipient is in satoshis.
|
|
588
|
+
*/
|
|
589
|
+
recipients: v13.array(
|
|
590
|
+
v13.object({
|
|
591
|
+
address: v13.string(),
|
|
592
|
+
amount: v13.number()
|
|
593
|
+
})
|
|
594
|
+
)
|
|
595
|
+
});
|
|
596
|
+
var sendTransferResultSchema = v13.object({
|
|
597
|
+
/**
|
|
598
|
+
* The transaction id as a hex-encoded string.
|
|
599
|
+
*/
|
|
600
|
+
txid: v13.string()
|
|
601
|
+
});
|
|
602
|
+
var sendTransferRequestMessageSchema = v13.object({
|
|
603
|
+
...rpcRequestMessageSchema.entries,
|
|
604
|
+
...v13.object({
|
|
605
|
+
method: v13.literal(sendTransferMethodName),
|
|
606
|
+
params: sendTransferParamsSchema,
|
|
607
|
+
id: v13.string()
|
|
608
|
+
}).entries
|
|
609
|
+
});
|
|
610
|
+
var signPsbtMethodName = "signPsbt";
|
|
611
|
+
var signPsbtParamsSchema = v13.object({
|
|
612
|
+
/**
|
|
613
|
+
* The base64 encoded PSBT to sign.
|
|
614
|
+
*/
|
|
615
|
+
psbt: v13.string(),
|
|
616
|
+
/**
|
|
617
|
+
* The inputs to sign.
|
|
618
|
+
* The key is the address and the value is an array of indexes of the inputs to sign.
|
|
619
|
+
*/
|
|
620
|
+
signInputs: v13.record(v13.string(), v13.array(v13.number())),
|
|
621
|
+
/**
|
|
622
|
+
* Whether to broadcast the transaction after signing.
|
|
623
|
+
**/
|
|
624
|
+
broadcast: v13.optional(v13.boolean())
|
|
625
|
+
});
|
|
626
|
+
var signPsbtResultSchema = v13.object({
|
|
627
|
+
/**
|
|
628
|
+
* The base64 encoded PSBT after signing.
|
|
629
|
+
*/
|
|
630
|
+
psbt: v13.string(),
|
|
631
|
+
/**
|
|
632
|
+
* The transaction id as a hex-encoded string.
|
|
633
|
+
* This is only returned if the transaction was broadcast.
|
|
634
|
+
**/
|
|
635
|
+
txid: v13.optional(v13.string())
|
|
636
|
+
});
|
|
637
|
+
var signPsbtRequestMessageSchema = v13.object({
|
|
638
|
+
...rpcRequestMessageSchema.entries,
|
|
639
|
+
...v13.object({
|
|
640
|
+
method: v13.literal(signPsbtMethodName),
|
|
641
|
+
params: signPsbtParamsSchema,
|
|
642
|
+
id: v13.string()
|
|
326
643
|
}).entries
|
|
327
644
|
});
|
|
328
645
|
var getAccountsMethodName = "getAccounts";
|
|
329
|
-
var getAccountsParamsSchema =
|
|
646
|
+
var getAccountsParamsSchema = v13.object({
|
|
330
647
|
/**
|
|
331
648
|
* The purposes for which to generate addresses. See
|
|
332
649
|
* {@linkcode AddressPurpose} for available purposes.
|
|
333
650
|
*/
|
|
334
|
-
purposes:
|
|
651
|
+
purposes: v13.array(v13.enum(AddressPurpose)),
|
|
335
652
|
/**
|
|
336
653
|
* A message to be displayed to the user in the request prompt.
|
|
337
654
|
*/
|
|
338
|
-
message:
|
|
655
|
+
message: v13.optional(v13.string())
|
|
339
656
|
});
|
|
340
|
-
var getAccountsResultSchema =
|
|
341
|
-
|
|
657
|
+
var getAccountsResultSchema = v13.array(
|
|
658
|
+
v13.object({
|
|
342
659
|
...addressSchema.entries,
|
|
343
|
-
...
|
|
660
|
+
...v13.object({
|
|
344
661
|
walletType: walletTypeSchema
|
|
345
662
|
}).entries
|
|
346
663
|
})
|
|
347
664
|
);
|
|
348
|
-
var getAccountsRequestMessageSchema =
|
|
665
|
+
var getAccountsRequestMessageSchema = v13.object({
|
|
349
666
|
...rpcRequestMessageSchema.entries,
|
|
350
|
-
...
|
|
351
|
-
method:
|
|
667
|
+
...v13.object({
|
|
668
|
+
method: v13.literal(getAccountsMethodName),
|
|
352
669
|
params: getAccountsParamsSchema,
|
|
353
|
-
id:
|
|
670
|
+
id: v13.string()
|
|
354
671
|
}).entries
|
|
355
672
|
});
|
|
356
673
|
var getBalanceMethodName = "getBalance";
|
|
357
|
-
var getBalanceParamsSchema =
|
|
358
|
-
var getBalanceResultSchema =
|
|
674
|
+
var getBalanceParamsSchema = v13.nullish(v13.null());
|
|
675
|
+
var getBalanceResultSchema = v13.object({
|
|
359
676
|
/**
|
|
360
677
|
* The confirmed balance of the wallet in sats. Using a string due to chrome
|
|
361
678
|
* messages not supporting bigint
|
|
362
679
|
* (https://issues.chromium.org/issues/40116184).
|
|
363
680
|
*/
|
|
364
|
-
confirmed:
|
|
681
|
+
confirmed: v13.string(),
|
|
365
682
|
/**
|
|
366
683
|
* The unconfirmed balance of the wallet in sats. Using a string due to chrome
|
|
367
684
|
* messages not supporting bigint
|
|
368
685
|
* (https://issues.chromium.org/issues/40116184).
|
|
369
686
|
*/
|
|
370
|
-
unconfirmed:
|
|
687
|
+
unconfirmed: v13.string(),
|
|
371
688
|
/**
|
|
372
689
|
* The total balance (both confirmed and unconfrimed UTXOs) of the wallet in
|
|
373
690
|
* sats. Using a string due to chrome messages not supporting bigint
|
|
374
691
|
* (https://issues.chromium.org/issues/40116184).
|
|
375
692
|
*/
|
|
376
|
-
total:
|
|
693
|
+
total: v13.string()
|
|
377
694
|
});
|
|
378
|
-
var getBalanceRequestMessageSchema =
|
|
695
|
+
var getBalanceRequestMessageSchema = v13.object({
|
|
379
696
|
...rpcRequestMessageSchema.entries,
|
|
380
|
-
...
|
|
381
|
-
method:
|
|
382
|
-
id:
|
|
697
|
+
...v13.object({
|
|
698
|
+
method: v13.literal(getBalanceMethodName),
|
|
699
|
+
id: v13.string()
|
|
383
700
|
}).entries
|
|
384
701
|
});
|
|
385
702
|
|
|
386
703
|
// src/request/types/walletMethods.ts
|
|
387
|
-
import * as
|
|
388
|
-
|
|
704
|
+
import * as v19 from "valibot";
|
|
705
|
+
|
|
706
|
+
// node_modules/@noble/hashes/esm/_assert.js
|
|
707
|
+
function isBytes(a) {
|
|
708
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
709
|
+
}
|
|
710
|
+
function bytes(b, ...lengths) {
|
|
711
|
+
if (!isBytes(b))
|
|
712
|
+
throw new Error("Uint8Array expected");
|
|
713
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
714
|
+
throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
|
|
715
|
+
}
|
|
716
|
+
function exists(instance, checkFinished = true) {
|
|
717
|
+
if (instance.destroyed)
|
|
718
|
+
throw new Error("Hash instance has been destroyed");
|
|
719
|
+
if (checkFinished && instance.finished)
|
|
720
|
+
throw new Error("Hash#digest() has already been called");
|
|
721
|
+
}
|
|
722
|
+
function output(out, instance) {
|
|
723
|
+
bytes(out);
|
|
724
|
+
const min = instance.outputLen;
|
|
725
|
+
if (out.length < min) {
|
|
726
|
+
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
// node_modules/@noble/hashes/esm/utils.js
|
|
731
|
+
var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
732
|
+
var rotr = (word, shift) => word << 32 - shift | word >>> shift;
|
|
733
|
+
var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
734
|
+
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
735
|
+
function bytesToHex(bytes2) {
|
|
736
|
+
bytes(bytes2);
|
|
737
|
+
let hex = "";
|
|
738
|
+
for (let i = 0; i < bytes2.length; i++) {
|
|
739
|
+
hex += hexes[bytes2[i]];
|
|
740
|
+
}
|
|
741
|
+
return hex;
|
|
742
|
+
}
|
|
743
|
+
function utf8ToBytes(str) {
|
|
744
|
+
if (typeof str !== "string")
|
|
745
|
+
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
746
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
747
|
+
}
|
|
748
|
+
function toBytes(data) {
|
|
749
|
+
if (typeof data === "string")
|
|
750
|
+
data = utf8ToBytes(data);
|
|
751
|
+
bytes(data);
|
|
752
|
+
return data;
|
|
753
|
+
}
|
|
754
|
+
var Hash = class {
|
|
755
|
+
// Safe version that clones internal state
|
|
756
|
+
clone() {
|
|
757
|
+
return this._cloneInto();
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
var toStr = {}.toString;
|
|
761
|
+
function wrapConstructor(hashCons) {
|
|
762
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
763
|
+
const tmp = hashCons();
|
|
764
|
+
hashC.outputLen = tmp.outputLen;
|
|
765
|
+
hashC.blockLen = tmp.blockLen;
|
|
766
|
+
hashC.create = () => hashCons();
|
|
767
|
+
return hashC;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// node_modules/@noble/hashes/esm/_md.js
|
|
771
|
+
function setBigUint64(view, byteOffset, value, isLE2) {
|
|
772
|
+
if (typeof view.setBigUint64 === "function")
|
|
773
|
+
return view.setBigUint64(byteOffset, value, isLE2);
|
|
774
|
+
const _32n = BigInt(32);
|
|
775
|
+
const _u32_max = BigInt(4294967295);
|
|
776
|
+
const wh = Number(value >> _32n & _u32_max);
|
|
777
|
+
const wl = Number(value & _u32_max);
|
|
778
|
+
const h = isLE2 ? 4 : 0;
|
|
779
|
+
const l = isLE2 ? 0 : 4;
|
|
780
|
+
view.setUint32(byteOffset + h, wh, isLE2);
|
|
781
|
+
view.setUint32(byteOffset + l, wl, isLE2);
|
|
782
|
+
}
|
|
783
|
+
var Chi = (a, b, c) => a & b ^ ~a & c;
|
|
784
|
+
var Maj = (a, b, c) => a & b ^ a & c ^ b & c;
|
|
785
|
+
var HashMD = class extends Hash {
|
|
786
|
+
constructor(blockLen, outputLen, padOffset, isLE2) {
|
|
787
|
+
super();
|
|
788
|
+
this.blockLen = blockLen;
|
|
789
|
+
this.outputLen = outputLen;
|
|
790
|
+
this.padOffset = padOffset;
|
|
791
|
+
this.isLE = isLE2;
|
|
792
|
+
this.finished = false;
|
|
793
|
+
this.length = 0;
|
|
794
|
+
this.pos = 0;
|
|
795
|
+
this.destroyed = false;
|
|
796
|
+
this.buffer = new Uint8Array(blockLen);
|
|
797
|
+
this.view = createView(this.buffer);
|
|
798
|
+
}
|
|
799
|
+
update(data) {
|
|
800
|
+
exists(this);
|
|
801
|
+
const { view, buffer, blockLen } = this;
|
|
802
|
+
data = toBytes(data);
|
|
803
|
+
const len = data.length;
|
|
804
|
+
for (let pos = 0; pos < len; ) {
|
|
805
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
806
|
+
if (take === blockLen) {
|
|
807
|
+
const dataView = createView(data);
|
|
808
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
809
|
+
this.process(dataView, pos);
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
813
|
+
this.pos += take;
|
|
814
|
+
pos += take;
|
|
815
|
+
if (this.pos === blockLen) {
|
|
816
|
+
this.process(view, 0);
|
|
817
|
+
this.pos = 0;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
this.length += data.length;
|
|
821
|
+
this.roundClean();
|
|
822
|
+
return this;
|
|
823
|
+
}
|
|
824
|
+
digestInto(out) {
|
|
825
|
+
exists(this);
|
|
826
|
+
output(out, this);
|
|
827
|
+
this.finished = true;
|
|
828
|
+
const { buffer, view, blockLen, isLE: isLE2 } = this;
|
|
829
|
+
let { pos } = this;
|
|
830
|
+
buffer[pos++] = 128;
|
|
831
|
+
this.buffer.subarray(pos).fill(0);
|
|
832
|
+
if (this.padOffset > blockLen - pos) {
|
|
833
|
+
this.process(view, 0);
|
|
834
|
+
pos = 0;
|
|
835
|
+
}
|
|
836
|
+
for (let i = pos; i < blockLen; i++)
|
|
837
|
+
buffer[i] = 0;
|
|
838
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE2);
|
|
839
|
+
this.process(view, 0);
|
|
840
|
+
const oview = createView(out);
|
|
841
|
+
const len = this.outputLen;
|
|
842
|
+
if (len % 4)
|
|
843
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
844
|
+
const outLen = len / 4;
|
|
845
|
+
const state = this.get();
|
|
846
|
+
if (outLen > state.length)
|
|
847
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
848
|
+
for (let i = 0; i < outLen; i++)
|
|
849
|
+
oview.setUint32(4 * i, state[i], isLE2);
|
|
850
|
+
}
|
|
851
|
+
digest() {
|
|
852
|
+
const { buffer, outputLen } = this;
|
|
853
|
+
this.digestInto(buffer);
|
|
854
|
+
const res = buffer.slice(0, outputLen);
|
|
855
|
+
this.destroy();
|
|
856
|
+
return res;
|
|
857
|
+
}
|
|
858
|
+
_cloneInto(to) {
|
|
859
|
+
to || (to = new this.constructor());
|
|
860
|
+
to.set(...this.get());
|
|
861
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
862
|
+
to.length = length;
|
|
863
|
+
to.pos = pos;
|
|
864
|
+
to.finished = finished;
|
|
865
|
+
to.destroyed = destroyed;
|
|
866
|
+
if (length % blockLen)
|
|
867
|
+
to.buffer.set(buffer);
|
|
868
|
+
return to;
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
// node_modules/@noble/hashes/esm/sha256.js
|
|
873
|
+
var SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
874
|
+
1116352408,
|
|
875
|
+
1899447441,
|
|
876
|
+
3049323471,
|
|
877
|
+
3921009573,
|
|
878
|
+
961987163,
|
|
879
|
+
1508970993,
|
|
880
|
+
2453635748,
|
|
881
|
+
2870763221,
|
|
882
|
+
3624381080,
|
|
883
|
+
310598401,
|
|
884
|
+
607225278,
|
|
885
|
+
1426881987,
|
|
886
|
+
1925078388,
|
|
887
|
+
2162078206,
|
|
888
|
+
2614888103,
|
|
889
|
+
3248222580,
|
|
890
|
+
3835390401,
|
|
891
|
+
4022224774,
|
|
892
|
+
264347078,
|
|
893
|
+
604807628,
|
|
894
|
+
770255983,
|
|
895
|
+
1249150122,
|
|
896
|
+
1555081692,
|
|
897
|
+
1996064986,
|
|
898
|
+
2554220882,
|
|
899
|
+
2821834349,
|
|
900
|
+
2952996808,
|
|
901
|
+
3210313671,
|
|
902
|
+
3336571891,
|
|
903
|
+
3584528711,
|
|
904
|
+
113926993,
|
|
905
|
+
338241895,
|
|
906
|
+
666307205,
|
|
907
|
+
773529912,
|
|
908
|
+
1294757372,
|
|
909
|
+
1396182291,
|
|
910
|
+
1695183700,
|
|
911
|
+
1986661051,
|
|
912
|
+
2177026350,
|
|
913
|
+
2456956037,
|
|
914
|
+
2730485921,
|
|
915
|
+
2820302411,
|
|
916
|
+
3259730800,
|
|
917
|
+
3345764771,
|
|
918
|
+
3516065817,
|
|
919
|
+
3600352804,
|
|
920
|
+
4094571909,
|
|
921
|
+
275423344,
|
|
922
|
+
430227734,
|
|
923
|
+
506948616,
|
|
924
|
+
659060556,
|
|
925
|
+
883997877,
|
|
926
|
+
958139571,
|
|
927
|
+
1322822218,
|
|
928
|
+
1537002063,
|
|
929
|
+
1747873779,
|
|
930
|
+
1955562222,
|
|
931
|
+
2024104815,
|
|
932
|
+
2227730452,
|
|
933
|
+
2361852424,
|
|
934
|
+
2428436474,
|
|
935
|
+
2756734187,
|
|
936
|
+
3204031479,
|
|
937
|
+
3329325298
|
|
938
|
+
]);
|
|
939
|
+
var SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
|
940
|
+
1779033703,
|
|
941
|
+
3144134277,
|
|
942
|
+
1013904242,
|
|
943
|
+
2773480762,
|
|
944
|
+
1359893119,
|
|
945
|
+
2600822924,
|
|
946
|
+
528734635,
|
|
947
|
+
1541459225
|
|
948
|
+
]);
|
|
949
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
950
|
+
var SHA256 = class extends HashMD {
|
|
951
|
+
constructor() {
|
|
952
|
+
super(64, 32, 8, false);
|
|
953
|
+
this.A = SHA256_IV[0] | 0;
|
|
954
|
+
this.B = SHA256_IV[1] | 0;
|
|
955
|
+
this.C = SHA256_IV[2] | 0;
|
|
956
|
+
this.D = SHA256_IV[3] | 0;
|
|
957
|
+
this.E = SHA256_IV[4] | 0;
|
|
958
|
+
this.F = SHA256_IV[5] | 0;
|
|
959
|
+
this.G = SHA256_IV[6] | 0;
|
|
960
|
+
this.H = SHA256_IV[7] | 0;
|
|
961
|
+
}
|
|
962
|
+
get() {
|
|
963
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
964
|
+
return [A, B, C, D, E, F, G, H];
|
|
965
|
+
}
|
|
966
|
+
// prettier-ignore
|
|
967
|
+
set(A, B, C, D, E, F, G, H) {
|
|
968
|
+
this.A = A | 0;
|
|
969
|
+
this.B = B | 0;
|
|
970
|
+
this.C = C | 0;
|
|
971
|
+
this.D = D | 0;
|
|
972
|
+
this.E = E | 0;
|
|
973
|
+
this.F = F | 0;
|
|
974
|
+
this.G = G | 0;
|
|
975
|
+
this.H = H | 0;
|
|
976
|
+
}
|
|
977
|
+
process(view, offset) {
|
|
978
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
979
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
980
|
+
for (let i = 16; i < 64; i++) {
|
|
981
|
+
const W15 = SHA256_W[i - 15];
|
|
982
|
+
const W2 = SHA256_W[i - 2];
|
|
983
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
984
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
985
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
986
|
+
}
|
|
987
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
988
|
+
for (let i = 0; i < 64; i++) {
|
|
989
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
990
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
991
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
992
|
+
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
993
|
+
H = G;
|
|
994
|
+
G = F;
|
|
995
|
+
F = E;
|
|
996
|
+
E = D + T1 | 0;
|
|
997
|
+
D = C;
|
|
998
|
+
C = B;
|
|
999
|
+
B = A;
|
|
1000
|
+
A = T1 + T2 | 0;
|
|
1001
|
+
}
|
|
1002
|
+
A = A + this.A | 0;
|
|
1003
|
+
B = B + this.B | 0;
|
|
1004
|
+
C = C + this.C | 0;
|
|
1005
|
+
D = D + this.D | 0;
|
|
1006
|
+
E = E + this.E | 0;
|
|
1007
|
+
F = F + this.F | 0;
|
|
1008
|
+
G = G + this.G | 0;
|
|
1009
|
+
H = H + this.H | 0;
|
|
1010
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
1011
|
+
}
|
|
1012
|
+
roundClean() {
|
|
1013
|
+
SHA256_W.fill(0);
|
|
1014
|
+
}
|
|
1015
|
+
destroy() {
|
|
1016
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
1017
|
+
this.buffer.fill(0);
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
1021
|
+
|
|
1022
|
+
// src/request/types/permissions/resources/account.ts
|
|
1023
|
+
import * as v16 from "valibot";
|
|
1024
|
+
|
|
1025
|
+
// src/request/types/permissions/resources/common.ts
|
|
1026
|
+
import * as v14 from "valibot";
|
|
1027
|
+
var actionDescriptionSchema = v14.object({
|
|
1028
|
+
name: v14.string(),
|
|
1029
|
+
description: v14.variant("type", [
|
|
1030
|
+
v14.object({ type: v14.literal("single"), value: v14.string() }),
|
|
1031
|
+
v14.object({ type: v14.literal("multiple"), values: v14.array(v14.string()) })
|
|
1032
|
+
])
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
// src/request/types/permissions/utils/account-id.ts
|
|
1036
|
+
import * as v15 from "valibot";
|
|
1037
|
+
var accountIdBrandName = "AccountId";
|
|
1038
|
+
var accountIdSchema = v15.pipe(v15.string(), v15.brand(accountIdBrandName));
|
|
1039
|
+
function makeAccountId(options) {
|
|
1040
|
+
return v15.parse(
|
|
1041
|
+
accountIdSchema,
|
|
1042
|
+
bytesToHex(
|
|
1043
|
+
sha256(
|
|
1044
|
+
`account-${options.masterPubKey}-${// NOTE: This "account ID" is actually the ~account~ address index from BIP-44.
|
|
1045
|
+
options.accountId}-${options.networkType}`
|
|
1046
|
+
)
|
|
1047
|
+
)
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// src/request/types/permissions/resources/account.ts
|
|
1052
|
+
var accountResourceIdBrandName = "AccountResourceId";
|
|
1053
|
+
var sha256HexStringRegex = /^[\da-f]{64}$/;
|
|
1054
|
+
var accountResourceIdSchema = v16.pipe(
|
|
1055
|
+
v16.string(),
|
|
1056
|
+
v16.check((input) => sha256HexStringRegex.test(input)),
|
|
1057
|
+
v16.brand("AccountResourceId")
|
|
1058
|
+
);
|
|
1059
|
+
function makeAccountResourceId(accountId) {
|
|
1060
|
+
return v16.parse(accountResourceIdSchema, bytesToHex(sha256(`account-resource-${accountId}`)));
|
|
1061
|
+
}
|
|
1062
|
+
var accountResourceSchema = v16.object({
|
|
1063
|
+
type: v16.literal("account"),
|
|
1064
|
+
id: accountResourceIdSchema,
|
|
1065
|
+
accountId: accountIdSchema,
|
|
1066
|
+
name: v16.string()
|
|
1067
|
+
});
|
|
1068
|
+
function makeAccountResource(args) {
|
|
1069
|
+
return {
|
|
1070
|
+
type: "account",
|
|
1071
|
+
id: makeAccountResourceId(args.accountId),
|
|
1072
|
+
accountId: args.accountId,
|
|
1073
|
+
name: `Account ${args.accountId}, ${args.masterPubKey.slice(0, 6)}...(${args.networkType})`
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
var accountActionsSchema = v16.object({
|
|
1077
|
+
read: v16.optional(v16.boolean()),
|
|
1078
|
+
autoSign: v16.optional(v16.boolean()),
|
|
1079
|
+
rename: v16.optional(v16.boolean())
|
|
1080
|
+
});
|
|
1081
|
+
var accountActionsDescriptionSchema = v16.record(
|
|
1082
|
+
v16.keyof(accountActionsSchema),
|
|
1083
|
+
actionDescriptionSchema
|
|
1084
|
+
);
|
|
1085
|
+
var accountPermissionSchema = v16.object({
|
|
1086
|
+
type: v16.literal("account"),
|
|
1087
|
+
resourceId: accountResourceIdSchema,
|
|
1088
|
+
clientId: v16.string(),
|
|
1089
|
+
actions: accountActionsSchema
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
// src/request/types/permissions/resources/wallet.ts
|
|
1093
|
+
import * as v17 from "valibot";
|
|
1094
|
+
var walletResourceSchema = v17.object({
|
|
1095
|
+
type: v17.literal("wallet"),
|
|
1096
|
+
id: v17.literal("wallet"),
|
|
1097
|
+
name: v17.literal("Wallet")
|
|
1098
|
+
});
|
|
1099
|
+
var walletActionsSchema = v17.object({
|
|
1100
|
+
addPrivateKey: v17.optional(v17.boolean()),
|
|
1101
|
+
openPopup: v17.optional(v17.boolean()),
|
|
1102
|
+
openFullPage: v17.optional(v17.boolean()),
|
|
1103
|
+
readAllAccounts: v17.optional(v17.boolean())
|
|
1104
|
+
});
|
|
1105
|
+
var walletActionsDescriptionSchema = v17.record(
|
|
1106
|
+
v17.keyof(walletActionsSchema),
|
|
1107
|
+
actionDescriptionSchema
|
|
1108
|
+
);
|
|
1109
|
+
var walletIdSchema = v17.literal("wallet");
|
|
1110
|
+
var walletPermissionSchema = v17.object({
|
|
1111
|
+
type: v17.literal("wallet"),
|
|
1112
|
+
resourceId: walletIdSchema,
|
|
1113
|
+
clientId: v17.string(),
|
|
1114
|
+
actions: walletActionsSchema
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
// src/request/types/permissions/resources/index.ts
|
|
1118
|
+
var account = {
|
|
1119
|
+
accountResourceIdBrandName,
|
|
1120
|
+
accountResourceIdSchema,
|
|
1121
|
+
accountResourceSchema,
|
|
1122
|
+
accountActionsSchema,
|
|
1123
|
+
accountActionsDescriptionSchema,
|
|
1124
|
+
accountPermissionSchema,
|
|
1125
|
+
makeAccountResourceId,
|
|
1126
|
+
makeAccountResource
|
|
1127
|
+
};
|
|
1128
|
+
var common = {
|
|
1129
|
+
actionDescriptionSchema
|
|
1130
|
+
};
|
|
1131
|
+
var wallet = {
|
|
1132
|
+
walletResourceSchema,
|
|
1133
|
+
walletActionsSchema,
|
|
1134
|
+
walletIdSchema,
|
|
1135
|
+
walletPermissionSchema,
|
|
1136
|
+
walletActionsDescriptionSchema
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
// src/request/types/permissions/utils/index.ts
|
|
1140
|
+
var account2 = {
|
|
1141
|
+
makeAccountId,
|
|
1142
|
+
accountIdBrandName,
|
|
1143
|
+
accountIdSchema
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
// src/request/types/permissions/store.ts
|
|
1147
|
+
import * as v18 from "valibot";
|
|
1148
|
+
var clientId = v18.pipe(v18.string(), v18.url(), v18.brand("ClientId"));
|
|
1149
|
+
var client = v18.object({
|
|
1150
|
+
id: clientId,
|
|
1151
|
+
origin: v18.string(),
|
|
1152
|
+
name: v18.optional(v18.string()),
|
|
1153
|
+
description: v18.optional(v18.string())
|
|
1154
|
+
});
|
|
1155
|
+
var clientsTable = v18.array(client);
|
|
1156
|
+
var clientMetadata = v18.object({
|
|
1157
|
+
clientId: client.entries.id,
|
|
1158
|
+
lastUsed: v18.optional(v18.number())
|
|
1159
|
+
});
|
|
1160
|
+
var clientMetadataTable = v18.array(clientMetadata);
|
|
1161
|
+
var resource = v18.variant("type", [accountResourceSchema, walletResourceSchema]);
|
|
1162
|
+
var resourcesTable = v18.array(resource);
|
|
1163
|
+
var permission = v18.variant("type", [accountPermissionSchema, walletPermissionSchema]);
|
|
1164
|
+
var permissionsTable = v18.array(permission);
|
|
1165
|
+
var permissionsStore = v18.object({
|
|
1166
|
+
version: v18.literal(4),
|
|
1167
|
+
clients: clientsTable,
|
|
1168
|
+
clientMetadata: clientMetadataTable,
|
|
1169
|
+
resources: resourcesTable,
|
|
1170
|
+
permissions: permissionsTable
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
// src/request/types/permissions/index.ts
|
|
1174
|
+
var resources = {
|
|
1175
|
+
account,
|
|
1176
|
+
common,
|
|
1177
|
+
wallet
|
|
1178
|
+
};
|
|
1179
|
+
var utils = {
|
|
1180
|
+
account: account2
|
|
1181
|
+
};
|
|
1182
|
+
var store = {
|
|
1183
|
+
clientId,
|
|
1184
|
+
client,
|
|
1185
|
+
clientMetadata,
|
|
1186
|
+
clientMetadataTable,
|
|
1187
|
+
clientsTable,
|
|
1188
|
+
resource,
|
|
1189
|
+
resourcesTable,
|
|
1190
|
+
permission,
|
|
1191
|
+
permissionsTable,
|
|
1192
|
+
permissionsStore
|
|
1193
|
+
};
|
|
1194
|
+
var permissions = {
|
|
1195
|
+
resources,
|
|
1196
|
+
utils,
|
|
1197
|
+
store
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
// src/request/types/walletMethods.ts
|
|
1201
|
+
var permissionTemplate = v19.variant("type", [
|
|
1202
|
+
v19.object({
|
|
1203
|
+
...v19.omit(permissions.resources.account.accountPermissionSchema, ["clientId"]).entries
|
|
1204
|
+
}),
|
|
1205
|
+
v19.object({
|
|
1206
|
+
...v19.omit(permissions.resources.wallet.walletPermissionSchema, ["clientId"]).entries
|
|
1207
|
+
})
|
|
1208
|
+
]);
|
|
389
1209
|
var requestPermissionsMethodName = "wallet_requestPermissions";
|
|
390
|
-
var requestPermissionsParamsSchema =
|
|
391
|
-
var requestPermissionsResultSchema =
|
|
392
|
-
var requestPermissionsRequestMessageSchema =
|
|
1210
|
+
var requestPermissionsParamsSchema = v19.nullish(v19.array(permissionTemplate));
|
|
1211
|
+
var requestPermissionsResultSchema = v19.literal(true);
|
|
1212
|
+
var requestPermissionsRequestMessageSchema = v19.object({
|
|
393
1213
|
...rpcRequestMessageSchema.entries,
|
|
394
|
-
...
|
|
395
|
-
method:
|
|
1214
|
+
...v19.object({
|
|
1215
|
+
method: v19.literal(requestPermissionsMethodName),
|
|
396
1216
|
params: requestPermissionsParamsSchema,
|
|
397
|
-
id:
|
|
1217
|
+
id: v19.string()
|
|
398
1218
|
}).entries
|
|
399
1219
|
});
|
|
400
1220
|
var renouncePermissionsMethodName = "wallet_renouncePermissions";
|
|
401
|
-
var renouncePermissionsParamsSchema =
|
|
402
|
-
var renouncePermissionsResultSchema =
|
|
403
|
-
var renouncePermissionsRequestMessageSchema =
|
|
1221
|
+
var renouncePermissionsParamsSchema = v19.nullish(v19.null());
|
|
1222
|
+
var renouncePermissionsResultSchema = v19.nullish(v19.null());
|
|
1223
|
+
var renouncePermissionsRequestMessageSchema = v19.object({
|
|
404
1224
|
...rpcRequestMessageSchema.entries,
|
|
405
|
-
...
|
|
406
|
-
method:
|
|
1225
|
+
...v19.object({
|
|
1226
|
+
method: v19.literal(renouncePermissionsMethodName),
|
|
407
1227
|
params: renouncePermissionsParamsSchema,
|
|
408
|
-
id:
|
|
1228
|
+
id: v19.string()
|
|
1229
|
+
}).entries
|
|
1230
|
+
});
|
|
1231
|
+
var disconnectMethodName = "wallet_disconnect";
|
|
1232
|
+
var disconnectParamsSchema = v19.nullish(v19.null());
|
|
1233
|
+
var disconnectResultSchema = v19.nullish(v19.null());
|
|
1234
|
+
var disconnectRequestMessageSchema = v19.object({
|
|
1235
|
+
...rpcRequestMessageSchema.entries,
|
|
1236
|
+
...v19.object({
|
|
1237
|
+
method: v19.literal(disconnectMethodName),
|
|
1238
|
+
params: disconnectParamsSchema,
|
|
1239
|
+
id: v19.string()
|
|
409
1240
|
}).entries
|
|
410
1241
|
});
|
|
411
1242
|
var getWalletTypeMethodName = "wallet_getWalletType";
|
|
412
|
-
var getWalletTypeParamsSchema =
|
|
1243
|
+
var getWalletTypeParamsSchema = v19.nullish(v19.null());
|
|
413
1244
|
var getWalletTypeResultSchema = walletTypeSchema;
|
|
414
|
-
var getWalletTypeRequestMessageSchema =
|
|
1245
|
+
var getWalletTypeRequestMessageSchema = v19.object({
|
|
415
1246
|
...rpcRequestMessageSchema.entries,
|
|
416
|
-
...
|
|
417
|
-
method:
|
|
418
|
-
|
|
1247
|
+
...v19.object({
|
|
1248
|
+
method: v19.literal(getWalletTypeMethodName),
|
|
1249
|
+
params: getWalletTypeParamsSchema,
|
|
1250
|
+
id: v19.string()
|
|
419
1251
|
}).entries
|
|
420
1252
|
});
|
|
421
1253
|
var getCurrentPermissionsMethodName = "wallet_getCurrentPermissions";
|
|
422
|
-
var getCurrentPermissionsParamsSchema =
|
|
423
|
-
var getCurrentPermissionsResultSchema =
|
|
424
|
-
|
|
1254
|
+
var getCurrentPermissionsParamsSchema = v19.nullish(v19.null());
|
|
1255
|
+
var getCurrentPermissionsResultSchema = v19.array(permissions.store.permission);
|
|
1256
|
+
var getCurrentPermissionsRequestMessageSchema = v19.object({
|
|
1257
|
+
...rpcRequestMessageSchema.entries,
|
|
1258
|
+
...v19.object({
|
|
1259
|
+
method: v19.literal(getCurrentPermissionsMethodName),
|
|
1260
|
+
params: getCurrentPermissionsParamsSchema,
|
|
1261
|
+
id: v19.string()
|
|
1262
|
+
}).entries
|
|
1263
|
+
});
|
|
1264
|
+
var getAccountMethodName = "wallet_getAccount";
|
|
1265
|
+
var getAccountParamsSchema = v19.nullish(v19.null());
|
|
1266
|
+
var getAccountResultSchema = v19.object({
|
|
1267
|
+
id: permissions.utils.account.accountIdSchema,
|
|
1268
|
+
addresses: v19.array(addressSchema),
|
|
1269
|
+
walletType: walletTypeSchema
|
|
1270
|
+
});
|
|
1271
|
+
var getAccountRequestMessageSchema = v19.object({
|
|
1272
|
+
...rpcRequestMessageSchema.entries,
|
|
1273
|
+
...v19.object({
|
|
1274
|
+
method: v19.literal(getAccountMethodName),
|
|
1275
|
+
params: getAccountParamsSchema,
|
|
1276
|
+
id: v19.string()
|
|
1277
|
+
}).entries
|
|
1278
|
+
});
|
|
1279
|
+
var connectMethodName = "wallet_connect";
|
|
1280
|
+
var connectParamsSchema = v19.nullish(
|
|
1281
|
+
v19.object({
|
|
1282
|
+
permissions: v19.optional(v19.array(permissionTemplate)),
|
|
1283
|
+
addresses: v19.optional(v19.array(v19.enum(AddressPurpose))),
|
|
1284
|
+
message: v19.optional(
|
|
1285
|
+
v19.pipe(v19.string(), v19.maxLength(80, "The message must not exceed 80 characters."))
|
|
1286
|
+
)
|
|
1287
|
+
})
|
|
425
1288
|
);
|
|
426
|
-
var
|
|
1289
|
+
var connectResultSchema = getAccountResultSchema;
|
|
1290
|
+
var connectRequestMessageSchema = v19.object({
|
|
427
1291
|
...rpcRequestMessageSchema.entries,
|
|
428
|
-
...
|
|
429
|
-
method:
|
|
430
|
-
|
|
1292
|
+
...v19.object({
|
|
1293
|
+
method: v19.literal(connectMethodName),
|
|
1294
|
+
params: connectParamsSchema,
|
|
1295
|
+
id: v19.string()
|
|
431
1296
|
}).entries
|
|
432
1297
|
});
|
|
433
1298
|
|
|
434
|
-
// src/request/types/runesMethods.ts
|
|
435
|
-
import * as
|
|
436
|
-
var
|
|
437
|
-
var
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1299
|
+
// src/request/types/runesMethods/etch.ts
|
|
1300
|
+
import * as v20 from "valibot";
|
|
1301
|
+
var runesEtchMethodName = "runes_etch";
|
|
1302
|
+
var etchTermsSchema = v20.object({
|
|
1303
|
+
amount: v20.string(),
|
|
1304
|
+
cap: v20.string(),
|
|
1305
|
+
heightStart: v20.optional(v20.string()),
|
|
1306
|
+
heightEnd: v20.optional(v20.string()),
|
|
1307
|
+
offsetStart: v20.optional(v20.string()),
|
|
1308
|
+
offsetEnd: v20.optional(v20.string())
|
|
1309
|
+
});
|
|
1310
|
+
var inscriptionDetailsSchema = v20.object({
|
|
1311
|
+
contentType: v20.string(),
|
|
1312
|
+
contentBase64: v20.string()
|
|
1313
|
+
});
|
|
1314
|
+
var runesEtchParamsSchema = v20.object({
|
|
1315
|
+
runeName: v20.string(),
|
|
1316
|
+
divisibility: v20.optional(v20.number()),
|
|
1317
|
+
symbol: v20.optional(v20.string()),
|
|
1318
|
+
premine: v20.optional(v20.string()),
|
|
1319
|
+
isMintable: v20.boolean(),
|
|
1320
|
+
delegateInscriptionId: v20.optional(v20.string()),
|
|
1321
|
+
destinationAddress: v20.string(),
|
|
1322
|
+
refundAddress: v20.string(),
|
|
1323
|
+
feeRate: v20.number(),
|
|
1324
|
+
appServiceFee: v20.optional(v20.number()),
|
|
1325
|
+
appServiceFeeAddress: v20.optional(v20.string()),
|
|
1326
|
+
terms: v20.optional(etchTermsSchema),
|
|
1327
|
+
inscriptionDetails: v20.optional(inscriptionDetailsSchema),
|
|
1328
|
+
network: v20.optional(v20.enum(BitcoinNetworkType))
|
|
1329
|
+
});
|
|
1330
|
+
var runesEtchResultSchema = v20.object({
|
|
1331
|
+
orderId: v20.string(),
|
|
1332
|
+
fundTransactionId: v20.string(),
|
|
1333
|
+
fundingAddress: v20.string()
|
|
1334
|
+
});
|
|
1335
|
+
var runesEtchRequestMessageSchema = v20.object({
|
|
1336
|
+
...rpcRequestMessageSchema.entries,
|
|
1337
|
+
...v20.object({
|
|
1338
|
+
method: v20.literal(runesEtchMethodName),
|
|
1339
|
+
params: runesEtchParamsSchema,
|
|
1340
|
+
id: v20.string()
|
|
1341
|
+
}).entries
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
// src/request/types/runesMethods/getBalance.ts
|
|
1345
|
+
import * as v21 from "valibot";
|
|
1346
|
+
var runesGetBalanceMethodName = "runes_getBalance";
|
|
1347
|
+
var runesGetBalanceParamsSchema = v21.nullish(v21.null());
|
|
1348
|
+
var runesGetBalanceResultSchema = v21.object({
|
|
1349
|
+
balances: v21.array(
|
|
1350
|
+
v21.object({
|
|
1351
|
+
runeName: v21.string(),
|
|
1352
|
+
amount: v21.string(),
|
|
1353
|
+
divisibility: v21.number(),
|
|
1354
|
+
symbol: v21.string(),
|
|
1355
|
+
inscriptionId: v21.nullish(v21.string())
|
|
446
1356
|
})
|
|
447
1357
|
)
|
|
448
1358
|
});
|
|
449
|
-
var
|
|
1359
|
+
var runesGetBalanceRequestMessageSchema = v21.object({
|
|
450
1360
|
...rpcRequestMessageSchema.entries,
|
|
451
|
-
...
|
|
452
|
-
method:
|
|
453
|
-
params:
|
|
454
|
-
id:
|
|
1361
|
+
...v21.object({
|
|
1362
|
+
method: v21.literal(runesGetBalanceMethodName),
|
|
1363
|
+
params: runesGetBalanceParamsSchema,
|
|
1364
|
+
id: v21.string()
|
|
455
1365
|
}).entries
|
|
456
1366
|
});
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
1367
|
+
|
|
1368
|
+
// src/request/types/runesMethods/mint.ts
|
|
1369
|
+
import * as v22 from "valibot";
|
|
1370
|
+
var runesMintMethodName = "runes_mint";
|
|
1371
|
+
var runesMintParamsSchema = v22.object({
|
|
1372
|
+
appServiceFee: v22.optional(v22.number()),
|
|
1373
|
+
appServiceFeeAddress: v22.optional(v22.string()),
|
|
1374
|
+
destinationAddress: v22.string(),
|
|
1375
|
+
feeRate: v22.number(),
|
|
1376
|
+
refundAddress: v22.string(),
|
|
1377
|
+
repeats: v22.number(),
|
|
1378
|
+
runeName: v22.string(),
|
|
1379
|
+
network: v22.optional(v22.enum(BitcoinNetworkType))
|
|
1380
|
+
});
|
|
1381
|
+
var runesMintResultSchema = v22.object({
|
|
1382
|
+
orderId: v22.string(),
|
|
1383
|
+
fundTransactionId: v22.string(),
|
|
1384
|
+
fundingAddress: v22.string()
|
|
1385
|
+
});
|
|
1386
|
+
var runesMintRequestMessageSchema = v22.object({
|
|
1387
|
+
...rpcRequestMessageSchema.entries,
|
|
1388
|
+
...v22.object({
|
|
1389
|
+
method: v22.literal(runesMintMethodName),
|
|
1390
|
+
params: runesMintParamsSchema,
|
|
1391
|
+
id: v22.string()
|
|
1392
|
+
}).entries
|
|
1393
|
+
});
|
|
1394
|
+
|
|
1395
|
+
// src/request/types/runesMethods/transfer.ts
|
|
1396
|
+
import * as v23 from "valibot";
|
|
1397
|
+
var runesTransferMethodName = "runes_transfer";
|
|
1398
|
+
var runesTransferParamsSchema = v23.object({
|
|
1399
|
+
recipients: v23.array(
|
|
1400
|
+
v23.object({
|
|
1401
|
+
runeName: v23.string(),
|
|
1402
|
+
amount: v23.string(),
|
|
1403
|
+
address: v23.string()
|
|
464
1404
|
})
|
|
465
1405
|
)
|
|
466
1406
|
});
|
|
467
|
-
var
|
|
1407
|
+
var runesTransferResultSchema = v23.object({
|
|
1408
|
+
txid: v23.string()
|
|
1409
|
+
});
|
|
1410
|
+
var runesTransferRequestMessageSchema = v23.object({
|
|
468
1411
|
...rpcRequestMessageSchema.entries,
|
|
469
|
-
...
|
|
470
|
-
method:
|
|
471
|
-
params:
|
|
472
|
-
id:
|
|
1412
|
+
...v23.object({
|
|
1413
|
+
method: v23.literal(runesTransferMethodName),
|
|
1414
|
+
params: runesTransferParamsSchema,
|
|
1415
|
+
id: v23.string()
|
|
473
1416
|
}).entries
|
|
474
1417
|
});
|
|
475
|
-
var TransferRunesResultSchema = v8.object({
|
|
476
|
-
txid: v8.string()
|
|
477
|
-
});
|
|
478
1418
|
|
|
479
1419
|
// src/request/types/ordinalsMethods.ts
|
|
480
|
-
import * as
|
|
1420
|
+
import * as v24 from "valibot";
|
|
481
1421
|
var getInscriptionsMethodName = "ord_getInscriptions";
|
|
482
|
-
var getInscriptionsParamsSchema =
|
|
483
|
-
offset:
|
|
484
|
-
limit:
|
|
485
|
-
});
|
|
486
|
-
var getInscriptionsResultSchema =
|
|
487
|
-
total:
|
|
488
|
-
limit:
|
|
489
|
-
offset:
|
|
490
|
-
inscriptions:
|
|
491
|
-
|
|
492
|
-
inscriptionId:
|
|
493
|
-
inscriptionNumber:
|
|
494
|
-
address:
|
|
495
|
-
collectionName:
|
|
496
|
-
postage:
|
|
497
|
-
contentLength:
|
|
498
|
-
contentType:
|
|
499
|
-
timestamp:
|
|
500
|
-
offset:
|
|
501
|
-
genesisTransaction:
|
|
502
|
-
output:
|
|
1422
|
+
var getInscriptionsParamsSchema = v24.object({
|
|
1423
|
+
offset: v24.number(),
|
|
1424
|
+
limit: v24.number()
|
|
1425
|
+
});
|
|
1426
|
+
var getInscriptionsResultSchema = v24.object({
|
|
1427
|
+
total: v24.number(),
|
|
1428
|
+
limit: v24.number(),
|
|
1429
|
+
offset: v24.number(),
|
|
1430
|
+
inscriptions: v24.array(
|
|
1431
|
+
v24.object({
|
|
1432
|
+
inscriptionId: v24.string(),
|
|
1433
|
+
inscriptionNumber: v24.string(),
|
|
1434
|
+
address: v24.string(),
|
|
1435
|
+
collectionName: v24.optional(v24.string()),
|
|
1436
|
+
postage: v24.string(),
|
|
1437
|
+
contentLength: v24.string(),
|
|
1438
|
+
contentType: v24.string(),
|
|
1439
|
+
timestamp: v24.number(),
|
|
1440
|
+
offset: v24.number(),
|
|
1441
|
+
genesisTransaction: v24.string(),
|
|
1442
|
+
output: v24.string()
|
|
503
1443
|
})
|
|
504
1444
|
)
|
|
505
1445
|
});
|
|
506
|
-
var
|
|
1446
|
+
var getInscriptionsRequestMessageSchema = v24.object({
|
|
507
1447
|
...rpcRequestMessageSchema.entries,
|
|
508
|
-
...
|
|
509
|
-
method:
|
|
1448
|
+
...v24.object({
|
|
1449
|
+
method: v24.literal(getInscriptionsMethodName),
|
|
510
1450
|
params: getInscriptionsParamsSchema,
|
|
511
|
-
id:
|
|
1451
|
+
id: v24.string()
|
|
512
1452
|
}).entries
|
|
513
1453
|
});
|
|
514
1454
|
var sendInscriptionsMethodName = "ord_sendInscriptions";
|
|
515
|
-
var sendInscriptionsParamsSchema =
|
|
516
|
-
transfers:
|
|
517
|
-
|
|
518
|
-
address:
|
|
519
|
-
inscriptionId:
|
|
1455
|
+
var sendInscriptionsParamsSchema = v24.object({
|
|
1456
|
+
transfers: v24.array(
|
|
1457
|
+
v24.object({
|
|
1458
|
+
address: v24.string(),
|
|
1459
|
+
inscriptionId: v24.string()
|
|
520
1460
|
})
|
|
521
1461
|
)
|
|
522
1462
|
});
|
|
523
|
-
var sendInscriptionsResultSchema =
|
|
524
|
-
txid:
|
|
1463
|
+
var sendInscriptionsResultSchema = v24.object({
|
|
1464
|
+
txid: v24.string()
|
|
525
1465
|
});
|
|
526
|
-
var
|
|
1466
|
+
var sendInscriptionsRequestMessageSchema = v24.object({
|
|
527
1467
|
...rpcRequestMessageSchema.entries,
|
|
528
|
-
...
|
|
529
|
-
method:
|
|
1468
|
+
...v24.object({
|
|
1469
|
+
method: v24.literal(sendInscriptionsMethodName),
|
|
530
1470
|
params: sendInscriptionsParamsSchema,
|
|
531
|
-
id:
|
|
1471
|
+
id: v24.string()
|
|
532
1472
|
}).entries
|
|
533
1473
|
});
|
|
534
1474
|
|
|
@@ -545,13 +1485,13 @@ var request = async (method, params, providerId) => {
|
|
|
545
1485
|
throw new Error("A wallet method is required");
|
|
546
1486
|
}
|
|
547
1487
|
const response = await provider.request(method, params);
|
|
548
|
-
if (
|
|
1488
|
+
if (v25.is(rpcErrorResponseMessageSchema, response)) {
|
|
549
1489
|
return {
|
|
550
1490
|
status: "error",
|
|
551
1491
|
error: response.error
|
|
552
1492
|
};
|
|
553
1493
|
}
|
|
554
|
-
if (
|
|
1494
|
+
if (v25.is(rpcSuccessResponseMessageSchema, response)) {
|
|
555
1495
|
return {
|
|
556
1496
|
status: "success",
|
|
557
1497
|
result: response.result
|
|
@@ -1062,17 +2002,16 @@ var XverseAdapter = class extends SatsConnectAdapter {
|
|
|
1062
2002
|
};
|
|
1063
2003
|
|
|
1064
2004
|
// src/adapters/unisat.ts
|
|
1065
|
-
import { Buffer } from "buffer";
|
|
1066
2005
|
import { AddressType as AddressType2, getAddressInfo } from "bitcoin-address-validation";
|
|
1067
|
-
|
|
2006
|
+
import { Buffer } from "buffer";
|
|
2007
|
+
function convertSignInputsToInputType(signInputs) {
|
|
1068
2008
|
let result = [];
|
|
1069
2009
|
for (let address in signInputs) {
|
|
1070
2010
|
let indexes = signInputs[address];
|
|
1071
2011
|
for (let index of indexes) {
|
|
1072
2012
|
result.push({
|
|
1073
2013
|
index,
|
|
1074
|
-
address
|
|
1075
|
-
sighashTypes: allowedSignHash ? [allowedSignHash] : void 0
|
|
2014
|
+
address
|
|
1076
2015
|
});
|
|
1077
2016
|
}
|
|
1078
2017
|
}
|
|
@@ -1104,10 +2043,10 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1104
2043
|
};
|
|
1105
2044
|
const response = [];
|
|
1106
2045
|
if (purposes.includes("payment" /* Payment */)) {
|
|
1107
|
-
response.push(paymentAddress);
|
|
2046
|
+
response.push({ ...paymentAddress, walletType: "software" });
|
|
1108
2047
|
}
|
|
1109
2048
|
if (purposes.includes("ordinals" /* Ordinals */)) {
|
|
1110
|
-
response.push(ordinalsAddress);
|
|
2049
|
+
response.push({ ...ordinalsAddress, walletType: "software" });
|
|
1111
2050
|
}
|
|
1112
2051
|
return response;
|
|
1113
2052
|
}
|
|
@@ -1120,14 +2059,16 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1120
2059
|
return {
|
|
1121
2060
|
address,
|
|
1122
2061
|
messageHash: "",
|
|
1123
|
-
signature: response2
|
|
2062
|
+
signature: response2,
|
|
2063
|
+
protocol: "BIP322" /* BIP322 */
|
|
1124
2064
|
};
|
|
1125
2065
|
}
|
|
1126
2066
|
const response = await window.unisat.signMessage(message, "ecdsa");
|
|
1127
2067
|
return {
|
|
1128
2068
|
address,
|
|
1129
2069
|
messageHash: "",
|
|
1130
|
-
signature: response
|
|
2070
|
+
signature: response,
|
|
2071
|
+
protocol: "ECDSA" /* ECDSA */
|
|
1131
2072
|
};
|
|
1132
2073
|
}
|
|
1133
2074
|
async sendTransfer(params) {
|
|
@@ -1141,11 +2082,11 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1141
2082
|
};
|
|
1142
2083
|
}
|
|
1143
2084
|
async signPsbt(params) {
|
|
1144
|
-
const { psbt, signInputs,
|
|
2085
|
+
const { psbt, signInputs, broadcast } = params;
|
|
1145
2086
|
const psbtHex = Buffer.from(psbt, "base64").toString("hex");
|
|
1146
2087
|
const signedPsbt = await window.unisat.signPsbt(psbtHex, {
|
|
1147
2088
|
autoFinalized: broadcast,
|
|
1148
|
-
toSignInputs: convertSignInputsToInputType(signInputs
|
|
2089
|
+
toSignInputs: convertSignInputsToInputType(signInputs)
|
|
1149
2090
|
});
|
|
1150
2091
|
if (broadcast) {
|
|
1151
2092
|
const txid = await window.unisat.pushPsbt(psbtHex);
|
|
@@ -1215,6 +2156,33 @@ var UnisatAdapter = class extends SatsConnectAdapter {
|
|
|
1215
2156
|
};
|
|
1216
2157
|
}
|
|
1217
2158
|
};
|
|
2159
|
+
addListener = (eventName, cb) => {
|
|
2160
|
+
switch (eventName) {
|
|
2161
|
+
case "accountChange": {
|
|
2162
|
+
const handler = () => {
|
|
2163
|
+
cb({ type: "accountChange" });
|
|
2164
|
+
};
|
|
2165
|
+
window.unisat.on("accountsChanged", handler);
|
|
2166
|
+
return () => {
|
|
2167
|
+
window.unisat.removeListener("accountsChanged", handler);
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
case "networkChange": {
|
|
2171
|
+
const handler = () => {
|
|
2172
|
+
cb({ type: "networkChange" });
|
|
2173
|
+
};
|
|
2174
|
+
window.unisat.on("networkChanged", handler);
|
|
2175
|
+
return () => {
|
|
2176
|
+
window.unisat.removeListener("networkChanged", handler);
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
default: {
|
|
2180
|
+
console.error("Event not supported by the selected wallet");
|
|
2181
|
+
return () => {
|
|
2182
|
+
};
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
1218
2186
|
};
|
|
1219
2187
|
|
|
1220
2188
|
// src/adapters/BaseAdapter.ts
|
|
@@ -1279,8 +2247,7 @@ var extractOrValidateCapabilities = (provider, reportedCapabilities) => {
|
|
|
1279
2247
|
addListener: validateCapability("addListener")
|
|
1280
2248
|
};
|
|
1281
2249
|
return Object.entries(capabilityMap).reduce((acc, [capability, value]) => {
|
|
1282
|
-
if (value)
|
|
1283
|
-
return [...acc, capability];
|
|
2250
|
+
if (value) return [...acc, capability];
|
|
1284
2251
|
return acc;
|
|
1285
2252
|
}, []);
|
|
1286
2253
|
};
|
|
@@ -1474,16 +2441,27 @@ export {
|
|
|
1474
2441
|
RpcErrorCode,
|
|
1475
2442
|
RpcIdSchema,
|
|
1476
2443
|
SatsConnectAdapter,
|
|
1477
|
-
TransferRunesResultSchema,
|
|
1478
2444
|
accountChangeEventName,
|
|
1479
2445
|
accountChangeSchema,
|
|
1480
2446
|
addListener,
|
|
1481
2447
|
addressSchema,
|
|
2448
|
+
connectMethodName,
|
|
2449
|
+
connectParamsSchema,
|
|
2450
|
+
connectRequestMessageSchema,
|
|
2451
|
+
connectResultSchema,
|
|
1482
2452
|
createInscription,
|
|
1483
2453
|
createRepeatInscriptions,
|
|
1484
2454
|
defaultAdapters,
|
|
1485
2455
|
disconnectEventName,
|
|
2456
|
+
disconnectMethodName,
|
|
2457
|
+
disconnectParamsSchema,
|
|
2458
|
+
disconnectRequestMessageSchema,
|
|
2459
|
+
disconnectResultSchema,
|
|
1486
2460
|
disconnectSchema,
|
|
2461
|
+
getAccountMethodName,
|
|
2462
|
+
getAccountParamsSchema,
|
|
2463
|
+
getAccountRequestMessageSchema,
|
|
2464
|
+
getAccountResultSchema,
|
|
1487
2465
|
getAccountsMethodName,
|
|
1488
2466
|
getAccountsParamsSchema,
|
|
1489
2467
|
getAccountsRequestMessageSchema,
|
|
@@ -1509,15 +2487,11 @@ export {
|
|
|
1509
2487
|
getInfoResultSchema,
|
|
1510
2488
|
getInscriptionsMethodName,
|
|
1511
2489
|
getInscriptionsParamsSchema,
|
|
2490
|
+
getInscriptionsRequestMessageSchema,
|
|
1512
2491
|
getInscriptionsResultSchema,
|
|
1513
|
-
getInscriptionsSchema,
|
|
1514
2492
|
getProviderById,
|
|
1515
2493
|
getProviderOrThrow,
|
|
1516
2494
|
getProviders,
|
|
1517
|
-
getRunesBalanceMethodName,
|
|
1518
|
-
getRunesBalanceParamsSchema,
|
|
1519
|
-
getRunesBalanceRequestMessageSchema,
|
|
1520
|
-
getRunesBalanceResultSchema,
|
|
1521
2495
|
getSupportedWallets,
|
|
1522
2496
|
getWalletTypeMethodName,
|
|
1523
2497
|
getWalletTypeParamsSchema,
|
|
@@ -1526,6 +2500,7 @@ export {
|
|
|
1526
2500
|
isProviderInstalled,
|
|
1527
2501
|
networkChangeEventName,
|
|
1528
2502
|
networkChangeSchema,
|
|
2503
|
+
permissionTemplate,
|
|
1529
2504
|
removeDefaultProvider,
|
|
1530
2505
|
renouncePermissionsMethodName,
|
|
1531
2506
|
renouncePermissionsParamsSchema,
|
|
@@ -1540,11 +2515,31 @@ export {
|
|
|
1540
2515
|
rpcRequestMessageSchema,
|
|
1541
2516
|
rpcResponseMessageSchema,
|
|
1542
2517
|
rpcSuccessResponseMessageSchema,
|
|
2518
|
+
runesEtchMethodName,
|
|
2519
|
+
runesEtchParamsSchema,
|
|
2520
|
+
runesEtchRequestMessageSchema,
|
|
2521
|
+
runesEtchResultSchema,
|
|
2522
|
+
runesGetBalanceMethodName,
|
|
2523
|
+
runesGetBalanceParamsSchema,
|
|
2524
|
+
runesGetBalanceRequestMessageSchema,
|
|
2525
|
+
runesGetBalanceResultSchema,
|
|
2526
|
+
runesMintMethodName,
|
|
2527
|
+
runesMintParamsSchema,
|
|
2528
|
+
runesMintRequestMessageSchema,
|
|
2529
|
+
runesMintResultSchema,
|
|
2530
|
+
runesTransferMethodName,
|
|
2531
|
+
runesTransferParamsSchema,
|
|
2532
|
+
runesTransferRequestMessageSchema,
|
|
2533
|
+
runesTransferResultSchema,
|
|
1543
2534
|
sendBtcTransaction,
|
|
1544
2535
|
sendInscriptionsMethodName,
|
|
1545
2536
|
sendInscriptionsParamsSchema,
|
|
2537
|
+
sendInscriptionsRequestMessageSchema,
|
|
1546
2538
|
sendInscriptionsResultSchema,
|
|
1547
|
-
|
|
2539
|
+
sendTransferMethodName,
|
|
2540
|
+
sendTransferParamsSchema,
|
|
2541
|
+
sendTransferRequestMessageSchema,
|
|
2542
|
+
sendTransferResultSchema,
|
|
1548
2543
|
setDefaultProvider,
|
|
1549
2544
|
signMessage,
|
|
1550
2545
|
signMessageMethodName,
|
|
@@ -1552,19 +2547,49 @@ export {
|
|
|
1552
2547
|
signMessageRequestMessageSchema,
|
|
1553
2548
|
signMessageResultSchema,
|
|
1554
2549
|
signMultipleTransactions,
|
|
2550
|
+
signPsbtMethodName,
|
|
2551
|
+
signPsbtParamsSchema,
|
|
2552
|
+
signPsbtRequestMessageSchema,
|
|
2553
|
+
signPsbtResultSchema,
|
|
1555
2554
|
signTransaction,
|
|
2555
|
+
stxCallContractMethodName,
|
|
2556
|
+
stxCallContractParamsSchema,
|
|
2557
|
+
stxCallContractRequestMessageSchema,
|
|
2558
|
+
stxCallContractResultSchema,
|
|
2559
|
+
stxDeployContractMethodName,
|
|
2560
|
+
stxDeployContractParamsSchema,
|
|
2561
|
+
stxDeployContractRequestMessageSchema,
|
|
2562
|
+
stxDeployContractResultSchema,
|
|
2563
|
+
stxGetAccountsMethodName,
|
|
2564
|
+
stxGetAccountsParamsSchema,
|
|
2565
|
+
stxGetAccountsRequestMessageSchema,
|
|
2566
|
+
stxGetAccountsResultSchema,
|
|
1556
2567
|
stxGetAddressesMethodName,
|
|
1557
2568
|
stxGetAddressesParamsSchema,
|
|
1558
2569
|
stxGetAddressesRequestMessageSchema,
|
|
1559
2570
|
stxGetAddressesResultSchema,
|
|
2571
|
+
stxSignMessageMethodName,
|
|
2572
|
+
stxSignMessageParamsSchema,
|
|
2573
|
+
stxSignMessageRequestMessageSchema,
|
|
2574
|
+
stxSignMessageResultSchema,
|
|
2575
|
+
stxSignStructuredMessageMethodName,
|
|
2576
|
+
stxSignStructuredMessageParamsSchema,
|
|
2577
|
+
stxSignStructuredMessageRequestMessageSchema,
|
|
2578
|
+
stxSignStructuredMessageResultSchema,
|
|
1560
2579
|
stxSignTransactionMethodName,
|
|
1561
2580
|
stxSignTransactionParamsSchema,
|
|
1562
2581
|
stxSignTransactionRequestMessageSchema,
|
|
1563
2582
|
stxSignTransactionResultSchema,
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
2583
|
+
stxTransferStxMethodName,
|
|
2584
|
+
stxTransferStxParamsSchema,
|
|
2585
|
+
stxTransferStxRequestMessageSchema,
|
|
2586
|
+
stxTransferStxResultSchema,
|
|
1567
2587
|
walletEventSchema,
|
|
1568
2588
|
walletTypeSchema,
|
|
1569
2589
|
walletTypes
|
|
1570
2590
|
};
|
|
2591
|
+
/*! Bundled license information:
|
|
2592
|
+
|
|
2593
|
+
@noble/hashes/esm/utils.js:
|
|
2594
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2595
|
+
*/
|