@sentio/sdk 1.32.2 → 1.32.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/lib/processor-runner.js
CHANGED
|
@@ -1,19 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
3
26
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
28
|
};
|
|
6
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
32
|
+
const util = __importStar(require("util"));
|
|
7
33
|
const command_line_args_1 = __importDefault(require("command-line-args"));
|
|
8
34
|
const nice_grpc_1 = require("nice-grpc");
|
|
35
|
+
const winston_1 = require("winston");
|
|
36
|
+
const compression_algorithms_1 = require("@grpc/grpc-js/build/src/compression-algorithms");
|
|
9
37
|
const gen_1 = require("./gen");
|
|
10
38
|
const service_1 = require("./service");
|
|
11
39
|
const provider_1 = require("./provider");
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
14
40
|
const processor_state_1 = require("./state/processor-state");
|
|
15
41
|
const loader_1 = require("./loader");
|
|
16
|
-
const compression_algorithms_1 = require("@grpc/grpc-js/build/src/compression-algorithms");
|
|
17
42
|
const endpoints_1 = require("./endpoints");
|
|
18
43
|
global.PROCESSOR_STATE = new processor_state_1.ProcessorState();
|
|
19
44
|
global.ENDPOINTS = new endpoints_1.Endpoints();
|
|
@@ -30,8 +55,29 @@ const optionDefinitions = [
|
|
|
30
55
|
},
|
|
31
56
|
{ name: 'chainquery-server', type: String, defaultValue: '' },
|
|
32
57
|
{ name: 'pricefeed-server', type: String, defaultValue: '' },
|
|
58
|
+
{ name: 'log-format', type: String, defaultValue: 'console' },
|
|
33
59
|
];
|
|
34
60
|
const options = (0, command_line_args_1.default)(optionDefinitions, { partial: true });
|
|
61
|
+
if (options['log-format'] === 'json') {
|
|
62
|
+
const utilFormatter = {
|
|
63
|
+
transform: (info) => {
|
|
64
|
+
const args = info[Symbol.for('splat')];
|
|
65
|
+
if (args) {
|
|
66
|
+
info.message = util.format(info.message, ...args);
|
|
67
|
+
}
|
|
68
|
+
return info;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
const logger = (0, winston_1.createLogger)({
|
|
72
|
+
format: winston_1.format.combine(winston_1.format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }), utilFormatter, winston_1.format.errors({ stack: true }), winston_1.format.json()),
|
|
73
|
+
transports: [new winston_1.transports.Console()],
|
|
74
|
+
});
|
|
75
|
+
console.log = (...args) => logger.info.call(logger, ...args);
|
|
76
|
+
console.info = (...args) => logger.info.call(logger, ...args);
|
|
77
|
+
console.warn = (...args) => logger.warn.call(logger, ...args);
|
|
78
|
+
console.error = (...args) => logger.error.call(logger, ...args);
|
|
79
|
+
console.debug = (...args) => logger.debug.call(logger, ...args);
|
|
80
|
+
}
|
|
35
81
|
console.log('loading', options.target);
|
|
36
82
|
const fullPath = path_1.default.resolve(options['chains-config']);
|
|
37
83
|
const chainsConfig = fs_extra_1.default.readJsonSync(fullPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":"
|
|
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,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IAChE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE;IACtD,EAAE,IAAI,EAAE,i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C,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AAEpC,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","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]\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}\nconsole.log('loading', options.target)\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\nconsole.log('Start Server', options)\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"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentio/sdk",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "1.32.
|
|
4
|
+
"version": "1.32.3",
|
|
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",
|
|
8
8
|
"build": "yarn gen && yarn compile",
|
|
9
|
-
"start_ts": "ts-node --files src/processor-runner.ts ../examples/x2y2/src/processor.ts",
|
|
9
|
+
"start_ts": "ts-node --files src/processor-runner.ts --log-format=json ../examples/x2y2/src/processor.ts",
|
|
10
10
|
"start": "ts-node --files src/processor-runner.ts ../examples/aptos/dist/lib.js",
|
|
11
11
|
"start_js": "node lib/processor-runner.js ../examples/aptos/dist/lib.js",
|
|
12
12
|
"ts-start": "ts-node --files src/processor-runner.ts ./src/anyswap/src/processor.ts",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"ts-loader": "^9.3.0",
|
|
51
51
|
"typechain": "^8.0.0",
|
|
52
52
|
"webpack": "^5.72.1",
|
|
53
|
-
"webpack-cli": "^4.9.2"
|
|
53
|
+
"webpack-cli": "^4.9.2",
|
|
54
|
+
"winston": "^3.8.2"
|
|
54
55
|
},
|
|
55
56
|
"resolutions": {
|
|
56
57
|
"@grpc/grpc-js": "1.7.3"
|
package/src/processor-runner.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import fs from 'fs-extra'
|
|
5
|
+
import * as util from 'util'
|
|
6
|
+
|
|
3
7
|
import commandLineArgs from 'command-line-args'
|
|
4
8
|
import { createServer } from 'nice-grpc'
|
|
9
|
+
import { createLogger, transports, format } from 'winston'
|
|
10
|
+
import { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'
|
|
11
|
+
|
|
5
12
|
import { ProcessorDefinition } from './gen'
|
|
6
13
|
import { ProcessorServiceImpl } from './service'
|
|
7
14
|
import { setProvider } from './provider'
|
|
8
|
-
|
|
9
|
-
import path from 'path'
|
|
10
|
-
import fs from 'fs-extra'
|
|
11
15
|
import { ProcessorState } from './state/processor-state'
|
|
12
16
|
import { load } from './loader'
|
|
13
|
-
import { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'
|
|
14
17
|
import { Endpoints } from './endpoints'
|
|
15
18
|
|
|
16
19
|
global.PROCESSOR_STATE = new ProcessorState()
|
|
@@ -29,10 +32,37 @@ const optionDefinitions = [
|
|
|
29
32
|
},
|
|
30
33
|
{ name: 'chainquery-server', type: String, defaultValue: '' },
|
|
31
34
|
{ name: 'pricefeed-server', type: String, defaultValue: '' },
|
|
35
|
+
{ name: 'log-format', type: String, defaultValue: 'console' },
|
|
32
36
|
]
|
|
33
37
|
|
|
34
38
|
const options = commandLineArgs(optionDefinitions, { partial: true })
|
|
35
39
|
|
|
40
|
+
if (options['log-format'] === 'json') {
|
|
41
|
+
const utilFormatter = {
|
|
42
|
+
transform: (info: any) => {
|
|
43
|
+
const args = info[Symbol.for('splat')]
|
|
44
|
+
if (args) {
|
|
45
|
+
info.message = util.format(info.message, ...args)
|
|
46
|
+
}
|
|
47
|
+
return info
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
const logger = createLogger({
|
|
51
|
+
format: format.combine(
|
|
52
|
+
format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }),
|
|
53
|
+
utilFormatter,
|
|
54
|
+
format.errors({ stack: true }),
|
|
55
|
+
format.json()
|
|
56
|
+
),
|
|
57
|
+
transports: [new transports.Console()],
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
console.log = (...args) => logger.info.call(logger, ...args)
|
|
61
|
+
console.info = (...args) => logger.info.call(logger, ...args)
|
|
62
|
+
console.warn = (...args) => logger.warn.call(logger, ...args)
|
|
63
|
+
console.error = (...args) => logger.error.call(logger, ...args)
|
|
64
|
+
console.debug = (...args) => logger.debug.call(logger, ...args)
|
|
65
|
+
}
|
|
36
66
|
console.log('loading', options.target)
|
|
37
67
|
|
|
38
68
|
const fullPath = path.resolve(options['chains-config'])
|