@arkade-os/sdk 0.5.3 → 0.5.5
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 +138 -50
- package/dist/adapters/expo.cjs +10 -5
- package/dist/adapters/expo.d.cts +13 -8
- package/dist/adapters/expo.d.ts +13 -8
- package/dist/adapters/expo.js +4 -3
- package/dist/{asyncStorageTaskQueue-C9PkPcW_.d.cts → asyncStorageTaskQueue-BbH-THYJ.d.cts} +2 -2
- package/dist/{asyncStorageTaskQueue-B3U5gQ-i.d.ts → asyncStorageTaskQueue-BlvkJyTa.d.ts} +2 -2
- package/dist/base-C-Y5t_0F.d.cts +359 -0
- package/dist/base-C-Y5t_0F.d.ts +359 -0
- package/dist/{chunk-OPX2HRWM.js → chunk-4I53THL6.js} +210 -937
- package/dist/chunk-4I53THL6.js.map +1 -0
- package/dist/{chunk-5WRA66RV.cjs → chunk-5SYUEVJH.cjs} +10 -10
- package/dist/chunk-5SYUEVJH.cjs.map +1 -0
- package/dist/{chunk-6FL4N4S2.js → chunk-7GIKLFHC.js} +83 -20
- package/dist/chunk-7GIKLFHC.js.map +1 -0
- package/dist/{chunk-BYPBVHVA.cjs → chunk-AMH7Q3DF.cjs} +61 -935
- package/dist/chunk-AMH7Q3DF.cjs.map +1 -0
- package/dist/{chunk-P7B4LQ3H.js → chunk-BCA6D255.js} +18 -842
- package/dist/chunk-BCA6D255.js.map +1 -0
- package/dist/{chunk-T7C3E2HL.js → chunk-CE46RS6L.js} +20 -39
- package/dist/chunk-CE46RS6L.js.map +1 -0
- package/dist/chunk-DNFTHG73.js +829 -0
- package/dist/chunk-DNFTHG73.js.map +1 -0
- package/dist/chunk-FDJ734CH.js +882 -0
- package/dist/chunk-FDJ734CH.js.map +1 -0
- package/dist/chunk-FLPWNMX3.cjs +930 -0
- package/dist/chunk-FLPWNMX3.cjs.map +1 -0
- package/dist/{chunk-Y4BL3YYX.js → chunk-FVVXCDNE.js} +4 -4
- package/dist/chunk-FVVXCDNE.js.map +1 -0
- package/dist/{chunk-ZPF4I3K2.cjs → chunk-HQQ4NRXI.cjs} +29 -47
- package/dist/chunk-HQQ4NRXI.cjs.map +1 -0
- package/dist/chunk-JFJNB7ZH.cjs +884 -0
- package/dist/chunk-JFJNB7ZH.cjs.map +1 -0
- package/dist/{chunk-KW7ZEWYS.cjs → chunk-KCL5AVML.cjs} +223 -985
- package/dist/chunk-KCL5AVML.cjs.map +1 -0
- package/dist/{chunk-HAQAWBYG.js → chunk-OO2KEK64.js} +2860 -1366
- package/dist/chunk-OO2KEK64.js.map +1 -0
- package/dist/{chunk-OUTWUYJ4.cjs → chunk-T254PXSN.cjs} +3337 -1824
- package/dist/chunk-T254PXSN.cjs.map +1 -0
- package/dist/chunk-V3ZLL5VY.js +380 -0
- package/dist/chunk-V3ZLL5VY.js.map +1 -0
- package/dist/chunk-X6ZI53DZ.cjs +383 -0
- package/dist/chunk-X6ZI53DZ.cjs.map +1 -0
- package/dist/{chunk-ZMSM3NOH.cjs → chunk-XWUCNMPN.cjs} +98 -34
- package/dist/chunk-XWUCNMPN.cjs.map +1 -0
- package/dist/compiler.cjs +50 -0
- package/dist/compiler.cjs.map +1 -0
- package/dist/compiler.d.cts +38 -0
- package/dist/compiler.d.ts +38 -0
- package/dist/compiler.js +47 -0
- package/dist/compiler.js.map +1 -0
- package/dist/contracts/handlers/index.cjs +11 -9
- package/dist/contracts/handlers/index.d.cts +6 -4
- package/dist/contracts/handlers/index.d.ts +6 -4
- package/dist/contracts/handlers/index.js +4 -2
- package/dist/{delegate-Cd28gxpM.d.ts → delegate-gGkUnYpi.d.cts} +1 -1
- package/dist/{delegate-ByfKszb6.d.cts → delegate-iyDum4fw.d.ts} +1 -1
- package/dist/{index-B6X2E7W_.d.ts → index-BWwVnJhU.d.cts} +7 -272
- package/dist/{index-DgH_0j14.d.cts → index-Bx-iArDs.d.ts} +7 -272
- package/dist/{index-BURzbRup.d.cts → index-DCml4QJn.d.ts} +1090 -1140
- package/dist/{index-BURzbRup.d.ts → index-DkyzIzKL.d.cts} +1090 -1140
- package/dist/index.cjs +470 -371
- package/dist/index.d.cts +687 -410
- package/dist/index.d.ts +687 -410
- package/dist/index.js +7 -4
- package/dist/{wallet-BnmhohgZ.d.ts → keyringDescriptorProvider-CS4w4PWd.d.ts} +427 -372
- package/dist/{wallet-BjQugVUt.d.cts → keyringDescriptorProvider-CmHXrIXd.d.cts} +427 -372
- package/dist/program-BARSNg3X.d.ts +286 -0
- package/dist/program-znrWkxE4.d.cts +286 -0
- package/dist/repositories/realm/index.cjs +100 -51
- package/dist/repositories/realm/index.cjs.map +1 -1
- package/dist/repositories/realm/index.d.cts +25 -10
- package/dist/repositories/realm/index.d.ts +25 -10
- package/dist/repositories/realm/index.js +72 -24
- package/dist/repositories/realm/index.js.map +1 -1
- package/dist/repositories/sqlite/index.cjs +222 -131
- package/dist/repositories/sqlite/index.cjs.map +1 -1
- package/dist/repositories/sqlite/index.d.cts +36 -17
- package/dist/repositories/sqlite/index.d.ts +36 -17
- package/dist/repositories/sqlite/index.js +196 -107
- package/dist/repositories/sqlite/index.js.map +1 -1
- package/dist/{taskRunner-BaNCSxqK.d.ts → taskRunner-DgMLSk_O.d.ts} +4 -4
- package/dist/{taskRunner-i56-drQV.d.cts → taskRunner-buh6aFpG.d.cts} +4 -4
- package/dist/wallet/expo/background.cjs +17 -14
- package/dist/wallet/expo/background.cjs.map +1 -1
- package/dist/wallet/expo/background.d.cts +5 -4
- package/dist/wallet/expo/background.d.ts +5 -4
- package/dist/wallet/expo/background.js +10 -7
- package/dist/wallet/expo/background.js.map +1 -1
- package/dist/wallet/expo/index.cjs +29 -16
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +12 -7
- package/dist/wallet/expo/index.d.ts +12 -7
- package/dist/wallet/expo/index.js +20 -7
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/worker/expo/index.cjs +12 -9
- package/dist/worker/expo/index.cjs.map +1 -1
- package/dist/worker/expo/index.d.cts +6 -5
- package/dist/worker/expo/index.d.ts +6 -5
- package/dist/worker/expo/index.js +8 -5
- package/dist/worker/expo/index.js.map +1 -1
- package/package.json +16 -1
- package/dist/chunk-5WRA66RV.cjs.map +0 -1
- package/dist/chunk-6FL4N4S2.js.map +0 -1
- package/dist/chunk-BYPBVHVA.cjs.map +0 -1
- package/dist/chunk-HAQAWBYG.js.map +0 -1
- package/dist/chunk-KW7ZEWYS.cjs.map +0 -1
- package/dist/chunk-OPX2HRWM.js.map +0 -1
- package/dist/chunk-OUTWUYJ4.cjs.map +0 -1
- package/dist/chunk-P7B4LQ3H.js.map +0 -1
- package/dist/chunk-T7C3E2HL.js.map +0 -1
- package/dist/chunk-Y4BL3YYX.js.map +0 -1
- package/dist/chunk-ZMSM3NOH.cjs.map +0 -1
- package/dist/chunk-ZPF4I3K2.cjs.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkKCL5AVML_cjs = require('./chunk-KCL5AVML.cjs');
|
|
4
|
+
var chunkFLPWNMX3_cjs = require('./chunk-FLPWNMX3.cjs');
|
|
4
5
|
var base = require('@scure/base');
|
|
5
6
|
var secp256k1_js = require('@noble/curves/secp256k1.js');
|
|
6
7
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
8
|
|
|
8
9
|
// src/extension/asset/index.ts
|
|
9
10
|
var asset_exports = {};
|
|
10
|
-
|
|
11
|
+
chunkFLPWNMX3_cjs.__export(asset_exports, {
|
|
11
12
|
ASSET_ID_VECTORS: () => ASSET_ID_VECTORS,
|
|
12
13
|
AssetGroup: () => AssetGroup,
|
|
13
14
|
AssetId: () => AssetId,
|
|
@@ -30,6 +31,7 @@ var AssetInputType = /* @__PURE__ */ ((AssetInputType2) => {
|
|
|
30
31
|
AssetInputType2[AssetInputType2["Unspecified"] = 0] = "Unspecified";
|
|
31
32
|
AssetInputType2[AssetInputType2["Local"] = 1] = "Local";
|
|
32
33
|
AssetInputType2[AssetInputType2["Intent"] = 2] = "Intent";
|
|
34
|
+
AssetInputType2[AssetInputType2["Proof"] = 2] = "Proof";
|
|
33
35
|
return AssetInputType2;
|
|
34
36
|
})(AssetInputType || {});
|
|
35
37
|
var AssetRefType = /* @__PURE__ */ ((AssetRefType2) => {
|
|
@@ -413,8 +415,8 @@ var AssetInput = class _AssetInput {
|
|
|
413
415
|
input.validate();
|
|
414
416
|
return input;
|
|
415
417
|
}
|
|
416
|
-
/** Create
|
|
417
|
-
static
|
|
418
|
+
/** Create a proof-backed asset input referencing an external proof transaction. */
|
|
419
|
+
static createProof(txid, vin, amount) {
|
|
418
420
|
if (!txid || txid.length === 0) {
|
|
419
421
|
throw new Error("missing input intent txid");
|
|
420
422
|
}
|
|
@@ -423,7 +425,7 @@ var AssetInput = class _AssetInput {
|
|
|
423
425
|
throw new Error("invalid input intent txid length");
|
|
424
426
|
}
|
|
425
427
|
const input = new _AssetInput({
|
|
426
|
-
type: 2 /*
|
|
428
|
+
type: 2 /* Proof */,
|
|
427
429
|
txid: buf,
|
|
428
430
|
vin,
|
|
429
431
|
amount: typeof amount === "number" ? BigInt(amount) : amount
|
|
@@ -431,6 +433,8 @@ var AssetInput = class _AssetInput {
|
|
|
431
433
|
input.validate();
|
|
432
434
|
return input;
|
|
433
435
|
}
|
|
436
|
+
/** @deprecated Use {@link createProof}. */
|
|
437
|
+
static createIntent = _AssetInput.createProof;
|
|
434
438
|
/** Decode an asset input from its hex string form. */
|
|
435
439
|
static fromString(s) {
|
|
436
440
|
return _AssetInput.fromBytes(hexOrThrow(s, "invalid format, must be hex"));
|
|
@@ -455,7 +459,7 @@ var AssetInput = class _AssetInput {
|
|
|
455
459
|
switch (this.input.type) {
|
|
456
460
|
case 1 /* Local */:
|
|
457
461
|
break;
|
|
458
|
-
case 2 /*
|
|
462
|
+
case 2 /* Proof */:
|
|
459
463
|
if (isZeroBytes(this.input.txid)) {
|
|
460
464
|
throw new Error("missing input intent txid");
|
|
461
465
|
}
|
|
@@ -477,7 +481,7 @@ var AssetInput = class _AssetInput {
|
|
|
477
481
|
});
|
|
478
482
|
break;
|
|
479
483
|
}
|
|
480
|
-
case 2 /*
|
|
484
|
+
case 2 /* Proof */: {
|
|
481
485
|
if (reader.remaining() < TX_HASH_SIZE) {
|
|
482
486
|
throw new Error("invalid input intent txid length");
|
|
483
487
|
}
|
|
@@ -485,7 +489,7 @@ var AssetInput = class _AssetInput {
|
|
|
485
489
|
const vin = reader.readUint16LE();
|
|
486
490
|
const amount = reader.readVarUint();
|
|
487
491
|
input = new _AssetInput({
|
|
488
|
-
type: 2 /*
|
|
492
|
+
type: 2 /* Proof */,
|
|
489
493
|
txid: new Uint8Array(txid),
|
|
490
494
|
vin,
|
|
491
495
|
amount
|
|
@@ -503,7 +507,7 @@ var AssetInput = class _AssetInput {
|
|
|
503
507
|
/** Serialize the asset input into an existing buffer writer. */
|
|
504
508
|
serializeTo(writer) {
|
|
505
509
|
writer.writeByte(this.input.type);
|
|
506
|
-
if (this.input.type === 2 /*
|
|
510
|
+
if (this.input.type === 2 /* Proof */) {
|
|
507
511
|
writer.write(this.input.txid);
|
|
508
512
|
}
|
|
509
513
|
writer.writeUint16LE(this.input.vin);
|
|
@@ -942,7 +946,7 @@ var AssetGroup = class _AssetGroup {
|
|
|
942
946
|
*
|
|
943
947
|
* @returns `true` when the group has an asset id and outputs exceed local inputs
|
|
944
948
|
* @remarks
|
|
945
|
-
* Only local inputs contribute to the comparison;
|
|
949
|
+
* Only local inputs contribute to the comparison; proof-backed inputs contribute `0` here.
|
|
946
950
|
*/
|
|
947
951
|
isReissuance() {
|
|
948
952
|
const sumReducer = (s, { amount }) => s + amount;
|
|
@@ -984,14 +988,14 @@ var AssetGroup = class _AssetGroup {
|
|
|
984
988
|
}
|
|
985
989
|
}
|
|
986
990
|
/**
|
|
987
|
-
* Convert the group into its batch-leaf representation for the given
|
|
991
|
+
* Convert the group into its batch-leaf representation for the given proof txid.
|
|
988
992
|
*
|
|
989
|
-
* @param
|
|
993
|
+
* @param proofTxid - Proof transaction id used to build the leaf input reference
|
|
990
994
|
* @returns Batch-leaf asset group
|
|
991
|
-
* @see AssetInput.
|
|
995
|
+
* @see AssetInput.createProof
|
|
992
996
|
*/
|
|
993
|
-
toBatchLeafAssetGroup(
|
|
994
|
-
const leafInput = AssetInput.
|
|
997
|
+
toBatchLeafAssetGroup(proofTxid) {
|
|
998
|
+
const leafInput = AssetInput.createProof(base.hex.encode(proofTxid), 0, 0);
|
|
995
999
|
return new _AssetGroup(
|
|
996
1000
|
this.assetId,
|
|
997
1001
|
this.controlAsset,
|
|
@@ -1106,9 +1110,9 @@ var Packet = class _Packet {
|
|
|
1106
1110
|
type() {
|
|
1107
1111
|
return _Packet.PACKET_TYPE;
|
|
1108
1112
|
}
|
|
1109
|
-
/** Convert the packet into the batch-leaf form for a specific
|
|
1110
|
-
leafTxPacket(
|
|
1111
|
-
const leafGroups = this.groups.map((group) => group.toBatchLeafAssetGroup(
|
|
1113
|
+
/** Convert the packet into the batch-leaf form for a specific proof transaction id. */
|
|
1114
|
+
leafTxPacket(proofTxid) {
|
|
1115
|
+
const leafGroups = this.groups.map((group) => group.toBatchLeafAssetGroup(proofTxid));
|
|
1112
1116
|
return new _Packet(leafGroups);
|
|
1113
1117
|
}
|
|
1114
1118
|
/**
|
|
@@ -1316,10 +1320,10 @@ async function indexerFetch(input, init) {
|
|
|
1316
1320
|
const lastAttempt = attempt >= maxAttempts;
|
|
1317
1321
|
let res;
|
|
1318
1322
|
try {
|
|
1319
|
-
res = await
|
|
1323
|
+
res = await chunkKCL5AVML_cjs.rateGate.runHttp(input, () => chunkKCL5AVML_cjs.baseFetch(input, init));
|
|
1320
1324
|
} catch (err) {
|
|
1321
|
-
const mapped =
|
|
1322
|
-
if (lastAttempt || !(mapped instanceof
|
|
1325
|
+
const mapped = chunkKCL5AVML_cjs.toProviderUnavailable(err, "indexer");
|
|
1326
|
+
if (lastAttempt || !(mapped instanceof chunkKCL5AVML_cjs.ProviderUnavailableError)) throw mapped;
|
|
1323
1327
|
await sleep(retryDelayMs(attempt));
|
|
1324
1328
|
continue;
|
|
1325
1329
|
}
|
|
@@ -1331,7 +1335,7 @@ async function indexerFetch(input, init) {
|
|
|
1331
1335
|
body = void 0;
|
|
1332
1336
|
}
|
|
1333
1337
|
try {
|
|
1334
|
-
|
|
1338
|
+
chunkKCL5AVML_cjs.throwIfHttpUnavailable(res, "indexer", body);
|
|
1335
1339
|
} catch (err) {
|
|
1336
1340
|
if (lastAttempt) throw err;
|
|
1337
1341
|
await sleep(retryDelayMs(attempt));
|
|
@@ -1359,14 +1363,22 @@ var ChainTxType = /* @__PURE__ */ ((ChainTxType2) => {
|
|
|
1359
1363
|
ChainTxType2["CHECKPOINT"] = "INDEXER_CHAINED_TX_TYPE_CHECKPOINT";
|
|
1360
1364
|
return ChainTxType2;
|
|
1361
1365
|
})(ChainTxType || {});
|
|
1366
|
+
var IndexerUtxosUnsupportedError = class extends Error {
|
|
1367
|
+
constructor() {
|
|
1368
|
+
super("Arkade server does not support GetUtxos");
|
|
1369
|
+
this.name = "IndexerUtxosUnsupportedError";
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1362
1372
|
var RestIndexerProvider = class {
|
|
1363
|
-
constructor(serverUrl =
|
|
1373
|
+
constructor(serverUrl = chunkFLPWNMX3_cjs.DEFAULT_ARKADE_SERVER_URL, options = {}) {
|
|
1364
1374
|
this.serverUrl = serverUrl;
|
|
1365
1375
|
this.eventSource = options.eventSource;
|
|
1366
1376
|
}
|
|
1367
1377
|
serverUrl;
|
|
1368
1378
|
/** Overrides {@link configureEventSource} for this provider's subscription. */
|
|
1369
1379
|
eventSource;
|
|
1380
|
+
/** Set by a 404 for this provider's lifetime: a server upgraded meanwhile needs a new one. */
|
|
1381
|
+
utxosUnsupported = false;
|
|
1370
1382
|
/** @see fetchVtxosJson */
|
|
1371
1383
|
inFlightVtxoReads = /* @__PURE__ */ new Map();
|
|
1372
1384
|
async getVtxoTree(batchOutpoint, opts) {
|
|
@@ -1487,8 +1499,8 @@ var RestIndexerProvider = class {
|
|
|
1487
1499
|
try {
|
|
1488
1500
|
while (!abortSignal?.aborted) {
|
|
1489
1501
|
try {
|
|
1490
|
-
const currentIterator =
|
|
1491
|
-
|
|
1502
|
+
const currentIterator = chunkKCL5AVML_cjs.eventSourceIterator(
|
|
1503
|
+
chunkKCL5AVML_cjs.resolveEventSource(override)(url)
|
|
1492
1504
|
);
|
|
1493
1505
|
iterator = currentIterator;
|
|
1494
1506
|
for await (const event of currentIterator) {
|
|
@@ -1505,14 +1517,14 @@ var RestIndexerProvider = class {
|
|
|
1505
1517
|
if (abortSignal?.aborted || error instanceof Error && error.name === "AbortError") {
|
|
1506
1518
|
break;
|
|
1507
1519
|
}
|
|
1508
|
-
if (
|
|
1520
|
+
if (chunkKCL5AVML_cjs.isFetchTimeoutError(error)) {
|
|
1509
1521
|
console.debug("Timeout error ignored");
|
|
1510
1522
|
continue;
|
|
1511
1523
|
}
|
|
1512
|
-
if (
|
|
1524
|
+
if (chunkKCL5AVML_cjs.isEventSourceError(error)) {
|
|
1513
1525
|
throw error;
|
|
1514
1526
|
}
|
|
1515
|
-
if (
|
|
1527
|
+
if (chunkKCL5AVML_cjs.isEventSourceUnavailableError(error)) throw error;
|
|
1516
1528
|
console.error("Subscription error:", error);
|
|
1517
1529
|
throw error;
|
|
1518
1530
|
} finally {
|
|
@@ -1641,7 +1653,7 @@ var RestIndexerProvider = class {
|
|
|
1641
1653
|
}
|
|
1642
1654
|
const data = await this.fetchVtxosJson(url);
|
|
1643
1655
|
return {
|
|
1644
|
-
vtxos: data.vtxos.map(
|
|
1656
|
+
vtxos: data.vtxos.map(chunkKCL5AVML_cjs.convertVtxo),
|
|
1645
1657
|
page: data.page
|
|
1646
1658
|
};
|
|
1647
1659
|
}
|
|
@@ -1676,6 +1688,32 @@ var RestIndexerProvider = class {
|
|
|
1676
1688
|
if (this.inFlightVtxoReads.get(url) === shared) this.inFlightVtxoReads.delete(url);
|
|
1677
1689
|
}
|
|
1678
1690
|
}
|
|
1691
|
+
async getUtxos(opts) {
|
|
1692
|
+
const hasScripts = (opts.scripts?.length ?? 0) > 0;
|
|
1693
|
+
const hasOutpoints = (opts.outpoints?.length ?? 0) > 0;
|
|
1694
|
+
if (hasScripts === hasOutpoints) {
|
|
1695
|
+
throw new Error("getUtxos needs either scripts or outpoints");
|
|
1696
|
+
}
|
|
1697
|
+
if (this.utxosUnsupported) throw new IndexerUtxosUnsupportedError();
|
|
1698
|
+
const params = new URLSearchParams();
|
|
1699
|
+
for (const script of opts.scripts ?? []) params.append("scripts", script);
|
|
1700
|
+
for (const o of opts.outpoints ?? []) params.append("outpoints", `${o.txid}:${o.vout}`);
|
|
1701
|
+
if (opts.pageIndex !== void 0) params.append("page.index", opts.pageIndex.toString());
|
|
1702
|
+
if (opts.pageSize !== void 0) params.append("page.size", opts.pageSize.toString());
|
|
1703
|
+
const res = await indexerFetch(`${this.serverUrl}/v1/indexer/utxos?${params.toString()}`);
|
|
1704
|
+
if (res.status === 404) {
|
|
1705
|
+
this.utxosUnsupported = true;
|
|
1706
|
+
throw new IndexerUtxosUnsupportedError();
|
|
1707
|
+
}
|
|
1708
|
+
if (!res.ok) {
|
|
1709
|
+
throw new Error(`Failed to fetch utxos: ${res.statusText}`);
|
|
1710
|
+
}
|
|
1711
|
+
const data = await res.json();
|
|
1712
|
+
if (!Response.isUtxosResponse(data)) {
|
|
1713
|
+
throw new Error("Invalid utxos data received");
|
|
1714
|
+
}
|
|
1715
|
+
return { utxos: data.utxos.map(convertUtxo), page: data.page ?? void 0 };
|
|
1716
|
+
}
|
|
1679
1717
|
async getAssetDetails(assetId) {
|
|
1680
1718
|
const url = `${this.serverUrl}/v1/indexer/asset/${encodeURIComponent(assetId)}`;
|
|
1681
1719
|
const res = await indexerFetch(url);
|
|
@@ -1727,6 +1765,18 @@ var RestIndexerProvider = class {
|
|
|
1727
1765
|
}
|
|
1728
1766
|
}
|
|
1729
1767
|
};
|
|
1768
|
+
function convertUtxo(utxo) {
|
|
1769
|
+
const height = Number(utxo.spend.confirmedAtHeight ?? 0);
|
|
1770
|
+
const time = Number(utxo.spend.confirmedAtTime ?? 0);
|
|
1771
|
+
return {
|
|
1772
|
+
txid: utxo.outpoint.txid,
|
|
1773
|
+
vout: utxo.outpoint.vout,
|
|
1774
|
+
value: Number(utxo.amount),
|
|
1775
|
+
script: utxo.script,
|
|
1776
|
+
spentBy: utxo.spend.txid,
|
|
1777
|
+
...(height > 0 || time > 0) && { spendConfirmation: { height, time } }
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1730
1780
|
function withPage(url, opts) {
|
|
1731
1781
|
const params = new URLSearchParams();
|
|
1732
1782
|
if (opts?.pageIndex !== void 0) params.append("page.index", opts.pageIndex.toString());
|
|
@@ -1750,9 +1800,9 @@ function toSubscriptionResponse(event) {
|
|
|
1750
1800
|
return {
|
|
1751
1801
|
txid: event.txid,
|
|
1752
1802
|
scripts: event.scripts || [],
|
|
1753
|
-
newVtxos: (event.newVtxos || []).map(
|
|
1754
|
-
spentVtxos: (event.spentVtxos || []).map(
|
|
1755
|
-
sweptVtxos: (event.sweptVtxos || []).map(
|
|
1803
|
+
newVtxos: (event.newVtxos || []).map(chunkKCL5AVML_cjs.convertVtxo),
|
|
1804
|
+
spentVtxos: (event.spentVtxos || []).map(chunkKCL5AVML_cjs.convertVtxo),
|
|
1805
|
+
sweptVtxos: (event.sweptVtxos || []).map(chunkKCL5AVML_cjs.convertVtxo),
|
|
1756
1806
|
tx: event.tx,
|
|
1757
1807
|
checkpointTxs: event.checkpointTxs
|
|
1758
1808
|
};
|
|
@@ -1843,6 +1893,19 @@ var Response;
|
|
|
1843
1893
|
return typeof data === "object" && Array.isArray(data.vtxos) && data.vtxos.every(isVtxo) && (!data.page || isPageResponse(data.page));
|
|
1844
1894
|
}
|
|
1845
1895
|
Response2.isVtxosResponse = isVtxosResponse;
|
|
1896
|
+
function isWireInt(data) {
|
|
1897
|
+
return typeof data === "string" ? /^\d+$/.test(data) && Number.isSafeInteger(Number(data)) : typeof data === "number" && Number.isSafeInteger(data) && data >= 0;
|
|
1898
|
+
}
|
|
1899
|
+
function isOptionalWireInt(data) {
|
|
1900
|
+
return data === void 0 || isWireInt(data);
|
|
1901
|
+
}
|
|
1902
|
+
function isUtxo(data) {
|
|
1903
|
+
return typeof data === "object" && data !== null && isOutpoint(data.outpoint) && isWireInt(data.amount) && typeof data.script === "string" && typeof data.spend === "object" && data.spend !== null && isTxid(data.spend.txid) && isOptionalWireInt(data.spend.confirmedAtTime) && isOptionalWireInt(data.spend.confirmedAtHeight);
|
|
1904
|
+
}
|
|
1905
|
+
function isUtxosResponse(data) {
|
|
1906
|
+
return typeof data === "object" && data !== null && Array.isArray(data.utxos) && data.utxos.every(isUtxo) && (!data.page || isPageResponse(data.page));
|
|
1907
|
+
}
|
|
1908
|
+
Response2.isUtxosResponse = isUtxosResponse;
|
|
1846
1909
|
function isGetAssetResponse(data) {
|
|
1847
1910
|
return typeof data === "object" && data !== null && typeof data.assetId === "string" && typeof data.supply === "string" && (data.controlAsset === void 0 || typeof data.controlAsset === "string") && (data.metadata === void 0 || typeof data.metadata === "string");
|
|
1848
1911
|
}
|
|
@@ -1859,10 +1922,11 @@ exports.BufferWriter = BufferWriter;
|
|
|
1859
1922
|
exports.ChainTxType = ChainTxType;
|
|
1860
1923
|
exports.DEFAULT_VTXO_PAGE_SIZE = DEFAULT_VTXO_PAGE_SIZE;
|
|
1861
1924
|
exports.IndexerTxType = IndexerTxType;
|
|
1925
|
+
exports.IndexerUtxosUnsupportedError = IndexerUtxosUnsupportedError;
|
|
1862
1926
|
exports.Metadata = Metadata;
|
|
1863
1927
|
exports.Packet = Packet;
|
|
1864
1928
|
exports.RestIndexerProvider = RestIndexerProvider;
|
|
1865
1929
|
exports.asset_exports = asset_exports;
|
|
1866
1930
|
exports.toSubscriptionMessage = toSubscriptionMessage;
|
|
1867
|
-
//# sourceMappingURL=chunk-
|
|
1868
|
-
//# sourceMappingURL=chunk-
|
|
1931
|
+
//# sourceMappingURL=chunk-XWUCNMPN.cjs.map
|
|
1932
|
+
//# sourceMappingURL=chunk-XWUCNMPN.cjs.map
|