univo 0.2.0 → 0.2.3

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,7 +5,7 @@ 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.HDazcQ9A.mjs';
8
+ import { c as createLogger, v as version, f as name } from './shared/univo.CKcWHEHI.mjs';
9
9
  import './shared/univo.C0flyVee.mjs';
10
10
 
11
11
  const log = createLogger({ quiet: false });
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 } from './shared/univo.HDazcQ9A.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 } from './shared/univo.CKcWHEHI.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) {
@@ -259,7 +259,9 @@ function indexer(opts) {
259
259
  }
260
260
  const nextUnfinalizedHeight = hexToNumber(nextUnfinalizedBlock.eth_getBlockByNumber.number);
261
261
  const canonicalFinalizedHeight = hexToNumber(finalizedBlock.eth_getBlockByNumber.number);
262
- assert(canonicalFinalizedHeight >= nextUnfinalizedHeight, "We should always trail the canonical chain");
262
+ if (canonicalFinalizedHeight < nextUnfinalizedHeight) {
263
+ throw new Error("Expected finalized chain to trail canonical chain");
264
+ }
263
265
  const finalizedHeads = heads.filter((head) => {
264
266
  return hexToNumber(head.number) >= nextUnfinalizedHeight && hexToNumber(head.number) <= canonicalFinalizedHeight;
265
267
  });
@@ -1,4 +1,5 @@
1
- import { T as Transport, N as NodeRpc, I as IndexerRpc } from './shared/univo.BZ_L9bc2.mjs';
1
+ import { NodeRpc, IndexerRpc } from './rpc.mjs';
2
+ import { Transport } from './transport.mjs';
2
3
  import './index.mjs';
3
4
  import 'unstorage';
4
5
 
@@ -1,4 +1,5 @@
1
- import { T as Transport, N as NodeRpc, I as IndexerRpc } from './shared/univo.BWa1smi3.js';
1
+ import { NodeRpc, IndexerRpc } from './rpc.js';
2
+ import { Transport } from './transport.js';
2
3
  import './index.js';
3
4
  import 'unstorage';
4
5
 
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, f as assert, i as isHexEqual } from './shared/univo.HDazcQ9A.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.CKcWHEHI.mjs';
2
2
 
3
3
  const MAX_LENGTH = 1e4;
4
4
  function defineBlockchain(opts) {
@@ -24,12 +24,16 @@ function defineBlockchain(opts) {
24
24
  }
25
25
  function getHeadBlock() {
26
26
  const block = chain[chain.length - 1];
27
- assert(block !== void 0, "Expected non-empty chain when retrieving latest block");
27
+ if (block === void 0) {
28
+ throw new Error("Expected non-empty chain when retrieving latest block");
29
+ }
28
30
  return block;
29
31
  }
30
32
  function getOldestBlock() {
31
33
  const block = chain[0];
32
- assert(block !== void 0, "Expected non-empty chain when retrieving oldest block");
34
+ if (block === void 0) {
35
+ throw new Error("Expected non-empty chain when retrieving oldest block");
36
+ }
33
37
  return block;
34
38
  }
35
39
  async function reconcile(newBlock) {
@@ -62,7 +66,9 @@ function defineBlockchain(opts) {
62
66
  if (parentBlock === null) {
63
67
  throw new Error(`Failed to fetch parent block ${hexToNumber(newBlock.number)} ${newBlock.parentHash.slice(0, 16)}`);
64
68
  }
65
- assert(isHexEqual(parentBlock.hash, newBlock.parentHash), "Expected block hashes to match");
69
+ if (!isHexEqual(parentBlock.hash, newBlock.parentHash)) {
70
+ throw new Error("Expected block hashes to match");
71
+ }
66
72
  await reconcile(parentBlock);
67
73
  return await reconcile(newBlock);
68
74
  }
@@ -1,4 +1,5 @@
1
- import { Head, Metadata, Filter, Block, Result } from '../index.js';
1
+ import { Head, Metadata, Filter, Block, Result } from './index.mjs';
2
+ import 'unstorage';
2
3
 
3
4
  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
5
  type Flatten<T> = {
@@ -97,35 +98,4 @@ type IndexerRpc = {
97
98
  subscribe: Record<string, never>;
98
99
  };
99
100
 
100
- type Protcol = "http" | "wss";
101
- type Transport<R extends Rpc, P extends Protcol = Protcol> = {
102
- /**
103
- * The underlying transport protocol.
104
- */
105
- protocol: P;
106
- /**
107
- * Performs a JSON RPC request
108
- * @returns The RPC response
109
- */
110
- request: <M extends keyof R["request"]>(opts: {
111
- method: M;
112
- params: Parameters<R["request"][M]>;
113
- }) => Promise<Awaited<ReturnType<R["request"][M]>>>;
114
- /**
115
- * Subscribes to specific event to receive and invoke a callback for a stream of values
116
- * @returns An async function to unsubscribe from the stream
117
- */
118
- subscribe: <M extends keyof R["subscribe"]>(param: M, handler: (message: R["subscribe"][M]) => void) => Promise<() => Promise<void>>;
119
- };
120
- declare function wss<R extends Rpc>(url: string, opts?: {
121
- quiet?: boolean;
122
- }): Transport<R, "wss">;
123
- /**
124
- * HTTP -----------------------------------------------------------------------------------------------------------------------------------
125
- */
126
- declare function http<R extends Rpc>(url: string, opts?: {
127
- signingKey?: string;
128
- }): Transport<R, "http">;
129
-
130
- export { http as h, wss as w };
131
- export type { IndexerRpc as I, NodeRpc as N, Transport as T };
101
+ export type { IndexerRpc, NodeRpc, Rpc };
@@ -1,4 +1,5 @@
1
- import { Head, Metadata, Filter, Block, Result } from '../index.mjs';
1
+ import { Head, Metadata, Filter, Block, Result } from './index.js';
2
+ import 'unstorage';
2
3
 
3
4
  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
5
  type Flatten<T> = {
@@ -97,35 +98,4 @@ type IndexerRpc = {
97
98
  subscribe: Record<string, never>;
98
99
  };
99
100
 
100
- type Protcol = "http" | "wss";
101
- type Transport<R extends Rpc, P extends Protcol = Protcol> = {
102
- /**
103
- * The underlying transport protocol.
104
- */
105
- protocol: P;
106
- /**
107
- * Performs a JSON RPC request
108
- * @returns The RPC response
109
- */
110
- request: <M extends keyof R["request"]>(opts: {
111
- method: M;
112
- params: Parameters<R["request"][M]>;
113
- }) => Promise<Awaited<ReturnType<R["request"][M]>>>;
114
- /**
115
- * Subscribes to specific event to receive and invoke a callback for a stream of values
116
- * @returns An async function to unsubscribe from the stream
117
- */
118
- subscribe: <M extends keyof R["subscribe"]>(param: M, handler: (message: R["subscribe"][M]) => void) => Promise<() => Promise<void>>;
119
- };
120
- declare function wss<R extends Rpc>(url: string, opts?: {
121
- quiet?: boolean;
122
- }): Transport<R, "wss">;
123
- /**
124
- * HTTP -----------------------------------------------------------------------------------------------------------------------------------
125
- */
126
- declare function http<R extends Rpc>(url: string, opts?: {
127
- signingKey?: string;
128
- }): Transport<R, "http">;
129
-
130
- export { http as h, wss as w };
131
- export type { IndexerRpc as I, NodeRpc as N, Transport as T };
101
+ export type { IndexerRpc, NodeRpc, Rpc };
package/dist/rpc.mjs ADDED
@@ -0,0 +1 @@
1
+
@@ -1,5 +1,5 @@
1
1
  const name = "univo";
2
- const version = "0.2.0";
2
+ const version = "0.2.3";
3
3
 
4
4
  function createLogger(opts) {
5
5
  return {
@@ -37,13 +37,6 @@ function createLogger(opts) {
37
37
  }
38
38
  };
39
39
  }
40
- new TextEncoder();
41
- function assert(value, message) {
42
- if (value === false || value === null || value === void 0) {
43
- throw new Error(message ?? `Assertion failed: value is ${String(value)}`);
44
- }
45
- return value;
46
- }
47
40
  const iife = (fn) => fn();
48
41
  function hexToNumber(hex) {
49
42
  return Number.parseInt(hex, 16);
@@ -89,4 +82,4 @@ async function decompress(input) {
89
82
  }
90
83
  const decoder = new TextDecoder();
91
84
 
92
- export { decoder as a, iife as b, createLogger as c, decompress as d, numberToHex as e, assert as f, name as g, hexToNumber as h, isHexEqual as i, compress as j, raise as k, mutex as m, nonNullable as n, retry as r, version as v };
85
+ 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, nonNullable as n, retry as r, version as v };
@@ -1,3 +1,36 @@
1
- export { T as Transport, h as http, w as wss } from './shared/univo.BZ_L9bc2.mjs';
1
+ import { Rpc } from './rpc.mjs';
2
2
  import './index.mjs';
3
3
  import 'unstorage';
4
+
5
+ type Protcol = "http" | "wss";
6
+ type Transport<R extends Rpc, P extends Protcol = Protcol> = {
7
+ /**
8
+ * The underlying transport protocol.
9
+ */
10
+ protocol: P;
11
+ /**
12
+ * Performs a JSON RPC request
13
+ * @returns The RPC response
14
+ */
15
+ request: <M extends keyof R["request"]>(opts: {
16
+ method: M;
17
+ params: Parameters<R["request"][M]>;
18
+ }) => Promise<Awaited<ReturnType<R["request"][M]>>>;
19
+ /**
20
+ * Subscribes to specific event to receive and invoke a callback for a stream of values
21
+ * @returns An async function to unsubscribe from the stream
22
+ */
23
+ subscribe: <M extends keyof R["subscribe"]>(param: M, handler: (message: R["subscribe"][M]) => void) => Promise<() => Promise<void>>;
24
+ };
25
+ declare function wss<R extends Rpc>(url: string, opts?: {
26
+ quiet?: boolean;
27
+ }): Transport<R, "wss">;
28
+ /**
29
+ * HTTP -----------------------------------------------------------------------------------------------------------------------------------
30
+ */
31
+ declare function http<R extends Rpc>(url: string, opts?: {
32
+ signingKey?: string;
33
+ }): Transport<R, "http">;
34
+
35
+ export { http, wss };
36
+ export type { Transport };
@@ -1,3 +1,36 @@
1
- export { T as Transport, h as http, w as wss } from './shared/univo.BWa1smi3.js';
1
+ import { Rpc } from './rpc.js';
2
2
  import './index.js';
3
3
  import 'unstorage';
4
+
5
+ type Protcol = "http" | "wss";
6
+ type Transport<R extends Rpc, P extends Protcol = Protcol> = {
7
+ /**
8
+ * The underlying transport protocol.
9
+ */
10
+ protocol: P;
11
+ /**
12
+ * Performs a JSON RPC request
13
+ * @returns The RPC response
14
+ */
15
+ request: <M extends keyof R["request"]>(opts: {
16
+ method: M;
17
+ params: Parameters<R["request"][M]>;
18
+ }) => Promise<Awaited<ReturnType<R["request"][M]>>>;
19
+ /**
20
+ * Subscribes to specific event to receive and invoke a callback for a stream of values
21
+ * @returns An async function to unsubscribe from the stream
22
+ */
23
+ subscribe: <M extends keyof R["subscribe"]>(param: M, handler: (message: R["subscribe"][M]) => void) => Promise<() => Promise<void>>;
24
+ };
25
+ declare function wss<R extends Rpc>(url: string, opts?: {
26
+ quiet?: boolean;
27
+ }): Transport<R, "wss">;
28
+ /**
29
+ * HTTP -----------------------------------------------------------------------------------------------------------------------------------
30
+ */
31
+ declare function http<R extends Rpc>(url: string, opts?: {
32
+ signingKey?: string;
33
+ }): Transport<R, "http">;
34
+
35
+ export { http, wss };
36
+ export type { Transport };
@@ -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.HDazcQ9A.mjs';
4
+ import { g as compress, j as raise, c as createLogger } from './shared/univo.CKcWHEHI.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.0",
5
+ "version": "0.2.3",
6
6
  "sideEffects": false,
7
7
  "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
@@ -14,6 +14,10 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "import": "./dist/index.mjs"
16
16
  },
17
+ "./rpc": {
18
+ "types": "./dist/rpc.d.ts",
19
+ "import": "./dist/rpc.mjs"
20
+ },
17
21
  "./transport": {
18
22
  "types": "./dist/transport.d.ts",
19
23
  "import": "./dist/transport.mjs"
@@ -29,8 +33,7 @@
29
33
  "scripts": {
30
34
  "test": "vitest",
31
35
  "build": "unbuild",
32
- "univo": "NODE_ENV=production LOG_LEVEL=DEBUG jiti ./src/cli",
33
- "build:release": "pnpm build && changelogen --release --push && pnpm build && npm publish"
36
+ "univo": "NODE_ENV=production LOG_LEVEL=DEBUG jiti ./src/cli"
34
37
  },
35
38
  "dependencies": {
36
39
  "citty": "^0.1.6",