@sentio/sdk 1.32.3 → 1.33.0
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/lib/loader.js
CHANGED
package/lib/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI,CAAC,IAAY;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAE3B,IAAI;QACF,IAAI,IAAY,CAAA;QAChB,IAAI;YACF,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;SACrD;QAAC,MAAM;YACN,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SACzB;QAED,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QAChD,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI,CAAC,IAAY;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAE3B,IAAI;QACF,IAAI,IAAY,CAAA;QAChB,IAAI;YACF,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;SACrD;QAAC,MAAM;YACN,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SACzB;QAED,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QAChD,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;QAC1C,OAAO,MAAM,CAAA;KACd;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,uBAAuB,IAAI,GAAG,CAAC,EAAE;YAClF,yBAAyB;YACzB,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAA;YAC/C,OAAO,SAAS,CAAA;SACjB;aAAM;YACL,MAAM,GAAG,CAAA;SACV;KACF;AACH,CAAC;AAvBD,oBAuBC","sourcesContent":["export function load(name: string): { module: any; name: string; path: string } | undefined {\n const req = eval('require')\n\n try {\n let path: string\n try {\n path = req.resolve(name, { paths: [process.cwd()] })\n } catch {\n path = req.resolve(name)\n }\n\n const module = { module: req(path), name, path }\n console.log('Processor Load successfully')\n return module\n } catch (err) {\n if (err instanceof Error && err.message.startsWith(`Cannot find module '${name}'`)) {\n // this error is expected\n console.log(\"Couldn't load (expected): \", name)\n return undefined\n } else {\n throw err\n }\n }\n}\n"]}
|
package/lib/processor-runner.js
CHANGED
|
@@ -56,6 +56,7 @@ const optionDefinitions = [
|
|
|
56
56
|
{ name: 'chainquery-server', type: String, defaultValue: '' },
|
|
57
57
|
{ name: 'pricefeed-server', type: String, defaultValue: '' },
|
|
58
58
|
{ name: 'log-format', type: String, defaultValue: 'console' },
|
|
59
|
+
{ name: 'debug', type: Boolean, defaultValue: false },
|
|
59
60
|
];
|
|
60
61
|
const options = (0, command_line_args_1.default)(optionDefinitions, { partial: true });
|
|
61
62
|
if (options['log-format'] === 'json') {
|
|
@@ -78,13 +79,17 @@ if (options['log-format'] === 'json') {
|
|
|
78
79
|
console.error = (...args) => logger.error.call(logger, ...args);
|
|
79
80
|
console.debug = (...args) => logger.debug.call(logger, ...args);
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
+
if (options.debug) {
|
|
83
|
+
console.log('Starting with', options.target);
|
|
84
|
+
}
|
|
82
85
|
const fullPath = path_1.default.resolve(options['chains-config']);
|
|
83
86
|
const chainsConfig = fs_extra_1.default.readJsonSync(fullPath);
|
|
84
87
|
(0, provider_1.setProvider)(chainsConfig, options.concurrency, options['use-chainserver']);
|
|
85
88
|
globalThis.ENDPOINTS.chainQueryAPI = options['chainquery-server'];
|
|
86
89
|
globalThis.ENDPOINTS.priceFeedAPI = options['pricefeed-server'];
|
|
87
|
-
|
|
90
|
+
if (options.debug) {
|
|
91
|
+
console.log('Starting Server', options);
|
|
92
|
+
}
|
|
88
93
|
const server = (0, nice_grpc_1.createServer)({
|
|
89
94
|
'grpc.max_send_message_length': 128 * 1024 * 1024,
|
|
90
95
|
'grpc.max_receive_message_length': 128 * 1024 * 1024,
|
|
@@ -93,4 +98,5 @@ const server = (0, nice_grpc_1.createServer)({
|
|
|
93
98
|
const service = new service_1.ProcessorServiceImpl(() => (0, loader_1.load)(options.target), server.shutdown);
|
|
94
99
|
server.add(gen_1.ProcessorDefinition, service);
|
|
95
100
|
server.listen('0.0.0.0:' + options.port);
|
|
101
|
+
console.log('Processor Server Started');
|
|
96
102
|
//# sourceMappingURL=processor-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gDAAuB;AACvB,wDAAyB;AACzB,2CAA4B;AAE5B,0EAA+C;AAC/C,yCAAwC;AACxC,qCAA0D;AAC1D,2FAAsF;AAEtF,+BAA2C;AAC3C,uCAAgD;AAChD,yCAAwC;AACxC,6DAAwD;AACxD,qCAA+B;AAC/B,2CAAuC;AAEvC,MAAM,CAAC,eAAe,GAAG,IAAI,gCAAc,EAAE,CAAA;AAC7C,MAAM,CAAC,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAA;AAElC,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,QAAQ,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C,CAAA;AACvD,MAAM,YAAY,GAAG,kBAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;AAE9C,IAAA,sBAAW,EAAC,YAAY,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAC1E,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AACjE,UAAU,CAAC,SAAS,CAAC,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAE/D,IAAI,OAAO,CAAC,KAAK,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;CACxC;AAED,MAAM,MAAM,GAAG,IAAA,wBAAY,EAAC;IAC1B,8BAA8B,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IACjD,iCAAiC,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IACpD,oCAAoC,EAAE,8CAAqB,CAAC,IAAI;CACjE,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAI,8BAAoB,CAAC,GAAG,EAAE,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACrF,MAAM,CAAC,GAAG,CAAC,yBAAmB,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAExC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport * as util from 'util'\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { createLogger, transports, format } from 'winston'\nimport { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'\n\nimport { ProcessorDefinition } from './gen'\nimport { ProcessorServiceImpl } from './service'\nimport { setProvider } from './provider'\nimport { ProcessorState } from './state/processor-state'\nimport { load } from './loader'\nimport { Endpoints } from './endpoints'\n\nglobal.PROCESSOR_STATE = new ProcessorState()\nglobal.ENDPOINTS = new Endpoints()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n { name: 'log-format', type: String, defaultValue: 'console' },\n { name: 'debug', type: Boolean, defaultValue: false },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nif (options['log-format'] === 'json') {\n const utilFormatter = {\n transform: (info: any) => {\n const args = info[Symbol.for('splat')]\n if (args) {\n info.message = util.format(info.message, ...args)\n }\n return info\n },\n }\n const logger = createLogger({\n format: format.combine(\n format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }),\n utilFormatter,\n format.errors({ stack: true }),\n format.json()\n ),\n transports: [new transports.Console()],\n })\n\n console.log = (...args) => logger.info.call(logger, ...args)\n console.info = (...args) => logger.info.call(logger, ...args)\n console.warn = (...args) => logger.warn.call(logger, ...args)\n console.error = (...args) => logger.error.call(logger, ...args)\n console.debug = (...args) => logger.debug.call(logger, ...args)\n}\nif (options.debug) {\n console.log('Starting with', options.target)\n}\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nsetProvider(chainsConfig, options.concurrency, options['use-chainserver'])\nglobalThis.ENDPOINTS.chainQueryAPI = options['chainquery-server']\nglobalThis.ENDPOINTS.priceFeedAPI = options['pricefeed-server']\n\nif (options.debug) {\n console.log('Starting Server', options)\n}\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,\n})\n\nconst service = new ProcessorServiceImpl(() => load(options.target), server.shutdown)\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n\nconsole.log('Processor Server Started')\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.33.0",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
|
|
7
7
|
"compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
|
package/src/loader.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function load(name: string): { module: any; name: string; path: string }
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const module = { module: req(path), name, path }
|
|
13
|
-
console.log('Load successfully
|
|
13
|
+
console.log('Processor Load successfully')
|
|
14
14
|
return module
|
|
15
15
|
} catch (err) {
|
|
16
16
|
if (err instanceof Error && err.message.startsWith(`Cannot find module '${name}'`)) {
|
package/src/processor-runner.ts
CHANGED
|
@@ -33,6 +33,7 @@ const optionDefinitions = [
|
|
|
33
33
|
{ name: 'chainquery-server', type: String, defaultValue: '' },
|
|
34
34
|
{ name: 'pricefeed-server', type: String, defaultValue: '' },
|
|
35
35
|
{ name: 'log-format', type: String, defaultValue: 'console' },
|
|
36
|
+
{ name: 'debug', type: Boolean, defaultValue: false },
|
|
36
37
|
]
|
|
37
38
|
|
|
38
39
|
const options = commandLineArgs(optionDefinitions, { partial: true })
|
|
@@ -63,7 +64,9 @@ if (options['log-format'] === 'json') {
|
|
|
63
64
|
console.error = (...args) => logger.error.call(logger, ...args)
|
|
64
65
|
console.debug = (...args) => logger.debug.call(logger, ...args)
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
+
if (options.debug) {
|
|
68
|
+
console.log('Starting with', options.target)
|
|
69
|
+
}
|
|
67
70
|
|
|
68
71
|
const fullPath = path.resolve(options['chains-config'])
|
|
69
72
|
const chainsConfig = fs.readJsonSync(fullPath)
|
|
@@ -72,7 +75,9 @@ setProvider(chainsConfig, options.concurrency, options['use-chainserver'])
|
|
|
72
75
|
globalThis.ENDPOINTS.chainQueryAPI = options['chainquery-server']
|
|
73
76
|
globalThis.ENDPOINTS.priceFeedAPI = options['pricefeed-server']
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
if (options.debug) {
|
|
79
|
+
console.log('Starting Server', options)
|
|
80
|
+
}
|
|
76
81
|
|
|
77
82
|
const server = createServer({
|
|
78
83
|
'grpc.max_send_message_length': 128 * 1024 * 1024,
|
|
@@ -84,3 +89,5 @@ const service = new ProcessorServiceImpl(() => load(options.target), server.shut
|
|
|
84
89
|
server.add(ProcessorDefinition, service)
|
|
85
90
|
|
|
86
91
|
server.listen('0.0.0.0:' + options.port)
|
|
92
|
+
|
|
93
|
+
console.log('Processor Server Started')
|
|
@@ -7,7 +7,7 @@ const rewardPerBlock = Gauge.register('reward_per_block', {
|
|
|
7
7
|
description: 'rewards for each block grouped by phase',
|
|
8
8
|
unit: 'x2y2',
|
|
9
9
|
})
|
|
10
|
-
const tokenCounter =
|
|
10
|
+
const tokenCounter = Counter.register('token')
|
|
11
11
|
|
|
12
12
|
X2y2Processor.bind({ address: '0xB329e39Ebefd16f40d38f07643652cE17Ca5Bac1' }).onBlockInterval(async (_, ctx) => {
|
|
13
13
|
const phase = (await ctx.contract.currentPhase()).toString()
|