univo 0.2.21 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import open from 'open';
|
|
|
4
4
|
import { config } from 'dotenv';
|
|
5
5
|
import { WebSocket } from 'partysocket';
|
|
6
6
|
import { defineCommand, runMain } from 'citty';
|
|
7
|
-
import { h as http } from './shared/univo.
|
|
8
|
-
import { c as createLogger, v as version, b as name } from './shared/univo.
|
|
7
|
+
import { h as http } from './shared/univo.1clH0g-n.mjs';
|
|
8
|
+
import { c as createLogger, v as version, b as name } from './shared/univo.DvxWs2zB.mjs';
|
|
9
9
|
|
|
10
10
|
const log = createLogger({ quiet: false });
|
|
11
11
|
const dev = defineCommand({
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorageError } from '@storagesdk/core';
|
|
2
|
-
import { g as getException, c as createException, a as catchException, l as local } from './shared/univo.
|
|
3
|
-
import { c as createLogger, d as decompress, e as decoder, r as retry, v as version, h as hexToNumber, a as isHexEqual, n as numberToHex, f as normalizeHex, g as compress } from './shared/univo.
|
|
2
|
+
import { g as getException, c as createException, a as catchException, l as local } from './shared/univo.1clH0g-n.mjs';
|
|
3
|
+
import { c as createLogger, d as decompress, e as decoder, r as retry, v as version, h as hexToNumber, a as isHexEqual, n as numberToHex, f as normalizeHex, g as compress } from './shared/univo.DvxWs2zB.mjs';
|
|
4
4
|
import 'ws';
|
|
5
5
|
import 'partysocket';
|
|
6
6
|
|
|
@@ -266,6 +266,14 @@ function indexer(opts) {
|
|
|
266
266
|
const prefix = `heights/v1/${normalizeHex(chain)}/${normalizeHex(number, 16)}`;
|
|
267
267
|
const body = JSON.stringify({ hello: "world" });
|
|
268
268
|
await opts.metadataStorage.upload(prefix, body);
|
|
269
|
+
},
|
|
270
|
+
async delete(heights) {
|
|
271
|
+
await Promise.all(
|
|
272
|
+
heights.map(async (height) => {
|
|
273
|
+
const prefix = `heights/v1/${normalizeHex(height.chain)}/${normalizeHex(height.number, 16)}`;
|
|
274
|
+
await opts.metadataStorage.delete(prefix);
|
|
275
|
+
})
|
|
276
|
+
);
|
|
269
277
|
}
|
|
270
278
|
}
|
|
271
279
|
};
|
|
@@ -490,20 +498,22 @@ function indexer(opts) {
|
|
|
490
498
|
throw new Error("Client has stalled. Chain has finalized greater than the heads received");
|
|
491
499
|
}
|
|
492
500
|
log.debug(`Indexer height ${indexerHeight}, finalized height ${finalizedHeight}`);
|
|
493
|
-
if (indexerHeight === finalizedHeight) {
|
|
494
|
-
log.debug("No heads to finalize, returning...");
|
|
495
|
-
return await cleanupFinalizedHeads(chain, numberToHex(finalizedHeight));
|
|
496
|
-
}
|
|
497
501
|
const newHeads = heads.filter((head) => {
|
|
498
502
|
return hexToNumber(head.number) > indexerHeight;
|
|
499
503
|
});
|
|
500
504
|
const [firstNewHead] = newHeads;
|
|
505
|
+
if (firstNewHead === void 0 && indexerHeight === finalizedHeight) {
|
|
506
|
+
return log.debug("No heads to finalize, returning...");
|
|
507
|
+
}
|
|
501
508
|
if (firstNewHead === void 0) {
|
|
502
|
-
throw new Error("Internal error. Expected at least one head greater than the indexer height.");
|
|
509
|
+
throw new Error("Internal error. Expected at least one head greater than the indexer height and less than the finalized height.");
|
|
503
510
|
}
|
|
504
511
|
if (hexToNumber(firstNewHead.number) !== indexerHeight + 1) {
|
|
505
512
|
throw new Error("Client advanced too far. Heads received are greater than the first new head");
|
|
506
513
|
}
|
|
514
|
+
if (heights.length > 1) {
|
|
515
|
+
await cleanupFinalizedHeads(chain, numberToHex(indexerHeight));
|
|
516
|
+
}
|
|
507
517
|
for (const head of newHeads) {
|
|
508
518
|
await Promise.all([
|
|
509
519
|
processEventsForCanonicalHead(head),
|
|
@@ -617,21 +627,26 @@ function indexer(opts) {
|
|
|
617
627
|
await Promise.all(promises);
|
|
618
628
|
}
|
|
619
629
|
async function cleanupFinalizedHeads(chain, finalized) {
|
|
620
|
-
const [_blocks, _commits] = await Promise.all([
|
|
630
|
+
const [_blocks, _commits, _heights] = await Promise.all([
|
|
621
631
|
metadata.blocks.list(chain),
|
|
622
632
|
//
|
|
623
|
-
metadata.commits.list(chain)
|
|
633
|
+
metadata.commits.list(chain),
|
|
634
|
+
metadata.heights.list(chain)
|
|
624
635
|
]);
|
|
625
636
|
const blocks = _blocks.filter((block) => {
|
|
626
637
|
return hexToNumber(block.number) <= hexToNumber(finalized);
|
|
627
638
|
});
|
|
628
639
|
const commits = _commits.filter((commit) => {
|
|
629
|
-
return hexToNumber(commit.number)
|
|
640
|
+
return hexToNumber(commit.number) <= hexToNumber(finalized);
|
|
641
|
+
});
|
|
642
|
+
const heights = _heights.filter((height) => {
|
|
643
|
+
return hexToNumber(height.number) < hexToNumber(finalized);
|
|
630
644
|
});
|
|
631
645
|
await Promise.all([
|
|
632
646
|
metadata.blocks.delete(blocks),
|
|
633
647
|
//
|
|
634
|
-
metadata.commits.delete(commits)
|
|
648
|
+
metadata.commits.delete(commits),
|
|
649
|
+
metadata.heights.delete(heights)
|
|
635
650
|
]);
|
|
636
651
|
}
|
|
637
652
|
const private_getMetadata = async () => {
|
package/dist/realtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createLogger, i as iife, h as hexToNumber, n as numberToHex, m as mutex, r as retry, a as isHexEqual } from './shared/univo.
|
|
1
|
+
import { c as createLogger, i as iife, h as hexToNumber, n as numberToHex, m as mutex, r as retry, a as isHexEqual } from './shared/univo.DvxWs2zB.mjs';
|
|
2
2
|
|
|
3
3
|
function defineBlockchain(opts) {
|
|
4
4
|
const log = createLogger({ quiet: opts.quiet });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ws from 'ws';
|
|
2
2
|
import { WebSocket } from 'partysocket';
|
|
3
|
-
import { g as compress, j as raise, c as createLogger, m as mutex } from './univo.
|
|
3
|
+
import { g as compress, j as raise, c as createLogger, m as mutex } from './univo.DvxWs2zB.mjs';
|
|
4
4
|
|
|
5
5
|
function createException(message) {
|
|
6
6
|
return `univo:${message}`;
|
|
@@ -26,20 +26,11 @@ const DEFAULT_TIMEOUT_MS = 60 * 1e3;
|
|
|
26
26
|
const UnknownMethodError = createException("The requested RPC method does not exist on the provided implementation");
|
|
27
27
|
function local(rpc) {
|
|
28
28
|
const request = async (opts) => {
|
|
29
|
-
const signal = opts.signal ?? AbortSignal.timeout(DEFAULT_TIMEOUT_MS);
|
|
30
|
-
if (signal.aborted) {
|
|
31
|
-
throw signal.reason;
|
|
32
|
-
}
|
|
33
29
|
const method = rpc.request[opts.method];
|
|
34
30
|
if (method === void 0) {
|
|
35
31
|
throw new Error(UnknownMethodError);
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
return await new Promise((resolve, reject) => {
|
|
39
|
-
const abort = () => reject(signal.reason);
|
|
40
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
41
|
-
Promise.resolve(result).then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
42
|
-
});
|
|
33
|
+
return await method(...opts.params);
|
|
43
34
|
};
|
|
44
35
|
const subscribe = async () => {
|
|
45
36
|
throw new Error("Unable to `subscribe` on `local` transport");
|
package/dist/transport.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'ws';
|
|
2
2
|
import 'partysocket';
|
|
3
|
-
export { h as http, l as local, w as wss } from './shared/univo.
|
|
4
|
-
import './shared/univo.
|
|
3
|
+
export { h as http, l as local, w as wss } from './shared/univo.1clH0g-n.mjs';
|
|
4
|
+
import './shared/univo.DvxWs2zB.mjs';
|