@arkade-os/sdk 0.5.0-rc.11 → 0.5.0-rc.13
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/README.md +43 -12
- package/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-DBaZsltv.d.cts → asyncStorageTaskQueue-0EeSeCAt.d.cts} +1 -1
- package/dist/{asyncStorageTaskQueue-uAG3XLyg.d.ts → asyncStorageTaskQueue-DV94jhwq.d.ts} +1 -1
- package/dist/{chunk-WSQAWSEH.js → chunk-3JLYJ5KZ.js} +75 -237
- package/dist/chunk-3JLYJ5KZ.js.map +1 -0
- package/dist/{chunk-VMLLYEYM.js → chunk-4EU2Q6YT.js} +12 -14
- package/dist/chunk-4EU2Q6YT.js.map +1 -0
- package/dist/{chunk-IA32YGLH.cjs → chunk-7BACS4XK.cjs} +10 -10
- package/dist/chunk-7BACS4XK.cjs.map +1 -0
- package/dist/{chunk-5OBGYL6U.cjs → chunk-7NK6XFC3.cjs} +120 -194
- package/dist/chunk-7NK6XFC3.cjs.map +1 -0
- package/dist/{chunk-CQPQ7D4U.cjs → chunk-BFQX2KS3.cjs} +87 -248
- package/dist/chunk-BFQX2KS3.cjs.map +1 -0
- package/dist/{chunk-DD6MTNAS.js → chunk-D7JLTHSZ.js} +5 -5
- package/dist/chunk-D7JLTHSZ.js.map +1 -0
- package/dist/{chunk-CMLSTGOC.js → chunk-EJYWGTZ7.js} +119 -194
- package/dist/chunk-EJYWGTZ7.js.map +1 -0
- package/dist/{chunk-T2ILYGWE.cjs → chunk-FDQQOF3F.cjs} +327 -1080
- package/dist/chunk-FDQQOF3F.cjs.map +1 -0
- package/dist/{chunk-MGDXN74N.cjs → chunk-I4YBVHAK.cjs} +2357 -3374
- package/dist/chunk-I4YBVHAK.cjs.map +1 -0
- package/dist/{chunk-M2ZUPLKQ.js → chunk-IV2252XM.js} +1946 -2977
- package/dist/chunk-IV2252XM.js.map +1 -0
- package/dist/{chunk-OMJRW2D5.js → chunk-JOUPIZ32.js} +263 -1036
- package/dist/chunk-JOUPIZ32.js.map +1 -0
- package/dist/{chunk-PWEBQNIE.cjs → chunk-RDQSVIXD.cjs} +22 -24
- package/dist/chunk-RDQSVIXD.cjs.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-DFwlkVYR.d.cts → delegate-BgpUJW5B.d.cts} +1 -1
- package/dist/{delegate-D3YHDERL.d.ts → delegate-BuagcGnG.d.ts} +1 -1
- package/dist/{index-DTvUv5lD.d.cts → index-CKmB14Yu.d.cts} +1145 -2263
- package/dist/{index-DTvUv5lD.d.ts → index-CKmB14Yu.d.ts} +1145 -2263
- package/dist/index-D0BuYwhF.d.cts +637 -0
- package/dist/index-DbzyrqK7.d.ts +637 -0
- package/dist/index.cjs +341 -297
- package/dist/index.d.cts +379 -788
- package/dist/index.d.ts +379 -788
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +142 -101
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +13 -11
- package/dist/repositories/realm/index.d.ts +13 -11
- package/dist/repositories/realm/index.js +130 -89
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +158 -118
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +14 -13
- package/dist/repositories/sqlite/index.d.ts +14 -13
- package/dist/repositories/sqlite/index.js +147 -107
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-B5bl0YRt.d.ts → taskRunner-BX-pB0sv.d.ts} +1 -1
- package/dist/{taskRunner--sKy9Inv.d.cts → taskRunner-DJrFFyus.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +8 -14
- package/dist/wallet/expo/background.d.ts +8 -14
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +14 -14
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +5 -5
- package/dist/wallet/expo/index.d.ts +5 -5
- package/dist/wallet/expo/index.js +5 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/wallet-BsL2G3Qb.d.cts +1542 -0
- package/dist/wallet-DXNiCmq8.d.ts +1542 -0
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +3 -2
- package/dist/chunk-5OBGYL6U.cjs.map +0 -1
- package/dist/chunk-CMLSTGOC.js.map +0 -1
- package/dist/chunk-CQPQ7D4U.cjs.map +0 -1
- package/dist/chunk-DD6MTNAS.js.map +0 -1
- package/dist/chunk-IA32YGLH.cjs.map +0 -1
- package/dist/chunk-M2ZUPLKQ.js.map +0 -1
- package/dist/chunk-MGDXN74N.cjs.map +0 -1
- package/dist/chunk-OMJRW2D5.js.map +0 -1
- package/dist/chunk-PWEBQNIE.cjs.map +0 -1
- package/dist/chunk-T2ILYGWE.cjs.map +0 -1
- package/dist/chunk-VMLLYEYM.js.map +0 -1
- package/dist/chunk-WSQAWSEH.js.map +0 -1
- package/dist/hdWalletCapable-C350s3bP.d.ts +0 -2206
- package/dist/hdWalletCapable-rrOmXcbT.d.cts +0 -2206
- package/dist/index-C0ZyGoyP.d.cts +0 -850
- package/dist/index-DASN1cVk.d.ts +0 -850
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk7NK6XFC3_cjs = require('./chunk-7NK6XFC3.cjs');
|
|
4
4
|
var base = require('@scure/base');
|
|
5
5
|
var secp256k1_js = require('@noble/curves/secp256k1.js');
|
|
6
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
7
|
|
|
8
8
|
// src/extension/asset/index.ts
|
|
9
9
|
var asset_exports = {};
|
|
10
|
-
|
|
10
|
+
chunk7NK6XFC3_cjs.__export(asset_exports, {
|
|
11
11
|
ASSET_ID_VECTORS: () => ASSET_ID_VECTORS,
|
|
12
12
|
AssetGroup: () => AssetGroup,
|
|
13
13
|
AssetId: () => AssetId,
|
|
@@ -41,8 +41,13 @@ var AssetRefType = /* @__PURE__ */ ((AssetRefType2) => {
|
|
|
41
41
|
var MASK_ASSET_ID = 1;
|
|
42
42
|
var MASK_CONTROL_ASSET = 2;
|
|
43
43
|
var MASK_METADATA = 4;
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
function hexOrThrow(s, message) {
|
|
45
|
+
try {
|
|
46
|
+
return base.hex.decode(s);
|
|
47
|
+
} catch {
|
|
48
|
+
throw new Error(message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
46
51
|
var BufferWriter = class {
|
|
47
52
|
buffer = [];
|
|
48
53
|
write(data) {
|
|
@@ -185,11 +190,10 @@ var AssetId = class _AssetId {
|
|
|
185
190
|
txid;
|
|
186
191
|
groupIndex;
|
|
187
192
|
/**
|
|
188
|
-
* Create
|
|
193
|
+
* Create a validated asset id from a genesis transaction id and group index.
|
|
189
194
|
*
|
|
190
195
|
* @param txid - Hex-encoded genesis transaction id
|
|
191
196
|
* @param groupIndex - Asset group index within the genesis transaction
|
|
192
|
-
* @returns A validated asset id
|
|
193
197
|
* @throws Error if the txid is missing, malformed, or not 32 bytes long
|
|
194
198
|
* @see fromString
|
|
195
199
|
*/
|
|
@@ -197,12 +201,7 @@ var AssetId = class _AssetId {
|
|
|
197
201
|
if (!txid) {
|
|
198
202
|
throw new Error("missing txid");
|
|
199
203
|
}
|
|
200
|
-
|
|
201
|
-
try {
|
|
202
|
-
buf = base.hex.decode(txid);
|
|
203
|
-
} catch {
|
|
204
|
-
throw new Error("invalid txid format, must be hex");
|
|
205
|
-
}
|
|
204
|
+
const buf = hexOrThrow(txid, "invalid txid format, must be hex");
|
|
206
205
|
if (buf.length !== TX_HASH_SIZE) {
|
|
207
206
|
throw new Error(
|
|
208
207
|
`invalid txid length: got ${buf.length} bytes, want ${TX_HASH_SIZE} bytes`
|
|
@@ -215,25 +214,15 @@ var AssetId = class _AssetId {
|
|
|
215
214
|
/**
|
|
216
215
|
* Decode an asset id from its hex string representation.
|
|
217
216
|
*
|
|
218
|
-
* @param s - Hex-encoded asset id
|
|
219
|
-
* @returns Decoded asset id
|
|
220
217
|
* @throws Error if the string is not valid hex or does not encode a valid asset id
|
|
221
218
|
* @see toString
|
|
222
219
|
*/
|
|
223
220
|
static fromString(s) {
|
|
224
|
-
|
|
225
|
-
try {
|
|
226
|
-
buf = base.hex.decode(s);
|
|
227
|
-
} catch {
|
|
228
|
-
throw new Error("invalid asset id format, must be hex");
|
|
229
|
-
}
|
|
230
|
-
return _AssetId.fromBytes(buf);
|
|
221
|
+
return _AssetId.fromBytes(hexOrThrow(s, "invalid asset id format, must be hex"));
|
|
231
222
|
}
|
|
232
223
|
/**
|
|
233
224
|
* Decode an asset id from its serialized bytes.
|
|
234
225
|
*
|
|
235
|
-
* @param buf - Serialized asset id bytes
|
|
236
|
-
* @returns Decoded asset id
|
|
237
226
|
* @throws Error if the buffer length is invalid
|
|
238
227
|
*/
|
|
239
228
|
static fromBytes(buf) {
|
|
@@ -251,7 +240,6 @@ var AssetId = class _AssetId {
|
|
|
251
240
|
/**
|
|
252
241
|
* Serialize the asset id to raw bytes.
|
|
253
242
|
*
|
|
254
|
-
* @returns Serialized asset id bytes
|
|
255
243
|
* @see fromBytes
|
|
256
244
|
*/
|
|
257
245
|
serialize() {
|
|
@@ -262,7 +250,6 @@ var AssetId = class _AssetId {
|
|
|
262
250
|
/**
|
|
263
251
|
* Encode the asset id to a hex string.
|
|
264
252
|
*
|
|
265
|
-
* @returns Hex-encoded asset id
|
|
266
253
|
* @see fromString
|
|
267
254
|
*/
|
|
268
255
|
toString() {
|
|
@@ -282,10 +269,8 @@ var AssetId = class _AssetId {
|
|
|
282
269
|
}
|
|
283
270
|
}
|
|
284
271
|
/**
|
|
285
|
-
* Decode an asset id from a binary reader.
|
|
272
|
+
* Decode an asset id from a binary reader positioned at one.
|
|
286
273
|
*
|
|
287
|
-
* @param reader - Reader positioned at an asset id
|
|
288
|
-
* @returns Decoded asset id
|
|
289
274
|
* @throws Error if the reader does not contain enough bytes
|
|
290
275
|
*/
|
|
291
276
|
static fromReader(reader) {
|
|
@@ -303,7 +288,6 @@ var AssetId = class _AssetId {
|
|
|
303
288
|
/**
|
|
304
289
|
* Serialize the asset id into an existing binary writer.
|
|
305
290
|
*
|
|
306
|
-
* @param writer - Writer to append the asset id to
|
|
307
291
|
* @see serialize
|
|
308
292
|
*/
|
|
309
293
|
serializeTo(writer) {
|
|
@@ -320,48 +304,31 @@ var AssetRef = class _AssetRef {
|
|
|
320
304
|
get type() {
|
|
321
305
|
return this.ref.type;
|
|
322
306
|
}
|
|
323
|
-
/**
|
|
324
|
-
* Create an asset reference that points to a specific asset id.
|
|
325
|
-
*
|
|
326
|
-
* @param assetId - Asset id referenced by this pointer
|
|
327
|
-
* @returns Asset reference by id
|
|
328
|
-
* @see fromGroupIndex
|
|
329
|
-
*/
|
|
307
|
+
/** Reference a specific asset id. @see fromGroupIndex */
|
|
330
308
|
static fromId(assetId) {
|
|
331
309
|
return new _AssetRef({ type: 1 /* ByID */, assetId });
|
|
332
310
|
}
|
|
333
311
|
/**
|
|
334
|
-
*
|
|
312
|
+
* Reference another asset group in the packet.
|
|
335
313
|
*
|
|
336
314
|
* @param groupIndex - Zero-based asset group index in the packet
|
|
337
|
-
* @returns Asset reference by group index
|
|
338
315
|
* @see fromId
|
|
339
316
|
*/
|
|
340
317
|
static fromGroupIndex(groupIndex) {
|
|
341
318
|
return new _AssetRef({ type: 2 /* ByGroup */, groupIndex });
|
|
342
319
|
}
|
|
343
320
|
/**
|
|
344
|
-
* Decode an asset reference from
|
|
321
|
+
* Decode an asset reference from hex.
|
|
345
322
|
*
|
|
346
|
-
* @param s - Hex-encoded asset reference
|
|
347
|
-
* @returns Decoded asset reference
|
|
348
323
|
* @throws Error if the string is not valid hex or does not encode a valid asset reference
|
|
349
324
|
* @see toString
|
|
350
325
|
*/
|
|
351
326
|
static fromString(s) {
|
|
352
|
-
|
|
353
|
-
try {
|
|
354
|
-
buf = base.hex.decode(s);
|
|
355
|
-
} catch {
|
|
356
|
-
throw new Error("invalid asset ref format, must be hex");
|
|
357
|
-
}
|
|
358
|
-
return _AssetRef.fromBytes(buf);
|
|
327
|
+
return _AssetRef.fromBytes(hexOrThrow(s, "invalid asset ref format, must be hex"));
|
|
359
328
|
}
|
|
360
329
|
/**
|
|
361
330
|
* Decode an asset reference from its serialized bytes.
|
|
362
331
|
*
|
|
363
|
-
* @param buf - Serialized asset reference bytes
|
|
364
|
-
* @returns Decoded asset reference
|
|
365
332
|
* @throws Error if the buffer is empty or malformed
|
|
366
333
|
*/
|
|
367
334
|
static fromBytes(buf) {
|
|
@@ -371,31 +338,19 @@ var AssetRef = class _AssetRef {
|
|
|
371
338
|
const reader = new BufferReader(buf);
|
|
372
339
|
return _AssetRef.fromReader(reader);
|
|
373
340
|
}
|
|
374
|
-
/**
|
|
375
|
-
* Serialize the asset reference to raw bytes.
|
|
376
|
-
*
|
|
377
|
-
* @returns Serialized asset reference bytes
|
|
378
|
-
* @see fromBytes
|
|
379
|
-
*/
|
|
341
|
+
/** Serialize to raw bytes. @see fromBytes */
|
|
380
342
|
serialize() {
|
|
381
343
|
const writer = new BufferWriter();
|
|
382
344
|
this.serializeTo(writer);
|
|
383
345
|
return writer.toBytes();
|
|
384
346
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Encode the asset reference to a hex string.
|
|
387
|
-
*
|
|
388
|
-
* @returns Hex-encoded asset reference
|
|
389
|
-
* @see fromString
|
|
390
|
-
*/
|
|
347
|
+
/** Encode to hex. @see fromString */
|
|
391
348
|
toString() {
|
|
392
349
|
return base.hex.encode(this.serialize());
|
|
393
350
|
}
|
|
394
351
|
/**
|
|
395
|
-
* Decode an asset reference from a
|
|
352
|
+
* Decode an asset reference from a reader positioned at one.
|
|
396
353
|
*
|
|
397
|
-
* @param reader - Reader positioned at an asset reference
|
|
398
|
-
* @returns Decoded asset reference
|
|
399
354
|
* @throws Error if the type is unknown or the reader does not contain enough bytes
|
|
400
355
|
*/
|
|
401
356
|
static fromReader(reader) {
|
|
@@ -422,12 +377,7 @@ var AssetRef = class _AssetRef {
|
|
|
422
377
|
}
|
|
423
378
|
return ref;
|
|
424
379
|
}
|
|
425
|
-
/**
|
|
426
|
-
* Serialize the asset reference into an existing binary writer.
|
|
427
|
-
*
|
|
428
|
-
* @param writer - Writer to append the asset reference to
|
|
429
|
-
* @see serialize
|
|
430
|
-
*/
|
|
380
|
+
/** Append the serialized reference to `writer`. @see serialize */
|
|
431
381
|
serializeTo(writer) {
|
|
432
382
|
writer.writeByte(this.ref.type);
|
|
433
383
|
switch (this.ref.type) {
|
|
@@ -468,12 +418,7 @@ var AssetInput = class _AssetInput {
|
|
|
468
418
|
if (!txid || txid.length === 0) {
|
|
469
419
|
throw new Error("missing input intent txid");
|
|
470
420
|
}
|
|
471
|
-
|
|
472
|
-
try {
|
|
473
|
-
buf = base.hex.decode(txid);
|
|
474
|
-
} catch {
|
|
475
|
-
throw new Error("invalid input intent txid format, must be hex");
|
|
476
|
-
}
|
|
421
|
+
const buf = hexOrThrow(txid, "invalid input intent txid format, must be hex");
|
|
477
422
|
if (buf.length !== TX_HASH_SIZE) {
|
|
478
423
|
throw new Error("invalid input intent txid length");
|
|
479
424
|
}
|
|
@@ -488,13 +433,7 @@ var AssetInput = class _AssetInput {
|
|
|
488
433
|
}
|
|
489
434
|
/** Decode an asset input from its hex string form. */
|
|
490
435
|
static fromString(s) {
|
|
491
|
-
|
|
492
|
-
try {
|
|
493
|
-
buf = base.hex.decode(s);
|
|
494
|
-
} catch {
|
|
495
|
-
throw new Error("invalid format, must be hex");
|
|
496
|
-
}
|
|
497
|
-
return _AssetInput.fromBytes(buf);
|
|
436
|
+
return _AssetInput.fromBytes(hexOrThrow(s, "invalid format, must be hex"));
|
|
498
437
|
}
|
|
499
438
|
/** Decode an asset input from its serialized bytes. */
|
|
500
439
|
static fromBytes(buf) {
|
|
@@ -587,13 +526,7 @@ var AssetInputs = class _AssetInputs {
|
|
|
587
526
|
if (!s || s.length === 0) {
|
|
588
527
|
throw new Error("missing asset inputs");
|
|
589
528
|
}
|
|
590
|
-
|
|
591
|
-
try {
|
|
592
|
-
buf = base.hex.decode(s);
|
|
593
|
-
} catch {
|
|
594
|
-
throw new Error("invalid asset inputs format, must be hex");
|
|
595
|
-
}
|
|
596
|
-
const reader = new BufferReader(buf);
|
|
529
|
+
const reader = new BufferReader(hexOrThrow(s, "invalid asset inputs format, must be hex"));
|
|
597
530
|
return _AssetInputs.fromReader(reader);
|
|
598
531
|
}
|
|
599
532
|
/** Serialize the asset input list to raw bytes. */
|
|
@@ -661,13 +594,7 @@ var AssetOutput = class _AssetOutput {
|
|
|
661
594
|
}
|
|
662
595
|
/** Decode an asset output from its hex string form. */
|
|
663
596
|
static fromString(s) {
|
|
664
|
-
|
|
665
|
-
try {
|
|
666
|
-
buf = base.hex.decode(s);
|
|
667
|
-
} catch {
|
|
668
|
-
throw new Error("invalid asset output format, must be hex");
|
|
669
|
-
}
|
|
670
|
-
return _AssetOutput.fromBytes(buf);
|
|
597
|
+
return _AssetOutput.fromBytes(hexOrThrow(s, "invalid asset output format, must be hex"));
|
|
671
598
|
}
|
|
672
599
|
/** Decode an asset output from its serialized bytes. */
|
|
673
600
|
static fromBytes(buf) {
|
|
@@ -742,13 +669,7 @@ var AssetOutputs = class _AssetOutputs {
|
|
|
742
669
|
if (!s || s.length === 0) {
|
|
743
670
|
throw new Error("missing asset outputs");
|
|
744
671
|
}
|
|
745
|
-
|
|
746
|
-
try {
|
|
747
|
-
buf = base.hex.decode(s);
|
|
748
|
-
} catch {
|
|
749
|
-
throw new Error("invalid asset outputs format, must be hex");
|
|
750
|
-
}
|
|
751
|
-
const reader = new BufferReader(buf);
|
|
672
|
+
const reader = new BufferReader(hexOrThrow(s, "invalid asset outputs format, must be hex"));
|
|
752
673
|
return _AssetOutputs.fromReader(reader);
|
|
753
674
|
}
|
|
754
675
|
/** Serialize the asset output list to raw bytes. */
|
|
@@ -810,13 +731,7 @@ var Metadata = class _Metadata {
|
|
|
810
731
|
}
|
|
811
732
|
/** Decode metadata from its hex string form. */
|
|
812
733
|
static fromString(s) {
|
|
813
|
-
|
|
814
|
-
try {
|
|
815
|
-
buf = base.hex.decode(s);
|
|
816
|
-
} catch {
|
|
817
|
-
throw new Error("invalid metadata format, must be hex");
|
|
818
|
-
}
|
|
819
|
-
return _Metadata.fromBytes(buf);
|
|
734
|
+
return _Metadata.fromBytes(hexOrThrow(s, "invalid metadata format, must be hex"));
|
|
820
735
|
}
|
|
821
736
|
/** Decode metadata from its serialized bytes. */
|
|
822
737
|
static fromBytes(buf) {
|
|
@@ -885,13 +800,7 @@ var MetadataList = class _MetadataList {
|
|
|
885
800
|
static ARK_LEAF_VERSION = 0;
|
|
886
801
|
/** Create a metadata list from its hex string form. */
|
|
887
802
|
static fromString(s) {
|
|
888
|
-
|
|
889
|
-
try {
|
|
890
|
-
buf = base.hex.decode(s);
|
|
891
|
-
} catch {
|
|
892
|
-
throw new Error("invalid metadata list format");
|
|
893
|
-
}
|
|
894
|
-
return _MetadataList.fromBytes(buf);
|
|
803
|
+
return _MetadataList.fromBytes(hexOrThrow(s, "invalid metadata list format"));
|
|
895
804
|
}
|
|
896
805
|
/** Decode a metadata list from its serialized bytes. */
|
|
897
806
|
static fromBytes(buf) {
|
|
@@ -1004,13 +913,7 @@ var AssetGroup = class _AssetGroup {
|
|
|
1004
913
|
* @see toString
|
|
1005
914
|
*/
|
|
1006
915
|
static fromString(s) {
|
|
1007
|
-
|
|
1008
|
-
try {
|
|
1009
|
-
buf = base.hex.decode(s);
|
|
1010
|
-
} catch {
|
|
1011
|
-
throw new Error("invalid format, must be hex");
|
|
1012
|
-
}
|
|
1013
|
-
return _AssetGroup.fromBytes(buf);
|
|
916
|
+
return _AssetGroup.fromBytes(hexOrThrow(s, "invalid format, must be hex"));
|
|
1014
917
|
}
|
|
1015
918
|
/**
|
|
1016
919
|
* Decode an asset group from its serialized bytes.
|
|
@@ -1195,13 +1098,7 @@ var Packet = class _Packet {
|
|
|
1195
1098
|
if (!s) {
|
|
1196
1099
|
throw new Error("missing packet data");
|
|
1197
1100
|
}
|
|
1198
|
-
|
|
1199
|
-
try {
|
|
1200
|
-
buf = base.hex.decode(s);
|
|
1201
|
-
} catch {
|
|
1202
|
-
throw new Error("invalid packet format, must be hex");
|
|
1203
|
-
}
|
|
1204
|
-
return _Packet.fromBytes(buf);
|
|
1101
|
+
return _Packet.fromBytes(hexOrThrow(s, "invalid packet format, must be hex"));
|
|
1205
1102
|
}
|
|
1206
1103
|
/**
|
|
1207
1104
|
* type returns the TLV packet type tag. Implements ExtensionPacket interface.
|
|
@@ -1419,10 +1316,10 @@ async function indexerFetch(input, init) {
|
|
|
1419
1316
|
const lastAttempt = attempt >= maxAttempts;
|
|
1420
1317
|
let res;
|
|
1421
1318
|
try {
|
|
1422
|
-
res = await
|
|
1319
|
+
res = await chunk7NK6XFC3_cjs.rateGate.runHttp(input, () => chunk7NK6XFC3_cjs.baseFetch(input, init));
|
|
1423
1320
|
} catch (err) {
|
|
1424
|
-
const mapped =
|
|
1425
|
-
if (lastAttempt || !(mapped instanceof
|
|
1321
|
+
const mapped = chunk7NK6XFC3_cjs.toProviderUnavailable(err, "indexer");
|
|
1322
|
+
if (lastAttempt || !(mapped instanceof chunk7NK6XFC3_cjs.ProviderUnavailableError)) throw mapped;
|
|
1426
1323
|
await sleep(retryDelayMs(attempt));
|
|
1427
1324
|
continue;
|
|
1428
1325
|
}
|
|
@@ -1434,7 +1331,7 @@ async function indexerFetch(input, init) {
|
|
|
1434
1331
|
body = void 0;
|
|
1435
1332
|
}
|
|
1436
1333
|
try {
|
|
1437
|
-
|
|
1334
|
+
chunk7NK6XFC3_cjs.throwIfHttpUnavailable(res, "indexer", body);
|
|
1438
1335
|
} catch (err) {
|
|
1439
1336
|
if (lastAttempt) throw err;
|
|
1440
1337
|
await sleep(retryDelayMs(attempt));
|
|
@@ -1463,7 +1360,7 @@ var ChainTxType = /* @__PURE__ */ ((ChainTxType2) => {
|
|
|
1463
1360
|
return ChainTxType2;
|
|
1464
1361
|
})(ChainTxType || {});
|
|
1465
1362
|
var RestIndexerProvider = class {
|
|
1466
|
-
constructor(serverUrl =
|
|
1363
|
+
constructor(serverUrl = chunk7NK6XFC3_cjs.DEFAULT_ARKADE_SERVER_URL, options = {}) {
|
|
1467
1364
|
this.serverUrl = serverUrl;
|
|
1468
1365
|
this.eventSource = options.eventSource;
|
|
1469
1366
|
}
|
|
@@ -1473,16 +1370,10 @@ var RestIndexerProvider = class {
|
|
|
1473
1370
|
/** @see fetchVtxosJson */
|
|
1474
1371
|
inFlightVtxoReads = /* @__PURE__ */ new Map();
|
|
1475
1372
|
async getVtxoTree(batchOutpoint, opts) {
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1481
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1482
|
-
}
|
|
1483
|
-
if (params.toString()) {
|
|
1484
|
-
url += "?" + params.toString();
|
|
1485
|
-
}
|
|
1373
|
+
const url = withPage(
|
|
1374
|
+
`${this.serverUrl}/v1/indexer/batch/${batchOutpoint.txid}/${batchOutpoint.vout}/tree`,
|
|
1375
|
+
opts
|
|
1376
|
+
);
|
|
1486
1377
|
const res = await indexerFetch(url);
|
|
1487
1378
|
if (!res.ok) {
|
|
1488
1379
|
throw new Error(`Failed to fetch vtxo tree: ${res.statusText}`);
|
|
@@ -1491,24 +1382,14 @@ var RestIndexerProvider = class {
|
|
|
1491
1382
|
if (!Response.isVtxoTreeResponse(data)) {
|
|
1492
1383
|
throw new Error("Invalid vtxo tree data received");
|
|
1493
1384
|
}
|
|
1494
|
-
data.vtxoTree
|
|
1495
|
-
tx.children = Object.fromEntries(
|
|
1496
|
-
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1497
|
-
);
|
|
1498
|
-
});
|
|
1385
|
+
numberChildKeys(data.vtxoTree);
|
|
1499
1386
|
return data;
|
|
1500
1387
|
}
|
|
1501
1388
|
async getVtxoTreeLeaves(batchOutpoint, opts) {
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1507
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1508
|
-
}
|
|
1509
|
-
if (params.toString()) {
|
|
1510
|
-
url += "?" + params.toString();
|
|
1511
|
-
}
|
|
1389
|
+
const url = withPage(
|
|
1390
|
+
`${this.serverUrl}/v1/indexer/batch/${batchOutpoint.txid}/${batchOutpoint.vout}/tree/leaves`,
|
|
1391
|
+
opts
|
|
1392
|
+
);
|
|
1512
1393
|
const res = await indexerFetch(url);
|
|
1513
1394
|
if (!res.ok) {
|
|
1514
1395
|
throw new Error(`Failed to fetch vtxo tree leaves: ${res.statusText}`);
|
|
@@ -1544,16 +1425,7 @@ var RestIndexerProvider = class {
|
|
|
1544
1425
|
return data;
|
|
1545
1426
|
}
|
|
1546
1427
|
async getCommitmentTxConnectors(txid, opts) {
|
|
1547
|
-
|
|
1548
|
-
const params = new URLSearchParams();
|
|
1549
|
-
if (opts) {
|
|
1550
|
-
if (opts.pageIndex !== void 0)
|
|
1551
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1552
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1553
|
-
}
|
|
1554
|
-
if (params.toString()) {
|
|
1555
|
-
url += "?" + params.toString();
|
|
1556
|
-
}
|
|
1428
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/commitmentTx/${txid}/connectors`, opts);
|
|
1557
1429
|
const res = await indexerFetch(url);
|
|
1558
1430
|
if (!res.ok) {
|
|
1559
1431
|
throw new Error(`Failed to fetch commitment tx connectors: ${res.statusText}`);
|
|
@@ -1562,24 +1434,11 @@ var RestIndexerProvider = class {
|
|
|
1562
1434
|
if (!Response.isConnectorsResponse(data)) {
|
|
1563
1435
|
throw new Error("Invalid commitment tx connectors data received");
|
|
1564
1436
|
}
|
|
1565
|
-
data.connectors
|
|
1566
|
-
tx.children = Object.fromEntries(
|
|
1567
|
-
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1568
|
-
);
|
|
1569
|
-
});
|
|
1437
|
+
numberChildKeys(data.connectors);
|
|
1570
1438
|
return data;
|
|
1571
1439
|
}
|
|
1572
1440
|
async getCommitmentTxForfeitTxs(txid, opts) {
|
|
1573
|
-
|
|
1574
|
-
const params = new URLSearchParams();
|
|
1575
|
-
if (opts) {
|
|
1576
|
-
if (opts.pageIndex !== void 0)
|
|
1577
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1578
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1579
|
-
}
|
|
1580
|
-
if (params.toString()) {
|
|
1581
|
-
url += "?" + params.toString();
|
|
1582
|
-
}
|
|
1441
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/commitmentTx/${txid}/forfeitTxs`, opts);
|
|
1583
1442
|
const res = await indexerFetch(url);
|
|
1584
1443
|
if (!res.ok) {
|
|
1585
1444
|
throw new Error(`Failed to fetch commitment tx forfeitTxs: ${res.statusText}`);
|
|
@@ -1601,8 +1460,8 @@ var RestIndexerProvider = class {
|
|
|
1601
1460
|
try {
|
|
1602
1461
|
while (!abortSignal?.aborted) {
|
|
1603
1462
|
try {
|
|
1604
|
-
const currentIterator =
|
|
1605
|
-
|
|
1463
|
+
const currentIterator = chunk7NK6XFC3_cjs.eventSourceIterator(
|
|
1464
|
+
chunk7NK6XFC3_cjs.resolveEventSource(override)(url)
|
|
1606
1465
|
);
|
|
1607
1466
|
iterator = currentIterator;
|
|
1608
1467
|
for await (const event of currentIterator) {
|
|
@@ -1610,15 +1469,7 @@ var RestIndexerProvider = class {
|
|
|
1610
1469
|
try {
|
|
1611
1470
|
const data = JSON.parse(event.data);
|
|
1612
1471
|
if (data.event) {
|
|
1613
|
-
yield
|
|
1614
|
-
txid: data.event.txid,
|
|
1615
|
-
scripts: data.event.scripts || [],
|
|
1616
|
-
newVtxos: (data.event.newVtxos || []).map(chunk5OBGYL6U_cjs.convertVtxo),
|
|
1617
|
-
spentVtxos: (data.event.spentVtxos || []).map(chunk5OBGYL6U_cjs.convertVtxo),
|
|
1618
|
-
sweptVtxos: (data.event.sweptVtxos || []).map(chunk5OBGYL6U_cjs.convertVtxo),
|
|
1619
|
-
tx: data.event.tx,
|
|
1620
|
-
checkpointTxs: data.event.checkpointTxs
|
|
1621
|
-
};
|
|
1472
|
+
yield toSubscriptionResponse(data.event);
|
|
1622
1473
|
}
|
|
1623
1474
|
} catch (err) {
|
|
1624
1475
|
console.error("Failed to parse subscription event:", err);
|
|
@@ -1629,14 +1480,14 @@ var RestIndexerProvider = class {
|
|
|
1629
1480
|
if (abortSignal?.aborted || error instanceof Error && error.name === "AbortError") {
|
|
1630
1481
|
break;
|
|
1631
1482
|
}
|
|
1632
|
-
if (
|
|
1483
|
+
if (chunk7NK6XFC3_cjs.isFetchTimeoutError(error)) {
|
|
1633
1484
|
console.debug("Timeout error ignored");
|
|
1634
1485
|
continue;
|
|
1635
1486
|
}
|
|
1636
|
-
if (
|
|
1487
|
+
if (chunk7NK6XFC3_cjs.isEventSourceError(error)) {
|
|
1637
1488
|
throw error;
|
|
1638
1489
|
}
|
|
1639
|
-
if (
|
|
1490
|
+
if (chunk7NK6XFC3_cjs.isEventSourceUnavailableError(error)) throw error;
|
|
1640
1491
|
console.error("Subscription error:", error);
|
|
1641
1492
|
throw error;
|
|
1642
1493
|
} finally {
|
|
@@ -1657,16 +1508,7 @@ var RestIndexerProvider = class {
|
|
|
1657
1508
|
return gen;
|
|
1658
1509
|
}
|
|
1659
1510
|
async getVirtualTxs(txids, opts) {
|
|
1660
|
-
|
|
1661
|
-
const params = new URLSearchParams();
|
|
1662
|
-
if (opts) {
|
|
1663
|
-
if (opts.pageIndex !== void 0)
|
|
1664
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1665
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1666
|
-
}
|
|
1667
|
-
if (params.toString()) {
|
|
1668
|
-
url += "?" + params.toString();
|
|
1669
|
-
}
|
|
1511
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/virtualTx/${txids.join(",")}`, opts);
|
|
1670
1512
|
const res = await indexerFetch(url);
|
|
1671
1513
|
if (!res.ok) {
|
|
1672
1514
|
throw new Error(`Failed to fetch virtual txs: ${res.statusText}`);
|
|
@@ -1678,16 +1520,10 @@ var RestIndexerProvider = class {
|
|
|
1678
1520
|
return data;
|
|
1679
1521
|
}
|
|
1680
1522
|
async getVtxoChain(vtxoOutpoint, opts) {
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1686
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1687
|
-
}
|
|
1688
|
-
if (params.toString()) {
|
|
1689
|
-
url += "?" + params.toString();
|
|
1690
|
-
}
|
|
1523
|
+
const url = withPage(
|
|
1524
|
+
`${this.serverUrl}/v1/indexer/vtxo/${vtxoOutpoint.txid}/${vtxoOutpoint.vout}/chain`,
|
|
1525
|
+
opts
|
|
1526
|
+
);
|
|
1691
1527
|
const res = await indexerFetch(url);
|
|
1692
1528
|
if (!res.ok) {
|
|
1693
1529
|
throw new Error(`Failed to fetch vtxo chain: ${res.statusText}`);
|
|
@@ -1780,7 +1616,7 @@ var RestIndexerProvider = class {
|
|
|
1780
1616
|
}
|
|
1781
1617
|
const data = await this.fetchVtxosJson(url);
|
|
1782
1618
|
return {
|
|
1783
|
-
vtxos: data.vtxos.map(
|
|
1619
|
+
vtxos: data.vtxos.map(chunk7NK6XFC3_cjs.convertVtxo),
|
|
1784
1620
|
page: data.page
|
|
1785
1621
|
};
|
|
1786
1622
|
}
|
|
@@ -1865,6 +1701,31 @@ var RestIndexerProvider = class {
|
|
|
1865
1701
|
}
|
|
1866
1702
|
}
|
|
1867
1703
|
};
|
|
1704
|
+
function withPage(url, opts) {
|
|
1705
|
+
const params = new URLSearchParams();
|
|
1706
|
+
if (opts?.pageIndex !== void 0) params.append("page.index", opts.pageIndex.toString());
|
|
1707
|
+
if (opts?.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1708
|
+
const query = params.toString();
|
|
1709
|
+
return query ? `${url}?${query}` : url;
|
|
1710
|
+
}
|
|
1711
|
+
function numberChildKeys(txs) {
|
|
1712
|
+
txs.forEach((tx) => {
|
|
1713
|
+
tx.children = Object.fromEntries(
|
|
1714
|
+
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1715
|
+
);
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
function toSubscriptionResponse(event) {
|
|
1719
|
+
return {
|
|
1720
|
+
txid: event.txid,
|
|
1721
|
+
scripts: event.scripts || [],
|
|
1722
|
+
newVtxos: (event.newVtxos || []).map(chunk7NK6XFC3_cjs.convertVtxo),
|
|
1723
|
+
spentVtxos: (event.spentVtxos || []).map(chunk7NK6XFC3_cjs.convertVtxo),
|
|
1724
|
+
sweptVtxos: (event.sweptVtxos || []).map(chunk7NK6XFC3_cjs.convertVtxo),
|
|
1725
|
+
tx: event.tx,
|
|
1726
|
+
checkpointTxs: event.checkpointTxs
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1868
1729
|
function parseAssetMetadata(metadata) {
|
|
1869
1730
|
const metadataList = MetadataList.fromString(metadata);
|
|
1870
1731
|
const out = {};
|
|
@@ -1904,31 +1765,12 @@ var Response;
|
|
|
1904
1765
|
return typeof data === "object" && typeof data.txid === "string" && typeof data.vout === "number";
|
|
1905
1766
|
}
|
|
1906
1767
|
Response2.isOutpoint = isOutpoint;
|
|
1907
|
-
function isOutpointArray(data) {
|
|
1908
|
-
return Array.isArray(data) && data.every(isOutpoint);
|
|
1909
|
-
}
|
|
1910
|
-
Response2.isOutpointArray = isOutpointArray;
|
|
1911
1768
|
function isTx(data) {
|
|
1912
1769
|
return typeof data === "object" && typeof data.txid === "string" && typeof data.children === "object" && Object.values(data.children).every(isTxid) && Object.keys(data.children).every((k) => Number.isInteger(Number(k)));
|
|
1913
1770
|
}
|
|
1914
|
-
function isTxsArray(data) {
|
|
1915
|
-
return Array.isArray(data) && data.every(isTx);
|
|
1916
|
-
}
|
|
1917
|
-
Response2.isTxsArray = isTxsArray;
|
|
1918
|
-
function isTxHistoryRecord(data) {
|
|
1919
|
-
return typeof data === "object" && typeof data.amount === "string" && typeof data.createdAt === "string" && typeof data.isSettled === "boolean" && typeof data.settledBy === "string" && Object.values(IndexerTxType).includes(data.type) && (!data.commitmentTxid && typeof data.virtualTxid === "string" || typeof data.commitmentTxid === "string" && !data.virtualTxid);
|
|
1920
|
-
}
|
|
1921
|
-
function isTxHistoryRecordArray(data) {
|
|
1922
|
-
return Array.isArray(data) && data.every(isTxHistoryRecord);
|
|
1923
|
-
}
|
|
1924
|
-
Response2.isTxHistoryRecordArray = isTxHistoryRecordArray;
|
|
1925
1771
|
function isTxid(data) {
|
|
1926
1772
|
return typeof data === "string" && data.length === 64;
|
|
1927
1773
|
}
|
|
1928
|
-
function isTxidArray(data) {
|
|
1929
|
-
return Array.isArray(data) && data.every(isTxid);
|
|
1930
|
-
}
|
|
1931
|
-
Response2.isTxidArray = isTxidArray;
|
|
1932
1774
|
function isVtxoAsset(data) {
|
|
1933
1775
|
return typeof data === "object" && data !== null && typeof data.assetId === "string" && typeof data.amount === "string";
|
|
1934
1776
|
}
|
|
@@ -1954,10 +1796,6 @@ var Response;
|
|
|
1954
1796
|
return typeof data === "object" && Array.isArray(data.txids) && data.txids.every(isTxid) && (!data.page || isPageResponse(data.page));
|
|
1955
1797
|
}
|
|
1956
1798
|
Response2.isForfeitTxsResponse = isForfeitTxsResponse;
|
|
1957
|
-
function isSweptCommitmentTxResponse(data) {
|
|
1958
|
-
return typeof data === "object" && Array.isArray(data.sweptBy) && data.sweptBy.every(isTxid);
|
|
1959
|
-
}
|
|
1960
|
-
Response2.isSweptCommitmentTxResponse = isSweptCommitmentTxResponse;
|
|
1961
1799
|
function isBatchSweepTransactionsResponse(data) {
|
|
1962
1800
|
return typeof data === "object" && Array.isArray(data.sweptBy) && data.sweptBy.every(isTxid);
|
|
1963
1801
|
}
|
|
@@ -1994,5 +1832,6 @@ exports.Metadata = Metadata;
|
|
|
1994
1832
|
exports.Packet = Packet;
|
|
1995
1833
|
exports.RestIndexerProvider = RestIndexerProvider;
|
|
1996
1834
|
exports.asset_exports = asset_exports;
|
|
1997
|
-
|
|
1998
|
-
//# sourceMappingURL=chunk-
|
|
1835
|
+
exports.toSubscriptionResponse = toSubscriptionResponse;
|
|
1836
|
+
//# sourceMappingURL=chunk-BFQX2KS3.cjs.map
|
|
1837
|
+
//# sourceMappingURL=chunk-BFQX2KS3.cjs.map
|