@subql/node-ethereum 1.10.1-3 → 2.0.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +3 -2
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/configure/SubqueryProject.d.ts +9 -11
  5. package/dist/configure/SubqueryProject.js +19 -9
  6. package/dist/configure/SubqueryProject.js.map +1 -1
  7. package/dist/configure/configure.module.js +5 -7
  8. package/dist/configure/configure.module.js.map +1 -1
  9. package/dist/ethereum/api.connection.d.ts +11 -0
  10. package/dist/ethereum/api.connection.js +27 -0
  11. package/dist/ethereum/api.connection.js.map +1 -0
  12. package/dist/ethereum/api.ethereum.d.ts +18 -5
  13. package/dist/ethereum/api.ethereum.js +135 -43
  14. package/dist/ethereum/api.ethereum.js.map +1 -1
  15. package/dist/ethereum/api.service.ethereum.d.ts +11 -3
  16. package/dist/ethereum/api.service.ethereum.js +68 -18
  17. package/dist/ethereum/api.service.ethereum.js.map +1 -1
  18. package/dist/ethereum/api.service.ethereum.test.d.ts +1 -0
  19. package/dist/ethereum/api.service.ethereum.test.js +73 -0
  20. package/dist/ethereum/api.service.ethereum.test.js.map +1 -0
  21. package/dist/ethereum/block.ethereum.d.ts +1 -1
  22. package/dist/ethereum/block.ethereum.js +10 -12
  23. package/dist/ethereum/block.ethereum.js.map +1 -1
  24. package/dist/ethereum/ethers/json-rpc-batch-provider.d.ts +21 -0
  25. package/dist/ethereum/ethers/json-rpc-batch-provider.js +114 -0
  26. package/dist/ethereum/ethers/json-rpc-batch-provider.js.map +1 -0
  27. package/dist/ethereum/ethers/json-rpc-provider.d.ts +7 -0
  28. package/dist/ethereum/ethers/json-rpc-provider.js +68 -0
  29. package/dist/ethereum/ethers/json-rpc-provider.js.map +1 -0
  30. package/dist/ethereum/ethers/web/_version.d.ts +1 -0
  31. package/dist/ethereum/ethers/web/_version.js +6 -0
  32. package/dist/ethereum/ethers/web/_version.js.map +1 -0
  33. package/dist/ethereum/ethers/web/geturl.d.ts +3 -0
  34. package/dist/ethereum/ethers/web/geturl.js +116 -0
  35. package/dist/ethereum/ethers/web/geturl.js.map +1 -0
  36. package/dist/ethereum/ethers/web/index.d.ts +49 -0
  37. package/dist/ethereum/ethers/web/index.js +437 -0
  38. package/dist/ethereum/ethers/web/index.js.map +1 -0
  39. package/dist/ethereum/ethers/web/types.d.ts +26 -0
  40. package/dist/ethereum/ethers/web/types.js +4 -0
  41. package/dist/ethereum/ethers/web/types.js.map +1 -0
  42. package/dist/ethereum/safe-api.d.ts +34 -0
  43. package/dist/ethereum/safe-api.js +114 -0
  44. package/dist/ethereum/safe-api.js.map +1 -0
  45. package/dist/ethereum/utils.ethereum.d.ts +1 -1
  46. package/dist/ethereum/utils.ethereum.js +22 -87
  47. package/dist/ethereum/utils.ethereum.js.map +1 -1
  48. package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +17 -0
  49. package/dist/indexer/blockDispatcher/block-dispatcher.service.js +55 -0
  50. package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -0
  51. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.d.ts +4 -0
  52. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js +5 -0
  53. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js.map +1 -0
  54. package/dist/indexer/blockDispatcher/index.d.ts +4 -0
  55. package/dist/indexer/blockDispatcher/index.js +10 -0
  56. package/dist/indexer/blockDispatcher/index.js.map +1 -0
  57. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +15 -0
  58. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +88 -0
  59. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -0
  60. package/dist/indexer/dictionary.service.d.ts +1 -0
  61. package/dist/indexer/dictionary.service.js +22 -2
  62. package/dist/indexer/dictionary.service.js.map +1 -1
  63. package/dist/indexer/ds-processor.service.d.ts +1 -1
  64. package/dist/indexer/ds-processor.service.js +4 -0
  65. package/dist/indexer/ds-processor.service.js.map +1 -1
  66. package/dist/indexer/dynamic-ds.service.d.ts +3 -19
  67. package/dist/indexer/dynamic-ds.service.js +20 -72
  68. package/dist/indexer/dynamic-ds.service.js.map +1 -1
  69. package/dist/indexer/fetch.module.js +40 -12
  70. package/dist/indexer/fetch.module.js.map +1 -1
  71. package/dist/indexer/fetch.service.d.ts +16 -7
  72. package/dist/indexer/fetch.service.js +188 -78
  73. package/dist/indexer/fetch.service.js.map +1 -1
  74. package/dist/indexer/indexer.manager.d.ts +11 -17
  75. package/dist/indexer/indexer.manager.js +68 -71
  76. package/dist/indexer/indexer.manager.js.map +1 -1
  77. package/dist/indexer/indexer.module.js +32 -8
  78. package/dist/indexer/indexer.module.js.map +1 -1
  79. package/dist/indexer/project.service.d.ts +11 -8
  80. package/dist/indexer/project.service.js +76 -82
  81. package/dist/indexer/project.service.js.map +1 -1
  82. package/dist/indexer/sandbox.service.js +11 -2
  83. package/dist/indexer/sandbox.service.js.map +1 -1
  84. package/dist/indexer/types.d.ts +2 -1
  85. package/dist/indexer/types.js.map +1 -1
  86. package/dist/indexer/unfinalizedBlocks.service.d.ts +36 -0
  87. package/dist/indexer/unfinalizedBlocks.service.js +197 -0
  88. package/dist/indexer/unfinalizedBlocks.service.js.map +1 -0
  89. package/dist/indexer/unfinalizedBlocks.spec.d.ts +1 -0
  90. package/dist/indexer/unfinalizedBlocks.spec.js +195 -0
  91. package/dist/indexer/unfinalizedBlocks.spec.js.map +1 -0
  92. package/dist/indexer/worker/worker.d.ts +22 -6
  93. package/dist/indexer/worker/worker.js +16 -3
  94. package/dist/indexer/worker/worker.js.map +1 -1
  95. package/dist/indexer/worker/worker.service.d.ts +10 -6
  96. package/dist/indexer/worker/worker.service.js +23 -10
  97. package/dist/indexer/worker/worker.service.js.map +1 -1
  98. package/dist/indexer/worker/worker.unfinalizedBlocks.service.d.ts +11 -0
  99. package/dist/indexer/worker/worker.unfinalizedBlocks.service.js +32 -0
  100. package/dist/indexer/worker/worker.unfinalizedBlocks.service.js.map +1 -0
  101. package/dist/init.js +2 -2
  102. package/dist/init.js.map +1 -1
  103. package/dist/main.js +6 -1
  104. package/dist/main.js.map +1 -1
  105. package/dist/meta/meta.module.js +8 -0
  106. package/dist/meta/meta.module.js.map +1 -1
  107. package/dist/meta/meta.service.d.ts +18 -3
  108. package/dist/meta/meta.service.js +89 -5
  109. package/dist/meta/meta.service.js.map +1 -1
  110. package/dist/subcommands/forceClean.service.d.ts +3 -1
  111. package/dist/subcommands/forceClean.service.js +30 -6
  112. package/dist/subcommands/forceClean.service.js.map +1 -1
  113. package/dist/subcommands/reindex.init.js +6 -1
  114. package/dist/subcommands/reindex.init.js.map +1 -1
  115. package/dist/subcommands/reindex.module.js +20 -1
  116. package/dist/subcommands/reindex.module.js.map +1 -1
  117. package/dist/subcommands/reindex.service.d.ts +7 -3
  118. package/dist/subcommands/reindex.service.js +44 -50
  119. package/dist/subcommands/reindex.service.js.map +1 -1
  120. package/dist/subcommands/testing.init.d.ts +1 -0
  121. package/dist/subcommands/testing.init.js +34 -0
  122. package/dist/subcommands/testing.init.js.map +1 -0
  123. package/dist/subcommands/testing.module.d.ts +4 -0
  124. package/dist/subcommands/testing.module.js +77 -0
  125. package/dist/subcommands/testing.module.js.map +1 -0
  126. package/dist/subcommands/testing.service.d.ts +9 -0
  127. package/dist/subcommands/testing.service.js +43 -0
  128. package/dist/subcommands/testing.service.js.map +1 -0
  129. package/dist/utils/project.d.ts +3 -0
  130. package/dist/utils/project.js +45 -1
  131. package/dist/utils/project.js.map +1 -1
  132. package/dist/utils/reindex.d.ts +6 -0
  133. package/dist/utils/reindex.js +48 -0
  134. package/dist/utils/reindex.js.map +1 -0
  135. package/dist/utils/string.js +10 -2
  136. package/dist/utils/string.js.map +1 -1
  137. package/dist/yargs.d.ts +97 -49
  138. package/dist/yargs.js +130 -69
  139. package/dist/yargs.js.map +1 -1
  140. package/package.json +13 -12
  141. package/dist/indexer/worker/block-dispatcher.service.d.ts +0 -69
  142. package/dist/indexer/worker/block-dispatcher.service.js +0 -356
  143. package/dist/indexer/worker/block-dispatcher.service.js.map +0 -1
@@ -0,0 +1,437 @@
1
+ /* eslint-disable */
2
+ 'use strict';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.poll = exports.fetchJson = exports._fetchData = void 0;
5
+ const base64_1 = require("@ethersproject/base64");
6
+ const bytes_1 = require("@ethersproject/bytes");
7
+ const properties_1 = require("@ethersproject/properties");
8
+ const strings_1 = require("@ethersproject/strings");
9
+ const logger_1 = require("@ethersproject/logger");
10
+ const _version_1 = require("./_version");
11
+ const logger = new logger_1.Logger(_version_1.version);
12
+ const geturl_1 = require("./geturl");
13
+ function staller(duration) {
14
+ return new Promise((resolve) => {
15
+ setTimeout(resolve, duration);
16
+ });
17
+ }
18
+ function bodyify(value, type) {
19
+ if (value == null) {
20
+ return null;
21
+ }
22
+ if (typeof value === 'string') {
23
+ return value;
24
+ }
25
+ if ((0, bytes_1.isBytesLike)(value)) {
26
+ if (type &&
27
+ (type.split('/')[0] === 'text' ||
28
+ type.split(';')[0].trim() === 'application/json')) {
29
+ try {
30
+ return (0, strings_1.toUtf8String)(value);
31
+ }
32
+ catch (error) { }
33
+ }
34
+ return (0, bytes_1.hexlify)(value);
35
+ }
36
+ return value;
37
+ }
38
+ function unpercent(value) {
39
+ return (0, strings_1.toUtf8Bytes)(value.replace(/%([0-9a-f][0-9a-f])/gi, (all, code) => {
40
+ return String.fromCharCode(parseInt(code, 16));
41
+ }));
42
+ }
43
+ // This API is still a work in progress; the future changes will likely be:
44
+ // - ConnectionInfo => FetchDataRequest<T = any>
45
+ // - FetchDataRequest.body? = string | Uint8Array | { contentType: string, data: string | Uint8Array }
46
+ // - If string => text/plain, Uint8Array => application/octet-stream (if content-type unspecified)
47
+ // - FetchDataRequest.processFunc = (body: Uint8Array, response: FetchDataResponse) => T
48
+ // For this reason, it should be considered internal until the API is finalized
49
+ function _fetchData(connection, body, processFunc) {
50
+ // How many times to retry in the event of a throttle
51
+ const attemptLimit = typeof connection === 'object' && connection.throttleLimit != null
52
+ ? connection.throttleLimit
53
+ : 12;
54
+ logger.assertArgument(attemptLimit > 0 && attemptLimit % 1 === 0, 'invalid connection throttle limit', 'connection.throttleLimit', attemptLimit);
55
+ const throttleCallback = typeof connection === 'object' ? connection.throttleCallback : null;
56
+ const throttleSlotInterval = typeof connection === 'object' &&
57
+ typeof connection.throttleSlotInterval === 'number'
58
+ ? connection.throttleSlotInterval
59
+ : 100;
60
+ logger.assertArgument(throttleSlotInterval > 0 && throttleSlotInterval % 1 === 0, 'invalid connection throttle slot interval', 'connection.throttleSlotInterval', throttleSlotInterval);
61
+ const errorPassThrough = typeof connection === 'object' ? !!connection.errorPassThrough : false;
62
+ const headers = {};
63
+ let url = null;
64
+ // @TODO: Allow ConnectionInfo to override some of these values
65
+ const options = {
66
+ method: 'GET',
67
+ };
68
+ let allow304 = false;
69
+ let timeout = 2 * 60 * 1000;
70
+ if (typeof connection === 'string') {
71
+ url = connection;
72
+ }
73
+ else if (typeof connection === 'object') {
74
+ if (connection == null || connection.url == null) {
75
+ logger.throwArgumentError('missing URL', 'connection.url', connection);
76
+ }
77
+ url = connection.url;
78
+ if (typeof connection.timeout === 'number' && connection.timeout > 0) {
79
+ timeout = connection.timeout;
80
+ }
81
+ if (connection.headers) {
82
+ for (const key in connection.headers) {
83
+ headers[key.toLowerCase()] = {
84
+ key: key,
85
+ value: String(connection.headers[key]),
86
+ };
87
+ if (['if-none-match', 'if-modified-since'].indexOf(key.toLowerCase()) >= 0) {
88
+ allow304 = true;
89
+ }
90
+ }
91
+ }
92
+ options.allowGzip = !!connection.allowGzip;
93
+ if (connection.user != null && connection.password != null) {
94
+ if (url.substring(0, 6) !== 'https:' &&
95
+ connection.allowInsecureAuthentication !== true) {
96
+ logger.throwError('basic authentication requires a secure https url', logger_1.Logger.errors.INVALID_ARGUMENT, {
97
+ argument: 'url',
98
+ url: url,
99
+ user: connection.user,
100
+ password: '[REDACTED]',
101
+ });
102
+ }
103
+ const authorization = connection.user + ':' + connection.password;
104
+ headers['authorization'] = {
105
+ key: 'Authorization',
106
+ value: 'Basic ' + (0, base64_1.encode)((0, strings_1.toUtf8Bytes)(authorization)),
107
+ };
108
+ }
109
+ if (connection.skipFetchSetup != null) {
110
+ options.skipFetchSetup = !!connection.skipFetchSetup;
111
+ }
112
+ if (connection.fetchOptions != null) {
113
+ options.fetchOptions = (0, properties_1.shallowCopy)(connection.fetchOptions);
114
+ }
115
+ if (connection.agents != null) {
116
+ options.agents = connection.agents;
117
+ }
118
+ }
119
+ const reData = new RegExp('^data:([^;:]*)?(;base64)?,(.*)$', 'i');
120
+ const dataMatch = url ? url.match(reData) : null;
121
+ if (dataMatch) {
122
+ try {
123
+ const response = {
124
+ statusCode: 200,
125
+ statusMessage: 'OK',
126
+ headers: { 'content-type': dataMatch[1] || 'text/plain' },
127
+ body: dataMatch[2]
128
+ ? (0, base64_1.decode)(dataMatch[3])
129
+ : unpercent(dataMatch[3]),
130
+ };
131
+ let result = response.body;
132
+ if (processFunc) {
133
+ result = processFunc(response.body, response);
134
+ }
135
+ return Promise.resolve(result);
136
+ }
137
+ catch (error) {
138
+ logger.throwError('processing response error', logger_1.Logger.errors.SERVER_ERROR, {
139
+ body: bodyify(dataMatch[1], dataMatch[2]),
140
+ error: error,
141
+ requestBody: null,
142
+ requestMethod: 'GET',
143
+ url: url,
144
+ });
145
+ }
146
+ }
147
+ if (body) {
148
+ options.method = 'POST';
149
+ options.body = body;
150
+ if (headers['content-type'] == null) {
151
+ headers['content-type'] = {
152
+ key: 'Content-Type',
153
+ value: 'application/octet-stream',
154
+ };
155
+ }
156
+ if (headers['content-length'] == null) {
157
+ headers['content-length'] = {
158
+ key: 'Content-Length',
159
+ value: String(body.length),
160
+ };
161
+ }
162
+ }
163
+ const flatHeaders = {};
164
+ Object.keys(headers).forEach((key) => {
165
+ const header = headers[key];
166
+ flatHeaders[header.key] = header.value;
167
+ });
168
+ options.headers = flatHeaders;
169
+ const runningTimeout = (function () {
170
+ let timer = null;
171
+ const promise = new Promise(function (resolve, reject) {
172
+ if (timeout) {
173
+ timer = setTimeout(() => {
174
+ if (timer == null) {
175
+ return;
176
+ }
177
+ timer = null;
178
+ reject(logger.makeError('timeout', logger_1.Logger.errors.TIMEOUT, {
179
+ requestBody: bodyify(options.body, flatHeaders['content-type']),
180
+ requestMethod: options.method,
181
+ timeout: timeout,
182
+ url: url,
183
+ }));
184
+ }, timeout);
185
+ }
186
+ });
187
+ const cancel = function () {
188
+ if (timer == null) {
189
+ return;
190
+ }
191
+ clearTimeout(timer);
192
+ timer = null;
193
+ };
194
+ return { promise, cancel };
195
+ })();
196
+ const runningFetch = (async function () {
197
+ for (let attempt = 0; attempt < attemptLimit; attempt++) {
198
+ let response = null;
199
+ try {
200
+ response = await (0, geturl_1.getUrl)(url, options);
201
+ if (response.statusCode === 301 || response.statusCode === 302) {
202
+ // Redirection; for now we only support absolute locataions
203
+ const location = response.headers.location || '';
204
+ if (options.method === 'GET' && location.match(/^https:/)) {
205
+ url = response.headers.location;
206
+ continue;
207
+ }
208
+ }
209
+ else if (response.statusCode === 429) {
210
+ // If it's the last attempt we throw an error with the response
211
+ if (attempt == attemptLimit - 1) {
212
+ const err = new Error('rate limited');
213
+ err.response = response;
214
+ throw err;
215
+ }
216
+ // Exponential back-off throttling
217
+ let tryAgain = true;
218
+ if (throttleCallback) {
219
+ tryAgain = await throttleCallback(attempt, url);
220
+ }
221
+ if (tryAgain) {
222
+ let stall = 0;
223
+ const retryAfter = response.headers['retry-after'];
224
+ if (typeof retryAfter === 'string' &&
225
+ retryAfter.match(/^[1-9][0-9]*$/)) {
226
+ stall = parseInt(retryAfter) * 1000;
227
+ }
228
+ else {
229
+ stall =
230
+ throttleSlotInterval *
231
+ parseInt(String(Math.random() * Math.pow(2, attempt)));
232
+ }
233
+ //console.log("Stalling 429");
234
+ await staller(stall);
235
+ continue;
236
+ }
237
+ }
238
+ }
239
+ catch (error) {
240
+ response = error.response;
241
+ if (response == null) {
242
+ runningTimeout.cancel();
243
+ logger.throwError('missing response', logger_1.Logger.errors.SERVER_ERROR, {
244
+ requestBody: bodyify(options.body, flatHeaders['content-type']),
245
+ requestMethod: options.method,
246
+ serverError: error,
247
+ url: url,
248
+ });
249
+ }
250
+ }
251
+ let body = response.body;
252
+ if (allow304 && response.statusCode === 304) {
253
+ body = null;
254
+ }
255
+ else if (!errorPassThrough &&
256
+ (response.statusCode < 200 || response.statusCode >= 300)) {
257
+ runningTimeout.cancel();
258
+ logger.throwError('bad response', logger_1.Logger.errors.SERVER_ERROR, {
259
+ status: response.statusCode,
260
+ headers: response.headers,
261
+ body: bodyify(body, response.headers ? response.headers['content-type'] : null),
262
+ requestBody: bodyify(options.body, flatHeaders['content-type']),
263
+ requestMethod: options.method,
264
+ url: url,
265
+ });
266
+ }
267
+ if (processFunc) {
268
+ try {
269
+ const result = await processFunc(body, response);
270
+ runningTimeout.cancel();
271
+ return result;
272
+ }
273
+ catch (error) {
274
+ // Allow the processFunc to trigger a throttle
275
+ if (error.throttleRetry && attempt < attemptLimit) {
276
+ let tryAgain = true;
277
+ if (throttleCallback) {
278
+ tryAgain = await throttleCallback(attempt, url);
279
+ }
280
+ if (tryAgain) {
281
+ const timeout = throttleSlotInterval *
282
+ parseInt(String(Math.random() * Math.pow(2, attempt)));
283
+ //console.log("Stalling callback");
284
+ await staller(timeout);
285
+ continue;
286
+ }
287
+ }
288
+ runningTimeout.cancel();
289
+ logger.throwError('processing response error', logger_1.Logger.errors.SERVER_ERROR, {
290
+ body: bodyify(body, response.headers ? response.headers['content-type'] : null),
291
+ error: error,
292
+ requestBody: bodyify(options.body, flatHeaders['content-type']),
293
+ requestMethod: options.method,
294
+ url: url,
295
+ });
296
+ }
297
+ }
298
+ runningTimeout.cancel();
299
+ // If we had a processFunc, it either returned a T or threw above.
300
+ // The "body" is now a Uint8Array.
301
+ return body;
302
+ }
303
+ return logger.throwError('failed response', logger_1.Logger.errors.SERVER_ERROR, {
304
+ requestBody: bodyify(options.body, flatHeaders['content-type']),
305
+ requestMethod: options.method,
306
+ url: url,
307
+ });
308
+ })();
309
+ return Promise.race([runningTimeout.promise, runningFetch]);
310
+ }
311
+ exports._fetchData = _fetchData;
312
+ function fetchJson(connection, json, processFunc) {
313
+ let processJsonFunc = (value, response) => {
314
+ let result = null;
315
+ if (value != null) {
316
+ try {
317
+ result = JSON.parse((0, strings_1.toUtf8String)(value));
318
+ }
319
+ catch (error) {
320
+ logger.throwError('invalid JSON', logger_1.Logger.errors.SERVER_ERROR, {
321
+ body: value,
322
+ error: error,
323
+ });
324
+ }
325
+ }
326
+ if (processFunc) {
327
+ result = processFunc(result, response);
328
+ }
329
+ return result;
330
+ };
331
+ // If we have json to send, we must
332
+ // - add content-type of application/json (unless already overridden)
333
+ // - convert the json to bytes
334
+ let body = null;
335
+ if (json != null) {
336
+ body = (0, strings_1.toUtf8Bytes)(json);
337
+ // Create a connection with the content-type set for JSON
338
+ const updated = typeof connection === 'string'
339
+ ? { url: connection }
340
+ : (0, properties_1.shallowCopy)(connection);
341
+ if (updated.headers) {
342
+ const hasContentType = Object.keys(updated.headers).filter((k) => k.toLowerCase() === 'content-type').length !== 0;
343
+ if (!hasContentType) {
344
+ updated.headers = (0, properties_1.shallowCopy)(updated.headers);
345
+ updated.headers['content-type'] = 'application/json';
346
+ }
347
+ }
348
+ else {
349
+ updated.headers = { 'content-type': 'application/json' };
350
+ }
351
+ connection = updated;
352
+ }
353
+ return _fetchData(connection, body, processJsonFunc);
354
+ }
355
+ exports.fetchJson = fetchJson;
356
+ function poll(func, options) {
357
+ if (!options) {
358
+ options = {};
359
+ }
360
+ options = (0, properties_1.shallowCopy)(options);
361
+ if (options.floor == null) {
362
+ options.floor = 0;
363
+ }
364
+ if (options.ceiling == null) {
365
+ options.ceiling = 10000;
366
+ }
367
+ if (options.interval == null) {
368
+ options.interval = 250;
369
+ }
370
+ return new Promise(function (resolve, reject) {
371
+ let timer = null;
372
+ let done = false;
373
+ // Returns true if cancel was successful. Unsuccessful cancel means we're already done.
374
+ const cancel = () => {
375
+ if (done) {
376
+ return false;
377
+ }
378
+ done = true;
379
+ if (timer) {
380
+ clearTimeout(timer);
381
+ }
382
+ return true;
383
+ };
384
+ if (options.timeout) {
385
+ timer = setTimeout(() => {
386
+ if (cancel()) {
387
+ reject(new Error('timeout'));
388
+ }
389
+ }, options.timeout);
390
+ }
391
+ const retryLimit = options.retryLimit;
392
+ let attempt = 0;
393
+ function check() {
394
+ return func().then(function (result) {
395
+ // If we have a result, or are allowed null then we're done
396
+ if (result !== undefined) {
397
+ if (cancel()) {
398
+ resolve(result);
399
+ }
400
+ }
401
+ else if (options.oncePoll) {
402
+ options.oncePoll.once('poll', check);
403
+ }
404
+ else if (options.onceBlock) {
405
+ options.onceBlock.once('block', check);
406
+ // Otherwise, exponential back-off (up to 10s) our next request
407
+ }
408
+ else if (!done) {
409
+ attempt++;
410
+ if (attempt > retryLimit) {
411
+ if (cancel()) {
412
+ reject(new Error('retry limit reached'));
413
+ }
414
+ return;
415
+ }
416
+ let timeout = options.interval *
417
+ parseInt(String(Math.random() * Math.pow(2, attempt)));
418
+ if (timeout < options.floor) {
419
+ timeout = options.floor;
420
+ }
421
+ if (timeout > options.ceiling) {
422
+ timeout = options.ceiling;
423
+ }
424
+ setTimeout(check, timeout);
425
+ }
426
+ return null;
427
+ }, function (error) {
428
+ if (cancel()) {
429
+ reject(error);
430
+ }
431
+ });
432
+ }
433
+ check();
434
+ });
435
+ }
436
+ exports.poll = poll;
437
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ethereum/ethers/web/index.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,YAAY,CAAC;;;AAIb,kDAG+B;AAC/B,gDAA4D;AAC5D,0DAAwD;AACxD,oDAAmE;AAEnE,kDAA+C;AAC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M,IAAI,CAAC,IAAI,EAAE;oBAChB,OAAO,EAAE,CAAC;oBACV,IAAI,OAAO,GAAG,UAAU,EAAE;wBACxB,IAAI,MAAM,EAAE,EAAE;4BACZ,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;yBAC1C;wBACD,OAAO;qBACR;oBAED,IAAI,OAAO,GACT,OAAO,CAAC,QAAQ;wBAChB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;oBACzD,IAAI,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE;wBAC3B,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;qBACzB;oBACD,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE;wBAC7B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;qBAC3B;oBAED,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;iBAC5B;gBAED,OAAO,IAAI,CAAC;YACd,CAAC,EACD,UAAU,KAAK;gBACb,IAAI,MAAM,EAAE,EAAE;oBACZ,MAAM,CAAC,KAAK,CAAC,CAAC;iBACf;YACH,CAAC,CACF,CAAC;QACJ,CAAC;QACD,KAAK,EAAE,CAAC;IACV,CAAC,CAAC,CAAC;AACL,CAAC;AA5FD,oBA4FC","sourcesContent":["/* eslint-disable */\n'use strict';\n\nimport http from 'http';\nimport https from 'https';\nimport {\n decode as base64Decode,\n encode as base64Encode,\n} from '@ethersproject/base64';\nimport { hexlify, isBytesLike } from '@ethersproject/bytes';\nimport { shallowCopy } from '@ethersproject/properties';\nimport { toUtf8Bytes, toUtf8String } from '@ethersproject/strings';\n\nimport { Logger } from '@ethersproject/logger';\nimport { version } from './_version';\nconst logger = new Logger(version);\n\nimport { getUrl, GetUrlResponse, Options } from './geturl';\n\nfunction staller(duration: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, duration);\n });\n}\n\nfunction bodyify(value: any, type: string): string {\n if (value == null) {\n return null;\n }\n\n if (typeof value === 'string') {\n return value;\n }\n\n if (isBytesLike(value)) {\n if (\n type &&\n (type.split('/')[0] === 'text' ||\n type.split(';')[0].trim() === 'application/json')\n ) {\n try {\n return toUtf8String(value);\n } catch (error) {}\n }\n return hexlify(value);\n }\n\n return value;\n}\n\n// Exported Types\nexport type ConnectionInfo = {\n url: string;\n headers?: { [key: string]: string | number };\n\n user?: string;\n password?: string;\n\n allowInsecureAuthentication?: boolean;\n allowGzip?: boolean;\n\n throttleLimit?: number;\n throttleSlotInterval?: number;\n throttleCallback?: (attempt: number, url: string) => Promise<boolean>;\n\n skipFetchSetup?: boolean;\n fetchOptions?: Record<string, string>;\n errorPassThrough?: boolean;\n\n timeout?: number;\n\n agents?: {\n http?: http.Agent;\n https?: https.Agent;\n };\n};\n\nexport interface OnceBlockable {\n once(eventName: 'block', handler: () => void): void;\n}\n\nexport interface OncePollable {\n once(eventName: 'poll', handler: () => void): void;\n}\n\nexport type PollOptions = {\n timeout?: number;\n floor?: number;\n ceiling?: number;\n interval?: number;\n retryLimit?: number;\n onceBlock?: OnceBlockable;\n oncePoll?: OncePollable;\n};\n\nexport type FetchJsonResponse = {\n statusCode: number;\n headers: { [header: string]: string };\n};\n\ntype Header = { key: string; value: string };\n\nfunction unpercent(value: string): Uint8Array {\n return toUtf8Bytes(\n value.replace(/%([0-9a-f][0-9a-f])/gi, (all, code) => {\n return String.fromCharCode(parseInt(code, 16));\n }),\n );\n}\n\n// This API is still a work in progress; the future changes will likely be:\n// - ConnectionInfo => FetchDataRequest<T = any>\n// - FetchDataRequest.body? = string | Uint8Array | { contentType: string, data: string | Uint8Array }\n// - If string => text/plain, Uint8Array => application/octet-stream (if content-type unspecified)\n// - FetchDataRequest.processFunc = (body: Uint8Array, response: FetchDataResponse) => T\n// For this reason, it should be considered internal until the API is finalized\nexport function _fetchData<T = Uint8Array>(\n connection: string | ConnectionInfo,\n body?: Uint8Array,\n processFunc?: (value: Uint8Array, response: FetchJsonResponse) => T,\n): Promise<T> {\n // How many times to retry in the event of a throttle\n const attemptLimit =\n typeof connection === 'object' && connection.throttleLimit != null\n ? connection.throttleLimit\n : 12;\n logger.assertArgument(\n attemptLimit > 0 && attemptLimit % 1 === 0,\n 'invalid connection throttle limit',\n 'connection.throttleLimit',\n attemptLimit,\n );\n\n const throttleCallback =\n typeof connection === 'object' ? connection.throttleCallback : null;\n const throttleSlotInterval =\n typeof connection === 'object' &&\n typeof connection.throttleSlotInterval === 'number'\n ? connection.throttleSlotInterval\n : 100;\n logger.assertArgument(\n throttleSlotInterval > 0 && throttleSlotInterval % 1 === 0,\n 'invalid connection throttle slot interval',\n 'connection.throttleSlotInterval',\n throttleSlotInterval,\n );\n\n const errorPassThrough =\n typeof connection === 'object' ? !!connection.errorPassThrough : false;\n\n const headers: { [key: string]: Header } = {};\n\n let url: string = null;\n\n // @TODO: Allow ConnectionInfo to override some of these values\n const options: Options = {\n method: 'GET',\n };\n\n let allow304 = false;\n\n let timeout = 2 * 60 * 1000;\n\n if (typeof connection === 'string') {\n url = connection;\n } else if (typeof connection === 'object') {\n if (connection == null || connection.url == null) {\n logger.throwArgumentError('missing URL', 'connection.url', connection);\n }\n\n url = connection.url;\n\n if (typeof connection.timeout === 'number' && connection.timeout > 0) {\n timeout = connection.timeout;\n }\n\n if (connection.headers) {\n for (const key in connection.headers) {\n headers[key.toLowerCase()] = {\n key: key,\n value: String(connection.headers[key]),\n };\n if (\n ['if-none-match', 'if-modified-since'].indexOf(key.toLowerCase()) >= 0\n ) {\n allow304 = true;\n }\n }\n }\n\n options.allowGzip = !!connection.allowGzip;\n\n if (connection.user != null && connection.password != null) {\n if (\n url.substring(0, 6) !== 'https:' &&\n connection.allowInsecureAuthentication !== true\n ) {\n logger.throwError(\n 'basic authentication requires a secure https url',\n Logger.errors.INVALID_ARGUMENT,\n {\n argument: 'url',\n url: url,\n user: connection.user,\n password: '[REDACTED]',\n },\n );\n }\n\n const authorization = connection.user + ':' + connection.password;\n headers['authorization'] = {\n key: 'Authorization',\n value: 'Basic ' + base64Encode(toUtf8Bytes(authorization)),\n };\n }\n\n if (connection.skipFetchSetup != null) {\n options.skipFetchSetup = !!connection.skipFetchSetup;\n }\n\n if (connection.fetchOptions != null) {\n options.fetchOptions = shallowCopy(connection.fetchOptions);\n }\n\n if (connection.agents != null) {\n options.agents = connection.agents;\n }\n }\n\n const reData = new RegExp('^data:([^;:]*)?(;base64)?,(.*)$', 'i');\n const dataMatch = url ? url.match(reData) : null;\n if (dataMatch) {\n try {\n const response = {\n statusCode: 200,\n statusMessage: 'OK',\n headers: { 'content-type': dataMatch[1] || 'text/plain' },\n body: dataMatch[2]\n ? base64Decode(dataMatch[3])\n : unpercent(dataMatch[3]),\n };\n\n let result: T = <T>(<unknown>response.body);\n if (processFunc) {\n result = processFunc(response.body, response);\n }\n return Promise.resolve(<T>(<unknown>result));\n } catch (error) {\n logger.throwError(\n 'processing response error',\n Logger.errors.SERVER_ERROR,\n {\n body: bodyify(dataMatch[1], dataMatch[2]),\n error: error,\n requestBody: null,\n requestMethod: 'GET',\n url: url,\n },\n );\n }\n }\n\n if (body) {\n options.method = 'POST';\n options.body = body;\n if (headers['content-type'] == null) {\n headers['content-type'] = {\n key: 'Content-Type',\n value: 'application/octet-stream',\n };\n }\n if (headers['content-length'] == null) {\n headers['content-length'] = {\n key: 'Content-Length',\n value: String(body.length),\n };\n }\n }\n\n const flatHeaders: { [key: string]: string } = {};\n Object.keys(headers).forEach((key) => {\n const header = headers[key];\n flatHeaders[header.key] = header.value;\n });\n options.headers = flatHeaders;\n\n const runningTimeout = (function () {\n let timer: NodeJS.Timer = null;\n const promise: Promise<never> = new Promise(function (resolve, reject) {\n if (timeout) {\n timer = setTimeout(() => {\n if (timer == null) {\n return;\n }\n timer = null;\n\n reject(\n logger.makeError('timeout', Logger.errors.TIMEOUT, {\n requestBody: bodyify(options.body, flatHeaders['content-type']),\n requestMethod: options.method,\n timeout: timeout,\n url: url,\n }),\n );\n }, timeout);\n }\n });\n\n const cancel = function () {\n if (timer == null) {\n return;\n }\n clearTimeout(timer);\n timer = null;\n };\n\n return { promise, cancel };\n })();\n\n const runningFetch = (async function () {\n for (let attempt = 0; attempt < attemptLimit; attempt++) {\n let response: GetUrlResponse = null;\n\n try {\n response = await getUrl(url, options);\n\n if (response.statusCode === 301 || response.statusCode === 302) {\n // Redirection; for now we only support absolute locataions\n const location = response.headers.location || '';\n if (options.method === 'GET' && location.match(/^https:/)) {\n url = response.headers.location;\n continue;\n }\n } else if (response.statusCode === 429) {\n // If it's the last attempt we throw an error with the response\n if (attempt == attemptLimit - 1) {\n const err = new Error('rate limited');\n (err as any).response = response;\n throw err;\n }\n\n // Exponential back-off throttling\n let tryAgain = true;\n if (throttleCallback) {\n tryAgain = await throttleCallback(attempt, url);\n }\n\n if (tryAgain) {\n let stall = 0;\n\n const retryAfter = response.headers['retry-after'];\n if (\n typeof retryAfter === 'string' &&\n retryAfter.match(/^[1-9][0-9]*$/)\n ) {\n stall = parseInt(retryAfter) * 1000;\n } else {\n stall =\n throttleSlotInterval *\n parseInt(String(Math.random() * Math.pow(2, attempt)));\n }\n\n //console.log(\"Stalling 429\");\n await staller(stall);\n continue;\n }\n }\n } catch (error) {\n response = (<any>error).response;\n if (response == null) {\n runningTimeout.cancel();\n logger.throwError('missing response', Logger.errors.SERVER_ERROR, {\n requestBody: bodyify(options.body, flatHeaders['content-type']),\n requestMethod: options.method,\n serverError: error,\n url: url,\n });\n }\n }\n\n let body = response.body;\n\n if (allow304 && response.statusCode === 304) {\n body = null;\n } else if (\n !errorPassThrough &&\n (response.statusCode < 200 || response.statusCode >= 300)\n ) {\n runningTimeout.cancel();\n logger.throwError('bad response', Logger.errors.SERVER_ERROR, {\n status: response.statusCode,\n headers: response.headers,\n body: bodyify(\n body,\n response.headers ? response.headers['content-type'] : null,\n ),\n requestBody: bodyify(options.body, flatHeaders['content-type']),\n requestMethod: options.method,\n url: url,\n });\n }\n\n if (processFunc) {\n try {\n const result = await processFunc(body, response);\n runningTimeout.cancel();\n return result;\n } catch (error) {\n // Allow the processFunc to trigger a throttle\n if (error.throttleRetry && attempt < attemptLimit) {\n let tryAgain = true;\n if (throttleCallback) {\n tryAgain = await throttleCallback(attempt, url);\n }\n\n if (tryAgain) {\n const timeout =\n throttleSlotInterval *\n parseInt(String(Math.random() * Math.pow(2, attempt)));\n //console.log(\"Stalling callback\");\n await staller(timeout);\n continue;\n }\n }\n\n runningTimeout.cancel();\n logger.throwError(\n 'processing response error',\n Logger.errors.SERVER_ERROR,\n {\n body: bodyify(\n body,\n response.headers ? response.headers['content-type'] : null,\n ),\n error: error,\n requestBody: bodyify(options.body, flatHeaders['content-type']),\n requestMethod: options.method,\n url: url,\n },\n );\n }\n }\n\n runningTimeout.cancel();\n\n // If we had a processFunc, it either returned a T or threw above.\n // The \"body\" is now a Uint8Array.\n return <T>(<unknown>body);\n }\n\n return logger.throwError('failed response', Logger.errors.SERVER_ERROR, {\n requestBody: bodyify(options.body, flatHeaders['content-type']),\n requestMethod: options.method,\n url: url,\n });\n })();\n\n return Promise.race([runningTimeout.promise, runningFetch]);\n}\n\nexport function fetchJson(\n connection: string | ConnectionInfo,\n json?: string,\n processFunc?: (value: any, response: FetchJsonResponse) => any,\n): Promise<any> {\n let processJsonFunc = (value: Uint8Array, response: FetchJsonResponse) => {\n let result: any = null;\n if (value != null) {\n try {\n result = JSON.parse(toUtf8String(value));\n } catch (error) {\n logger.throwError('invalid JSON', Logger.errors.SERVER_ERROR, {\n body: value,\n error: error,\n });\n }\n }\n\n if (processFunc) {\n result = processFunc(result, response);\n }\n\n return result;\n };\n\n // If we have json to send, we must\n // - add content-type of application/json (unless already overridden)\n // - convert the json to bytes\n let body: Uint8Array = null;\n if (json != null) {\n body = toUtf8Bytes(json);\n\n // Create a connection with the content-type set for JSON\n const updated: ConnectionInfo =\n typeof connection === 'string'\n ? { url: connection }\n : shallowCopy(connection);\n if (updated.headers) {\n const hasContentType =\n Object.keys(updated.headers).filter(\n (k) => k.toLowerCase() === 'content-type',\n ).length !== 0;\n if (!hasContentType) {\n updated.headers = shallowCopy(updated.headers);\n updated.headers['content-type'] = 'application/json';\n }\n } else {\n updated.headers = { 'content-type': 'application/json' };\n }\n connection = updated;\n }\n\n return _fetchData<any>(connection, body, processJsonFunc);\n}\n\nexport function poll<T>(\n func: () => Promise<T>,\n options?: PollOptions,\n): Promise<T> {\n if (!options) {\n options = {};\n }\n options = shallowCopy(options);\n if (options.floor == null) {\n options.floor = 0;\n }\n if (options.ceiling == null) {\n options.ceiling = 10000;\n }\n if (options.interval == null) {\n options.interval = 250;\n }\n\n return new Promise(function (resolve, reject) {\n let timer: NodeJS.Timer = null;\n let done: boolean = false;\n\n // Returns true if cancel was successful. Unsuccessful cancel means we're already done.\n const cancel = (): boolean => {\n if (done) {\n return false;\n }\n done = true;\n if (timer) {\n clearTimeout(timer);\n }\n return true;\n };\n\n if (options.timeout) {\n timer = setTimeout(() => {\n if (cancel()) {\n reject(new Error('timeout'));\n }\n }, options.timeout);\n }\n\n const retryLimit = options.retryLimit;\n\n let attempt = 0;\n function check() {\n return func().then(\n function (result) {\n // If we have a result, or are allowed null then we're done\n if (result !== undefined) {\n if (cancel()) {\n resolve(result);\n }\n } else if (options.oncePoll) {\n options.oncePoll.once('poll', check);\n } else if (options.onceBlock) {\n options.onceBlock.once('block', check);\n\n // Otherwise, exponential back-off (up to 10s) our next request\n } else if (!done) {\n attempt++;\n if (attempt > retryLimit) {\n if (cancel()) {\n reject(new Error('retry limit reached'));\n }\n return;\n }\n\n let timeout =\n options.interval *\n parseInt(String(Math.random() * Math.pow(2, attempt)));\n if (timeout < options.floor) {\n timeout = options.floor;\n }\n if (timeout > options.ceiling) {\n timeout = options.ceiling;\n }\n\n setTimeout(check, timeout);\n }\n\n return null;\n },\n function (error) {\n if (cancel()) {\n reject(error);\n }\n },\n );\n }\n check();\n });\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import http from 'http';
4
+ import https from 'https';
5
+ export type GetUrlResponse = {
6
+ statusCode: number;
7
+ statusMessage: string;
8
+ headers: {
9
+ [key: string]: string;
10
+ };
11
+ body: Uint8Array;
12
+ };
13
+ export type Options = {
14
+ method?: string;
15
+ allowGzip?: boolean;
16
+ body?: Uint8Array;
17
+ headers?: {
18
+ [key: string]: string;
19
+ };
20
+ skipFetchSetup?: boolean;
21
+ fetchOptions?: Record<string, string>;
22
+ agents?: {
23
+ http?: http.Agent;
24
+ https?: https.Agent;
25
+ };
26
+ };
@@ -0,0 +1,4 @@
1
+ /* eslint-disable */
2
+ 'use strict';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ethereum/ethers/web/types.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,YAAY,CAAC","sourcesContent":["/* eslint-disable */\n'use strict';\nimport http from 'http';\nimport https from 'https';\n\nexport type GetUrlResponse = {\n statusCode: number;\n statusMessage: string;\n headers: { [key: string]: string };\n body: Uint8Array;\n};\n\nexport type Options = {\n method?: string;\n allowGzip?: boolean;\n body?: Uint8Array;\n headers?: { [key: string]: string };\n skipFetchSetup?: boolean;\n fetchOptions?: Record<string, string>;\n agents?: {\n http?: http.Agent;\n https?: https.Agent;\n };\n};\n"]}
@@ -0,0 +1,34 @@
1
+ import { Block, BlockTag, BlockWithTransactions, EventType, Filter, Listener, Log, TransactionReceipt, TransactionRequest, TransactionResponse, Provider } from '@ethersproject/abstract-provider';
2
+ import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
3
+ import type { Network } from '@ethersproject/networks';
4
+ import type { Deferrable } from '@ethersproject/properties';
5
+ export default class SafeEthProvider extends Provider {
6
+ private baseApi;
7
+ private blockHeight;
8
+ constructor(baseApi: Provider, blockHeight: BlockTag | Promise<BlockTag>);
9
+ getBalance(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<BigNumber>;
10
+ getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
11
+ getCode(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
12
+ getStorageAt(addressOrName: string | Promise<string>, position: BigNumberish | Promise<BigNumberish>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
13
+ call(transaction: Deferrable<TransactionRequest>, blockTag?: BlockTag | Promise<BlockTag>): Promise<string>;
14
+ getBlockWithTransactions(blockHashOrBlockTag: BlockTag | Promise<BlockTag>): Promise<BlockWithTransactions>;
15
+ getBlock(blockHashOrBlockTag: BlockTag | Promise<BlockTag>): Promise<Block>;
16
+ getTransaction(transactionHash: string): Promise<TransactionResponse>;
17
+ getTransactionReceipt(transactionHash: string): Promise<TransactionReceipt>;
18
+ getLogs(filter: Filter): Promise<Log[]>;
19
+ getBlockNumber(): Promise<number>;
20
+ getNetwork(): Promise<Network>;
21
+ getGasPrice(): Promise<BigNumber>;
22
+ estimateGas(transaction: Deferrable<TransactionRequest>): Promise<BigNumber>;
23
+ sendTransaction(signedTransaction: string | Promise<string>): Promise<TransactionResponse>;
24
+ resolveName(name: string | Promise<string>): Promise<string | null>;
25
+ lookupAddress(address: string | Promise<string>): Promise<string | null>;
26
+ on(eventName: EventType, listener: Listener): Provider;
27
+ once(eventName: EventType, listener: Listener): Provider;
28
+ emit(eventName: EventType, ...args: any[]): boolean;
29
+ listenerCount(eventName?: EventType): number;
30
+ listeners(eventName?: EventType): Listener[];
31
+ off(eventName: EventType, listener?: Listener): Provider;
32
+ removeAllListeners(eventName?: EventType): Provider;
33
+ waitForTransaction(transactionHash: string, confirmations?: number, timeout?: number): Promise<TransactionReceipt>;
34
+ }