univo 0.2.13 → 0.2.14
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 +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +24 -17
- package/dist/realtime.d.mts +1 -1
- package/dist/realtime.d.ts +1 -1
- package/dist/realtime.mjs +28 -20
- package/dist/rpc.d.mts +9 -12
- package/dist/rpc.d.ts +9 -12
- package/dist/shared/{univo.BwPUSTpl.mjs → univo.CzTm3CDN.mjs} +1 -1
- package/dist/shared/{univo.Cj4s4jNq.d.mts → univo.DcmLb3Hn.d.mts} +4 -3
- package/dist/shared/{univo.Cj4s4jNq.d.ts → univo.DcmLb3Hn.d.ts} +4 -3
- package/dist/shared/{univo.B_UsEiYb.mjs → univo.sqV2c2Yj.mjs} +1 -1
- package/dist/transport.d.mts +1 -1
- package/dist/transport.d.ts +1 -1
- package/dist/transport.mjs +2 -2
- package/package.json +1 -1
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, f as name } from './shared/univo.
|
|
7
|
+
import { h as http } from './shared/univo.CzTm3CDN.mjs';
|
|
8
|
+
import { c as createLogger, v as version, f as name } from './shared/univo.sqV2c2Yj.mjs';
|
|
9
9
|
|
|
10
10
|
const log = createLogger({ quiet: false });
|
|
11
11
|
const dev = defineCommand({
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { B as Block, E as Event, a as Filter, H as Head, I as Indexer, M as Metadata, R as Result, i as indexer, m as matchFilter } from './shared/univo.
|
|
1
|
+
export { B as Block, E as Event, a as Filter, H as Head, I as Indexer, M as Metadata, R as Result, i as indexer, m as matchFilter } from './shared/univo.DcmLb3Hn.mjs';
|
|
2
2
|
import 'unstorage';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { B as Block, E as Event, a as Filter, H as Head, I as Indexer, M as Metadata, R as Result, i as indexer, m as matchFilter } from './shared/univo.
|
|
1
|
+
export { B as Block, E as Event, a as Filter, H as Head, I as Indexer, M as Metadata, R as Result, i as indexer, m as matchFilter } from './shared/univo.DcmLb3Hn.js';
|
|
2
2
|
import 'unstorage';
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createException, a as catchException, l as local, g as getException } from './shared/univo.
|
|
2
|
-
import { c as createLogger, r as retry, v as version, h as hexToNumber, i as isHexEqual, d as decompress, a as decoder, n as normalizeHex } from './shared/univo.
|
|
1
|
+
import { c as createException, a as catchException, l as local, g as getException } from './shared/univo.CzTm3CDN.mjs';
|
|
2
|
+
import { c as createLogger, r as retry, v as version, h as hexToNumber, i as isHexEqual, d as decompress, a as decoder, n as normalizeHex } from './shared/univo.sqV2c2Yj.mjs';
|
|
3
3
|
import 'ws';
|
|
4
4
|
import 'partysocket';
|
|
5
5
|
|
|
@@ -294,7 +294,7 @@ function indexer(opts) {
|
|
|
294
294
|
if (hexToNumber(head.number) !== hexToNumber(previousHead.number) + 1) {
|
|
295
295
|
throw new Error("Found invalid block number in received heads, aborting...");
|
|
296
296
|
}
|
|
297
|
-
if (!isHexEqual(head.
|
|
297
|
+
if (!isHexEqual(head.parent_hash, previousHead.hash)) {
|
|
298
298
|
throw new Error("Found invalid block hash in received heads, aborting...");
|
|
299
299
|
}
|
|
300
300
|
previousHead = head;
|
|
@@ -515,8 +515,9 @@ function indexer(opts) {
|
|
|
515
515
|
status,
|
|
516
516
|
event_id: event2.id,
|
|
517
517
|
chain: block.eth_chainId,
|
|
518
|
-
|
|
519
|
-
|
|
518
|
+
hash: block.eth_getBlockByNumber.hash,
|
|
519
|
+
number: block.eth_getBlockByNumber.number,
|
|
520
|
+
parent_hash: block.eth_getBlockByNumber.parentHash,
|
|
520
521
|
created_at: Date.now()
|
|
521
522
|
};
|
|
522
523
|
}
|
|
@@ -541,8 +542,9 @@ function indexer(opts) {
|
|
|
541
542
|
status,
|
|
542
543
|
event_id: event2.id,
|
|
543
544
|
chain: block.eth_chainId,
|
|
544
|
-
|
|
545
|
-
|
|
545
|
+
hash: block.eth_getBlockByNumber.hash,
|
|
546
|
+
number: block.eth_getBlockByNumber.number,
|
|
547
|
+
parent_hash: block.eth_getBlockByNumber.parentHash,
|
|
546
548
|
created_at: Date.now()
|
|
547
549
|
};
|
|
548
550
|
}
|
|
@@ -577,8 +579,9 @@ function indexer(opts) {
|
|
|
577
579
|
event_id: event2.id,
|
|
578
580
|
status: "block_error",
|
|
579
581
|
chain: params.head.chain,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
+
hash: params.head.hash,
|
|
583
|
+
number: params.head.number,
|
|
584
|
+
parent_hash: params.head.parent_hash,
|
|
582
585
|
created_at: Date.now()
|
|
583
586
|
};
|
|
584
587
|
})
|
|
@@ -622,8 +625,9 @@ function indexer(opts) {
|
|
|
622
625
|
status: "handler_error",
|
|
623
626
|
event_id: event2.id,
|
|
624
627
|
chain: proxy.eth_chainId,
|
|
625
|
-
|
|
626
|
-
|
|
628
|
+
hash: proxy.eth_getBlockByNumber.hash,
|
|
629
|
+
number: proxy.eth_getBlockByNumber.number,
|
|
630
|
+
parent_hash: proxy.eth_getBlockByNumber.parentHash,
|
|
627
631
|
created_at: Date.now()
|
|
628
632
|
};
|
|
629
633
|
return;
|
|
@@ -633,8 +637,9 @@ function indexer(opts) {
|
|
|
633
637
|
status: "ok",
|
|
634
638
|
event_id: event2.id,
|
|
635
639
|
chain: proxy.eth_chainId,
|
|
636
|
-
|
|
637
|
-
|
|
640
|
+
hash: proxy.eth_getBlockByNumber.hash,
|
|
641
|
+
number: proxy.eth_getBlockByNumber.number,
|
|
642
|
+
parent_hash: proxy.eth_getBlockByNumber.parentHash,
|
|
638
643
|
created_at: Date.now()
|
|
639
644
|
};
|
|
640
645
|
return;
|
|
@@ -651,8 +656,9 @@ function indexer(opts) {
|
|
|
651
656
|
status: "upsert_error",
|
|
652
657
|
event_id: event2.id,
|
|
653
658
|
chain: proxy.eth_chainId,
|
|
654
|
-
|
|
655
|
-
|
|
659
|
+
hash: proxy.eth_getBlockByNumber.hash,
|
|
660
|
+
number: proxy.eth_getBlockByNumber.number,
|
|
661
|
+
parent_hash: proxy.eth_getBlockByNumber.parentHash,
|
|
656
662
|
created_at: Date.now()
|
|
657
663
|
};
|
|
658
664
|
return;
|
|
@@ -661,8 +667,9 @@ function indexer(opts) {
|
|
|
661
667
|
status: "ok",
|
|
662
668
|
event_id: event2.id,
|
|
663
669
|
chain: proxy.eth_chainId,
|
|
664
|
-
|
|
665
|
-
|
|
670
|
+
hash: proxy.eth_getBlockByNumber.hash,
|
|
671
|
+
number: proxy.eth_getBlockByNumber.number,
|
|
672
|
+
parent_hash: proxy.eth_getBlockByNumber.parentHash,
|
|
666
673
|
created_at: Date.now()
|
|
667
674
|
};
|
|
668
675
|
})
|
package/dist/realtime.d.mts
CHANGED
package/dist/realtime.d.ts
CHANGED
package/dist/realtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createLogger, b as iife, h as hexToNumber, e as numberToHex, m as mutex, r as retry, i as isHexEqual } from './shared/univo.
|
|
1
|
+
import { c as createLogger, b as iife, h as hexToNumber, e as numberToHex, m as mutex, r as retry, i as isHexEqual } from './shared/univo.sqV2c2Yj.mjs';
|
|
2
2
|
|
|
3
3
|
const MAX_LENGTH = 1e4;
|
|
4
4
|
function defineBlockchain(opts) {
|
|
@@ -47,26 +47,26 @@ function defineBlockchain(opts) {
|
|
|
47
47
|
if (chain.some((block) => block.hash === newBlock.hash)) {
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
if (getHeadBlock().hash === newBlock.
|
|
50
|
+
if (getHeadBlock().hash === newBlock.parent_hash) {
|
|
51
51
|
return setHeadBlock(newBlock);
|
|
52
52
|
}
|
|
53
|
-
if (chain.some((block) => block.hash === newBlock.
|
|
54
|
-
while (getHeadBlock().hash !== newBlock.
|
|
53
|
+
if (chain.some((block) => block.hash === newBlock.parent_hash)) {
|
|
54
|
+
while (getHeadBlock().hash !== newBlock.parent_hash) {
|
|
55
55
|
removeHeadBlock();
|
|
56
56
|
}
|
|
57
57
|
return setHeadBlock(newBlock);
|
|
58
58
|
}
|
|
59
|
-
if (newBlock.
|
|
59
|
+
if (newBlock.parent_hash === "0x0000000000000000000000000000000000000000000000000000000000000000") {
|
|
60
60
|
while (chain.length > 0) {
|
|
61
61
|
removeHeadBlock();
|
|
62
62
|
}
|
|
63
63
|
return setHeadBlock(newBlock);
|
|
64
64
|
}
|
|
65
|
-
const parentBlock = await retry(() => opts.getBlockByHash(newBlock.
|
|
65
|
+
const parentBlock = await retry(() => opts.getBlockByHash(newBlock.parent_hash), 5);
|
|
66
66
|
if (parentBlock === null) {
|
|
67
|
-
throw new Error(`Failed to fetch parent block ${hexToNumber(newBlock.number)} ${newBlock.
|
|
67
|
+
throw new Error(`Failed to fetch parent block ${hexToNumber(newBlock.number)} ${newBlock.parent_hash.slice(0, 16)}`);
|
|
68
68
|
}
|
|
69
|
-
if (!isHexEqual(parentBlock.hash, newBlock.
|
|
69
|
+
if (!isHexEqual(parentBlock.hash, newBlock.parent_hash)) {
|
|
70
70
|
throw new Error("Expected block hashes to match");
|
|
71
71
|
}
|
|
72
72
|
await reconcile(parentBlock);
|
|
@@ -82,7 +82,7 @@ function realtime(opts) {
|
|
|
82
82
|
const log = createLogger({ quiet: opts.quiet ?? false, prefix: "[realtime]" });
|
|
83
83
|
const getBlockByHash = async (hash) => {
|
|
84
84
|
const block = await opts.node.request({ method: "eth_getBlockByHash", params: [hash, false] });
|
|
85
|
-
return { number: block.number, hash: block.hash,
|
|
85
|
+
return { number: block.number, hash: block.hash, parent_hash: block.parentHash };
|
|
86
86
|
};
|
|
87
87
|
const promise = iife(async () => {
|
|
88
88
|
log.debug("Initialising realtime client for indexer");
|
|
@@ -124,15 +124,17 @@ function realtime(opts) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
|
-
await latest.reconcile(
|
|
127
|
+
await latest.reconcile({
|
|
128
|
+
hash: latestBlock.hash,
|
|
129
|
+
number: latestBlock.number,
|
|
130
|
+
parent_hash: latestBlock.parentHash
|
|
131
|
+
});
|
|
128
132
|
await opts.node.subscribe("newHeads", async (head) => {
|
|
129
|
-
|
|
130
|
-
await latest.reconcile(head);
|
|
131
|
-
} catch (error) {
|
|
133
|
+
await latest.reconcile({ hash: head.hash, number: head.number, parent_hash: head.parentHash }).catch((error) => {
|
|
132
134
|
if (error instanceof Error) {
|
|
133
135
|
log.error(`Failed to reconcile latest head: ${error.message}`);
|
|
134
136
|
}
|
|
135
|
-
}
|
|
137
|
+
});
|
|
136
138
|
});
|
|
137
139
|
log.debug("Subscribed latest chain to new heads");
|
|
138
140
|
const indexer = defineBlockchain({
|
|
@@ -144,17 +146,23 @@ function realtime(opts) {
|
|
|
144
146
|
method: "eth_getBlockByNumber",
|
|
145
147
|
params: [numberToHex(initialIndexerHeight), false]
|
|
146
148
|
});
|
|
147
|
-
await indexer.reconcile(
|
|
148
|
-
|
|
149
|
+
await indexer.reconcile({
|
|
150
|
+
hash: indexerBlock.hash,
|
|
151
|
+
number: indexerBlock.number,
|
|
152
|
+
parent_hash: indexerBlock.parentHash
|
|
153
|
+
});
|
|
154
|
+
await indexer.reconcile({
|
|
155
|
+
hash: latestBlock.hash,
|
|
156
|
+
number: latestBlock.number,
|
|
157
|
+
parent_hash: latestBlock.parentHash
|
|
158
|
+
});
|
|
149
159
|
log.debug("Reconciled local indexer chain");
|
|
150
160
|
await opts.node.subscribe("newHeads", async (head) => {
|
|
151
|
-
|
|
152
|
-
await indexer.reconcile(head);
|
|
153
|
-
} catch (error) {
|
|
161
|
+
await indexer.reconcile({ hash: head.hash, number: head.number, parent_hash: head.parentHash }).catch((error) => {
|
|
154
162
|
if (error instanceof Error) {
|
|
155
163
|
log.debug(`Failed to reconcile latest indexer head: ${error.message}`);
|
|
156
164
|
}
|
|
157
|
-
}
|
|
165
|
+
});
|
|
158
166
|
});
|
|
159
167
|
log.debug("Subscribed indexer chain to new heads");
|
|
160
168
|
let indexerHeight = initialIndexerHeight;
|
package/dist/rpc.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as Head, M as Metadata, F as Flatten, a as Filter, B as Block, R as Result } from './shared/univo.
|
|
1
|
+
import { H as Head, M as Metadata, F as Flatten, a as Filter, B as Block, R as Result } from './shared/univo.DcmLb3Hn.mjs';
|
|
2
2
|
import 'unstorage';
|
|
3
3
|
|
|
4
4
|
type Rpc = {
|
|
@@ -24,25 +24,22 @@ type NodeRpc = {
|
|
|
24
24
|
* Accepts a block tag and boolean for including receipts
|
|
25
25
|
* @returns A block with optional receipts
|
|
26
26
|
*/
|
|
27
|
-
eth_getBlockByNumber: (number: string, receipts: boolean) => Promise<
|
|
28
|
-
hash: `0x${string}`;
|
|
29
|
-
number: `0x${string}`;
|
|
30
|
-
parentHash: `0x${string}`;
|
|
31
|
-
}>;
|
|
27
|
+
eth_getBlockByNumber: (number: string, receipts: boolean) => Promise<NodeBlock>;
|
|
32
28
|
/**
|
|
33
29
|
* Accepts a block hash and boolean for including receipts
|
|
34
30
|
* @returns A block with optional receipts
|
|
35
31
|
*/
|
|
36
|
-
eth_getBlockByHash: (hash: `0x${string}`, receipts: boolean) => Promise<
|
|
37
|
-
hash: `0x${string}`;
|
|
38
|
-
number: `0x${string}`;
|
|
39
|
-
parentHash: `0x${string}`;
|
|
40
|
-
}>;
|
|
32
|
+
eth_getBlockByHash: (hash: `0x${string}`, receipts: boolean) => Promise<NodeBlock>;
|
|
41
33
|
};
|
|
42
34
|
subscribe: {
|
|
43
|
-
newHeads:
|
|
35
|
+
newHeads: NodeBlock;
|
|
44
36
|
};
|
|
45
37
|
};
|
|
38
|
+
type NodeBlock = {
|
|
39
|
+
hash: `0x${string}`;
|
|
40
|
+
number: `0x${string}`;
|
|
41
|
+
parentHash: `0x${string}`;
|
|
42
|
+
};
|
|
46
43
|
/**
|
|
47
44
|
* Indexer -----------------------------------------------------------------------------------------------------------------------------------
|
|
48
45
|
*/
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as Head, M as Metadata, F as Flatten, a as Filter, B as Block, R as Result } from './shared/univo.
|
|
1
|
+
import { H as Head, M as Metadata, F as Flatten, a as Filter, B as Block, R as Result } from './shared/univo.DcmLb3Hn.js';
|
|
2
2
|
import 'unstorage';
|
|
3
3
|
|
|
4
4
|
type Rpc = {
|
|
@@ -24,25 +24,22 @@ type NodeRpc = {
|
|
|
24
24
|
* Accepts a block tag and boolean for including receipts
|
|
25
25
|
* @returns A block with optional receipts
|
|
26
26
|
*/
|
|
27
|
-
eth_getBlockByNumber: (number: string, receipts: boolean) => Promise<
|
|
28
|
-
hash: `0x${string}`;
|
|
29
|
-
number: `0x${string}`;
|
|
30
|
-
parentHash: `0x${string}`;
|
|
31
|
-
}>;
|
|
27
|
+
eth_getBlockByNumber: (number: string, receipts: boolean) => Promise<NodeBlock>;
|
|
32
28
|
/**
|
|
33
29
|
* Accepts a block hash and boolean for including receipts
|
|
34
30
|
* @returns A block with optional receipts
|
|
35
31
|
*/
|
|
36
|
-
eth_getBlockByHash: (hash: `0x${string}`, receipts: boolean) => Promise<
|
|
37
|
-
hash: `0x${string}`;
|
|
38
|
-
number: `0x${string}`;
|
|
39
|
-
parentHash: `0x${string}`;
|
|
40
|
-
}>;
|
|
32
|
+
eth_getBlockByHash: (hash: `0x${string}`, receipts: boolean) => Promise<NodeBlock>;
|
|
41
33
|
};
|
|
42
34
|
subscribe: {
|
|
43
|
-
newHeads:
|
|
35
|
+
newHeads: NodeBlock;
|
|
44
36
|
};
|
|
45
37
|
};
|
|
38
|
+
type NodeBlock = {
|
|
39
|
+
hash: `0x${string}`;
|
|
40
|
+
number: `0x${string}`;
|
|
41
|
+
parentHash: `0x${string}`;
|
|
42
|
+
};
|
|
46
43
|
/**
|
|
47
44
|
* Indexer -----------------------------------------------------------------------------------------------------------------------------------
|
|
48
45
|
*/
|
|
@@ -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 } from './univo.
|
|
3
|
+
import { g as compress, j as raise, c as createLogger } from './univo.sqV2c2Yj.mjs';
|
|
4
4
|
|
|
5
5
|
function createException(message) {
|
|
6
6
|
return `univo:${message}`;
|
|
@@ -117,7 +117,7 @@ type Head = {
|
|
|
117
117
|
hash: `0x${string}`;
|
|
118
118
|
chain: `0x${string}`;
|
|
119
119
|
number: `0x${string}`;
|
|
120
|
-
|
|
120
|
+
parent_hash: `0x${string}`;
|
|
121
121
|
};
|
|
122
122
|
type Metadata = {
|
|
123
123
|
version: string;
|
|
@@ -126,9 +126,10 @@ type Metadata = {
|
|
|
126
126
|
type Result = {
|
|
127
127
|
status: string;
|
|
128
128
|
event_id: string;
|
|
129
|
+
hash: `0x${string}`;
|
|
129
130
|
chain: `0x${string}`;
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
number: `0x${string}`;
|
|
132
|
+
parent_hash: `0x${string}`;
|
|
132
133
|
created_at: number;
|
|
133
134
|
};
|
|
134
135
|
type IndexerOptions<TBlock> = {
|
|
@@ -117,7 +117,7 @@ type Head = {
|
|
|
117
117
|
hash: `0x${string}`;
|
|
118
118
|
chain: `0x${string}`;
|
|
119
119
|
number: `0x${string}`;
|
|
120
|
-
|
|
120
|
+
parent_hash: `0x${string}`;
|
|
121
121
|
};
|
|
122
122
|
type Metadata = {
|
|
123
123
|
version: string;
|
|
@@ -126,9 +126,10 @@ type Metadata = {
|
|
|
126
126
|
type Result = {
|
|
127
127
|
status: string;
|
|
128
128
|
event_id: string;
|
|
129
|
+
hash: `0x${string}`;
|
|
129
130
|
chain: `0x${string}`;
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
number: `0x${string}`;
|
|
132
|
+
parent_hash: `0x${string}`;
|
|
132
133
|
created_at: number;
|
|
133
134
|
};
|
|
134
135
|
type IndexerOptions<TBlock> = {
|
package/dist/transport.d.mts
CHANGED
package/dist/transport.d.ts
CHANGED
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.CzTm3CDN.mjs';
|
|
4
|
+
import './shared/univo.sqV2c2Yj.mjs';
|