univo 0.4.2 → 0.4.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 +1 -1
- package/dist/index.mjs +13 -2
- package/dist/proxy.mjs +40 -54
- package/dist/realtime.mjs +2 -1
- package/dist/shared/{univo.CUNaTwXY.mjs → univo.DEUuEEoe.mjs} +2 -2
- package/dist/transport.mjs +1 -1
- package/package.json +1 -1
- package/dist/shared/univo.C0flyVee.mjs +0 -21
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,
|
|
8
|
+
import { c as createLogger, v as version, n as name } from './shared/univo.DEUuEEoe.mjs';
|
|
9
9
|
|
|
10
10
|
const log = createLogger({ quiet: false });
|
|
11
11
|
const dev = defineCommand({
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { hexToNumber, numberToHex, hexToBytes, keccak256, toRlp, hexToBigInt, numberToBytes, isHex, concatBytes, concatHex, formatTransaction, serializeTransaction } from 'viem';
|
|
2
2
|
import { local } from './transport.mjs';
|
|
3
|
-
import { c as createLogger, r as retry, v as version,
|
|
3
|
+
import { c as createLogger, r as retry, v as version, d as normalizeHex, e as decompress, a as isHexEqual, b as compress, i as iife, f as decoder } from './shared/univo.DEUuEEoe.mjs';
|
|
4
4
|
import { AdapterError } from './metadata/adapters.mjs';
|
|
5
|
-
import { c as createException, a as catchException } from './shared/univo.C0flyVee.mjs';
|
|
6
5
|
import 'ws';
|
|
7
6
|
import 'partysocket';
|
|
8
7
|
|
|
8
|
+
function createException(message) {
|
|
9
|
+
return `univo:${message}`;
|
|
10
|
+
}
|
|
11
|
+
function catchException(unknown, exception) {
|
|
12
|
+
if (unknown instanceof Error) {
|
|
13
|
+
if (unknown.message === exception) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
function matchFilter(block, filter) {
|
|
10
21
|
if (hexToNumber(block.eth_chainId) !== filter.chain) {
|
|
11
22
|
return false;
|
package/dist/proxy.mjs
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createLogger, d as decompress, e as decoder } from './shared/univo.CUNaTwXY.mjs';
|
|
1
|
+
import { c as createLogger } from './shared/univo.DEUuEEoe.mjs';
|
|
3
2
|
|
|
4
3
|
function http(opts) {
|
|
5
4
|
const log = createLogger({ quiet: opts.quiet, prefix: "[proxy]" });
|
|
6
5
|
return async function proxy(req) {
|
|
7
|
-
|
|
6
|
+
const authorization = req.headers.get("Authorization");
|
|
7
|
+
const compressed = req.headers.get("Content-Encoding") === "gzip";
|
|
8
|
+
const authenticated = authorization === `Bearer ${opts.signingKey}`;
|
|
9
|
+
if (compressed && (!authorization || !authenticated)) {
|
|
10
|
+
return Response.json(
|
|
11
|
+
{ jsonrpc: "2.0", id: null, error: { code: 0, message: "Invalid bearer token" } },
|
|
12
|
+
//
|
|
13
|
+
{ status: 400 }
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
let body_string = "";
|
|
8
17
|
try {
|
|
9
|
-
|
|
18
|
+
if (compressed) {
|
|
19
|
+
if (!req.body) {
|
|
20
|
+
throw new Error("Missing compressed request body");
|
|
21
|
+
}
|
|
22
|
+
const reader = req.body.pipeThrough(new DecompressionStream("gzip")).pipeThrough(new TextDecoderStream()).getReader();
|
|
23
|
+
try {
|
|
24
|
+
while (true) {
|
|
25
|
+
const { done, value } = await reader.read();
|
|
26
|
+
if (done) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
body_string += value;
|
|
30
|
+
}
|
|
31
|
+
} finally {
|
|
32
|
+
reader.releaseLock();
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
body_string = await req.text();
|
|
36
|
+
}
|
|
10
37
|
} catch {
|
|
11
38
|
return Response.json(
|
|
12
39
|
{ jsonrpc: "2.0", id: null, error: { code: 0, message: "Invalid request body" } },
|
|
@@ -14,28 +41,6 @@ function http(opts) {
|
|
|
14
41
|
{ status: 400 }
|
|
15
42
|
);
|
|
16
43
|
}
|
|
17
|
-
const authorization = req.headers.get("Authorization");
|
|
18
|
-
const authenticated = authorization === `Bearer ${opts.signingKey}`;
|
|
19
|
-
let body_string;
|
|
20
|
-
if (req.headers.get("Content-Encoding") === "gzip") {
|
|
21
|
-
if (!authorization) {
|
|
22
|
-
return Response.json(
|
|
23
|
-
{ jsonrpc: "2.0", id: null, error: { code: 0, message: "No bearer token provided" } },
|
|
24
|
-
//
|
|
25
|
-
{ status: 400 }
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
if (!authenticated) {
|
|
29
|
-
return Response.json(
|
|
30
|
-
{ jsonrpc: "2.0", id: null, error: { code: 0, message: "Invalid bearer token" } },
|
|
31
|
-
//
|
|
32
|
-
{ status: 400 }
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
body_string = await decompress(body_buffer);
|
|
36
|
-
} else {
|
|
37
|
-
body_string = decoder.decode(body_buffer);
|
|
38
|
-
}
|
|
39
44
|
let json;
|
|
40
45
|
try {
|
|
41
46
|
json = JSON.parse(body_string);
|
|
@@ -46,40 +51,21 @@ function http(opts) {
|
|
|
46
51
|
{ status: 400 }
|
|
47
52
|
);
|
|
48
53
|
}
|
|
49
|
-
if (json.method.startsWith("private_")) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (authorization !== `Bearer ${opts.signingKey}`) {
|
|
58
|
-
return Response.json(
|
|
59
|
-
{ jsonrpc: "2.0", id: json.id, error: { code: 0, message: "Invalid bearer token" } },
|
|
60
|
-
//
|
|
61
|
-
{ status: 400 }
|
|
62
|
-
);
|
|
63
|
-
}
|
|
54
|
+
if (json.method.startsWith("private_") && (!authorization || !authenticated)) {
|
|
55
|
+
return Response.json(
|
|
56
|
+
{ jsonrpc: "2.0", id: json.id, error: { code: 0, message: "Invalid bearer token" } },
|
|
57
|
+
//
|
|
58
|
+
{ status: 400 }
|
|
59
|
+
);
|
|
64
60
|
}
|
|
65
61
|
try {
|
|
66
62
|
const result = await opts.indexer.request({ method: json.method, params: json.params });
|
|
67
63
|
return Response.json({ jsonrpc: "2.0", id: json.id, result });
|
|
68
64
|
} catch (error) {
|
|
69
|
-
const message =
|
|
70
|
-
|
|
71
|
-
log.error(message);
|
|
72
|
-
return Response.json(
|
|
73
|
-
{ jsonrpc: "2.0", id: json.id, error: { code: 0, message } },
|
|
74
|
-
//
|
|
75
|
-
{ status: 400 }
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
if (error instanceof Error) {
|
|
79
|
-
log.error(error.message);
|
|
80
|
-
}
|
|
65
|
+
const message = error instanceof Error ? error.message : "Internal error";
|
|
66
|
+
log.error(message);
|
|
81
67
|
return Response.json(
|
|
82
|
-
{ jsonrpc: "2.0", id: json.id, error: { code: 0, message
|
|
68
|
+
{ jsonrpc: "2.0", id: json.id, error: { code: 0, message } },
|
|
83
69
|
//
|
|
84
70
|
{ status: 500 }
|
|
85
71
|
);
|
package/dist/realtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hexToNumber } from 'viem';
|
|
2
|
-
import { c as createLogger,
|
|
2
|
+
import { c as createLogger, i as iife, m as mutex, l as lifecycle, q as queue, r as retry, a as isHexEqual } from './shared/univo.DEUuEEoe.mjs';
|
|
3
3
|
|
|
4
4
|
function defineBlockchain(opts) {
|
|
5
5
|
const log = createLogger({ quiet: opts.quiet });
|
|
@@ -182,6 +182,7 @@ function realtime(realtime2) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
const mutex_finalize = mutex(finalize);
|
|
185
|
+
void mutex_finalize();
|
|
185
186
|
let chainFinalizedHeight = hexToNumber(chainFinalizedBlock.number);
|
|
186
187
|
async function poll() {
|
|
187
188
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const name = "univo";
|
|
2
|
-
const version = "0.4.
|
|
2
|
+
const version = "0.4.3";
|
|
3
3
|
|
|
4
4
|
function createLogger(opts) {
|
|
5
5
|
const noop = (..._) => {
|
|
@@ -159,4 +159,4 @@ const normalizeHex = (hex, length) => {
|
|
|
159
159
|
return `0x${hex.slice(2).toLowerCase().padStart(length, "0")}`;
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
-
export {
|
|
162
|
+
export { isHexEqual as a, compress as b, createLogger as c, normalizeHex as d, decompress as e, decoder as f, iife as i, lifecycle as l, mutex as m, name as n, queue as q, retry as r, version as v };
|
package/dist/transport.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ws from 'ws';
|
|
2
2
|
import { WebSocket } from 'partysocket';
|
|
3
|
-
import {
|
|
3
|
+
import { b as compress, c as createLogger, m as mutex } from './shared/univo.DEUuEEoe.mjs';
|
|
4
4
|
|
|
5
5
|
const DEFAULT_TIMEOUT_MS = 60 * 1e3;
|
|
6
6
|
function local(rpc) {
|
package/package.json
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
function createException(message) {
|
|
2
|
-
return `univo:${message}`;
|
|
3
|
-
}
|
|
4
|
-
function catchException(unknown, exception) {
|
|
5
|
-
if (unknown instanceof Error) {
|
|
6
|
-
if (unknown.message === exception) {
|
|
7
|
-
return true;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
function getException(unknown) {
|
|
13
|
-
if (unknown instanceof Error) {
|
|
14
|
-
if (unknown.message.startsWith("univo")) {
|
|
15
|
-
const [_, message] = unknown.message.split(":");
|
|
16
|
-
if (message) return message;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { catchException as a, createException as c, getException as g };
|