@subql/node-ethereum 1.10.1-3 → 2.0.1-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/CHANGELOG.md +65 -0
- package/README.md +3 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/configure/SubqueryProject.d.ts +9 -11
- package/dist/configure/SubqueryProject.js +19 -9
- package/dist/configure/SubqueryProject.js.map +1 -1
- package/dist/configure/configure.module.js +5 -7
- package/dist/configure/configure.module.js.map +1 -1
- package/dist/ethereum/api.connection.d.ts +11 -0
- package/dist/ethereum/api.connection.js +27 -0
- package/dist/ethereum/api.connection.js.map +1 -0
- package/dist/ethereum/api.ethereum.d.ts +18 -5
- package/dist/ethereum/api.ethereum.js +138 -43
- package/dist/ethereum/api.ethereum.js.map +1 -1
- package/dist/ethereum/api.service.ethereum.d.ts +11 -3
- package/dist/ethereum/api.service.ethereum.js +68 -18
- package/dist/ethereum/api.service.ethereum.js.map +1 -1
- package/dist/ethereum/api.service.ethereum.test.d.ts +1 -0
- package/dist/ethereum/api.service.ethereum.test.js +73 -0
- package/dist/ethereum/api.service.ethereum.test.js.map +1 -0
- package/dist/ethereum/block.ethereum.d.ts +1 -1
- package/dist/ethereum/block.ethereum.js +10 -12
- package/dist/ethereum/block.ethereum.js.map +1 -1
- package/dist/ethereum/ethers/json-rpc-batch-provider.d.ts +21 -0
- package/dist/ethereum/ethers/json-rpc-batch-provider.js +114 -0
- package/dist/ethereum/ethers/json-rpc-batch-provider.js.map +1 -0
- package/dist/ethereum/ethers/json-rpc-provider.d.ts +7 -0
- package/dist/ethereum/ethers/json-rpc-provider.js +68 -0
- package/dist/ethereum/ethers/json-rpc-provider.js.map +1 -0
- package/dist/ethereum/ethers/web/_version.d.ts +1 -0
- package/dist/ethereum/ethers/web/_version.js +6 -0
- package/dist/ethereum/ethers/web/_version.js.map +1 -0
- package/dist/ethereum/ethers/web/geturl.d.ts +3 -0
- package/dist/ethereum/ethers/web/geturl.js +116 -0
- package/dist/ethereum/ethers/web/geturl.js.map +1 -0
- package/dist/ethereum/ethers/web/index.d.ts +49 -0
- package/dist/ethereum/ethers/web/index.js +437 -0
- package/dist/ethereum/ethers/web/index.js.map +1 -0
- package/dist/ethereum/ethers/web/types.d.ts +26 -0
- package/dist/ethereum/ethers/web/types.js +4 -0
- package/dist/ethereum/ethers/web/types.js.map +1 -0
- package/dist/ethereum/safe-api.d.ts +34 -0
- package/dist/ethereum/safe-api.js +114 -0
- package/dist/ethereum/safe-api.js.map +1 -0
- package/dist/ethereum/utils.ethereum.d.ts +1 -1
- package/dist/ethereum/utils.ethereum.js +22 -87
- package/dist/ethereum/utils.ethereum.js.map +1 -1
- package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +17 -0
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js +55 -0
- package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -0
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.d.ts +4 -0
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js +5 -0
- package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js.map +1 -0
- package/dist/indexer/blockDispatcher/index.d.ts +4 -0
- package/dist/indexer/blockDispatcher/index.js +10 -0
- package/dist/indexer/blockDispatcher/index.js.map +1 -0
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +15 -0
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +88 -0
- package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -0
- package/dist/indexer/dictionary.service.d.ts +1 -0
- package/dist/indexer/dictionary.service.js +22 -2
- package/dist/indexer/dictionary.service.js.map +1 -1
- package/dist/indexer/ds-processor.service.d.ts +1 -1
- package/dist/indexer/ds-processor.service.js +4 -0
- package/dist/indexer/ds-processor.service.js.map +1 -1
- package/dist/indexer/dynamic-ds.service.d.ts +3 -19
- package/dist/indexer/dynamic-ds.service.js +20 -72
- package/dist/indexer/dynamic-ds.service.js.map +1 -1
- package/dist/indexer/fetch.module.js +40 -12
- package/dist/indexer/fetch.module.js.map +1 -1
- package/dist/indexer/fetch.service.d.ts +16 -7
- package/dist/indexer/fetch.service.js +188 -78
- package/dist/indexer/fetch.service.js.map +1 -1
- package/dist/indexer/indexer.manager.d.ts +11 -17
- package/dist/indexer/indexer.manager.js +68 -71
- package/dist/indexer/indexer.manager.js.map +1 -1
- package/dist/indexer/indexer.module.js +32 -8
- package/dist/indexer/indexer.module.js.map +1 -1
- package/dist/indexer/project.service.d.ts +11 -8
- package/dist/indexer/project.service.js +76 -82
- package/dist/indexer/project.service.js.map +1 -1
- package/dist/indexer/sandbox.service.js +11 -2
- package/dist/indexer/sandbox.service.js.map +1 -1
- package/dist/indexer/types.d.ts +2 -1
- package/dist/indexer/types.js.map +1 -1
- package/dist/indexer/unfinalizedBlocks.service.d.ts +36 -0
- package/dist/indexer/unfinalizedBlocks.service.js +197 -0
- package/dist/indexer/unfinalizedBlocks.service.js.map +1 -0
- package/dist/indexer/unfinalizedBlocks.spec.d.ts +1 -0
- package/dist/indexer/unfinalizedBlocks.spec.js +195 -0
- package/dist/indexer/unfinalizedBlocks.spec.js.map +1 -0
- package/dist/indexer/worker/worker.d.ts +22 -6
- package/dist/indexer/worker/worker.js +16 -3
- package/dist/indexer/worker/worker.js.map +1 -1
- package/dist/indexer/worker/worker.service.d.ts +10 -6
- package/dist/indexer/worker/worker.service.js +23 -10
- package/dist/indexer/worker/worker.service.js.map +1 -1
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.d.ts +11 -0
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js +32 -0
- package/dist/indexer/worker/worker.unfinalizedBlocks.service.js.map +1 -0
- package/dist/init.js +2 -2
- package/dist/init.js.map +1 -1
- package/dist/main.js +6 -1
- package/dist/main.js.map +1 -1
- package/dist/meta/meta.module.js +8 -0
- package/dist/meta/meta.module.js.map +1 -1
- package/dist/meta/meta.service.d.ts +18 -3
- package/dist/meta/meta.service.js +89 -5
- package/dist/meta/meta.service.js.map +1 -1
- package/dist/subcommands/forceClean.service.d.ts +3 -1
- package/dist/subcommands/forceClean.service.js +30 -6
- package/dist/subcommands/forceClean.service.js.map +1 -1
- package/dist/subcommands/reindex.init.js +6 -1
- package/dist/subcommands/reindex.init.js.map +1 -1
- package/dist/subcommands/reindex.module.js +20 -1
- package/dist/subcommands/reindex.module.js.map +1 -1
- package/dist/subcommands/reindex.service.d.ts +7 -3
- package/dist/subcommands/reindex.service.js +44 -50
- package/dist/subcommands/reindex.service.js.map +1 -1
- package/dist/subcommands/testing.init.d.ts +1 -0
- package/dist/subcommands/testing.init.js +34 -0
- package/dist/subcommands/testing.init.js.map +1 -0
- package/dist/subcommands/testing.module.d.ts +4 -0
- package/dist/subcommands/testing.module.js +77 -0
- package/dist/subcommands/testing.module.js.map +1 -0
- package/dist/subcommands/testing.service.d.ts +9 -0
- package/dist/subcommands/testing.service.js +43 -0
- package/dist/subcommands/testing.service.js.map +1 -0
- package/dist/utils/project.d.ts +3 -0
- package/dist/utils/project.js +45 -1
- package/dist/utils/project.js.map +1 -1
- package/dist/utils/reindex.d.ts +6 -0
- package/dist/utils/reindex.js +48 -0
- package/dist/utils/reindex.js.map +1 -0
- package/dist/utils/string.js +10 -2
- package/dist/utils/string.js.map +1 -1
- package/dist/yargs.d.ts +97 -49
- package/dist/yargs.js +130 -69
- package/dist/yargs.js.map +1 -1
- package/package.json +13 -11
- package/dist/indexer/worker/block-dispatcher.service.d.ts +0 -69
- package/dist/indexer/worker/block-dispatcher.service.js +0 -356
- package/dist/indexer/worker/block-dispatcher.service.js.map +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonRpcProvider = void 0;
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
const properties_1 = require("@ethersproject/properties");
|
|
6
|
+
const providers_1 = require("@ethersproject/providers");
|
|
7
|
+
const web_1 = require("./web");
|
|
8
|
+
function getResult(payload) {
|
|
9
|
+
if (payload.error) {
|
|
10
|
+
// @TODO: not any
|
|
11
|
+
const error = new Error(payload.error.message);
|
|
12
|
+
error.code = payload.error.code;
|
|
13
|
+
error.data = payload.error.data;
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
return payload.result;
|
|
17
|
+
}
|
|
18
|
+
class JsonRpcProvider extends providers_1.JsonRpcProvider {
|
|
19
|
+
constructor(url, network) {
|
|
20
|
+
super(url, network);
|
|
21
|
+
}
|
|
22
|
+
send(method, params) {
|
|
23
|
+
const request = {
|
|
24
|
+
method: method,
|
|
25
|
+
params: params,
|
|
26
|
+
id: this._nextId++,
|
|
27
|
+
jsonrpc: '2.0',
|
|
28
|
+
};
|
|
29
|
+
this.emit('debug', {
|
|
30
|
+
action: 'request',
|
|
31
|
+
request: (0, properties_1.deepCopy)(request),
|
|
32
|
+
provider: this,
|
|
33
|
+
});
|
|
34
|
+
// We can expand this in the future to any call, but for now these
|
|
35
|
+
// are the biggest wins and do not require any serializing parameters.
|
|
36
|
+
const cache = ['eth_chainId', 'eth_blockNumber'].indexOf(method) >= 0;
|
|
37
|
+
if (cache && this._cache[method]) {
|
|
38
|
+
return this._cache[method];
|
|
39
|
+
}
|
|
40
|
+
const result = (0, web_1.fetchJson)(this.connection, JSON.stringify(request), getResult).then((result) => {
|
|
41
|
+
this.emit('debug', {
|
|
42
|
+
action: 'response',
|
|
43
|
+
request: request,
|
|
44
|
+
response: result,
|
|
45
|
+
provider: this,
|
|
46
|
+
});
|
|
47
|
+
return result;
|
|
48
|
+
}, (error) => {
|
|
49
|
+
this.emit('debug', {
|
|
50
|
+
action: 'response',
|
|
51
|
+
error: error,
|
|
52
|
+
request: request,
|
|
53
|
+
provider: this,
|
|
54
|
+
});
|
|
55
|
+
throw error;
|
|
56
|
+
});
|
|
57
|
+
// Cache the fetch, but clear it on the next event loop
|
|
58
|
+
if (cache) {
|
|
59
|
+
this._cache[method] = result;
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
this._cache[method] = null;
|
|
62
|
+
}, 0);
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.JsonRpcProvider = JsonRpcProvider;
|
|
68
|
+
//# sourceMappingURL=json-rpc-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-rpc-provider.js","sourceRoot":"","sources":["../../../src/ethereum/ethers/json-rpc-provider.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,0DAAqD;AAErD,wDAAkF;AAElF,+BAAkD;AAElD,SAAS,SAAS,CAAC,OAGlB;IACC,IAAI,OAAO,CAAC,KAAK,EAAE;QACjB,iBAAiB;QACjB,MAAM,KAAK,GAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACpD,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;QAChC,KAAK,CAAC,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC;QAChC,MAAM,KAAK,CAAC;KACb;IAED,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC;AAED,MAAa,eAAgB,SAAQ,2BAAmB;IACtD,YAAY,GAA4B,EAAE,OAAoB;QAC5D,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,MAAc,EAAE,MAAkB;QACrC,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,MAAM;YACd,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE;YAClB,OAAO,EAAE,KAAK;SACf,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,IAAA,qBAAQ,EAAC,OAAO,CAAC;YAC1B,QAAQ,EAAE,IAAI;SACf,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ider } from '@ethersproject/providers';\nimport { Networkish } from '@ethersproject/networks';\nimport { ConnectionInfo, fetchJson } from './web';\n\nfunction getResult(payload: {\n error?: { code?: number; data?: any; message?: string };\n result?: any;\n}): any {\n if (payload.error) {\n // @TODO: not any\n const error: any = new Error(payload.error.message);\n error.code = payload.error.code;\n error.data = payload.error.data;\n throw error;\n }\n\n return payload.result;\n}\n\nexport class JsonRpcProvider extends BaseJsonRpcProvider {\n constructor(url: string | ConnectionInfo, network?: Networkish) {\n super(url, network);\n }\n\n send(method: string, params: Array<any>): Promise<any> {\n const request = {\n method: method,\n params: params,\n id: this._nextId++,\n jsonrpc: '2.0',\n };\n\n this.emit('debug', {\n action: 'request',\n request: deepCopy(request),\n provider: this,\n });\n\n // We can expand this in the future to any call, but for now these\n // are the biggest wins and do not require any serializing parameters.\n const cache = ['eth_chainId', 'eth_blockNumber'].indexOf(method) >= 0;\n if (cache && this._cache[method]) {\n return this._cache[method];\n }\n\n const result = fetchJson(\n this.connection,\n JSON.stringify(request),\n getResult,\n ).then(\n (result) => {\n this.emit('debug', {\n action: 'response',\n request: request,\n response: result,\n provider: this,\n });\n\n return result;\n },\n (error) => {\n this.emit('debug', {\n action: 'response',\n error: error,\n request: request,\n provider: this,\n });\n\n throw error;\n },\n );\n\n // Cache the fetch, but clear it on the next event loop\n if (cache) {\n this._cache[method] = result;\n setTimeout(() => {\n this._cache[method] = null;\n }, 0);\n }\n\n return result;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "web/5.7.1";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_version.js","sourceRoot":"","sources":["../../../../src/ethereum/ethers/web/_version.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACP,QAAA,OAAO,GAAG,WAAW,CAAC","sourcesContent":["/* eslint-disable */\nexport const version = 'web/5.7.1';\n"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
'use strict';
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getUrl = void 0;
|
|
8
|
+
const http_1 = __importDefault(require("http"));
|
|
9
|
+
const https_1 = __importDefault(require("https"));
|
|
10
|
+
const zlib_1 = require("zlib");
|
|
11
|
+
const url_1 = require("url");
|
|
12
|
+
const bytes_1 = require("@ethersproject/bytes");
|
|
13
|
+
const properties_1 = require("@ethersproject/properties");
|
|
14
|
+
const logger_1 = require("@ethersproject/logger");
|
|
15
|
+
const _version_1 = require("./_version");
|
|
16
|
+
const logger = new logger_1.Logger(_version_1.version);
|
|
17
|
+
function getResponse(request) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
request.once('response', (resp) => {
|
|
20
|
+
const response = {
|
|
21
|
+
statusCode: resp.statusCode,
|
|
22
|
+
statusMessage: resp.statusMessage,
|
|
23
|
+
headers: Object.keys(resp.headers).reduce((accum, name) => {
|
|
24
|
+
let value = resp.headers[name];
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
value = value.join(', ');
|
|
27
|
+
}
|
|
28
|
+
accum[name] = value;
|
|
29
|
+
return accum;
|
|
30
|
+
}, {}),
|
|
31
|
+
body: null,
|
|
32
|
+
};
|
|
33
|
+
//resp.setEncoding("utf8");
|
|
34
|
+
resp.on('data', (chunk) => {
|
|
35
|
+
if (response.body == null) {
|
|
36
|
+
response.body = new Uint8Array(0);
|
|
37
|
+
}
|
|
38
|
+
response.body = (0, bytes_1.concat)([response.body, chunk]);
|
|
39
|
+
});
|
|
40
|
+
resp.on('end', () => {
|
|
41
|
+
if (response.headers['content-encoding'] === 'gzip') {
|
|
42
|
+
//const size = response.body.length;
|
|
43
|
+
response.body = (0, bytes_1.arrayify)((0, zlib_1.gunzipSync)(response.body));
|
|
44
|
+
//console.log("Delta:", response.body.length - size, Buffer.from(response.body).toString());
|
|
45
|
+
}
|
|
46
|
+
resolve(response);
|
|
47
|
+
});
|
|
48
|
+
resp.on('error', (error) => {
|
|
49
|
+
/* istanbul ignore next */
|
|
50
|
+
error.response = response;
|
|
51
|
+
reject(error);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
request.on('error', (error) => {
|
|
55
|
+
reject(error);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// The URL.parse uses null instead of the empty string
|
|
60
|
+
function nonnull(value) {
|
|
61
|
+
if (value == null) {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
async function getUrl(href, options) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
if (options == null) {
|
|
69
|
+
options = {};
|
|
70
|
+
}
|
|
71
|
+
// @TODO: Once we drop support for node 8, we can pass the href
|
|
72
|
+
// directly into request and skip adding the components
|
|
73
|
+
// to this request object
|
|
74
|
+
const url = (0, url_1.parse)(href);
|
|
75
|
+
const request = {
|
|
76
|
+
protocol: nonnull(url.protocol),
|
|
77
|
+
hostname: nonnull(url.hostname),
|
|
78
|
+
port: nonnull(url.port),
|
|
79
|
+
path: nonnull(url.pathname) + nonnull(url.search),
|
|
80
|
+
method: options.method || 'GET',
|
|
81
|
+
headers: (0, properties_1.shallowCopy)(options.headers || {}),
|
|
82
|
+
agent: null,
|
|
83
|
+
};
|
|
84
|
+
if (options.allowGzip) {
|
|
85
|
+
request.headers['accept-encoding'] = 'gzip';
|
|
86
|
+
}
|
|
87
|
+
let req = null;
|
|
88
|
+
switch (nonnull(url.protocol)) {
|
|
89
|
+
case 'http:':
|
|
90
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.agents) === null || _a === void 0 ? void 0 : _a.http) {
|
|
91
|
+
request.agent = options.agents.http;
|
|
92
|
+
}
|
|
93
|
+
req = http_1.default.request(request);
|
|
94
|
+
break;
|
|
95
|
+
case 'https:':
|
|
96
|
+
if ((_b = options === null || options === void 0 ? void 0 : options.agents) === null || _b === void 0 ? void 0 : _b.https) {
|
|
97
|
+
request.agent = options.agents.https;
|
|
98
|
+
}
|
|
99
|
+
req = https_1.default.request(request);
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
/* istanbul ignore next */
|
|
103
|
+
logger.throwError(`unsupported protocol ${url.protocol}`, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
104
|
+
protocol: url.protocol,
|
|
105
|
+
operation: 'request',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (options.body) {
|
|
109
|
+
req.write(Buffer.from(options.body));
|
|
110
|
+
}
|
|
111
|
+
req.end();
|
|
112
|
+
const response = await getResponse(req);
|
|
113
|
+
return response;
|
|
114
|
+
}
|
|
115
|
+
exports.getUrl = getUrl;
|
|
116
|
+
//# sourceMappingURL=geturl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geturl.js","sourceRoot":"","sources":["../../../../src/ethereum/ethers/web/geturl.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,YAAY,CAAC;;;;;;AAEb,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAkC;AAClC,6BAA4B;AAE5B,gDAAwD;AACxD,0DAAwD;AAIxD,kDAA+C;AAC/C,yCAAqC;AACrC,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAO,CAAC,CAAC;AAInC,SAAS,WAAW,CAAC,OAA2B;IAC9C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAA0B,EAAE,EAAE;YACtD,MAAM,QAAQ,GAAmB;gBAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAA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QAC7B,KAAK,OAAO;YACV,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,0CAAE,IAAI,EAAE;gBACzB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;aACrC;YACD,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC5B,MAAM;QACR,KAAK,QAAQ;YACX,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,0CAAE,KAAK,EAAE;gBAC1B,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;aACtC;YACD,GAAG,GAAG,eAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC7B,MAAM;QACR;YACE,0BAA0B;YAC1B,MAAM,CAAC,UAAU,CACf,wBAAwB,GAAG,CAAC,QAAQ,EAAE,EACtC,eAAM,CAAC,MAAM,CAAC,qBAAqB,EACnC;gBACE,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,SAAS,EAAE,SAAS;aACrB,CACF,CAAC;KACL;IAED,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;KACtC;IACD,GAAG,CAAC,GAAG,EAAE,CAAC;IAEV,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,QAAQ,CAAC;AAClB,CAAC;AA7DD,wBA6DC","sourcesContent":["/* eslint-disable */\n'use strict';\n\nimport http from 'http';\nimport https from 'https';\nimport { gunzipSync } from 'zlib';\nimport { parse } from 'url';\n\nimport { arrayify, concat } from '@ethersproject/bytes';\nimport { shallowCopy } from '@ethersproject/properties';\n\nimport type { GetUrlResponse, Options } from './types';\n\nimport { Logger } from '@ethersproject/logger';\nimport { version } from './_version';\nconst logger = new Logger(version);\n\nexport { GetUrlResponse, Options };\n\nfunction getResponse(request: http.ClientRequest): Promise<GetUrlResponse> {\n return new Promise((resolve, reject) => {\n request.once('response', (resp: http.IncomingMessage) => {\n const response: GetUrlResponse = {\n statusCode: resp.statusCode,\n statusMessage: resp.statusMessage,\n headers: Object.keys(resp.headers).reduce((accum, name) => {\n let value = resp.headers[name];\n if (Array.isArray(value)) {\n value = value.join(', ');\n }\n accum[name] = value;\n return accum;\n }, <{ [name: string]: string }>{}),\n body: null,\n };\n //resp.setEncoding(\"utf8\");\n\n resp.on('data', (chunk: Uint8Array) => {\n if (response.body == null) {\n response.body = new Uint8Array(0);\n }\n response.body = concat([response.body, chunk]);\n });\n\n resp.on('end', () => {\n if (response.headers['content-encoding'] === 'gzip') {\n //const size = response.body.length;\n response.body = arrayify(gunzipSync(response.body));\n //console.log(\"Delta:\", response.body.length - size, Buffer.from(response.body).toString());\n }\n resolve(response);\n });\n\n resp.on('error', (error) => {\n /* istanbul ignore next */\n (<any>error).response = response;\n reject(error);\n });\n });\n\n request.on('error', (error) => {\n reject(error);\n });\n });\n}\n\n// The URL.parse uses null instead of the empty string\nfunction nonnull(value: string): string {\n if (value == null) {\n return '';\n }\n return value;\n}\n\nexport async function getUrl(\n href: string,\n options?: Options,\n): Promise<GetUrlResponse> {\n if (options == null) {\n options = {};\n }\n\n // @TODO: Once we drop support for node 8, we can pass the href\n // directly into request and skip adding the components\n // to this request object\n const url = parse(href);\n\n const request = {\n protocol: nonnull(url.protocol),\n hostname: nonnull(url.hostname),\n port: nonnull(url.port),\n path: nonnull(url.pathname) + nonnull(url.search),\n\n method: options.method || 'GET',\n headers: shallowCopy(options.headers || {}),\n agent: null,\n };\n\n if (options.allowGzip) {\n request.headers['accept-encoding'] = 'gzip';\n }\n\n let req: http.ClientRequest = null;\n switch (nonnull(url.protocol)) {\n case 'http:':\n if (options?.agents?.http) {\n request.agent = options.agents.http;\n }\n req = http.request(request);\n break;\n case 'https:':\n if (options?.agents?.https) {\n request.agent = options.agents.https;\n }\n req = https.request(request);\n break;\n default:\n /* istanbul ignore next */\n logger.throwError(\n `unsupported protocol ${url.protocol}`,\n Logger.errors.UNSUPPORTED_OPERATION,\n {\n protocol: url.protocol,\n operation: 'request',\n },\n );\n }\n\n if (options.body) {\n req.write(Buffer.from(options.body));\n }\n req.end();\n\n const response = await getResponse(req);\n return response;\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import http from 'http';
|
|
4
|
+
import https from 'https';
|
|
5
|
+
export type ConnectionInfo = {
|
|
6
|
+
url: string;
|
|
7
|
+
headers?: {
|
|
8
|
+
[key: string]: string | number;
|
|
9
|
+
};
|
|
10
|
+
user?: string;
|
|
11
|
+
password?: string;
|
|
12
|
+
allowInsecureAuthentication?: boolean;
|
|
13
|
+
allowGzip?: boolean;
|
|
14
|
+
throttleLimit?: number;
|
|
15
|
+
throttleSlotInterval?: number;
|
|
16
|
+
throttleCallback?: (attempt: number, url: string) => Promise<boolean>;
|
|
17
|
+
skipFetchSetup?: boolean;
|
|
18
|
+
fetchOptions?: Record<string, string>;
|
|
19
|
+
errorPassThrough?: boolean;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
agents?: {
|
|
22
|
+
http?: http.Agent;
|
|
23
|
+
https?: https.Agent;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export interface OnceBlockable {
|
|
27
|
+
once(eventName: 'block', handler: () => void): void;
|
|
28
|
+
}
|
|
29
|
+
export interface OncePollable {
|
|
30
|
+
once(eventName: 'poll', handler: () => void): void;
|
|
31
|
+
}
|
|
32
|
+
export type PollOptions = {
|
|
33
|
+
timeout?: number;
|
|
34
|
+
floor?: number;
|
|
35
|
+
ceiling?: number;
|
|
36
|
+
interval?: number;
|
|
37
|
+
retryLimit?: number;
|
|
38
|
+
onceBlock?: OnceBlockable;
|
|
39
|
+
oncePoll?: OncePollable;
|
|
40
|
+
};
|
|
41
|
+
export type FetchJsonResponse = {
|
|
42
|
+
statusCode: number;
|
|
43
|
+
headers: {
|
|
44
|
+
[header: string]: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare function _fetchData<T = Uint8Array>(connection: string | ConnectionInfo, body?: Uint8Array, processFunc?: (value: Uint8Array, response: FetchJsonResponse) => T): Promise<T>;
|
|
48
|
+
export declare function fetchJson(connection: string | ConnectionInfo, json?: string, processFunc?: (value: any, response: FetchJsonResponse) => any): Promise<any>;
|
|
49
|
+
export declare function poll<T>(func: () => Promise<T>, options?: PollOptions): Promise<T>;
|