univo 0.2.16 → 0.2.17
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.
|
|
8
|
-
import { c as createLogger, v as version, b as name } from './shared/univo.
|
|
7
|
+
import { h as http } from './shared/univo.DgQqsZEe.mjs';
|
|
8
|
+
import { c as createLogger, v as version, b as name } from './shared/univo.BMmU53c6.mjs';
|
|
9
9
|
|
|
10
10
|
const log = createLogger({ quiet: false });
|
|
11
11
|
const dev = defineCommand({
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorageError } from '@storagesdk/core';
|
|
2
|
-
import { g as getException, c as createException, a as catchException, l as local } from './shared/univo.
|
|
3
|
-
import { c as createLogger, d as decompress, e as decoder, r as retry, v as version, h as hexToNumber, a as isHexEqual, f as normalizeHex, g as compress } from './shared/univo.
|
|
2
|
+
import { g as getException, c as createException, a as catchException, l as local } from './shared/univo.DgQqsZEe.mjs';
|
|
3
|
+
import { c as createLogger, d as decompress, e as decoder, r as retry, v as version, h as hexToNumber, a as isHexEqual, f as normalizeHex, g as compress } from './shared/univo.BMmU53c6.mjs';
|
|
4
4
|
import 'ws';
|
|
5
5
|
import 'partysocket';
|
|
6
6
|
|
package/dist/realtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createLogger, i as iife, h as hexToNumber, n as numberToHex, m as mutex, r as retry, a as isHexEqual } from './shared/univo.
|
|
1
|
+
import { c as createLogger, i as iife, h as hexToNumber, n as numberToHex, m as mutex, r as retry, a as isHexEqual } from './shared/univo.BMmU53c6.mjs';
|
|
2
2
|
|
|
3
3
|
function defineBlockchain(opts) {
|
|
4
4
|
const log = createLogger({ quiet: opts.quiet });
|
|
@@ -97,31 +97,25 @@ function realtime(opts) {
|
|
|
97
97
|
opts.node.request({ method: "eth_getBlockByNumber", params: ["latest", false] }),
|
|
98
98
|
opts.indexer.request({ method: "public_getFinalizedHeight", params: [chain] })
|
|
99
99
|
]);
|
|
100
|
-
let pending = [];
|
|
101
100
|
const latest = defineBlockchain({
|
|
102
101
|
getBlockByHash,
|
|
103
102
|
quiet: opts.quiet ?? false,
|
|
104
103
|
onBlockAdded: async (head) => {
|
|
105
104
|
try {
|
|
106
105
|
log.debug("Received unfinalized head");
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
await opts.indexer.request({ method: "public_writeUnfinalizedHeads", params: [heads] });
|
|
110
|
-
log.debug(`Delivered ${heads.length} unfinalized head(s)`);
|
|
111
|
-
pending = pending.filter((head2) => {
|
|
112
|
-
return !heads.some((_head) => {
|
|
113
|
-
return isHexEqual(head2.hash, _head.hash);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
106
|
+
await retry(() => opts.indexer.request({ method: "public_writeUnfinalizedHead", params: [{ chain, ...head }] }), 2);
|
|
107
|
+
log.debug("Delivered unfinalized head");
|
|
116
108
|
} catch (error) {
|
|
117
109
|
if (error instanceof Error) {
|
|
118
|
-
log.warn(`Failed to write
|
|
110
|
+
log.warn(`Failed to write unfinalized head: ${error.message}`);
|
|
119
111
|
}
|
|
120
112
|
}
|
|
121
113
|
},
|
|
122
114
|
onBlockReorganised: async (head) => {
|
|
123
115
|
try {
|
|
116
|
+
log.debug("Received reorganised head");
|
|
124
117
|
await retry(() => opts.indexer.request({ method: "public_deleteReorganisedHead", params: [{ chain, ...head }] }), 2);
|
|
118
|
+
log.debug("Delivered reorganised head");
|
|
125
119
|
} catch (error) {
|
|
126
120
|
if (error instanceof Error) {
|
|
127
121
|
log.warn(`Failed to write reorganised head: ${error.message}`);
|
|
@@ -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.
|
|
3
|
+
import { g as compress, j as raise, c as createLogger } from './univo.BMmU53c6.mjs';
|
|
4
4
|
|
|
5
5
|
function createException(message) {
|
|
6
6
|
return `univo:${message}`;
|
|
@@ -22,6 +22,7 @@ function getException(unknown) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
const DEFAULT_TIMEOUT = 60 * 1e3;
|
|
25
26
|
const UnknownMethodError = createException("The requested RPC method does not exist on the provided implementation");
|
|
26
27
|
function local(rpc) {
|
|
27
28
|
const request = async (opts) => {
|
|
@@ -114,7 +115,7 @@ function wss(url, opts = {}) {
|
|
|
114
115
|
const timeout = setTimeout(() => {
|
|
115
116
|
requests.delete(body.id);
|
|
116
117
|
reject(new Error("wss request timed out after 30 seconds"));
|
|
117
|
-
},
|
|
118
|
+
}, DEFAULT_TIMEOUT);
|
|
118
119
|
requests.set(body.id, (data) => {
|
|
119
120
|
clearTimeout(timeout);
|
|
120
121
|
requests.delete(body.id);
|
|
@@ -194,7 +195,7 @@ function http(url, opts = {}) {
|
|
|
194
195
|
headers.set("Content-Encoding", "gzip");
|
|
195
196
|
headers.set("Authorization", `Bearer ${opts.signingKey}`);
|
|
196
197
|
}
|
|
197
|
-
const res = await fetch(url, { headers, body, method: "POST", signal: AbortSignal.timeout(
|
|
198
|
+
const res = await fetch(url, { headers, body, method: "POST", signal: AbortSignal.timeout(DEFAULT_TIMEOUT) }).catch((cause) => {
|
|
198
199
|
throw new Error(ClientConnectionError, { cause });
|
|
199
200
|
});
|
|
200
201
|
if (!res.ok || res.status < 200 || res.status >= 300) {
|
package/dist/transport.mjs
CHANGED
|
@@ -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.
|
|
4
|
-
import './shared/univo.
|
|
3
|
+
export { h as http, l as local, w as wss } from './shared/univo.DgQqsZEe.mjs';
|
|
4
|
+
import './shared/univo.BMmU53c6.mjs';
|