@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,4 +1,4 @@
|
|
|
1
|
-
import { __export, DEFAULT_ARKADE_SERVER_URL, eventSourceIterator, resolveEventSource,
|
|
1
|
+
import { __export, DEFAULT_ARKADE_SERVER_URL, eventSourceIterator, resolveEventSource, isFetchTimeoutError, isEventSourceError, isEventSourceUnavailableError, convertVtxo, rateGate, baseFetch, toProviderUnavailable, ProviderUnavailableError, throwIfHttpUnavailable } from './chunk-EJYWGTZ7.js';
|
|
2
2
|
import { hex } from '@scure/base';
|
|
3
3
|
import { schnorr } from '@noble/curves/secp256k1.js';
|
|
4
4
|
import { compareBytes } from '@scure/btc-signer/utils.js';
|
|
@@ -39,8 +39,13 @@ var AssetRefType = /* @__PURE__ */ ((AssetRefType2) => {
|
|
|
39
39
|
var MASK_ASSET_ID = 1;
|
|
40
40
|
var MASK_CONTROL_ASSET = 2;
|
|
41
41
|
var MASK_METADATA = 4;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
function hexOrThrow(s, message) {
|
|
43
|
+
try {
|
|
44
|
+
return hex.decode(s);
|
|
45
|
+
} catch {
|
|
46
|
+
throw new Error(message);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
44
49
|
var BufferWriter = class {
|
|
45
50
|
buffer = [];
|
|
46
51
|
write(data) {
|
|
@@ -183,11 +188,10 @@ var AssetId = class _AssetId {
|
|
|
183
188
|
txid;
|
|
184
189
|
groupIndex;
|
|
185
190
|
/**
|
|
186
|
-
* Create
|
|
191
|
+
* Create a validated asset id from a genesis transaction id and group index.
|
|
187
192
|
*
|
|
188
193
|
* @param txid - Hex-encoded genesis transaction id
|
|
189
194
|
* @param groupIndex - Asset group index within the genesis transaction
|
|
190
|
-
* @returns A validated asset id
|
|
191
195
|
* @throws Error if the txid is missing, malformed, or not 32 bytes long
|
|
192
196
|
* @see fromString
|
|
193
197
|
*/
|
|
@@ -195,12 +199,7 @@ var AssetId = class _AssetId {
|
|
|
195
199
|
if (!txid) {
|
|
196
200
|
throw new Error("missing txid");
|
|
197
201
|
}
|
|
198
|
-
|
|
199
|
-
try {
|
|
200
|
-
buf = hex.decode(txid);
|
|
201
|
-
} catch {
|
|
202
|
-
throw new Error("invalid txid format, must be hex");
|
|
203
|
-
}
|
|
202
|
+
const buf = hexOrThrow(txid, "invalid txid format, must be hex");
|
|
204
203
|
if (buf.length !== TX_HASH_SIZE) {
|
|
205
204
|
throw new Error(
|
|
206
205
|
`invalid txid length: got ${buf.length} bytes, want ${TX_HASH_SIZE} bytes`
|
|
@@ -213,25 +212,15 @@ var AssetId = class _AssetId {
|
|
|
213
212
|
/**
|
|
214
213
|
* Decode an asset id from its hex string representation.
|
|
215
214
|
*
|
|
216
|
-
* @param s - Hex-encoded asset id
|
|
217
|
-
* @returns Decoded asset id
|
|
218
215
|
* @throws Error if the string is not valid hex or does not encode a valid asset id
|
|
219
216
|
* @see toString
|
|
220
217
|
*/
|
|
221
218
|
static fromString(s) {
|
|
222
|
-
|
|
223
|
-
try {
|
|
224
|
-
buf = hex.decode(s);
|
|
225
|
-
} catch {
|
|
226
|
-
throw new Error("invalid asset id format, must be hex");
|
|
227
|
-
}
|
|
228
|
-
return _AssetId.fromBytes(buf);
|
|
219
|
+
return _AssetId.fromBytes(hexOrThrow(s, "invalid asset id format, must be hex"));
|
|
229
220
|
}
|
|
230
221
|
/**
|
|
231
222
|
* Decode an asset id from its serialized bytes.
|
|
232
223
|
*
|
|
233
|
-
* @param buf - Serialized asset id bytes
|
|
234
|
-
* @returns Decoded asset id
|
|
235
224
|
* @throws Error if the buffer length is invalid
|
|
236
225
|
*/
|
|
237
226
|
static fromBytes(buf) {
|
|
@@ -249,7 +238,6 @@ var AssetId = class _AssetId {
|
|
|
249
238
|
/**
|
|
250
239
|
* Serialize the asset id to raw bytes.
|
|
251
240
|
*
|
|
252
|
-
* @returns Serialized asset id bytes
|
|
253
241
|
* @see fromBytes
|
|
254
242
|
*/
|
|
255
243
|
serialize() {
|
|
@@ -260,7 +248,6 @@ var AssetId = class _AssetId {
|
|
|
260
248
|
/**
|
|
261
249
|
* Encode the asset id to a hex string.
|
|
262
250
|
*
|
|
263
|
-
* @returns Hex-encoded asset id
|
|
264
251
|
* @see fromString
|
|
265
252
|
*/
|
|
266
253
|
toString() {
|
|
@@ -280,10 +267,8 @@ var AssetId = class _AssetId {
|
|
|
280
267
|
}
|
|
281
268
|
}
|
|
282
269
|
/**
|
|
283
|
-
* Decode an asset id from a binary reader.
|
|
270
|
+
* Decode an asset id from a binary reader positioned at one.
|
|
284
271
|
*
|
|
285
|
-
* @param reader - Reader positioned at an asset id
|
|
286
|
-
* @returns Decoded asset id
|
|
287
272
|
* @throws Error if the reader does not contain enough bytes
|
|
288
273
|
*/
|
|
289
274
|
static fromReader(reader) {
|
|
@@ -301,7 +286,6 @@ var AssetId = class _AssetId {
|
|
|
301
286
|
/**
|
|
302
287
|
* Serialize the asset id into an existing binary writer.
|
|
303
288
|
*
|
|
304
|
-
* @param writer - Writer to append the asset id to
|
|
305
289
|
* @see serialize
|
|
306
290
|
*/
|
|
307
291
|
serializeTo(writer) {
|
|
@@ -318,48 +302,31 @@ var AssetRef = class _AssetRef {
|
|
|
318
302
|
get type() {
|
|
319
303
|
return this.ref.type;
|
|
320
304
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Create an asset reference that points to a specific asset id.
|
|
323
|
-
*
|
|
324
|
-
* @param assetId - Asset id referenced by this pointer
|
|
325
|
-
* @returns Asset reference by id
|
|
326
|
-
* @see fromGroupIndex
|
|
327
|
-
*/
|
|
305
|
+
/** Reference a specific asset id. @see fromGroupIndex */
|
|
328
306
|
static fromId(assetId) {
|
|
329
307
|
return new _AssetRef({ type: 1 /* ByID */, assetId });
|
|
330
308
|
}
|
|
331
309
|
/**
|
|
332
|
-
*
|
|
310
|
+
* Reference another asset group in the packet.
|
|
333
311
|
*
|
|
334
312
|
* @param groupIndex - Zero-based asset group index in the packet
|
|
335
|
-
* @returns Asset reference by group index
|
|
336
313
|
* @see fromId
|
|
337
314
|
*/
|
|
338
315
|
static fromGroupIndex(groupIndex) {
|
|
339
316
|
return new _AssetRef({ type: 2 /* ByGroup */, groupIndex });
|
|
340
317
|
}
|
|
341
318
|
/**
|
|
342
|
-
* Decode an asset reference from
|
|
319
|
+
* Decode an asset reference from hex.
|
|
343
320
|
*
|
|
344
|
-
* @param s - Hex-encoded asset reference
|
|
345
|
-
* @returns Decoded asset reference
|
|
346
321
|
* @throws Error if the string is not valid hex or does not encode a valid asset reference
|
|
347
322
|
* @see toString
|
|
348
323
|
*/
|
|
349
324
|
static fromString(s) {
|
|
350
|
-
|
|
351
|
-
try {
|
|
352
|
-
buf = hex.decode(s);
|
|
353
|
-
} catch {
|
|
354
|
-
throw new Error("invalid asset ref format, must be hex");
|
|
355
|
-
}
|
|
356
|
-
return _AssetRef.fromBytes(buf);
|
|
325
|
+
return _AssetRef.fromBytes(hexOrThrow(s, "invalid asset ref format, must be hex"));
|
|
357
326
|
}
|
|
358
327
|
/**
|
|
359
328
|
* Decode an asset reference from its serialized bytes.
|
|
360
329
|
*
|
|
361
|
-
* @param buf - Serialized asset reference bytes
|
|
362
|
-
* @returns Decoded asset reference
|
|
363
330
|
* @throws Error if the buffer is empty or malformed
|
|
364
331
|
*/
|
|
365
332
|
static fromBytes(buf) {
|
|
@@ -369,31 +336,19 @@ var AssetRef = class _AssetRef {
|
|
|
369
336
|
const reader = new BufferReader(buf);
|
|
370
337
|
return _AssetRef.fromReader(reader);
|
|
371
338
|
}
|
|
372
|
-
/**
|
|
373
|
-
* Serialize the asset reference to raw bytes.
|
|
374
|
-
*
|
|
375
|
-
* @returns Serialized asset reference bytes
|
|
376
|
-
* @see fromBytes
|
|
377
|
-
*/
|
|
339
|
+
/** Serialize to raw bytes. @see fromBytes */
|
|
378
340
|
serialize() {
|
|
379
341
|
const writer = new BufferWriter();
|
|
380
342
|
this.serializeTo(writer);
|
|
381
343
|
return writer.toBytes();
|
|
382
344
|
}
|
|
383
|
-
/**
|
|
384
|
-
* Encode the asset reference to a hex string.
|
|
385
|
-
*
|
|
386
|
-
* @returns Hex-encoded asset reference
|
|
387
|
-
* @see fromString
|
|
388
|
-
*/
|
|
345
|
+
/** Encode to hex. @see fromString */
|
|
389
346
|
toString() {
|
|
390
347
|
return hex.encode(this.serialize());
|
|
391
348
|
}
|
|
392
349
|
/**
|
|
393
|
-
* Decode an asset reference from a
|
|
350
|
+
* Decode an asset reference from a reader positioned at one.
|
|
394
351
|
*
|
|
395
|
-
* @param reader - Reader positioned at an asset reference
|
|
396
|
-
* @returns Decoded asset reference
|
|
397
352
|
* @throws Error if the type is unknown or the reader does not contain enough bytes
|
|
398
353
|
*/
|
|
399
354
|
static fromReader(reader) {
|
|
@@ -420,12 +375,7 @@ var AssetRef = class _AssetRef {
|
|
|
420
375
|
}
|
|
421
376
|
return ref;
|
|
422
377
|
}
|
|
423
|
-
/**
|
|
424
|
-
* Serialize the asset reference into an existing binary writer.
|
|
425
|
-
*
|
|
426
|
-
* @param writer - Writer to append the asset reference to
|
|
427
|
-
* @see serialize
|
|
428
|
-
*/
|
|
378
|
+
/** Append the serialized reference to `writer`. @see serialize */
|
|
429
379
|
serializeTo(writer) {
|
|
430
380
|
writer.writeByte(this.ref.type);
|
|
431
381
|
switch (this.ref.type) {
|
|
@@ -466,12 +416,7 @@ var AssetInput = class _AssetInput {
|
|
|
466
416
|
if (!txid || txid.length === 0) {
|
|
467
417
|
throw new Error("missing input intent txid");
|
|
468
418
|
}
|
|
469
|
-
|
|
470
|
-
try {
|
|
471
|
-
buf = hex.decode(txid);
|
|
472
|
-
} catch {
|
|
473
|
-
throw new Error("invalid input intent txid format, must be hex");
|
|
474
|
-
}
|
|
419
|
+
const buf = hexOrThrow(txid, "invalid input intent txid format, must be hex");
|
|
475
420
|
if (buf.length !== TX_HASH_SIZE) {
|
|
476
421
|
throw new Error("invalid input intent txid length");
|
|
477
422
|
}
|
|
@@ -486,13 +431,7 @@ var AssetInput = class _AssetInput {
|
|
|
486
431
|
}
|
|
487
432
|
/** Decode an asset input from its hex string form. */
|
|
488
433
|
static fromString(s) {
|
|
489
|
-
|
|
490
|
-
try {
|
|
491
|
-
buf = hex.decode(s);
|
|
492
|
-
} catch {
|
|
493
|
-
throw new Error("invalid format, must be hex");
|
|
494
|
-
}
|
|
495
|
-
return _AssetInput.fromBytes(buf);
|
|
434
|
+
return _AssetInput.fromBytes(hexOrThrow(s, "invalid format, must be hex"));
|
|
496
435
|
}
|
|
497
436
|
/** Decode an asset input from its serialized bytes. */
|
|
498
437
|
static fromBytes(buf) {
|
|
@@ -585,13 +524,7 @@ var AssetInputs = class _AssetInputs {
|
|
|
585
524
|
if (!s || s.length === 0) {
|
|
586
525
|
throw new Error("missing asset inputs");
|
|
587
526
|
}
|
|
588
|
-
|
|
589
|
-
try {
|
|
590
|
-
buf = hex.decode(s);
|
|
591
|
-
} catch {
|
|
592
|
-
throw new Error("invalid asset inputs format, must be hex");
|
|
593
|
-
}
|
|
594
|
-
const reader = new BufferReader(buf);
|
|
527
|
+
const reader = new BufferReader(hexOrThrow(s, "invalid asset inputs format, must be hex"));
|
|
595
528
|
return _AssetInputs.fromReader(reader);
|
|
596
529
|
}
|
|
597
530
|
/** Serialize the asset input list to raw bytes. */
|
|
@@ -659,13 +592,7 @@ var AssetOutput = class _AssetOutput {
|
|
|
659
592
|
}
|
|
660
593
|
/** Decode an asset output from its hex string form. */
|
|
661
594
|
static fromString(s) {
|
|
662
|
-
|
|
663
|
-
try {
|
|
664
|
-
buf = hex.decode(s);
|
|
665
|
-
} catch {
|
|
666
|
-
throw new Error("invalid asset output format, must be hex");
|
|
667
|
-
}
|
|
668
|
-
return _AssetOutput.fromBytes(buf);
|
|
595
|
+
return _AssetOutput.fromBytes(hexOrThrow(s, "invalid asset output format, must be hex"));
|
|
669
596
|
}
|
|
670
597
|
/** Decode an asset output from its serialized bytes. */
|
|
671
598
|
static fromBytes(buf) {
|
|
@@ -740,13 +667,7 @@ var AssetOutputs = class _AssetOutputs {
|
|
|
740
667
|
if (!s || s.length === 0) {
|
|
741
668
|
throw new Error("missing asset outputs");
|
|
742
669
|
}
|
|
743
|
-
|
|
744
|
-
try {
|
|
745
|
-
buf = hex.decode(s);
|
|
746
|
-
} catch {
|
|
747
|
-
throw new Error("invalid asset outputs format, must be hex");
|
|
748
|
-
}
|
|
749
|
-
const reader = new BufferReader(buf);
|
|
670
|
+
const reader = new BufferReader(hexOrThrow(s, "invalid asset outputs format, must be hex"));
|
|
750
671
|
return _AssetOutputs.fromReader(reader);
|
|
751
672
|
}
|
|
752
673
|
/** Serialize the asset output list to raw bytes. */
|
|
@@ -808,13 +729,7 @@ var Metadata = class _Metadata {
|
|
|
808
729
|
}
|
|
809
730
|
/** Decode metadata from its hex string form. */
|
|
810
731
|
static fromString(s) {
|
|
811
|
-
|
|
812
|
-
try {
|
|
813
|
-
buf = hex.decode(s);
|
|
814
|
-
} catch {
|
|
815
|
-
throw new Error("invalid metadata format, must be hex");
|
|
816
|
-
}
|
|
817
|
-
return _Metadata.fromBytes(buf);
|
|
732
|
+
return _Metadata.fromBytes(hexOrThrow(s, "invalid metadata format, must be hex"));
|
|
818
733
|
}
|
|
819
734
|
/** Decode metadata from its serialized bytes. */
|
|
820
735
|
static fromBytes(buf) {
|
|
@@ -883,13 +798,7 @@ var MetadataList = class _MetadataList {
|
|
|
883
798
|
static ARK_LEAF_VERSION = 0;
|
|
884
799
|
/** Create a metadata list from its hex string form. */
|
|
885
800
|
static fromString(s) {
|
|
886
|
-
|
|
887
|
-
try {
|
|
888
|
-
buf = hex.decode(s);
|
|
889
|
-
} catch {
|
|
890
|
-
throw new Error("invalid metadata list format");
|
|
891
|
-
}
|
|
892
|
-
return _MetadataList.fromBytes(buf);
|
|
801
|
+
return _MetadataList.fromBytes(hexOrThrow(s, "invalid metadata list format"));
|
|
893
802
|
}
|
|
894
803
|
/** Decode a metadata list from its serialized bytes. */
|
|
895
804
|
static fromBytes(buf) {
|
|
@@ -1002,13 +911,7 @@ var AssetGroup = class _AssetGroup {
|
|
|
1002
911
|
* @see toString
|
|
1003
912
|
*/
|
|
1004
913
|
static fromString(s) {
|
|
1005
|
-
|
|
1006
|
-
try {
|
|
1007
|
-
buf = hex.decode(s);
|
|
1008
|
-
} catch {
|
|
1009
|
-
throw new Error("invalid format, must be hex");
|
|
1010
|
-
}
|
|
1011
|
-
return _AssetGroup.fromBytes(buf);
|
|
914
|
+
return _AssetGroup.fromBytes(hexOrThrow(s, "invalid format, must be hex"));
|
|
1012
915
|
}
|
|
1013
916
|
/**
|
|
1014
917
|
* Decode an asset group from its serialized bytes.
|
|
@@ -1193,13 +1096,7 @@ var Packet = class _Packet {
|
|
|
1193
1096
|
if (!s) {
|
|
1194
1097
|
throw new Error("missing packet data");
|
|
1195
1098
|
}
|
|
1196
|
-
|
|
1197
|
-
try {
|
|
1198
|
-
buf = hex.decode(s);
|
|
1199
|
-
} catch {
|
|
1200
|
-
throw new Error("invalid packet format, must be hex");
|
|
1201
|
-
}
|
|
1202
|
-
return _Packet.fromBytes(buf);
|
|
1099
|
+
return _Packet.fromBytes(hexOrThrow(s, "invalid packet format, must be hex"));
|
|
1203
1100
|
}
|
|
1204
1101
|
/**
|
|
1205
1102
|
* type returns the TLV packet type tag. Implements ExtensionPacket interface.
|
|
@@ -1471,16 +1368,10 @@ var RestIndexerProvider = class {
|
|
|
1471
1368
|
/** @see fetchVtxosJson */
|
|
1472
1369
|
inFlightVtxoReads = /* @__PURE__ */ new Map();
|
|
1473
1370
|
async getVtxoTree(batchOutpoint, opts) {
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1479
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1480
|
-
}
|
|
1481
|
-
if (params.toString()) {
|
|
1482
|
-
url += "?" + params.toString();
|
|
1483
|
-
}
|
|
1371
|
+
const url = withPage(
|
|
1372
|
+
`${this.serverUrl}/v1/indexer/batch/${batchOutpoint.txid}/${batchOutpoint.vout}/tree`,
|
|
1373
|
+
opts
|
|
1374
|
+
);
|
|
1484
1375
|
const res = await indexerFetch(url);
|
|
1485
1376
|
if (!res.ok) {
|
|
1486
1377
|
throw new Error(`Failed to fetch vtxo tree: ${res.statusText}`);
|
|
@@ -1489,24 +1380,14 @@ var RestIndexerProvider = class {
|
|
|
1489
1380
|
if (!Response.isVtxoTreeResponse(data)) {
|
|
1490
1381
|
throw new Error("Invalid vtxo tree data received");
|
|
1491
1382
|
}
|
|
1492
|
-
data.vtxoTree
|
|
1493
|
-
tx.children = Object.fromEntries(
|
|
1494
|
-
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1495
|
-
);
|
|
1496
|
-
});
|
|
1383
|
+
numberChildKeys(data.vtxoTree);
|
|
1497
1384
|
return data;
|
|
1498
1385
|
}
|
|
1499
1386
|
async getVtxoTreeLeaves(batchOutpoint, opts) {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1505
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1506
|
-
}
|
|
1507
|
-
if (params.toString()) {
|
|
1508
|
-
url += "?" + params.toString();
|
|
1509
|
-
}
|
|
1387
|
+
const url = withPage(
|
|
1388
|
+
`${this.serverUrl}/v1/indexer/batch/${batchOutpoint.txid}/${batchOutpoint.vout}/tree/leaves`,
|
|
1389
|
+
opts
|
|
1390
|
+
);
|
|
1510
1391
|
const res = await indexerFetch(url);
|
|
1511
1392
|
if (!res.ok) {
|
|
1512
1393
|
throw new Error(`Failed to fetch vtxo tree leaves: ${res.statusText}`);
|
|
@@ -1542,16 +1423,7 @@ var RestIndexerProvider = class {
|
|
|
1542
1423
|
return data;
|
|
1543
1424
|
}
|
|
1544
1425
|
async getCommitmentTxConnectors(txid, opts) {
|
|
1545
|
-
|
|
1546
|
-
const params = new URLSearchParams();
|
|
1547
|
-
if (opts) {
|
|
1548
|
-
if (opts.pageIndex !== void 0)
|
|
1549
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1550
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1551
|
-
}
|
|
1552
|
-
if (params.toString()) {
|
|
1553
|
-
url += "?" + params.toString();
|
|
1554
|
-
}
|
|
1426
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/commitmentTx/${txid}/connectors`, opts);
|
|
1555
1427
|
const res = await indexerFetch(url);
|
|
1556
1428
|
if (!res.ok) {
|
|
1557
1429
|
throw new Error(`Failed to fetch commitment tx connectors: ${res.statusText}`);
|
|
@@ -1560,24 +1432,11 @@ var RestIndexerProvider = class {
|
|
|
1560
1432
|
if (!Response.isConnectorsResponse(data)) {
|
|
1561
1433
|
throw new Error("Invalid commitment tx connectors data received");
|
|
1562
1434
|
}
|
|
1563
|
-
data.connectors
|
|
1564
|
-
tx.children = Object.fromEntries(
|
|
1565
|
-
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1566
|
-
);
|
|
1567
|
-
});
|
|
1435
|
+
numberChildKeys(data.connectors);
|
|
1568
1436
|
return data;
|
|
1569
1437
|
}
|
|
1570
1438
|
async getCommitmentTxForfeitTxs(txid, opts) {
|
|
1571
|
-
|
|
1572
|
-
const params = new URLSearchParams();
|
|
1573
|
-
if (opts) {
|
|
1574
|
-
if (opts.pageIndex !== void 0)
|
|
1575
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1576
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1577
|
-
}
|
|
1578
|
-
if (params.toString()) {
|
|
1579
|
-
url += "?" + params.toString();
|
|
1580
|
-
}
|
|
1439
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/commitmentTx/${txid}/forfeitTxs`, opts);
|
|
1581
1440
|
const res = await indexerFetch(url);
|
|
1582
1441
|
if (!res.ok) {
|
|
1583
1442
|
throw new Error(`Failed to fetch commitment tx forfeitTxs: ${res.statusText}`);
|
|
@@ -1608,15 +1467,7 @@ var RestIndexerProvider = class {
|
|
|
1608
1467
|
try {
|
|
1609
1468
|
const data = JSON.parse(event.data);
|
|
1610
1469
|
if (data.event) {
|
|
1611
|
-
yield
|
|
1612
|
-
txid: data.event.txid,
|
|
1613
|
-
scripts: data.event.scripts || [],
|
|
1614
|
-
newVtxos: (data.event.newVtxos || []).map(convertVtxo),
|
|
1615
|
-
spentVtxos: (data.event.spentVtxos || []).map(convertVtxo),
|
|
1616
|
-
sweptVtxos: (data.event.sweptVtxos || []).map(convertVtxo),
|
|
1617
|
-
tx: data.event.tx,
|
|
1618
|
-
checkpointTxs: data.event.checkpointTxs
|
|
1619
|
-
};
|
|
1470
|
+
yield toSubscriptionResponse(data.event);
|
|
1620
1471
|
}
|
|
1621
1472
|
} catch (err) {
|
|
1622
1473
|
console.error("Failed to parse subscription event:", err);
|
|
@@ -1655,16 +1506,7 @@ var RestIndexerProvider = class {
|
|
|
1655
1506
|
return gen;
|
|
1656
1507
|
}
|
|
1657
1508
|
async getVirtualTxs(txids, opts) {
|
|
1658
|
-
|
|
1659
|
-
const params = new URLSearchParams();
|
|
1660
|
-
if (opts) {
|
|
1661
|
-
if (opts.pageIndex !== void 0)
|
|
1662
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1663
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1664
|
-
}
|
|
1665
|
-
if (params.toString()) {
|
|
1666
|
-
url += "?" + params.toString();
|
|
1667
|
-
}
|
|
1509
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/virtualTx/${txids.join(",")}`, opts);
|
|
1668
1510
|
const res = await indexerFetch(url);
|
|
1669
1511
|
if (!res.ok) {
|
|
1670
1512
|
throw new Error(`Failed to fetch virtual txs: ${res.statusText}`);
|
|
@@ -1676,16 +1518,10 @@ var RestIndexerProvider = class {
|
|
|
1676
1518
|
return data;
|
|
1677
1519
|
}
|
|
1678
1520
|
async getVtxoChain(vtxoOutpoint, opts) {
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1684
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1685
|
-
}
|
|
1686
|
-
if (params.toString()) {
|
|
1687
|
-
url += "?" + params.toString();
|
|
1688
|
-
}
|
|
1521
|
+
const url = withPage(
|
|
1522
|
+
`${this.serverUrl}/v1/indexer/vtxo/${vtxoOutpoint.txid}/${vtxoOutpoint.vout}/chain`,
|
|
1523
|
+
opts
|
|
1524
|
+
);
|
|
1689
1525
|
const res = await indexerFetch(url);
|
|
1690
1526
|
if (!res.ok) {
|
|
1691
1527
|
throw new Error(`Failed to fetch vtxo chain: ${res.statusText}`);
|
|
@@ -1863,6 +1699,31 @@ var RestIndexerProvider = class {
|
|
|
1863
1699
|
}
|
|
1864
1700
|
}
|
|
1865
1701
|
};
|
|
1702
|
+
function withPage(url, opts) {
|
|
1703
|
+
const params = new URLSearchParams();
|
|
1704
|
+
if (opts?.pageIndex !== void 0) params.append("page.index", opts.pageIndex.toString());
|
|
1705
|
+
if (opts?.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1706
|
+
const query = params.toString();
|
|
1707
|
+
return query ? `${url}?${query}` : url;
|
|
1708
|
+
}
|
|
1709
|
+
function numberChildKeys(txs) {
|
|
1710
|
+
txs.forEach((tx) => {
|
|
1711
|
+
tx.children = Object.fromEntries(
|
|
1712
|
+
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1713
|
+
);
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
function toSubscriptionResponse(event) {
|
|
1717
|
+
return {
|
|
1718
|
+
txid: event.txid,
|
|
1719
|
+
scripts: event.scripts || [],
|
|
1720
|
+
newVtxos: (event.newVtxos || []).map(convertVtxo),
|
|
1721
|
+
spentVtxos: (event.spentVtxos || []).map(convertVtxo),
|
|
1722
|
+
sweptVtxos: (event.sweptVtxos || []).map(convertVtxo),
|
|
1723
|
+
tx: event.tx,
|
|
1724
|
+
checkpointTxs: event.checkpointTxs
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1866
1727
|
function parseAssetMetadata(metadata) {
|
|
1867
1728
|
const metadataList = MetadataList.fromString(metadata);
|
|
1868
1729
|
const out = {};
|
|
@@ -1902,31 +1763,12 @@ var Response;
|
|
|
1902
1763
|
return typeof data === "object" && typeof data.txid === "string" && typeof data.vout === "number";
|
|
1903
1764
|
}
|
|
1904
1765
|
Response2.isOutpoint = isOutpoint;
|
|
1905
|
-
function isOutpointArray(data) {
|
|
1906
|
-
return Array.isArray(data) && data.every(isOutpoint);
|
|
1907
|
-
}
|
|
1908
|
-
Response2.isOutpointArray = isOutpointArray;
|
|
1909
1766
|
function isTx(data) {
|
|
1910
1767
|
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)));
|
|
1911
1768
|
}
|
|
1912
|
-
function isTxsArray(data) {
|
|
1913
|
-
return Array.isArray(data) && data.every(isTx);
|
|
1914
|
-
}
|
|
1915
|
-
Response2.isTxsArray = isTxsArray;
|
|
1916
|
-
function isTxHistoryRecord(data) {
|
|
1917
|
-
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);
|
|
1918
|
-
}
|
|
1919
|
-
function isTxHistoryRecordArray(data) {
|
|
1920
|
-
return Array.isArray(data) && data.every(isTxHistoryRecord);
|
|
1921
|
-
}
|
|
1922
|
-
Response2.isTxHistoryRecordArray = isTxHistoryRecordArray;
|
|
1923
1769
|
function isTxid(data) {
|
|
1924
1770
|
return typeof data === "string" && data.length === 64;
|
|
1925
1771
|
}
|
|
1926
|
-
function isTxidArray(data) {
|
|
1927
|
-
return Array.isArray(data) && data.every(isTxid);
|
|
1928
|
-
}
|
|
1929
|
-
Response2.isTxidArray = isTxidArray;
|
|
1930
1772
|
function isVtxoAsset(data) {
|
|
1931
1773
|
return typeof data === "object" && data !== null && typeof data.assetId === "string" && typeof data.amount === "string";
|
|
1932
1774
|
}
|
|
@@ -1952,10 +1794,6 @@ var Response;
|
|
|
1952
1794
|
return typeof data === "object" && Array.isArray(data.txids) && data.txids.every(isTxid) && (!data.page || isPageResponse(data.page));
|
|
1953
1795
|
}
|
|
1954
1796
|
Response2.isForfeitTxsResponse = isForfeitTxsResponse;
|
|
1955
|
-
function isSweptCommitmentTxResponse(data) {
|
|
1956
|
-
return typeof data === "object" && Array.isArray(data.sweptBy) && data.sweptBy.every(isTxid);
|
|
1957
|
-
}
|
|
1958
|
-
Response2.isSweptCommitmentTxResponse = isSweptCommitmentTxResponse;
|
|
1959
1797
|
function isBatchSweepTransactionsResponse(data) {
|
|
1960
1798
|
return typeof data === "object" && Array.isArray(data.sweptBy) && data.sweptBy.every(isTxid);
|
|
1961
1799
|
}
|
|
@@ -1978,6 +1816,6 @@ var Response;
|
|
|
1978
1816
|
Response2.isGetAssetResponse = isGetAssetResponse;
|
|
1979
1817
|
})(Response || (Response = {}));
|
|
1980
1818
|
|
|
1981
|
-
export { AssetGroup, AssetId, AssetInput, AssetOutput, AssetRef, BufferReader, BufferWriter, ChainTxType, DEFAULT_VTXO_PAGE_SIZE, IndexerTxType, Metadata, Packet, RestIndexerProvider, asset_exports };
|
|
1982
|
-
//# sourceMappingURL=chunk-
|
|
1983
|
-
//# sourceMappingURL=chunk-
|
|
1819
|
+
export { AssetGroup, AssetId, AssetInput, AssetOutput, AssetRef, BufferReader, BufferWriter, ChainTxType, DEFAULT_VTXO_PAGE_SIZE, IndexerTxType, Metadata, Packet, RestIndexerProvider, asset_exports, toSubscriptionResponse };
|
|
1820
|
+
//# sourceMappingURL=chunk-3JLYJ5KZ.js.map
|
|
1821
|
+
//# sourceMappingURL=chunk-3JLYJ5KZ.js.map
|