univo 0.2.13 → 0.2.15

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.BwPUSTpl.mjs';
8
- import { c as createLogger, v as version, f as name } from './shared/univo.B_UsEiYb.mjs';
7
+ import { h as http } from './shared/univo.O0SoVQWh.mjs';
8
+ import { c as createLogger, v as version, g as name } from './shared/univo.BgwFxZpJ.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';
2
- import 'unstorage';
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.CjvLVVxo.mjs';
2
+ import '@storagesdk/core';
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';
2
- import 'unstorage';
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.CjvLVVxo.js';
2
+ import '@storagesdk/core';
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
- import { c as createException, a as catchException, l as local, g as getException } from './shared/univo.BwPUSTpl.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.B_UsEiYb.mjs';
1
+ import { StorageError } from '@storagesdk/core';
2
+ import { c as createException, a as catchException, l as local, g as getException } from './shared/univo.O0SoVQWh.mjs';
3
+ 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, b as compress } from './shared/univo.BgwFxZpJ.mjs';
3
4
  import 'ws';
4
5
  import 'partysocket';
5
6
 
@@ -48,48 +49,61 @@ function indexer(opts) {
48
49
  const events_grouped_by_storage_map = /* @__PURE__ */ new Map();
49
50
  const metadata = {
50
51
  blocks: {
51
- async list(head) {
52
- let prefix = `/blocks/v1/${normalizeHex(head.chain)}`;
53
- if (typeof head.number === "string") {
54
- prefix += `/${normalizeHex(head.number, 16)}`;
52
+ async getNextUnfinalizedBlock(chain) {
53
+ const prefix = `blocks/v1/${normalizeHex(chain)}`;
54
+ const keys = await opts.metadataStorage.list({ prefix, limit: 1 });
55
+ const [key] = keys.items;
56
+ if (key === void 0) {
57
+ return null;
55
58
  }
56
- const keys = await opts.metadataStorage.getKeys(prefix);
57
- return keys.map((key) => {
58
- const [__, ___, chain, number, hash] = key.split(":");
59
- return { chain, number, hash };
60
- });
59
+ const [_, __, ___, number, hash] = key.path.split("/");
60
+ return { chain, number, hash };
61
61
  },
62
- async get(head) {
63
- let prefix = `/blocks/v1/${head.chain.toLowerCase()}`;
64
- if (typeof head.number === "string") {
65
- prefix += `/${normalizeHex(head.number, 16)}`;
62
+ async getBlocksByNumber(chain, number) {
63
+ const prefix = `blocks/v1/${normalizeHex(chain)}/${normalizeHex(number, 16)}`;
64
+ const keys = await opts.metadataStorage.list({ prefix });
65
+ if (keys.items.length === 0) {
66
+ return [];
66
67
  }
67
- if (typeof head.hash === "string") {
68
- if (head.number === void 0) {
69
- throw new Error("Requested block by hash without specifying a block number");
70
- }
71
- prefix += `/${head.hash.toLowerCase()}`;
72
- const block = await opts.metadataStorage.getItem(prefix);
73
- if (block === null) {
74
- return [];
68
+ const blocks = await Promise.all(
69
+ keys.items.map(async (item) => {
70
+ const blob = await opts.metadataStorage.download(item.path, { as: "blob" });
71
+ const block = await decompress(blob);
72
+ const parsed = JSON.parse(block);
73
+ return parsed;
74
+ })
75
+ );
76
+ return blocks;
77
+ },
78
+ async getBlockByNumberAndHash(chain, number, hash) {
79
+ const prefix = `blocks/v1/${normalizeHex(chain)}/${normalizeHex(number, 16)}/${normalizeHex(hash)}`;
80
+ const blob = await opts.metadataStorage.download(prefix, { as: "blob" }).catch((error) => {
81
+ if (error instanceof StorageError) {
82
+ if (error.code === "NotFound") {
83
+ return null;
84
+ }
75
85
  }
76
- return [block];
86
+ throw error;
87
+ });
88
+ if (blob === null) {
89
+ return null;
77
90
  }
78
- const keys = await opts.metadataStorage.getKeys(prefix);
79
- const results = await opts.metadataStorage.getItems(keys);
80
- return results.map((result) => result.value);
91
+ const block = await decompress(blob);
92
+ const parsed = JSON.parse(block);
93
+ return parsed;
81
94
  },
82
95
  async upsert(blocks) {
83
96
  if (blocks.length === 0) {
84
97
  return;
85
98
  }
86
- await opts.metadataStorage.setItems(
87
- blocks.map((block) => {
99
+ await Promise.all(
100
+ blocks.map(async (block) => {
88
101
  const chain = normalizeHex(block.eth_chainId);
89
102
  const hash = normalizeHex(block.eth_getBlockByNumber.hash);
90
103
  const number = normalizeHex(block.eth_getBlockByNumber.number, 16);
91
- const key = `/blocks/v1/${chain}/${number}/${hash}`;
92
- return { key, value: block };
104
+ const prefix = `blocks/v1/${chain}/${number}/${hash}`;
105
+ const compressed = await compress(JSON.stringify(block));
106
+ await opts.metadataStorage.upload(prefix, compressed);
93
107
  })
94
108
  );
95
109
  },
@@ -102,7 +116,8 @@ function indexer(opts) {
102
116
  const chain = normalizeHex(block.eth_chainId);
103
117
  const hash = normalizeHex(block.eth_getBlockByNumber.hash);
104
118
  const number = normalizeHex(block.eth_getBlockByNumber.number, 16);
105
- await opts.metadataStorage.del(`/blocks/v1/${chain}/${number}/${hash}`);
119
+ const prefix = `blocks/v1/${chain}/${number}/${hash}`;
120
+ await opts.metadataStorage.delete(prefix);
106
121
  })
107
122
  );
108
123
  }
@@ -133,8 +148,8 @@ function indexer(opts) {
133
148
  }
134
149
  const GetBlockError = createException("Failed to load block from the provided `getBlock` function");
135
150
  const public_getFinalizedHeight = async (chain) => {
136
- const [[stored], finalizedBlock] = await Promise.all([
137
- metadata.blocks.list({ chain }),
151
+ const [stored, finalizedBlock] = await Promise.all([
152
+ metadata.blocks.getNextUnfinalizedBlock(chain),
138
153
  //
139
154
  getBlock({ chain, number: "finalized" })
140
155
  ]);
@@ -143,7 +158,7 @@ function indexer(opts) {
143
158
  throw new Error(GetBlockError);
144
159
  }
145
160
  const finalizedHeight = hexToNumber(finalizedBlock.eth_getBlockByNumber.number);
146
- if (stored === void 0) {
161
+ if (stored === null) {
147
162
  return finalizedHeight;
148
163
  }
149
164
  const indexerHeight = hexToNumber(stored.number) - 1;
@@ -231,11 +246,11 @@ function indexer(opts) {
231
246
  };
232
247
  const public_deleteReorganisedHead = async (head) => {
233
248
  log.debug(`Received reorganised head ${hexToNumber(head.number)}`);
234
- const [canonical_block, [stored_block]] = await Promise.all([
249
+ const [canonical_block, stored_block] = await Promise.all([
235
250
  getBlock({ chain: head.chain, number: head.number }),
236
- metadata.blocks.get({ chain: head.chain, number: head.number, hash: head.hash })
251
+ metadata.blocks.getBlockByNumberAndHash(head.chain, head.number, head.hash)
237
252
  ]);
238
- if (stored_block === void 0) {
253
+ if (stored_block === null) {
239
254
  return log.debug("Reorganised block never/already processed");
240
255
  }
241
256
  if (canonical_block === null) {
@@ -294,13 +309,13 @@ function indexer(opts) {
294
309
  if (hexToNumber(head.number) !== hexToNumber(previousHead.number) + 1) {
295
310
  throw new Error("Found invalid block number in received heads, aborting...");
296
311
  }
297
- if (!isHexEqual(head.parentHash, previousHead.hash)) {
312
+ if (!isHexEqual(head.parent_hash, previousHead.hash)) {
298
313
  throw new Error("Found invalid block hash in received heads, aborting...");
299
314
  }
300
315
  previousHead = head;
301
316
  }
302
- const [[unfinalizedMetadataBlock], finalizedBlock] = await Promise.all([
303
- metadata.blocks.list({ chain }),
317
+ const [unfinalizedMetadataBlock, finalizedBlock] = await Promise.all([
318
+ metadata.blocks.getNextUnfinalizedBlock(chain),
304
319
  //
305
320
  getBlock({ chain, number: "finalized" })
306
321
  ]);
@@ -314,7 +329,7 @@ function indexer(opts) {
314
329
  throw new Error("Received head greater than chain finalized height");
315
330
  }
316
331
  }
317
- if (unfinalizedMetadataBlock === void 0) {
332
+ if (unfinalizedMetadataBlock === null) {
318
333
  return log.debug("No heads to finalize, returning...");
319
334
  }
320
335
  const indexerHeight = hexToNumber(unfinalizedMetadataBlock.number) - 1;
@@ -333,7 +348,7 @@ function indexer(opts) {
333
348
  throw new Error("Client advanced too far. Heads received are greater than the indexer height");
334
349
  }
335
350
  for (const head of newHeads) {
336
- const processed = await metadata.blocks.get({ chain: head.chain, number: head.number });
351
+ const processed = await metadata.blocks.getBlocksByNumber(head.chain, head.number);
337
352
  if (processed.length === 0) {
338
353
  await writeFinalizedHead(head, null);
339
354
  continue;
@@ -515,8 +530,9 @@ function indexer(opts) {
515
530
  status,
516
531
  event_id: event2.id,
517
532
  chain: block.eth_chainId,
518
- block_hash: block.eth_getBlockByNumber.hash,
519
- block_number: block.eth_getBlockByNumber.number,
533
+ hash: block.eth_getBlockByNumber.hash,
534
+ number: block.eth_getBlockByNumber.number,
535
+ parent_hash: block.eth_getBlockByNumber.parentHash,
520
536
  created_at: Date.now()
521
537
  };
522
538
  }
@@ -541,8 +557,9 @@ function indexer(opts) {
541
557
  status,
542
558
  event_id: event2.id,
543
559
  chain: block.eth_chainId,
544
- block_hash: block.eth_getBlockByNumber.hash,
545
- block_number: block.eth_getBlockByNumber.number,
560
+ hash: block.eth_getBlockByNumber.hash,
561
+ number: block.eth_getBlockByNumber.number,
562
+ parent_hash: block.eth_getBlockByNumber.parentHash,
546
563
  created_at: Date.now()
547
564
  };
548
565
  }
@@ -577,8 +594,9 @@ function indexer(opts) {
577
594
  event_id: event2.id,
578
595
  status: "block_error",
579
596
  chain: params.head.chain,
580
- block_hash: params.head.hash,
581
- block_number: params.head.number,
597
+ hash: params.head.hash,
598
+ number: params.head.number,
599
+ parent_hash: params.head.parent_hash,
582
600
  created_at: Date.now()
583
601
  };
584
602
  })
@@ -622,8 +640,9 @@ function indexer(opts) {
622
640
  status: "handler_error",
623
641
  event_id: event2.id,
624
642
  chain: proxy.eth_chainId,
625
- block_hash: proxy.eth_getBlockByNumber.hash,
626
- block_number: proxy.eth_getBlockByNumber.number,
643
+ hash: proxy.eth_getBlockByNumber.hash,
644
+ number: proxy.eth_getBlockByNumber.number,
645
+ parent_hash: proxy.eth_getBlockByNumber.parentHash,
627
646
  created_at: Date.now()
628
647
  };
629
648
  return;
@@ -633,8 +652,9 @@ function indexer(opts) {
633
652
  status: "ok",
634
653
  event_id: event2.id,
635
654
  chain: proxy.eth_chainId,
636
- block_hash: proxy.eth_getBlockByNumber.hash,
637
- block_number: proxy.eth_getBlockByNumber.number,
655
+ hash: proxy.eth_getBlockByNumber.hash,
656
+ number: proxy.eth_getBlockByNumber.number,
657
+ parent_hash: proxy.eth_getBlockByNumber.parentHash,
638
658
  created_at: Date.now()
639
659
  };
640
660
  return;
@@ -651,8 +671,9 @@ function indexer(opts) {
651
671
  status: "upsert_error",
652
672
  event_id: event2.id,
653
673
  chain: proxy.eth_chainId,
654
- block_hash: proxy.eth_getBlockByNumber.hash,
655
- block_number: proxy.eth_getBlockByNumber.number,
674
+ hash: proxy.eth_getBlockByNumber.hash,
675
+ number: proxy.eth_getBlockByNumber.number,
676
+ parent_hash: proxy.eth_getBlockByNumber.parentHash,
656
677
  created_at: Date.now()
657
678
  };
658
679
  return;
@@ -661,8 +682,9 @@ function indexer(opts) {
661
682
  status: "ok",
662
683
  event_id: event2.id,
663
684
  chain: proxy.eth_chainId,
664
- block_hash: proxy.eth_getBlockByNumber.hash,
665
- block_number: proxy.eth_getBlockByNumber.number,
685
+ hash: proxy.eth_getBlockByNumber.hash,
686
+ number: proxy.eth_getBlockByNumber.number,
687
+ parent_hash: proxy.eth_getBlockByNumber.parentHash,
666
688
  created_at: Date.now()
667
689
  };
668
690
  })
@@ -1,7 +1,7 @@
1
1
  import { NodeRpc, IndexerRpc } from './rpc.mjs';
2
2
  import { Transport } from './transport.mjs';
3
- import './shared/univo.Cj4s4jNq.mjs';
4
- import 'unstorage';
3
+ import './shared/univo.CjvLVVxo.mjs';
4
+ import '@storagesdk/core';
5
5
 
6
6
  type RealtimeOptions = {
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { NodeRpc, IndexerRpc } from './rpc.js';
2
2
  import { Transport } from './transport.js';
3
- import './shared/univo.Cj4s4jNq.js';
4
- import 'unstorage';
3
+ import './shared/univo.CjvLVVxo.js';
4
+ import '@storagesdk/core';
5
5
 
6
6
  type RealtimeOptions = {
7
7
  /**
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.B_UsEiYb.mjs';
1
+ import { c as createLogger, e as iife, h as hexToNumber, f as numberToHex, m as mutex, r as retry, i as isHexEqual } from './shared/univo.BgwFxZpJ.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,5 +1,5 @@
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';
2
- import 'unstorage';
1
+ import { H as Head, M as Metadata, F as Flatten, a as Filter, B as Block, R as Result } from './shared/univo.CjvLVVxo.mjs';
2
+ import '@storagesdk/core';
3
3
 
4
4
  type Rpc = {
5
5
  /**
@@ -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,5 +1,5 @@
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';
2
- import 'unstorage';
1
+ import { H as Head, M as Metadata, F as Flatten, a as Filter, B as Block, R as Result } from './shared/univo.CjvLVVxo.js';
2
+ import '@storagesdk/core';
3
3
 
4
4
  type Rpc = {
5
5
  /**
@@ -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,5 +1,5 @@
1
1
  const name = "univo";
2
- const version = "0.2.13";
2
+ const version = "0.2.15";
3
3
 
4
4
  function createLogger(opts) {
5
5
  let prefix = `[${name}@${version}]`;
@@ -78,6 +78,10 @@ async function compress(input) {
78
78
  return new Response(compressed).arrayBuffer();
79
79
  }
80
80
  async function decompress(input) {
81
+ if (input instanceof Blob) {
82
+ const decompressed2 = input.stream().pipeThrough(new DecompressionStream("gzip"));
83
+ return new Response(decompressed2).text();
84
+ }
81
85
  const decompressed = new Blob([input]).stream().pipeThrough(new DecompressionStream("gzip"));
82
86
  return new Response(decompressed).text();
83
87
  }
@@ -89,4 +93,4 @@ const normalizeHex = (hex, length) => {
89
93
  return `0x${hex.slice(2).toLowerCase().padStart(length, "0")}`;
90
94
  };
91
95
 
92
- export { decoder as a, iife as b, createLogger as c, decompress as d, numberToHex as e, name as f, compress as g, hexToNumber as h, isHexEqual as i, raise as j, mutex as m, normalizeHex as n, retry as r, version as v };
96
+ export { decoder as a, compress as b, createLogger as c, decompress as d, iife as e, numberToHex as f, name as g, hexToNumber as h, isHexEqual as i, raise as j, mutex as m, normalizeHex as n, retry as r, version as v };
@@ -1,4 +1,4 @@
1
- import { Storage } from 'unstorage';
1
+ import { Storage } from '@storagesdk/core';
2
2
 
3
3
  type CamelToSnake<T extends string, P extends string = ""> = string extends T ? string : T extends `${infer C0}${infer R}` ? CamelToSnake<R, `${P}${C0 extends Lowercase<C0> ? "" : "_"}${Lowercase<C0>}`> : P;
4
4
  type Flatten<T> = {
@@ -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,4 +1,4 @@
1
- import { Storage } from 'unstorage';
1
+ import { Storage } from '@storagesdk/core';
2
2
 
3
3
  type CamelToSnake<T extends string, P extends string = ""> = string extends T ? string : T extends `${infer C0}${infer R}` ? CamelToSnake<R, `${P}${C0 extends Lowercase<C0> ? "" : "_"}${Lowercase<C0>}`> : P;
4
4
  type Flatten<T> = {
@@ -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,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.B_UsEiYb.mjs';
3
+ import { b as compress, j as raise, c as createLogger } from './univo.BgwFxZpJ.mjs';
4
4
 
5
5
  function createException(message) {
6
6
  return `univo:${message}`;
@@ -1,6 +1,6 @@
1
1
  import { Rpc } from './rpc.mjs';
2
- import './shared/univo.Cj4s4jNq.mjs';
3
- import 'unstorage';
2
+ import './shared/univo.CjvLVVxo.mjs';
3
+ import '@storagesdk/core';
4
4
 
5
5
  type Protocol = "http" | "wss" | "local";
6
6
  type Transport<R extends Rpc, P extends Protocol = Protocol> = {
@@ -1,6 +1,6 @@
1
1
  import { Rpc } from './rpc.js';
2
- import './shared/univo.Cj4s4jNq.js';
3
- import 'unstorage';
2
+ import './shared/univo.CjvLVVxo.js';
3
+ import '@storagesdk/core';
4
4
 
5
5
  type Protocol = "http" | "wss" | "local";
6
6
  type Transport<R extends Rpc, P extends Protocol = Protocol> = {
@@ -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.BwPUSTpl.mjs';
4
- import './shared/univo.B_UsEiYb.mjs';
3
+ export { h as http, l as local, w as wss } from './shared/univo.O0SoVQWh.mjs';
4
+ import './shared/univo.BgwFxZpJ.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.13",
5
+ "version": "0.2.15",
6
6
  "sideEffects": false,
7
7
  "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
@@ -54,6 +54,7 @@
54
54
  "vitest": "^3.1.3"
55
55
  },
56
56
  "peerDependencies": {
57
- "unstorage": ">=1"
57
+ "@storagesdk/core": ">=0.4.2",
58
+ "@storagesdk/adapters": ">=0.6.0"
58
59
  }
59
60
  }