@certik/skynet 0.18.4 → 0.18.6
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/.vscode/settings.json +5 -0
- package/CHANGELOG.md +8 -0
- package/app.d.ts +1 -33
- package/bun.lockb +0 -0
- package/cli.js +1 -6
- package/const.js +6 -6
- package/date.js +1 -6
- package/env.js +1 -8
- package/examples/api.js +0 -0
- package/examples/consumer.js +0 -0
- package/examples/indexer.js +0 -0
- package/examples/mode-indexer.js +0 -0
- package/examples/producer.js +0 -0
- package/indexer.js +21 -21
- package/log.js +5 -7
- package/package.json +2 -2
- package/selector.d.ts +1 -1
- package/selector.js +2 -7
- package/snowflake.js +1 -4
- package/util.js +1 -7
- package/web3.js +1 -5
package/CHANGELOG.md
CHANGED
package/app.d.ts
CHANGED
|
@@ -23,15 +23,6 @@ export type Serve = {
|
|
|
23
23
|
instances?: number;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export type Consume = {
|
|
27
|
-
func: ({ protocol, messages, verbose }: { protocol: string; messages: any; verbose: boolean }) => Promise<void>;
|
|
28
|
-
topic: ({ protocol }: { protocol: string }) => string;
|
|
29
|
-
maxRetry?: number;
|
|
30
|
-
killTimeout?: string;
|
|
31
|
-
cpu: number;
|
|
32
|
-
mem: number;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
26
|
export type State = {
|
|
36
27
|
type: string;
|
|
37
28
|
updateInterval: ({ protocol }: { protocol: string }) => number;
|
|
@@ -39,29 +30,6 @@ export type State = {
|
|
|
39
30
|
getMaxId: ({ protocol }: { protocol: string }) => Promise<number>;
|
|
40
31
|
};
|
|
41
32
|
|
|
42
|
-
export type Produce = {
|
|
43
|
-
func: ({
|
|
44
|
-
protocol,
|
|
45
|
-
from,
|
|
46
|
-
to,
|
|
47
|
-
verbose,
|
|
48
|
-
send,
|
|
49
|
-
}: {
|
|
50
|
-
protocol: string;
|
|
51
|
-
from: number;
|
|
52
|
-
to: number;
|
|
53
|
-
verbose: boolean;
|
|
54
|
-
send: (items: { id: string; name: string }[]) => Promise<void>;
|
|
55
|
-
}) => Promise<void>;
|
|
56
|
-
topic: ({ protocol }) => string;
|
|
57
|
-
deadLetterTopic: ({ protocol }) => string;
|
|
58
|
-
batchSize: number;
|
|
59
|
-
maxRetry?: number;
|
|
60
|
-
killTimeout?: string;
|
|
61
|
-
cpu: number;
|
|
62
|
-
mem: number;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
33
|
export type Schedule = string | ((jobName: string) => string);
|
|
66
34
|
|
|
67
35
|
export type Check = {
|
|
@@ -78,7 +46,7 @@ export type Check = {
|
|
|
78
46
|
|
|
79
47
|
export type Build = {
|
|
80
48
|
func: ({ protocol, from, to, verbose }: { protocol: string; from: number; to: number; verbose: boolean }) => void;
|
|
81
|
-
batchSize
|
|
49
|
+
batchSize?: number;
|
|
82
50
|
schedule: Schedule;
|
|
83
51
|
killTimeout?: string;
|
|
84
52
|
cpu: number;
|
package/bun.lockb
CHANGED
|
File without changes
|
package/cli.js
CHANGED
|
@@ -45,9 +45,4 @@ function detectBin() {
|
|
|
45
45
|
return process.argv[1].slice(wd.length + path.sep.length).replace(path.sep, "/");
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export {
|
|
49
|
-
getBinaryName,
|
|
50
|
-
detectSkynetDirectory,
|
|
51
|
-
detectWorkingDirectory,
|
|
52
|
-
detectBin,
|
|
53
|
-
};
|
|
48
|
+
export { getBinaryName, detectSkynetDirectory, detectWorkingDirectory, detectBin };
|
package/const.js
CHANGED
|
@@ -6,7 +6,7 @@ const PROTOCOLS = {
|
|
|
6
6
|
nativeTokenSymbol: "ETH",
|
|
7
7
|
nativeTokenDecimals: 18,
|
|
8
8
|
nativeTokenAddress: "eth:0x0000000000000000000000000000000000000000",
|
|
9
|
-
nativeTokenLogo: `https://
|
|
9
|
+
nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/eth:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
|
|
10
10
|
nativeTokenCoinGeckoId: "ethereum",
|
|
11
11
|
nativeTokenCmcId: 1027,
|
|
12
12
|
endpoint: `https://eth-mainnet.nodereal.io/v1/${getNodeRealApiKey("ETH")}`,
|
|
@@ -25,7 +25,7 @@ const PROTOCOLS = {
|
|
|
25
25
|
nativeTokenSymbol: "BNB",
|
|
26
26
|
nativeTokenDecimals: 18,
|
|
27
27
|
nativeTokenAddress: "bsc:0x0000000000000000000000000000000000000000",
|
|
28
|
-
nativeTokenLogo: `https://
|
|
28
|
+
nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/bsc:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
|
|
29
29
|
nativeTokenCoinGeckoId: "binance-coin",
|
|
30
30
|
nativeTokenCmcId: 1839,
|
|
31
31
|
endpoint: `https://bsc-mainnet.nodereal.io/v1/${getNodeRealApiKey("BSC")}`,
|
|
@@ -44,7 +44,7 @@ const PROTOCOLS = {
|
|
|
44
44
|
nativeTokenSymbol: "MATIC",
|
|
45
45
|
nativeTokenDecimals: 18,
|
|
46
46
|
nativeTokenAddress: "polygon:0x0000000000000000000000000000000000000000",
|
|
47
|
-
nativeTokenLogo: `https://
|
|
47
|
+
nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/polygon:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
|
|
48
48
|
nativeTokenCoinGeckoId: "matic-network",
|
|
49
49
|
nativeTokenCmcId: 3890,
|
|
50
50
|
endpoint: `https://polygon-mainnet.nodereal.io/v1/${getNodeRealApiKey("POLYGON")}`,
|
|
@@ -75,7 +75,7 @@ const PROTOCOLS = {
|
|
|
75
75
|
nativeTokenSymbol: "AVAX",
|
|
76
76
|
nativeTokenDecimals: 18,
|
|
77
77
|
nativeTokenAddress: "avax:0x0000000000000000000000000000000000000000",
|
|
78
|
-
nativeTokenLogo: `https://
|
|
78
|
+
nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/avax:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
|
|
79
79
|
nativeTokenCoinGeckoId: "avalanche-2",
|
|
80
80
|
nativeTokenCmcId: 5805,
|
|
81
81
|
endpoint: `https://api.avax.network/ext/bc/C/rpc`,
|
|
@@ -92,7 +92,7 @@ const PROTOCOLS = {
|
|
|
92
92
|
nativeTokenSymbol: "FTM",
|
|
93
93
|
nativeTokenDecimals: 18,
|
|
94
94
|
nativeTokenAddress: "ftm:0x0000000000000000000000000000000000000000",
|
|
95
|
-
nativeTokenLogo: `https://
|
|
95
|
+
nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/ftm:0x0000000000000000000000000000000000000000.png`, // TODO: Can replace domain if needed
|
|
96
96
|
nativeTokenCoinGeckoId: "fantom",
|
|
97
97
|
nativeTokenCmcId: 3513,
|
|
98
98
|
endpoint: `https://rpcapi.fantom.network`,
|
|
@@ -109,7 +109,7 @@ const PROTOCOLS = {
|
|
|
109
109
|
nativeTokenSymbol: "ALGO",
|
|
110
110
|
nativeTokenDecimals: 6,
|
|
111
111
|
nativeTokenAddress: "algo:native",
|
|
112
|
-
nativeTokenLogo: `https://
|
|
112
|
+
nativeTokenLogo: `https://d1w63vqp8iwj2x.cloudfront.net/algo:native.png`,
|
|
113
113
|
nativeTokenCoinGeckoId: "algorand",
|
|
114
114
|
nativeTokenCmcId: 4030,
|
|
115
115
|
endpoint: "https://algo-node.certik-skynet.com/",
|
package/date.js
CHANGED
package/env.js
CHANGED
|
@@ -39,11 +39,4 @@ function isDev() {
|
|
|
39
39
|
return getEnvironment() === "dev";
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export {
|
|
43
|
-
ensureAndGet,
|
|
44
|
-
getEnvOrThrow,
|
|
45
|
-
getEnvironment,
|
|
46
|
-
isProduction,
|
|
47
|
-
isDev,
|
|
48
|
-
getNodeRealApiKey,
|
|
49
|
-
};
|
|
42
|
+
export { ensureAndGet, getEnvOrThrow, getEnvironment, isProduction, isDev, getNodeRealApiKey };
|
package/examples/api.js
CHANGED
|
File without changes
|
package/examples/consumer.js
CHANGED
|
File without changes
|
package/examples/indexer.js
CHANGED
|
File without changes
|
package/examples/mode-indexer.js
CHANGED
|
File without changes
|
package/examples/producer.js
CHANGED
|
File without changes
|
package/indexer.js
CHANGED
|
@@ -200,8 +200,8 @@ function createModeIndexerApp({
|
|
|
200
200
|
inline.log(
|
|
201
201
|
`[MODE INDEXER] building range, from=${from}, to=${to}, ${toSelectorString(
|
|
202
202
|
selectorFlags,
|
|
203
|
-
", "
|
|
204
|
-
)}, batchSize=${buildBatchSize}, concurrency=${buildConcurrency}
|
|
203
|
+
", ",
|
|
204
|
+
)}, batchSize=${buildBatchSize}, concurrency=${buildConcurrency}`,
|
|
205
205
|
);
|
|
206
206
|
|
|
207
207
|
const failedIds = await execBuild(selectorFlags, from, to, verbose, false);
|
|
@@ -226,14 +226,14 @@ function createModeIndexerApp({
|
|
|
226
226
|
inline.log(
|
|
227
227
|
`[MODE INDEXER] validating, from=${from}, to=${to}, ${toSelectorString(
|
|
228
228
|
selectorFlags,
|
|
229
|
-
", "
|
|
230
|
-
)}, batchSize=${validateBatchSize}, concurrency=${validateConcurrency}
|
|
229
|
+
", ",
|
|
230
|
+
)}, batchSize=${validateBatchSize}, concurrency=${validateConcurrency}`,
|
|
231
231
|
);
|
|
232
232
|
|
|
233
233
|
const windows = range(from, to, validateBatchSize * validateConcurrency);
|
|
234
234
|
|
|
235
235
|
inline.log(
|
|
236
|
-
`[MODE INDEXER] from=${from}, to=${to}, batchSize=${validateBatchSize}, concurrency=${validateConcurrency}
|
|
236
|
+
`[MODE INDEXER] from=${from}, to=${to}, batchSize=${validateBatchSize}, concurrency=${validateConcurrency}`,
|
|
237
237
|
);
|
|
238
238
|
|
|
239
239
|
for (let [windowStart, windowEnd] of windows) {
|
|
@@ -265,13 +265,13 @@ function createModeIndexerApp({
|
|
|
265
265
|
maxRetry,
|
|
266
266
|
test: (r) => r,
|
|
267
267
|
verbose,
|
|
268
|
-
}
|
|
268
|
+
},
|
|
269
269
|
);
|
|
270
270
|
|
|
271
271
|
if (!result) {
|
|
272
272
|
throw new Error(`Terminate validation due to critical errors, from=${batchStart}, to=${batchEnd}`);
|
|
273
273
|
}
|
|
274
|
-
})
|
|
274
|
+
}),
|
|
275
275
|
);
|
|
276
276
|
|
|
277
277
|
if (shouldSaveState) {
|
|
@@ -287,7 +287,7 @@ function createModeIndexerApp({
|
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
inline.log(
|
|
290
|
-
`[MODE INDEXER] validated ${offsetRange(from, to)} ${finalState.type} successfully in ${Date.now() - startTime}ms
|
|
290
|
+
`[MODE INDEXER] validated ${offsetRange(from, to)} ${finalState.type} successfully in ${Date.now() - startTime}ms`,
|
|
291
291
|
);
|
|
292
292
|
}
|
|
293
293
|
|
|
@@ -329,9 +329,9 @@ function createModeIndexerApp({
|
|
|
329
329
|
maxRetry,
|
|
330
330
|
test: (r) => !r,
|
|
331
331
|
verbose,
|
|
332
|
-
}
|
|
332
|
+
},
|
|
333
333
|
);
|
|
334
|
-
})
|
|
334
|
+
}),
|
|
335
335
|
);
|
|
336
336
|
|
|
337
337
|
if (shouldSaveState) {
|
|
@@ -363,8 +363,8 @@ function createModeIndexerApp({
|
|
|
363
363
|
inline.log(
|
|
364
364
|
`[MODE INDEXER] rebuilding, from=${from}, to=${to}, ${toSelectorString(
|
|
365
365
|
selectorFlags,
|
|
366
|
-
", "
|
|
367
|
-
)}, batchSize=${buildBatchSize}, concurrency=${buildConcurrency}
|
|
366
|
+
", ",
|
|
367
|
+
)}, batchSize=${buildBatchSize}, concurrency=${buildConcurrency}`,
|
|
368
368
|
);
|
|
369
369
|
|
|
370
370
|
// add a flag to stop delta from running
|
|
@@ -390,14 +390,14 @@ function createModeIndexerApp({
|
|
|
390
390
|
if (failedIds.length > 0) {
|
|
391
391
|
inline.log(
|
|
392
392
|
`[MODE INDEXER] built ${offsetRange(from, to)} ${finalState.type}(s) with some failed ${finalState.type}`,
|
|
393
|
-
failedIds
|
|
393
|
+
failedIds,
|
|
394
394
|
);
|
|
395
395
|
process.exit(1);
|
|
396
396
|
} else {
|
|
397
397
|
inline.log(
|
|
398
398
|
`[MODE INDEXER] built ${offsetRange(from, to)} ${finalState.type}(s) successfully in ${
|
|
399
399
|
Date.now() - startTime
|
|
400
|
-
}ms
|
|
400
|
+
}ms`,
|
|
401
401
|
);
|
|
402
402
|
process.exit(0);
|
|
403
403
|
}
|
|
@@ -410,8 +410,8 @@ function createModeIndexerApp({
|
|
|
410
410
|
inline.log(
|
|
411
411
|
`[MODE INDEXER] skip delta, there're no more items need to be processed, from=${from}, to=${to}, ${toSelectorString(
|
|
412
412
|
selectorFlags,
|
|
413
|
-
", "
|
|
414
|
-
)}
|
|
413
|
+
", ",
|
|
414
|
+
)}`,
|
|
415
415
|
);
|
|
416
416
|
|
|
417
417
|
return;
|
|
@@ -420,8 +420,8 @@ function createModeIndexerApp({
|
|
|
420
420
|
inline.log(
|
|
421
421
|
`[MODE INDEXER] starting delta, from=${from}, to=${to}, ${toSelectorString(
|
|
422
422
|
selectorFlags,
|
|
423
|
-
", "
|
|
424
|
-
)}, batchSize=${buildBatchSize}, concurrency=${buildConcurrency}
|
|
423
|
+
", ",
|
|
424
|
+
)}, batchSize=${buildBatchSize}, concurrency=${buildConcurrency}`,
|
|
425
425
|
);
|
|
426
426
|
|
|
427
427
|
try {
|
|
@@ -532,7 +532,7 @@ ${getSelectorDesc(selector)}
|
|
|
532
532
|
default: false,
|
|
533
533
|
},
|
|
534
534
|
},
|
|
535
|
-
}
|
|
535
|
+
},
|
|
536
536
|
);
|
|
537
537
|
|
|
538
538
|
return runMode(cli.flags).catch((err) => {
|
|
@@ -573,7 +573,7 @@ ${getSelectorDesc(selector)}
|
|
|
573
573
|
default: false,
|
|
574
574
|
},
|
|
575
575
|
},
|
|
576
|
-
}
|
|
576
|
+
},
|
|
577
577
|
);
|
|
578
578
|
|
|
579
579
|
async function runBuild({ verbose, ...selectorFlags }) {
|
|
@@ -601,7 +601,7 @@ ${getSelectorDesc(selector)}
|
|
|
601
601
|
maxRetry,
|
|
602
602
|
test: (r) => r,
|
|
603
603
|
verbose,
|
|
604
|
-
}
|
|
604
|
+
},
|
|
605
605
|
);
|
|
606
606
|
|
|
607
607
|
if (!result) {
|
package/log.js
CHANGED
|
@@ -4,11 +4,13 @@ function isObject(a) {
|
|
|
4
4
|
|
|
5
5
|
function print(o) {
|
|
6
6
|
if (Array.isArray(o)) {
|
|
7
|
-
return `[${o.map(print).join(", ")}]
|
|
7
|
+
return `[${o.map(print).join(", ")}]`;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
if (isObject(o)) {
|
|
11
|
-
return `{${Object.keys(o)
|
|
11
|
+
return `{${Object.keys(o)
|
|
12
|
+
.map((k) => `${k}: ${o[k]}`)
|
|
13
|
+
.join(", ")}}`;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
return `${o}`;
|
|
@@ -40,8 +42,4 @@ const inline = {
|
|
|
40
42
|
},
|
|
41
43
|
};
|
|
42
44
|
|
|
43
|
-
export {
|
|
44
|
-
getLine,
|
|
45
|
-
print,
|
|
46
|
-
inline,
|
|
47
|
-
};
|
|
45
|
+
export { getLine, print, inline };
|
package/package.json
CHANGED
package/selector.d.ts
CHANGED
package/selector.js
CHANGED
|
@@ -22,7 +22,7 @@ function getSelectorFlags(selector) {
|
|
|
22
22
|
return Object.keys(selector).reduce((acc, name) => {
|
|
23
23
|
const flag = {
|
|
24
24
|
type: selector[name].type || "string",
|
|
25
|
-
...selector[name]
|
|
25
|
+
...selector[name],
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
// by default to be required
|
|
@@ -68,9 +68,4 @@ function getJobName(name, selectorFlags, mode = null) {
|
|
|
68
68
|
return jobName;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export {
|
|
72
|
-
getJobName,
|
|
73
|
-
getSelectorDesc,
|
|
74
|
-
getSelectorFlags,
|
|
75
|
-
toSelectorString,
|
|
76
|
-
};
|
|
71
|
+
export { getJobName, getSelectorDesc, getSelectorFlags, toSelectorString };
|
package/snowflake.js
CHANGED
package/util.js
CHANGED
package/web3.js
CHANGED
|
@@ -110,8 +110,4 @@ async function multiCall({ protocol, limiter = null, target, abi, calls }) {
|
|
|
110
110
|
return { actualCallCount: callChunks.length, output: responses };
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
export {
|
|
114
|
-
newWeb3ByProtocol,
|
|
115
|
-
singleCall,
|
|
116
|
-
multiCall,
|
|
117
|
-
};
|
|
113
|
+
export { newWeb3ByProtocol, singleCall, multiCall };
|