univo 0.2.12 → 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 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.Bb9Aplq9.mjs';
8
- import { c as createLogger, v as version, f as name } from './shared/univo.DicQZf-2.mjs';
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.Cj4s4jNq.mjs';
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.Cj4s4jNq.js';
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.Bb9Aplq9.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.DicQZf-2.mjs';
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.parentHash, previousHead.hash)) {
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
- block_hash: block.eth_getBlockByNumber.hash,
519
- block_number: block.eth_getBlockByNumber.number,
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
- block_hash: block.eth_getBlockByNumber.hash,
545
- block_number: block.eth_getBlockByNumber.number,
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
  }
@@ -570,7 +572,20 @@ function indexer(opts) {
570
572
  }
571
573
  const block = await getBlock(params.head);
572
574
  if (block === null) {
573
- throw new Error(GetBlockError);
575
+ return {
576
+ keys: [],
577
+ results: relevant_events.map((event2) => {
578
+ return {
579
+ event_id: event2.id,
580
+ status: "block_error",
581
+ chain: params.head.chain,
582
+ hash: params.head.hash,
583
+ number: params.head.number,
584
+ parent_hash: params.head.parent_hash,
585
+ created_at: Date.now()
586
+ };
587
+ })
588
+ };
574
589
  }
575
590
  const keys = /* @__PURE__ */ new Set();
576
591
  const results = {};
@@ -610,8 +625,9 @@ function indexer(opts) {
610
625
  status: "handler_error",
611
626
  event_id: event2.id,
612
627
  chain: proxy.eth_chainId,
613
- block_hash: proxy.eth_getBlockByNumber.hash,
614
- block_number: proxy.eth_getBlockByNumber.number,
628
+ hash: proxy.eth_getBlockByNumber.hash,
629
+ number: proxy.eth_getBlockByNumber.number,
630
+ parent_hash: proxy.eth_getBlockByNumber.parentHash,
615
631
  created_at: Date.now()
616
632
  };
617
633
  return;
@@ -621,8 +637,9 @@ function indexer(opts) {
621
637
  status: "ok",
622
638
  event_id: event2.id,
623
639
  chain: proxy.eth_chainId,
624
- block_hash: proxy.eth_getBlockByNumber.hash,
625
- block_number: proxy.eth_getBlockByNumber.number,
640
+ hash: proxy.eth_getBlockByNumber.hash,
641
+ number: proxy.eth_getBlockByNumber.number,
642
+ parent_hash: proxy.eth_getBlockByNumber.parentHash,
626
643
  created_at: Date.now()
627
644
  };
628
645
  return;
@@ -639,8 +656,9 @@ function indexer(opts) {
639
656
  status: "upsert_error",
640
657
  event_id: event2.id,
641
658
  chain: proxy.eth_chainId,
642
- block_hash: proxy.eth_getBlockByNumber.hash,
643
- block_number: proxy.eth_getBlockByNumber.number,
659
+ hash: proxy.eth_getBlockByNumber.hash,
660
+ number: proxy.eth_getBlockByNumber.number,
661
+ parent_hash: proxy.eth_getBlockByNumber.parentHash,
644
662
  created_at: Date.now()
645
663
  };
646
664
  return;
@@ -649,8 +667,9 @@ function indexer(opts) {
649
667
  status: "ok",
650
668
  event_id: event2.id,
651
669
  chain: proxy.eth_chainId,
652
- block_hash: proxy.eth_getBlockByNumber.hash,
653
- block_number: proxy.eth_getBlockByNumber.number,
670
+ hash: proxy.eth_getBlockByNumber.hash,
671
+ number: proxy.eth_getBlockByNumber.number,
672
+ parent_hash: proxy.eth_getBlockByNumber.parentHash,
654
673
  created_at: Date.now()
655
674
  };
656
675
  })
@@ -1,6 +1,6 @@
1
1
  import { NodeRpc, IndexerRpc } from './rpc.mjs';
2
2
  import { Transport } from './transport.mjs';
3
- import './shared/univo.Cj4s4jNq.mjs';
3
+ import './shared/univo.DcmLb3Hn.mjs';
4
4
  import 'unstorage';
5
5
 
6
6
  type RealtimeOptions = {
@@ -1,6 +1,6 @@
1
1
  import { NodeRpc, IndexerRpc } from './rpc.js';
2
2
  import { Transport } from './transport.js';
3
- import './shared/univo.Cj4s4jNq.js';
3
+ import './shared/univo.DcmLb3Hn.js';
4
4
  import 'unstorage';
5
5
 
6
6
  type RealtimeOptions = {
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.DicQZf-2.mjs';
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.parentHash) {
50
+ if (getHeadBlock().hash === newBlock.parent_hash) {
51
51
  return setHeadBlock(newBlock);
52
52
  }
53
- if (chain.some((block) => block.hash === newBlock.parentHash)) {
54
- while (getHeadBlock().hash !== newBlock.parentHash) {
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.parentHash === "0x0000000000000000000000000000000000000000000000000000000000000000") {
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.parentHash), 5);
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.parentHash.slice(0, 16)}`);
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.parentHash)) {
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, parentHash: block.parentHash };
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(latestBlock);
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
- try {
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(indexerBlock);
148
- await indexer.reconcile(latestBlock);
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
- try {
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.Cj4s4jNq.mjs';
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: Head;
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.Cj4s4jNq.js';
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: Head;
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.DicQZf-2.mjs';
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
- parentHash: `0x${string}`;
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
- block_hash: `0x${string}`;
131
- block_number: `0x${string}`;
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
- parentHash: `0x${string}`;
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
- block_hash: `0x${string}`;
131
- block_number: `0x${string}`;
131
+ number: `0x${string}`;
132
+ parent_hash: `0x${string}`;
132
133
  created_at: number;
133
134
  };
134
135
  type IndexerOptions<TBlock> = {
@@ -1,5 +1,5 @@
1
1
  const name = "univo";
2
- const version = "0.2.12";
2
+ const version = "0.2.14";
3
3
 
4
4
  function createLogger(opts) {
5
5
  let prefix = `[${name}@${version}]`;
@@ -1,5 +1,5 @@
1
1
  import { Rpc } from './rpc.mjs';
2
- import './shared/univo.Cj4s4jNq.mjs';
2
+ import './shared/univo.DcmLb3Hn.mjs';
3
3
  import 'unstorage';
4
4
 
5
5
  type Protocol = "http" | "wss" | "local";
@@ -1,5 +1,5 @@
1
1
  import { Rpc } from './rpc.js';
2
- import './shared/univo.Cj4s4jNq.js';
2
+ import './shared/univo.DcmLb3Hn.js';
3
3
  import 'unstorage';
4
4
 
5
5
  type Protocol = "http" | "wss" | "local";
@@ -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.Bb9Aplq9.mjs';
4
- import './shared/univo.DicQZf-2.mjs';
3
+ export { h as http, l as local, w as wss } from './shared/univo.CzTm3CDN.mjs';
4
+ import './shared/univo.sqV2c2Yj.mjs';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "univo",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "0.2.12",
5
+ "version": "0.2.14",
6
6
  "sideEffects": false,
7
7
  "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",