@arkade-os/sdk 0.5.0-rc.3 → 0.5.0-rc.30
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 +223 -83
- package/dist/adapters/expo.cjs +5 -6
- package/dist/adapters/expo.d.cts +5 -5
- package/dist/adapters/expo.d.ts +5 -5
- package/dist/adapters/expo.js +3 -4
- package/dist/{asyncStorageTaskQueue-DAs_n1xr.d.ts → asyncStorageTaskQueue-DAVf4Fyy.d.ts} +2 -2
- package/dist/{asyncStorageTaskQueue-DqGRG66E.d.cts → asyncStorageTaskQueue-fkkUPrhz.d.cts} +2 -2
- package/dist/{chunk-FSF2PGTR.cjs → chunk-3SM7BMIE.cjs} +6736 -5189
- package/dist/chunk-3SM7BMIE.cjs.map +1 -0
- package/dist/{chunk-UCSTNXB4.cjs → chunk-4MCQZYH6.cjs} +501 -1153
- package/dist/chunk-4MCQZYH6.cjs.map +1 -0
- package/dist/{chunk-BCT7DT2J.cjs → chunk-6BTZ6KFI.cjs} +12 -10
- package/dist/chunk-6BTZ6KFI.cjs.map +1 -0
- package/dist/{chunk-L4HZK4KK.cjs → chunk-AICUNREA.cjs} +158 -263
- package/dist/chunk-AICUNREA.cjs.map +1 -0
- package/dist/{chunk-UJTYUYY4.cjs → chunk-ASKOHVGX.cjs} +596 -467
- package/dist/chunk-ASKOHVGX.cjs.map +1 -0
- package/dist/{chunk-43XGA362.cjs → chunk-DLHE4RCH.cjs} +40 -43
- package/dist/chunk-DLHE4RCH.cjs.map +1 -0
- package/dist/{chunk-7W6FHWYN.js → chunk-ESEHYZAY.js} +434 -1109
- package/dist/chunk-ESEHYZAY.js.map +1 -0
- package/dist/{chunk-HSG2GQTM.js → chunk-G6ZPX2GL.js} +586 -462
- package/dist/chunk-G6ZPX2GL.js.map +1 -0
- package/dist/{chunk-G4UPMCKW.js → chunk-KK6GXY4L.js} +33 -36
- package/dist/chunk-KK6GXY4L.js.map +1 -0
- package/dist/{chunk-ERUAQGYF.js → chunk-PY3YQNHP.js} +146 -252
- package/dist/chunk-PY3YQNHP.js.map +1 -0
- package/dist/{chunk-VQCDDGRW.js → chunk-XW72DWYO.js} +6350 -4816
- package/dist/chunk-XW72DWYO.js.map +1 -0
- package/dist/{chunk-ROD5H7RX.js → chunk-YML2N4SC.js} +7 -5
- package/dist/chunk-YML2N4SC.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +9 -10
- package/dist/contracts/handlers/index.d.cts +5 -5
- package/dist/contracts/handlers/index.d.ts +5 -5
- package/dist/contracts/handlers/index.js +2 -3
- package/dist/{delegate-CZzIduW4.d.cts → delegate-BYoNu3lf.d.cts} +1 -1
- package/dist/{delegate-B9Bmrns7.d.ts → delegate-DsqzUVId.d.ts} +1 -1
- package/dist/index-CXNTURO_.d.cts +645 -0
- package/dist/{index-DnNIOqHS.d.ts → index-DhP68WBD.d.cts} +1698 -2402
- package/dist/{index-DnNIOqHS.d.cts → index-DhP68WBD.d.ts} +1698 -2402
- package/dist/index-pQr5y77P.d.ts +645 -0
- package/dist/index.cjs +407 -356
- package/dist/index.d.cts +1045 -1302
- package/dist/index.d.ts +1045 -1302
- package/dist/index.js +4 -5
- package/dist/repositories/realm/index.cjs +201 -106
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +28 -16
- package/dist/repositories/realm/index.d.ts +28 -16
- package/dist/repositories/realm/index.js +190 -95
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +301 -189
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +32 -21
- package/dist/repositories/sqlite/index.d.ts +32 -21
- package/dist/repositories/sqlite/index.js +294 -182
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-BDb5Ee2J.d.cts → taskRunner-C8H3bSsk.d.cts} +2 -2
- package/dist/{taskRunner-F7wNJcF3.d.ts → taskRunner-DKtBy8Yo.d.ts} +2 -2
- package/dist/wallet/expo/background.cjs +14 -15
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +10 -16
- package/dist/wallet/expo/background.d.ts +10 -16
- package/dist/wallet/expo/background.js +6 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +20 -23
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +8 -9
- package/dist/wallet/expo/index.d.ts +8 -9
- package/dist/wallet/expo/index.js +12 -15
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/wallet-BmAHDzK3.d.cts +1874 -0
- package/dist/wallet-C0W8EOnA.d.ts +1874 -0
- package/dist/worker/expo/index.cjs +9 -10
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +6 -6
- package/dist/worker/expo/index.d.ts +6 -6
- package/dist/worker/expo/index.js +5 -6
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +12 -51
- package/dist/adapters/asyncStorage.cjs +0 -48
- package/dist/adapters/asyncStorage.cjs.map +0 -1
- package/dist/adapters/asyncStorage.d.cts +0 -16
- package/dist/adapters/asyncStorage.d.ts +0 -16
- package/dist/adapters/asyncStorage.js +0 -46
- package/dist/adapters/asyncStorage.js.map +0 -1
- package/dist/adapters/fileSystem.cjs +0 -116
- package/dist/adapters/fileSystem.cjs.map +0 -1
- package/dist/adapters/fileSystem.d.cts +0 -17
- package/dist/adapters/fileSystem.d.ts +0 -17
- package/dist/adapters/fileSystem.js +0 -93
- package/dist/adapters/fileSystem.js.map +0 -1
- package/dist/adapters/indexedDB.cjs +0 -103
- package/dist/adapters/indexedDB.cjs.map +0 -1
- package/dist/adapters/indexedDB.d.cts +0 -18
- package/dist/adapters/indexedDB.d.ts +0 -18
- package/dist/adapters/indexedDB.js +0 -101
- package/dist/adapters/indexedDB.js.map +0 -1
- package/dist/adapters/localStorage.cjs +0 -50
- package/dist/adapters/localStorage.cjs.map +0 -1
- package/dist/adapters/localStorage.d.cts +0 -14
- package/dist/adapters/localStorage.d.ts +0 -14
- package/dist/adapters/localStorage.js +0 -48
- package/dist/adapters/localStorage.js.map +0 -1
- package/dist/chunk-43XGA362.cjs.map +0 -1
- package/dist/chunk-5BLDMQED.cjs +0 -18
- package/dist/chunk-5BLDMQED.cjs.map +0 -1
- package/dist/chunk-7W6FHWYN.js.map +0 -1
- package/dist/chunk-BCT7DT2J.cjs.map +0 -1
- package/dist/chunk-ERUAQGYF.js.map +0 -1
- package/dist/chunk-FSF2PGTR.cjs.map +0 -1
- package/dist/chunk-G4UPMCKW.js.map +0 -1
- package/dist/chunk-HSG2GQTM.js.map +0 -1
- package/dist/chunk-L4HZK4KK.cjs.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -15
- package/dist/chunk-NSBPE2FW.js.map +0 -1
- package/dist/chunk-ROD5H7RX.js.map +0 -1
- package/dist/chunk-UCSTNXB4.cjs.map +0 -1
- package/dist/chunk-UJTYUYY4.cjs.map +0 -1
- package/dist/chunk-VQCDDGRW.js.map +0 -1
- package/dist/hdWalletCapable-BIl3yLVM.d.cts +0 -2232
- package/dist/hdWalletCapable-Cr5nGpK5.d.ts +0 -2232
- package/dist/index-C0IanN1m.d.cts +0 -11
- package/dist/index-C0IanN1m.d.ts +0 -11
- package/dist/index-Ci5MmNnK.d.cts +0 -850
- package/dist/index-DQ1Hb2w_.d.ts +0 -850
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
|
|
3
|
+
var chunkASKOHVGX_cjs = require('./chunk-ASKOHVGX.cjs');
|
|
5
4
|
var base = require('@scure/base');
|
|
6
5
|
var secp256k1_js = require('@noble/curves/secp256k1.js');
|
|
7
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
8
7
|
|
|
9
8
|
// src/extension/asset/index.ts
|
|
10
9
|
var asset_exports = {};
|
|
11
|
-
|
|
10
|
+
chunkASKOHVGX_cjs.__export(asset_exports, {
|
|
12
11
|
ASSET_ID_VECTORS: () => ASSET_ID_VECTORS,
|
|
13
12
|
AssetGroup: () => AssetGroup,
|
|
14
13
|
AssetId: () => AssetId,
|
|
@@ -42,8 +41,13 @@ var AssetRefType = /* @__PURE__ */ ((AssetRefType2) => {
|
|
|
42
41
|
var MASK_ASSET_ID = 1;
|
|
43
42
|
var MASK_CONTROL_ASSET = 2;
|
|
44
43
|
var MASK_METADATA = 4;
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
function hexOrThrow(s, message) {
|
|
45
|
+
try {
|
|
46
|
+
return base.hex.decode(s);
|
|
47
|
+
} catch {
|
|
48
|
+
throw new Error(message);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
47
51
|
var BufferWriter = class {
|
|
48
52
|
buffer = [];
|
|
49
53
|
write(data) {
|
|
@@ -186,11 +190,10 @@ var AssetId = class _AssetId {
|
|
|
186
190
|
txid;
|
|
187
191
|
groupIndex;
|
|
188
192
|
/**
|
|
189
|
-
* Create
|
|
193
|
+
* Create a validated asset id from a genesis transaction id and group index.
|
|
190
194
|
*
|
|
191
195
|
* @param txid - Hex-encoded genesis transaction id
|
|
192
196
|
* @param groupIndex - Asset group index within the genesis transaction
|
|
193
|
-
* @returns A validated asset id
|
|
194
197
|
* @throws Error if the txid is missing, malformed, or not 32 bytes long
|
|
195
198
|
* @see fromString
|
|
196
199
|
*/
|
|
@@ -198,12 +201,7 @@ var AssetId = class _AssetId {
|
|
|
198
201
|
if (!txid) {
|
|
199
202
|
throw new Error("missing txid");
|
|
200
203
|
}
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
buf = base.hex.decode(txid);
|
|
204
|
-
} catch {
|
|
205
|
-
throw new Error("invalid txid format, must be hex");
|
|
206
|
-
}
|
|
204
|
+
const buf = hexOrThrow(txid, "invalid txid format, must be hex");
|
|
207
205
|
if (buf.length !== TX_HASH_SIZE) {
|
|
208
206
|
throw new Error(
|
|
209
207
|
`invalid txid length: got ${buf.length} bytes, want ${TX_HASH_SIZE} bytes`
|
|
@@ -216,25 +214,15 @@ var AssetId = class _AssetId {
|
|
|
216
214
|
/**
|
|
217
215
|
* Decode an asset id from its hex string representation.
|
|
218
216
|
*
|
|
219
|
-
* @param s - Hex-encoded asset id
|
|
220
|
-
* @returns Decoded asset id
|
|
221
217
|
* @throws Error if the string is not valid hex or does not encode a valid asset id
|
|
222
218
|
* @see toString
|
|
223
219
|
*/
|
|
224
220
|
static fromString(s) {
|
|
225
|
-
|
|
226
|
-
try {
|
|
227
|
-
buf = base.hex.decode(s);
|
|
228
|
-
} catch {
|
|
229
|
-
throw new Error("invalid asset id format, must be hex");
|
|
230
|
-
}
|
|
231
|
-
return _AssetId.fromBytes(buf);
|
|
221
|
+
return _AssetId.fromBytes(hexOrThrow(s, "invalid asset id format, must be hex"));
|
|
232
222
|
}
|
|
233
223
|
/**
|
|
234
224
|
* Decode an asset id from its serialized bytes.
|
|
235
225
|
*
|
|
236
|
-
* @param buf - Serialized asset id bytes
|
|
237
|
-
* @returns Decoded asset id
|
|
238
226
|
* @throws Error if the buffer length is invalid
|
|
239
227
|
*/
|
|
240
228
|
static fromBytes(buf) {
|
|
@@ -252,7 +240,6 @@ var AssetId = class _AssetId {
|
|
|
252
240
|
/**
|
|
253
241
|
* Serialize the asset id to raw bytes.
|
|
254
242
|
*
|
|
255
|
-
* @returns Serialized asset id bytes
|
|
256
243
|
* @see fromBytes
|
|
257
244
|
*/
|
|
258
245
|
serialize() {
|
|
@@ -263,7 +250,6 @@ var AssetId = class _AssetId {
|
|
|
263
250
|
/**
|
|
264
251
|
* Encode the asset id to a hex string.
|
|
265
252
|
*
|
|
266
|
-
* @returns Hex-encoded asset id
|
|
267
253
|
* @see fromString
|
|
268
254
|
*/
|
|
269
255
|
toString() {
|
|
@@ -283,10 +269,8 @@ var AssetId = class _AssetId {
|
|
|
283
269
|
}
|
|
284
270
|
}
|
|
285
271
|
/**
|
|
286
|
-
* Decode an asset id from a binary reader.
|
|
272
|
+
* Decode an asset id from a binary reader positioned at one.
|
|
287
273
|
*
|
|
288
|
-
* @param reader - Reader positioned at an asset id
|
|
289
|
-
* @returns Decoded asset id
|
|
290
274
|
* @throws Error if the reader does not contain enough bytes
|
|
291
275
|
*/
|
|
292
276
|
static fromReader(reader) {
|
|
@@ -304,7 +288,6 @@ var AssetId = class _AssetId {
|
|
|
304
288
|
/**
|
|
305
289
|
* Serialize the asset id into an existing binary writer.
|
|
306
290
|
*
|
|
307
|
-
* @param writer - Writer to append the asset id to
|
|
308
291
|
* @see serialize
|
|
309
292
|
*/
|
|
310
293
|
serializeTo(writer) {
|
|
@@ -321,48 +304,31 @@ var AssetRef = class _AssetRef {
|
|
|
321
304
|
get type() {
|
|
322
305
|
return this.ref.type;
|
|
323
306
|
}
|
|
324
|
-
/**
|
|
325
|
-
* Create an asset reference that points to a specific asset id.
|
|
326
|
-
*
|
|
327
|
-
* @param assetId - Asset id referenced by this pointer
|
|
328
|
-
* @returns Asset reference by id
|
|
329
|
-
* @see fromGroupIndex
|
|
330
|
-
*/
|
|
307
|
+
/** Reference a specific asset id. @see fromGroupIndex */
|
|
331
308
|
static fromId(assetId) {
|
|
332
309
|
return new _AssetRef({ type: 1 /* ByID */, assetId });
|
|
333
310
|
}
|
|
334
311
|
/**
|
|
335
|
-
*
|
|
312
|
+
* Reference another asset group in the packet.
|
|
336
313
|
*
|
|
337
314
|
* @param groupIndex - Zero-based asset group index in the packet
|
|
338
|
-
* @returns Asset reference by group index
|
|
339
315
|
* @see fromId
|
|
340
316
|
*/
|
|
341
317
|
static fromGroupIndex(groupIndex) {
|
|
342
318
|
return new _AssetRef({ type: 2 /* ByGroup */, groupIndex });
|
|
343
319
|
}
|
|
344
320
|
/**
|
|
345
|
-
* Decode an asset reference from
|
|
321
|
+
* Decode an asset reference from hex.
|
|
346
322
|
*
|
|
347
|
-
* @param s - Hex-encoded asset reference
|
|
348
|
-
* @returns Decoded asset reference
|
|
349
323
|
* @throws Error if the string is not valid hex or does not encode a valid asset reference
|
|
350
324
|
* @see toString
|
|
351
325
|
*/
|
|
352
326
|
static fromString(s) {
|
|
353
|
-
|
|
354
|
-
try {
|
|
355
|
-
buf = base.hex.decode(s);
|
|
356
|
-
} catch {
|
|
357
|
-
throw new Error("invalid asset ref format, must be hex");
|
|
358
|
-
}
|
|
359
|
-
return _AssetRef.fromBytes(buf);
|
|
327
|
+
return _AssetRef.fromBytes(hexOrThrow(s, "invalid asset ref format, must be hex"));
|
|
360
328
|
}
|
|
361
329
|
/**
|
|
362
330
|
* Decode an asset reference from its serialized bytes.
|
|
363
331
|
*
|
|
364
|
-
* @param buf - Serialized asset reference bytes
|
|
365
|
-
* @returns Decoded asset reference
|
|
366
332
|
* @throws Error if the buffer is empty or malformed
|
|
367
333
|
*/
|
|
368
334
|
static fromBytes(buf) {
|
|
@@ -372,31 +338,19 @@ var AssetRef = class _AssetRef {
|
|
|
372
338
|
const reader = new BufferReader(buf);
|
|
373
339
|
return _AssetRef.fromReader(reader);
|
|
374
340
|
}
|
|
375
|
-
/**
|
|
376
|
-
* Serialize the asset reference to raw bytes.
|
|
377
|
-
*
|
|
378
|
-
* @returns Serialized asset reference bytes
|
|
379
|
-
* @see fromBytes
|
|
380
|
-
*/
|
|
341
|
+
/** Serialize to raw bytes. @see fromBytes */
|
|
381
342
|
serialize() {
|
|
382
343
|
const writer = new BufferWriter();
|
|
383
344
|
this.serializeTo(writer);
|
|
384
345
|
return writer.toBytes();
|
|
385
346
|
}
|
|
386
|
-
/**
|
|
387
|
-
* Encode the asset reference to a hex string.
|
|
388
|
-
*
|
|
389
|
-
* @returns Hex-encoded asset reference
|
|
390
|
-
* @see fromString
|
|
391
|
-
*/
|
|
347
|
+
/** Encode to hex. @see fromString */
|
|
392
348
|
toString() {
|
|
393
349
|
return base.hex.encode(this.serialize());
|
|
394
350
|
}
|
|
395
351
|
/**
|
|
396
|
-
* Decode an asset reference from a
|
|
352
|
+
* Decode an asset reference from a reader positioned at one.
|
|
397
353
|
*
|
|
398
|
-
* @param reader - Reader positioned at an asset reference
|
|
399
|
-
* @returns Decoded asset reference
|
|
400
354
|
* @throws Error if the type is unknown or the reader does not contain enough bytes
|
|
401
355
|
*/
|
|
402
356
|
static fromReader(reader) {
|
|
@@ -423,12 +377,7 @@ var AssetRef = class _AssetRef {
|
|
|
423
377
|
}
|
|
424
378
|
return ref;
|
|
425
379
|
}
|
|
426
|
-
/**
|
|
427
|
-
* Serialize the asset reference into an existing binary writer.
|
|
428
|
-
*
|
|
429
|
-
* @param writer - Writer to append the asset reference to
|
|
430
|
-
* @see serialize
|
|
431
|
-
*/
|
|
380
|
+
/** Append the serialized reference to `writer`. @see serialize */
|
|
432
381
|
serializeTo(writer) {
|
|
433
382
|
writer.writeByte(this.ref.type);
|
|
434
383
|
switch (this.ref.type) {
|
|
@@ -469,12 +418,7 @@ var AssetInput = class _AssetInput {
|
|
|
469
418
|
if (!txid || txid.length === 0) {
|
|
470
419
|
throw new Error("missing input intent txid");
|
|
471
420
|
}
|
|
472
|
-
|
|
473
|
-
try {
|
|
474
|
-
buf = base.hex.decode(txid);
|
|
475
|
-
} catch {
|
|
476
|
-
throw new Error("invalid input intent txid format, must be hex");
|
|
477
|
-
}
|
|
421
|
+
const buf = hexOrThrow(txid, "invalid input intent txid format, must be hex");
|
|
478
422
|
if (buf.length !== TX_HASH_SIZE) {
|
|
479
423
|
throw new Error("invalid input intent txid length");
|
|
480
424
|
}
|
|
@@ -489,13 +433,7 @@ var AssetInput = class _AssetInput {
|
|
|
489
433
|
}
|
|
490
434
|
/** Decode an asset input from its hex string form. */
|
|
491
435
|
static fromString(s) {
|
|
492
|
-
|
|
493
|
-
try {
|
|
494
|
-
buf = base.hex.decode(s);
|
|
495
|
-
} catch {
|
|
496
|
-
throw new Error("invalid format, must be hex");
|
|
497
|
-
}
|
|
498
|
-
return _AssetInput.fromBytes(buf);
|
|
436
|
+
return _AssetInput.fromBytes(hexOrThrow(s, "invalid format, must be hex"));
|
|
499
437
|
}
|
|
500
438
|
/** Decode an asset input from its serialized bytes. */
|
|
501
439
|
static fromBytes(buf) {
|
|
@@ -588,13 +526,7 @@ var AssetInputs = class _AssetInputs {
|
|
|
588
526
|
if (!s || s.length === 0) {
|
|
589
527
|
throw new Error("missing asset inputs");
|
|
590
528
|
}
|
|
591
|
-
|
|
592
|
-
try {
|
|
593
|
-
buf = base.hex.decode(s);
|
|
594
|
-
} catch {
|
|
595
|
-
throw new Error("invalid asset inputs format, must be hex");
|
|
596
|
-
}
|
|
597
|
-
const reader = new BufferReader(buf);
|
|
529
|
+
const reader = new BufferReader(hexOrThrow(s, "invalid asset inputs format, must be hex"));
|
|
598
530
|
return _AssetInputs.fromReader(reader);
|
|
599
531
|
}
|
|
600
532
|
/** Serialize the asset input list to raw bytes. */
|
|
@@ -662,13 +594,7 @@ var AssetOutput = class _AssetOutput {
|
|
|
662
594
|
}
|
|
663
595
|
/** Decode an asset output from its hex string form. */
|
|
664
596
|
static fromString(s) {
|
|
665
|
-
|
|
666
|
-
try {
|
|
667
|
-
buf = base.hex.decode(s);
|
|
668
|
-
} catch {
|
|
669
|
-
throw new Error("invalid asset output format, must be hex");
|
|
670
|
-
}
|
|
671
|
-
return _AssetOutput.fromBytes(buf);
|
|
597
|
+
return _AssetOutput.fromBytes(hexOrThrow(s, "invalid asset output format, must be hex"));
|
|
672
598
|
}
|
|
673
599
|
/** Decode an asset output from its serialized bytes. */
|
|
674
600
|
static fromBytes(buf) {
|
|
@@ -743,13 +669,7 @@ var AssetOutputs = class _AssetOutputs {
|
|
|
743
669
|
if (!s || s.length === 0) {
|
|
744
670
|
throw new Error("missing asset outputs");
|
|
745
671
|
}
|
|
746
|
-
|
|
747
|
-
try {
|
|
748
|
-
buf = base.hex.decode(s);
|
|
749
|
-
} catch {
|
|
750
|
-
throw new Error("invalid asset outputs format, must be hex");
|
|
751
|
-
}
|
|
752
|
-
const reader = new BufferReader(buf);
|
|
672
|
+
const reader = new BufferReader(hexOrThrow(s, "invalid asset outputs format, must be hex"));
|
|
753
673
|
return _AssetOutputs.fromReader(reader);
|
|
754
674
|
}
|
|
755
675
|
/** Serialize the asset output list to raw bytes. */
|
|
@@ -811,13 +731,7 @@ var Metadata = class _Metadata {
|
|
|
811
731
|
}
|
|
812
732
|
/** Decode metadata from its hex string form. */
|
|
813
733
|
static fromString(s) {
|
|
814
|
-
|
|
815
|
-
try {
|
|
816
|
-
buf = base.hex.decode(s);
|
|
817
|
-
} catch {
|
|
818
|
-
throw new Error("invalid metadata format, must be hex");
|
|
819
|
-
}
|
|
820
|
-
return _Metadata.fromBytes(buf);
|
|
734
|
+
return _Metadata.fromBytes(hexOrThrow(s, "invalid metadata format, must be hex"));
|
|
821
735
|
}
|
|
822
736
|
/** Decode metadata from its serialized bytes. */
|
|
823
737
|
static fromBytes(buf) {
|
|
@@ -886,13 +800,7 @@ var MetadataList = class _MetadataList {
|
|
|
886
800
|
static ARK_LEAF_VERSION = 0;
|
|
887
801
|
/** Create a metadata list from its hex string form. */
|
|
888
802
|
static fromString(s) {
|
|
889
|
-
|
|
890
|
-
try {
|
|
891
|
-
buf = base.hex.decode(s);
|
|
892
|
-
} catch {
|
|
893
|
-
throw new Error("invalid metadata list format");
|
|
894
|
-
}
|
|
895
|
-
return _MetadataList.fromBytes(buf);
|
|
803
|
+
return _MetadataList.fromBytes(hexOrThrow(s, "invalid metadata list format"));
|
|
896
804
|
}
|
|
897
805
|
/** Decode a metadata list from its serialized bytes. */
|
|
898
806
|
static fromBytes(buf) {
|
|
@@ -1005,13 +913,7 @@ var AssetGroup = class _AssetGroup {
|
|
|
1005
913
|
* @see toString
|
|
1006
914
|
*/
|
|
1007
915
|
static fromString(s) {
|
|
1008
|
-
|
|
1009
|
-
try {
|
|
1010
|
-
buf = base.hex.decode(s);
|
|
1011
|
-
} catch {
|
|
1012
|
-
throw new Error("invalid format, must be hex");
|
|
1013
|
-
}
|
|
1014
|
-
return _AssetGroup.fromBytes(buf);
|
|
916
|
+
return _AssetGroup.fromBytes(hexOrThrow(s, "invalid format, must be hex"));
|
|
1015
917
|
}
|
|
1016
918
|
/**
|
|
1017
919
|
* Decode an asset group from its serialized bytes.
|
|
@@ -1196,13 +1098,7 @@ var Packet = class _Packet {
|
|
|
1196
1098
|
if (!s) {
|
|
1197
1099
|
throw new Error("missing packet data");
|
|
1198
1100
|
}
|
|
1199
|
-
|
|
1200
|
-
try {
|
|
1201
|
-
buf = base.hex.decode(s);
|
|
1202
|
-
} catch {
|
|
1203
|
-
throw new Error("invalid packet format, must be hex");
|
|
1204
|
-
}
|
|
1205
|
-
return _Packet.fromBytes(buf);
|
|
1101
|
+
return _Packet.fromBytes(hexOrThrow(s, "invalid packet format, must be hex"));
|
|
1206
1102
|
}
|
|
1207
1103
|
/**
|
|
1208
1104
|
* type returns the TLV packet type tag. Implements ExtensionPacket interface.
|
|
@@ -1420,10 +1316,10 @@ async function indexerFetch(input, init) {
|
|
|
1420
1316
|
const lastAttempt = attempt >= maxAttempts;
|
|
1421
1317
|
let res;
|
|
1422
1318
|
try {
|
|
1423
|
-
res = await
|
|
1319
|
+
res = await chunkASKOHVGX_cjs.rateGate.runHttp(input, () => chunkASKOHVGX_cjs.baseFetch(input, init));
|
|
1424
1320
|
} catch (err) {
|
|
1425
|
-
const mapped =
|
|
1426
|
-
if (lastAttempt || !(mapped instanceof
|
|
1321
|
+
const mapped = chunkASKOHVGX_cjs.toProviderUnavailable(err, "indexer");
|
|
1322
|
+
if (lastAttempt || !(mapped instanceof chunkASKOHVGX_cjs.ProviderUnavailableError)) throw mapped;
|
|
1427
1323
|
await sleep(retryDelayMs(attempt));
|
|
1428
1324
|
continue;
|
|
1429
1325
|
}
|
|
@@ -1435,7 +1331,7 @@ async function indexerFetch(input, init) {
|
|
|
1435
1331
|
body = void 0;
|
|
1436
1332
|
}
|
|
1437
1333
|
try {
|
|
1438
|
-
|
|
1334
|
+
chunkASKOHVGX_cjs.throwIfHttpUnavailable(res, "indexer", body);
|
|
1439
1335
|
} catch (err) {
|
|
1440
1336
|
if (lastAttempt) throw err;
|
|
1441
1337
|
await sleep(retryDelayMs(attempt));
|
|
@@ -1464,24 +1360,20 @@ var ChainTxType = /* @__PURE__ */ ((ChainTxType2) => {
|
|
|
1464
1360
|
return ChainTxType2;
|
|
1465
1361
|
})(ChainTxType || {});
|
|
1466
1362
|
var RestIndexerProvider = class {
|
|
1467
|
-
constructor(serverUrl =
|
|
1363
|
+
constructor(serverUrl = chunkASKOHVGX_cjs.DEFAULT_ARKADE_SERVER_URL, options = {}) {
|
|
1468
1364
|
this.serverUrl = serverUrl;
|
|
1469
1365
|
this.eventSource = options.eventSource;
|
|
1470
1366
|
}
|
|
1471
1367
|
serverUrl;
|
|
1472
1368
|
/** Overrides {@link configureEventSource} for this provider's subscription. */
|
|
1473
1369
|
eventSource;
|
|
1370
|
+
/** @see fetchVtxosJson */
|
|
1371
|
+
inFlightVtxoReads = /* @__PURE__ */ new Map();
|
|
1474
1372
|
async getVtxoTree(batchOutpoint, opts) {
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1480
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1481
|
-
}
|
|
1482
|
-
if (params.toString()) {
|
|
1483
|
-
url += "?" + params.toString();
|
|
1484
|
-
}
|
|
1373
|
+
const url = withPage(
|
|
1374
|
+
`${this.serverUrl}/v1/indexer/batch/${batchOutpoint.txid}/${batchOutpoint.vout}/tree`,
|
|
1375
|
+
opts
|
|
1376
|
+
);
|
|
1485
1377
|
const res = await indexerFetch(url);
|
|
1486
1378
|
if (!res.ok) {
|
|
1487
1379
|
throw new Error(`Failed to fetch vtxo tree: ${res.statusText}`);
|
|
@@ -1490,24 +1382,14 @@ var RestIndexerProvider = class {
|
|
|
1490
1382
|
if (!Response.isVtxoTreeResponse(data)) {
|
|
1491
1383
|
throw new Error("Invalid vtxo tree data received");
|
|
1492
1384
|
}
|
|
1493
|
-
data.vtxoTree
|
|
1494
|
-
tx.children = Object.fromEntries(
|
|
1495
|
-
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1496
|
-
);
|
|
1497
|
-
});
|
|
1385
|
+
numberChildKeys(data.vtxoTree);
|
|
1498
1386
|
return data;
|
|
1499
1387
|
}
|
|
1500
1388
|
async getVtxoTreeLeaves(batchOutpoint, opts) {
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1506
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1507
|
-
}
|
|
1508
|
-
if (params.toString()) {
|
|
1509
|
-
url += "?" + params.toString();
|
|
1510
|
-
}
|
|
1389
|
+
const url = withPage(
|
|
1390
|
+
`${this.serverUrl}/v1/indexer/batch/${batchOutpoint.txid}/${batchOutpoint.vout}/tree/leaves`,
|
|
1391
|
+
opts
|
|
1392
|
+
);
|
|
1511
1393
|
const res = await indexerFetch(url);
|
|
1512
1394
|
if (!res.ok) {
|
|
1513
1395
|
throw new Error(`Failed to fetch vtxo tree leaves: ${res.statusText}`);
|
|
@@ -1543,16 +1425,7 @@ var RestIndexerProvider = class {
|
|
|
1543
1425
|
return data;
|
|
1544
1426
|
}
|
|
1545
1427
|
async getCommitmentTxConnectors(txid, opts) {
|
|
1546
|
-
|
|
1547
|
-
const params = new URLSearchParams();
|
|
1548
|
-
if (opts) {
|
|
1549
|
-
if (opts.pageIndex !== void 0)
|
|
1550
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1551
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1552
|
-
}
|
|
1553
|
-
if (params.toString()) {
|
|
1554
|
-
url += "?" + params.toString();
|
|
1555
|
-
}
|
|
1428
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/commitmentTx/${txid}/connectors`, opts);
|
|
1556
1429
|
const res = await indexerFetch(url);
|
|
1557
1430
|
if (!res.ok) {
|
|
1558
1431
|
throw new Error(`Failed to fetch commitment tx connectors: ${res.statusText}`);
|
|
@@ -1561,24 +1434,11 @@ var RestIndexerProvider = class {
|
|
|
1561
1434
|
if (!Response.isConnectorsResponse(data)) {
|
|
1562
1435
|
throw new Error("Invalid commitment tx connectors data received");
|
|
1563
1436
|
}
|
|
1564
|
-
data.connectors
|
|
1565
|
-
tx.children = Object.fromEntries(
|
|
1566
|
-
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1567
|
-
);
|
|
1568
|
-
});
|
|
1437
|
+
numberChildKeys(data.connectors);
|
|
1569
1438
|
return data;
|
|
1570
1439
|
}
|
|
1571
1440
|
async getCommitmentTxForfeitTxs(txid, opts) {
|
|
1572
|
-
|
|
1573
|
-
const params = new URLSearchParams();
|
|
1574
|
-
if (opts) {
|
|
1575
|
-
if (opts.pageIndex !== void 0)
|
|
1576
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1577
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1578
|
-
}
|
|
1579
|
-
if (params.toString()) {
|
|
1580
|
-
url += "?" + params.toString();
|
|
1581
|
-
}
|
|
1441
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/commitmentTx/${txid}/forfeitTxs`, opts);
|
|
1582
1442
|
const res = await indexerFetch(url);
|
|
1583
1443
|
if (!res.ok) {
|
|
1584
1444
|
throw new Error(`Failed to fetch commitment tx forfeitTxs: ${res.statusText}`);
|
|
@@ -1590,7 +1450,34 @@ var RestIndexerProvider = class {
|
|
|
1590
1450
|
return data;
|
|
1591
1451
|
}
|
|
1592
1452
|
getSubscription(subscriptionId, abortSignal) {
|
|
1593
|
-
const
|
|
1453
|
+
const stream = this.subscriptionStream(
|
|
1454
|
+
`${this.serverUrl}/v1/indexer/script/subscription/${subscriptionId}`,
|
|
1455
|
+
abortSignal
|
|
1456
|
+
);
|
|
1457
|
+
const gen = (async function* () {
|
|
1458
|
+
for await (const message of stream) if (message.type === "event") yield message;
|
|
1459
|
+
})();
|
|
1460
|
+
const origReturn = gen.return.bind(gen);
|
|
1461
|
+
gen.return = (value) => {
|
|
1462
|
+
stream.return?.();
|
|
1463
|
+
return origReturn(value);
|
|
1464
|
+
};
|
|
1465
|
+
return gen;
|
|
1466
|
+
}
|
|
1467
|
+
getFilteredSubscription(filter, abortSignal) {
|
|
1468
|
+
if (filter.expressions.length === 0) {
|
|
1469
|
+
throw new Error("A filtered subscription needs at least one expression");
|
|
1470
|
+
}
|
|
1471
|
+
const query = new URLSearchParams(
|
|
1472
|
+
filter.expressions.map((expression) => ["filter.expressions", expression])
|
|
1473
|
+
);
|
|
1474
|
+
return this.subscriptionStream(
|
|
1475
|
+
`${this.serverUrl}/v1/indexer/subscription?${query}`,
|
|
1476
|
+
abortSignal
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
/** The SSE transport behind every subscription; `ExpoIndexerProvider` replaces only this. */
|
|
1480
|
+
subscriptionStream(url, abortSignal) {
|
|
1594
1481
|
const override = this.eventSource;
|
|
1595
1482
|
let iterator = null;
|
|
1596
1483
|
const closeIterator = () => iterator?.close();
|
|
@@ -1600,25 +1487,15 @@ var RestIndexerProvider = class {
|
|
|
1600
1487
|
try {
|
|
1601
1488
|
while (!abortSignal?.aborted) {
|
|
1602
1489
|
try {
|
|
1603
|
-
const currentIterator =
|
|
1604
|
-
|
|
1490
|
+
const currentIterator = chunkASKOHVGX_cjs.eventSourceIterator(
|
|
1491
|
+
chunkASKOHVGX_cjs.resolveEventSource(override)(url)
|
|
1605
1492
|
);
|
|
1606
1493
|
iterator = currentIterator;
|
|
1607
1494
|
for await (const event of currentIterator) {
|
|
1608
1495
|
if (abortSignal?.aborted) break;
|
|
1609
1496
|
try {
|
|
1610
|
-
const
|
|
1611
|
-
if (
|
|
1612
|
-
yield {
|
|
1613
|
-
txid: data.event.txid,
|
|
1614
|
-
scripts: data.event.scripts || [],
|
|
1615
|
-
newVtxos: (data.event.newVtxos || []).map(chunkUJTYUYY4_cjs.convertVtxo),
|
|
1616
|
-
spentVtxos: (data.event.spentVtxos || []).map(chunkUJTYUYY4_cjs.convertVtxo),
|
|
1617
|
-
sweptVtxos: (data.event.sweptVtxos || []).map(chunkUJTYUYY4_cjs.convertVtxo),
|
|
1618
|
-
tx: data.event.tx,
|
|
1619
|
-
checkpointTxs: data.event.checkpointTxs
|
|
1620
|
-
};
|
|
1621
|
-
}
|
|
1497
|
+
const message = toSubscriptionMessage(JSON.parse(event.data));
|
|
1498
|
+
if (message) yield message;
|
|
1622
1499
|
} catch (err) {
|
|
1623
1500
|
console.error("Failed to parse subscription event:", err);
|
|
1624
1501
|
throw err;
|
|
@@ -1628,14 +1505,14 @@ var RestIndexerProvider = class {
|
|
|
1628
1505
|
if (abortSignal?.aborted || error instanceof Error && error.name === "AbortError") {
|
|
1629
1506
|
break;
|
|
1630
1507
|
}
|
|
1631
|
-
if (
|
|
1508
|
+
if (chunkASKOHVGX_cjs.isFetchTimeoutError(error)) {
|
|
1632
1509
|
console.debug("Timeout error ignored");
|
|
1633
1510
|
continue;
|
|
1634
1511
|
}
|
|
1635
|
-
if (
|
|
1512
|
+
if (chunkASKOHVGX_cjs.isEventSourceError(error)) {
|
|
1636
1513
|
throw error;
|
|
1637
1514
|
}
|
|
1638
|
-
if (
|
|
1515
|
+
if (chunkASKOHVGX_cjs.isEventSourceUnavailableError(error)) throw error;
|
|
1639
1516
|
console.error("Subscription error:", error);
|
|
1640
1517
|
throw error;
|
|
1641
1518
|
} finally {
|
|
@@ -1656,16 +1533,7 @@ var RestIndexerProvider = class {
|
|
|
1656
1533
|
return gen;
|
|
1657
1534
|
}
|
|
1658
1535
|
async getVirtualTxs(txids, opts) {
|
|
1659
|
-
|
|
1660
|
-
const params = new URLSearchParams();
|
|
1661
|
-
if (opts) {
|
|
1662
|
-
if (opts.pageIndex !== void 0)
|
|
1663
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1664
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1665
|
-
}
|
|
1666
|
-
if (params.toString()) {
|
|
1667
|
-
url += "?" + params.toString();
|
|
1668
|
-
}
|
|
1536
|
+
const url = withPage(`${this.serverUrl}/v1/indexer/virtualTx/${txids.join(",")}`, opts);
|
|
1669
1537
|
const res = await indexerFetch(url);
|
|
1670
1538
|
if (!res.ok) {
|
|
1671
1539
|
throw new Error(`Failed to fetch virtual txs: ${res.statusText}`);
|
|
@@ -1677,16 +1545,10 @@ var RestIndexerProvider = class {
|
|
|
1677
1545
|
return data;
|
|
1678
1546
|
}
|
|
1679
1547
|
async getVtxoChain(vtxoOutpoint, opts) {
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
params.append("page.index", opts.pageIndex.toString());
|
|
1685
|
-
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1686
|
-
}
|
|
1687
|
-
if (params.toString()) {
|
|
1688
|
-
url += "?" + params.toString();
|
|
1689
|
-
}
|
|
1548
|
+
const url = withPage(
|
|
1549
|
+
`${this.serverUrl}/v1/indexer/vtxo/${vtxoOutpoint.txid}/${vtxoOutpoint.vout}/chain`,
|
|
1550
|
+
opts
|
|
1551
|
+
);
|
|
1690
1552
|
const res = await indexerFetch(url);
|
|
1691
1553
|
if (!res.ok) {
|
|
1692
1554
|
throw new Error(`Failed to fetch vtxo chain: ${res.statusText}`);
|
|
@@ -1777,19 +1639,43 @@ var RestIndexerProvider = class {
|
|
|
1777
1639
|
if (params.toString()) {
|
|
1778
1640
|
url += "?" + params.toString();
|
|
1779
1641
|
}
|
|
1780
|
-
const
|
|
1781
|
-
if (!res.ok) {
|
|
1782
|
-
throw new Error(`Failed to fetch vtxos: ${res.statusText}`);
|
|
1783
|
-
}
|
|
1784
|
-
const data = await res.json();
|
|
1785
|
-
if (!Response.isVtxosResponse(data)) {
|
|
1786
|
-
throw new Error("Invalid vtxos data received");
|
|
1787
|
-
}
|
|
1642
|
+
const data = await this.fetchVtxosJson(url);
|
|
1788
1643
|
return {
|
|
1789
|
-
vtxos: data.vtxos.map(
|
|
1644
|
+
vtxos: data.vtxos.map(chunkASKOHVGX_cjs.convertVtxo),
|
|
1790
1645
|
page: data.page
|
|
1791
1646
|
};
|
|
1792
1647
|
}
|
|
1648
|
+
/**
|
|
1649
|
+
* The wire read behind {@link fetchVtxosPage}, with an identical read
|
|
1650
|
+
* already in flight served from that one request instead of repeated.
|
|
1651
|
+
*
|
|
1652
|
+
* Two callers can want the same page at the same instant without either
|
|
1653
|
+
* being redundant, so there is no single call site to remove: a send that
|
|
1654
|
+
* leaves change makes the indexer emit `vtxo_spent` and `vtxo_received` for
|
|
1655
|
+
* the wallet's own contract milliseconds apart, and `handleContractEvent`
|
|
1656
|
+
* delta-syncs that contract on both arms.
|
|
1657
|
+
*/
|
|
1658
|
+
async fetchVtxosJson(url) {
|
|
1659
|
+
const joined = this.inFlightVtxoReads.get(url);
|
|
1660
|
+
if (joined) return joined;
|
|
1661
|
+
const shared = (async () => {
|
|
1662
|
+
const res = await indexerFetch(url);
|
|
1663
|
+
if (!res.ok) {
|
|
1664
|
+
throw new Error(`Failed to fetch vtxos: ${res.statusText}`);
|
|
1665
|
+
}
|
|
1666
|
+
const data = await res.json();
|
|
1667
|
+
if (!Response.isVtxosResponse(data)) {
|
|
1668
|
+
throw new Error("Invalid vtxos data received");
|
|
1669
|
+
}
|
|
1670
|
+
return data;
|
|
1671
|
+
})();
|
|
1672
|
+
this.inFlightVtxoReads.set(url, shared);
|
|
1673
|
+
try {
|
|
1674
|
+
return await shared;
|
|
1675
|
+
} finally {
|
|
1676
|
+
if (this.inFlightVtxoReads.get(url) === shared) this.inFlightVtxoReads.delete(url);
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1793
1679
|
async getAssetDetails(assetId) {
|
|
1794
1680
|
const url = `${this.serverUrl}/v1/indexer/asset/${encodeURIComponent(assetId)}`;
|
|
1795
1681
|
const res = await indexerFetch(url);
|
|
@@ -1808,14 +1694,15 @@ var RestIndexerProvider = class {
|
|
|
1808
1694
|
controlAssetId: data.controlAsset || void 0
|
|
1809
1695
|
};
|
|
1810
1696
|
}
|
|
1811
|
-
async subscribeForScripts(scripts, subscriptionId) {
|
|
1697
|
+
async subscribeForScripts(scripts, subscriptionId, signal) {
|
|
1812
1698
|
const url = `${this.serverUrl}/v1/indexer/script/subscribe`;
|
|
1813
1699
|
const res = await indexerFetch(url, {
|
|
1814
1700
|
headers: {
|
|
1815
1701
|
"Content-Type": "application/json"
|
|
1816
1702
|
},
|
|
1817
1703
|
method: "POST",
|
|
1818
|
-
body: JSON.stringify({ scripts, subscriptionId })
|
|
1704
|
+
body: JSON.stringify({ scripts, subscriptionId }),
|
|
1705
|
+
signal
|
|
1819
1706
|
});
|
|
1820
1707
|
if (!res.ok) {
|
|
1821
1708
|
const errorText = await res.text();
|
|
@@ -1840,6 +1727,36 @@ var RestIndexerProvider = class {
|
|
|
1840
1727
|
}
|
|
1841
1728
|
}
|
|
1842
1729
|
};
|
|
1730
|
+
function withPage(url, opts) {
|
|
1731
|
+
const params = new URLSearchParams();
|
|
1732
|
+
if (opts?.pageIndex !== void 0) params.append("page.index", opts.pageIndex.toString());
|
|
1733
|
+
if (opts?.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1734
|
+
const query = params.toString();
|
|
1735
|
+
return query ? `${url}?${query}` : url;
|
|
1736
|
+
}
|
|
1737
|
+
function numberChildKeys(txs) {
|
|
1738
|
+
txs.forEach((tx) => {
|
|
1739
|
+
tx.children = Object.fromEntries(
|
|
1740
|
+
Object.entries(tx.children).map(([key, value]) => [Number(key), value])
|
|
1741
|
+
);
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
function toSubscriptionMessage(data) {
|
|
1745
|
+
if (data.event) return { type: "event", ...toSubscriptionResponse(data.event) };
|
|
1746
|
+
if (data.heartbeat !== void 0) return { type: "heartbeat" };
|
|
1747
|
+
return null;
|
|
1748
|
+
}
|
|
1749
|
+
function toSubscriptionResponse(event) {
|
|
1750
|
+
return {
|
|
1751
|
+
txid: event.txid,
|
|
1752
|
+
scripts: event.scripts || [],
|
|
1753
|
+
newVtxos: (event.newVtxos || []).map(chunkASKOHVGX_cjs.convertVtxo),
|
|
1754
|
+
spentVtxos: (event.spentVtxos || []).map(chunkASKOHVGX_cjs.convertVtxo),
|
|
1755
|
+
sweptVtxos: (event.sweptVtxos || []).map(chunkASKOHVGX_cjs.convertVtxo),
|
|
1756
|
+
tx: event.tx,
|
|
1757
|
+
checkpointTxs: event.checkpointTxs
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1843
1760
|
function parseAssetMetadata(metadata) {
|
|
1844
1761
|
const metadataList = MetadataList.fromString(metadata);
|
|
1845
1762
|
const out = {};
|
|
@@ -1879,31 +1796,12 @@ var Response;
|
|
|
1879
1796
|
return typeof data === "object" && typeof data.txid === "string" && typeof data.vout === "number";
|
|
1880
1797
|
}
|
|
1881
1798
|
Response2.isOutpoint = isOutpoint;
|
|
1882
|
-
function isOutpointArray(data) {
|
|
1883
|
-
return Array.isArray(data) && data.every(isOutpoint);
|
|
1884
|
-
}
|
|
1885
|
-
Response2.isOutpointArray = isOutpointArray;
|
|
1886
1799
|
function isTx(data) {
|
|
1887
1800
|
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)));
|
|
1888
1801
|
}
|
|
1889
|
-
function isTxsArray(data) {
|
|
1890
|
-
return Array.isArray(data) && data.every(isTx);
|
|
1891
|
-
}
|
|
1892
|
-
Response2.isTxsArray = isTxsArray;
|
|
1893
|
-
function isTxHistoryRecord(data) {
|
|
1894
|
-
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);
|
|
1895
|
-
}
|
|
1896
|
-
function isTxHistoryRecordArray(data) {
|
|
1897
|
-
return Array.isArray(data) && data.every(isTxHistoryRecord);
|
|
1898
|
-
}
|
|
1899
|
-
Response2.isTxHistoryRecordArray = isTxHistoryRecordArray;
|
|
1900
1802
|
function isTxid(data) {
|
|
1901
1803
|
return typeof data === "string" && data.length === 64;
|
|
1902
1804
|
}
|
|
1903
|
-
function isTxidArray(data) {
|
|
1904
|
-
return Array.isArray(data) && data.every(isTxid);
|
|
1905
|
-
}
|
|
1906
|
-
Response2.isTxidArray = isTxidArray;
|
|
1907
1805
|
function isVtxoAsset(data) {
|
|
1908
1806
|
return typeof data === "object" && data !== null && typeof data.assetId === "string" && typeof data.amount === "string";
|
|
1909
1807
|
}
|
|
@@ -1929,10 +1827,6 @@ var Response;
|
|
|
1929
1827
|
return typeof data === "object" && Array.isArray(data.txids) && data.txids.every(isTxid) && (!data.page || isPageResponse(data.page));
|
|
1930
1828
|
}
|
|
1931
1829
|
Response2.isForfeitTxsResponse = isForfeitTxsResponse;
|
|
1932
|
-
function isSweptCommitmentTxResponse(data) {
|
|
1933
|
-
return typeof data === "object" && Array.isArray(data.sweptBy) && data.sweptBy.every(isTxid);
|
|
1934
|
-
}
|
|
1935
|
-
Response2.isSweptCommitmentTxResponse = isSweptCommitmentTxResponse;
|
|
1936
1830
|
function isBatchSweepTransactionsResponse(data) {
|
|
1937
1831
|
return typeof data === "object" && Array.isArray(data.sweptBy) && data.sweptBy.every(isTxid);
|
|
1938
1832
|
}
|
|
@@ -1969,5 +1863,6 @@ exports.Metadata = Metadata;
|
|
|
1969
1863
|
exports.Packet = Packet;
|
|
1970
1864
|
exports.RestIndexerProvider = RestIndexerProvider;
|
|
1971
1865
|
exports.asset_exports = asset_exports;
|
|
1972
|
-
|
|
1973
|
-
//# sourceMappingURL=chunk-
|
|
1866
|
+
exports.toSubscriptionMessage = toSubscriptionMessage;
|
|
1867
|
+
//# sourceMappingURL=chunk-AICUNREA.cjs.map
|
|
1868
|
+
//# sourceMappingURL=chunk-AICUNREA.cjs.map
|