univo 0.2.5 → 0.2.7

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
@@ -5,10 +5,10 @@ import { config } from 'dotenv';
5
5
  import { WebSocket } from 'partysocket';
6
6
  import { defineCommand, runMain } from 'citty';
7
7
  import { http } from './transport.mjs';
8
- import { c as createLogger, v as version, g as name } from './shared/univo.CpIzl9sz.mjs';
8
+ import { c as createLogger, v as version, g as name } from './shared/univo.Crj0ggpm.mjs';
9
9
  import './shared/univo.C0flyVee.mjs';
10
10
 
11
- const log = createLogger({ quiet: false, prefix: "[cli]" });
11
+ const log = createLogger({ quiet: false });
12
12
  const dev = defineCommand({
13
13
  args: {
14
14
  url: {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as createLogger, d as decompress, a as decoder, h as hexToNumber, i as isHexEqual, r as retry, v as version, n as nonNullable, b as normalizeHex } from './shared/univo.CpIzl9sz.mjs';
1
+ import { c as createLogger, d as decompress, a as decoder, h as hexToNumber, i as isHexEqual, r as retry, v as version, n as nonNullable, b as normalizeHex } from './shared/univo.Crj0ggpm.mjs';
2
2
  import { c as createException, g as getException, a as catchException } from './shared/univo.C0flyVee.mjs';
3
3
 
4
4
  function matchFilter(block, filter) {
@@ -46,6 +46,17 @@ function indexer(opts) {
46
46
  const events_grouped_by_storage_map = /* @__PURE__ */ new Map();
47
47
  const metadata = {
48
48
  blocks: {
49
+ async list(head) {
50
+ let prefix = `/blocks/v1/${normalizeHex(head.chain)}`;
51
+ if (typeof head.number === "string") {
52
+ prefix += `/${normalizeHex(head.number, 16)}`;
53
+ }
54
+ const keys = await opts.metadataStorage.getKeys(prefix);
55
+ return keys.map((key) => {
56
+ const [__, ___, chain, number, hash] = key.split(":");
57
+ return { chain, number, hash };
58
+ });
59
+ },
49
60
  async get(head) {
50
61
  let prefix = `/blocks/v1/${head.chain.toLowerCase()}`;
51
62
  if (typeof head.number === "string") {
@@ -64,7 +75,6 @@ function indexer(opts) {
64
75
  }
65
76
  const keys = await opts.metadataStorage.getKeys(prefix);
66
77
  const results = await opts.metadataStorage.getItems(keys);
67
- results.sort((a, b) => a.key.localeCompare(b.key));
68
78
  return results.map((result) => result.value);
69
79
  },
70
80
  async upsert(blocks) {
@@ -120,11 +130,11 @@ function indexer(opts) {
120
130
  return block;
121
131
  }
122
132
  const public_getFinalizedHeight = async (chain) => {
123
- const [stored] = await metadata.blocks.get({ chain });
133
+ const [stored] = await metadata.blocks.list({ chain });
124
134
  if (stored === void 0) {
125
135
  return null;
126
136
  }
127
- return hexToNumber(stored.eth_getBlockByNumber.number) - 1;
137
+ return hexToNumber(stored.number) - 1;
128
138
  };
129
139
  const public_writeUnfinalizedHeads = async (heads) => {
130
140
  let chain = void 0;
@@ -267,8 +277,7 @@ function indexer(opts) {
267
277
  });
268
278
  const [firstHead, ...remainingHeads] = newHeads;
269
279
  if (firstHead === void 0) {
270
- log.debug("Received no new finalized heads, aborting...");
271
- throw new Error(InvalidHeadsError);
280
+ return log.debug("Received no new finalized heads, aborting...");
272
281
  }
273
282
  if (hexToNumber(firstHead.number) !== indexerHeight + 1) {
274
283
  log.debug("First unfinalized head received didn't match metadata, aborting...");
package/dist/realtime.mjs CHANGED
@@ -1,8 +1,8 @@
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.CpIzl9sz.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.Crj0ggpm.mjs';
2
2
 
3
3
  const MAX_LENGTH = 1e4;
4
4
  function defineBlockchain(opts) {
5
- const log = createLogger({ quiet: opts.quiet, prefix: "[realtime]" });
5
+ const log = createLogger({ quiet: opts.quiet });
6
6
  const chain = [];
7
7
  function setHeadBlock(newBlock) {
8
8
  chain.push(newBlock);
@@ -1,14 +1,18 @@
1
1
  const name = "univo";
2
- const version = "0.2.5";
2
+ const version = "0.2.7";
3
3
 
4
4
  function createLogger(opts) {
5
+ let prefix = `[${name}@${version}]`;
6
+ if (opts.prefix !== void 0) {
7
+ prefix += ` ${opts.prefix}`;
8
+ }
5
9
  return {
6
10
  debug(...any) {
7
11
  if (opts.quiet) {
8
12
  return;
9
13
  }
10
14
  if (process.env.LOG_LEVEL === "DEBUG") {
11
- console.log(`[${name}@${version}] ${opts.prefix} DEBUG`, ...any);
15
+ console.log(`${opts.prefix} DEBUG`, ...any);
12
16
  }
13
17
  },
14
18
  info(...any) {
@@ -16,7 +20,7 @@ function createLogger(opts) {
16
20
  return;
17
21
  }
18
22
  if (process.env.LOG_LEVEL === "DEBUG" || process.env.LOG_LEVEL === "INFO") {
19
- console.log(`[${name}@${version}] ${opts.prefix} INFO`, ...any);
23
+ console.log(`${opts.prefix} INFO`, ...any);
20
24
  }
21
25
  },
22
26
  warn(...any) {
@@ -24,7 +28,7 @@ function createLogger(opts) {
24
28
  return;
25
29
  }
26
30
  if (process.env.LOG_LEVEL === "DEBUG" || process.env.LOG_LEVEL === "INFO" || process.env.LOG_LEVEL === "WARN") {
27
- console.log(`[${name}@${version}] ${opts.prefix} WARN`, ...any);
31
+ console.log(`${opts.prefix} WARN`, ...any);
28
32
  }
29
33
  },
30
34
  error(...any) {
@@ -32,7 +36,7 @@ function createLogger(opts) {
32
36
  return;
33
37
  }
34
38
  if (process.env.LOG_LEVEL === "DEBUG" || process.env.LOG_LEVEL === "INFO" || process.env.LOG_LEVEL === "WARN" || process.env.LOG_LEVEL === "ERROR") {
35
- console.log(`[${name}@${version}] ${opts.prefix} ERROR`, ...any);
39
+ console.log(`${opts.prefix} ERROR`, ...any);
36
40
  }
37
41
  }
38
42
  };
@@ -1,7 +1,7 @@
1
1
  import ws from 'ws';
2
2
  import { WebSocket } from 'partysocket';
3
3
  import { c as createException } from './shared/univo.C0flyVee.mjs';
4
- import { j as compress, k as raise, c as createLogger } from './shared/univo.CpIzl9sz.mjs';
4
+ import { j as compress, k as raise, c as createLogger } from './shared/univo.Crj0ggpm.mjs';
5
5
 
6
6
  function createSocket(url, opts) {
7
7
  const socket = new WebSocket(url, [], { WebSocket: ws });
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "univo",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "0.2.5",
5
+ "version": "0.2.7",
6
6
  "sideEffects": false,
7
7
  "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",