@qevm/providers 1.0.2 → 1.0.4
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/README.md +3 -9
- package/lib/_version.d.ts +1 -1
- package/lib/_version.js +1 -1
- package/lib/base-provider.d.ts +2 -2
- package/lib/base-provider.d.ts.map +1 -1
- package/lib/base-provider.js +300 -145
- package/lib/base-provider.js.map +1 -1
- package/lib/browser-ipc-provider.d.ts.map +1 -1
- package/lib/browser-ipc-provider.js.map +1 -1
- package/lib/browser-net.d.ts.map +1 -1
- package/lib/browser-net.js.map +1 -1
- package/lib/browser-ws.d.ts.map +1 -1
- package/lib/browser-ws.js +2 -2
- package/lib/browser-ws.js.map +1 -1
- package/lib/fallback-provider.d.ts +1 -1
- package/lib/fallback-provider.d.ts.map +1 -1
- package/lib/fallback-provider.js +86 -55
- package/lib/fallback-provider.js.map +1 -1
- package/lib/formatter.d.ts.map +1 -1
- package/lib/formatter.js +35 -29
- package/lib/formatter.js.map +1 -1
- package/lib/index.d.ts +3 -10
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -29
- package/lib/index.js.map +1 -1
- package/lib/ipc-provider.d.ts +1 -1
- package/lib/ipc-provider.d.ts.map +1 -1
- package/lib/ipc-provider.js +6 -4
- package/lib/ipc-provider.js.map +1 -1
- package/lib/json-rpc-batch-provider.d.ts.map +1 -1
- package/lib/json-rpc-batch-provider.js +6 -6
- package/lib/json-rpc-batch-provider.js.map +1 -1
- package/lib/json-rpc-provider.d.ts +2 -2
- package/lib/json-rpc-provider.d.ts.map +1 -1
- package/lib/json-rpc-provider.js +167 -69
- package/lib/json-rpc-provider.js.map +1 -1
- package/lib/url-json-rpc-provider.d.ts +1 -1
- package/lib/url-json-rpc-provider.d.ts.map +1 -1
- package/lib/url-json-rpc-provider.js +4 -4
- package/lib/url-json-rpc-provider.js.map +1 -1
- package/lib/web3-provider.d.ts +1 -2
- package/lib/web3-provider.d.ts.map +1 -1
- package/lib/web3-provider.js +11 -14
- package/lib/web3-provider.js.map +1 -1
- package/lib/websocket-provider.d.ts +1 -1
- package/lib/websocket-provider.d.ts.map +1 -1
- package/lib/websocket-provider.js +21 -17
- package/lib/websocket-provider.js.map +1 -1
- package/lib/ws.d.ts.map +1 -1
- package/package.json +61 -58
- package/src.ts/_version.ts +1 -1
- package/src.ts/base-provider.ts +1418 -645
- package/src.ts/browser-ipc-provider.ts +1 -3
- package/src.ts/browser-net.ts +1 -1
- package/src.ts/browser-ws.ts +14 -8
- package/src.ts/fallback-provider.ts +375 -198
- package/src.ts/formatter.ts +161 -81
- package/src.ts/index.ts +54 -68
- package/src.ts/ipc-provider.ts +8 -7
- package/src.ts/json-rpc-batch-provider.ts +48 -44
- package/src.ts/json-rpc-provider.ts +594 -245
- package/src.ts/url-json-rpc-provider.ts +34 -15
- package/src.ts/web3-provider.ts +87 -54
- package/src.ts/websocket-provider.ts +124 -66
- package/src.ts/ws.ts +1 -1
- package/lib/alchemy-provider.d.ts +0 -17
- package/lib/alchemy-provider.d.ts.map +0 -1
- package/lib/alchemy-provider.js +0 -88
- package/lib/alchemy-provider.js.map +0 -1
- package/lib/ankr-provider.d.ts +0 -10
- package/lib/ankr-provider.d.ts.map +0 -1
- package/lib/ankr-provider.js +0 -59
- package/lib/ankr-provider.js.map +0 -1
- package/lib/cloudflare-provider.d.ts +0 -8
- package/lib/cloudflare-provider.d.ts.map +0 -1
- package/lib/cloudflare-provider.js +0 -37
- package/lib/cloudflare-provider.js.map +0 -1
- package/lib/etherscan-provider.d.ts +0 -18
- package/lib/etherscan-provider.d.ts.map +0 -1
- package/lib/etherscan-provider.js +0 -408
- package/lib/etherscan-provider.js.map +0 -1
- package/lib/infura-provider.d.ts +0 -21
- package/lib/infura-provider.d.ts.map +0 -1
- package/lib/infura-provider.js +0 -117
- package/lib/infura-provider.js.map +0 -1
- package/lib/nodesmith-provider.d.ts +0 -7
- package/lib/nodesmith-provider.d.ts.map +0 -1
- package/lib/nodesmith-provider.js +0 -44
- package/lib/nodesmith-provider.js.map +0 -1
- package/lib/pocket-provider.d.ts +0 -12
- package/lib/pocket-provider.d.ts.map +0 -1
- package/lib/pocket-provider.js +0 -78
- package/lib/pocket-provider.js.map +0 -1
- package/src.ts/alchemy-provider.ts +0 -101
- package/src.ts/ankr-provider.ts +0 -68
- package/src.ts/cloudflare-provider.ts +0 -42
- package/src.ts/etherscan-provider.ts +0 -454
- package/src.ts/infura-provider.ts +0 -143
- package/src.ts/nodesmith-provider.ts +0 -50
- package/src.ts/pocket-provider.ts +0 -93
package/lib/base-provider.js
CHANGED
|
@@ -11,13 +11,13 @@ const bignumber_1 = require("@qevm/bignumber");
|
|
|
11
11
|
const bytes_1 = require("@qevm/bytes");
|
|
12
12
|
const constants_1 = require("@qevm/constants");
|
|
13
13
|
const hash_1 = require("@qevm/hash");
|
|
14
|
-
const networks_1 = require("@
|
|
15
|
-
const properties_1 = require("@
|
|
14
|
+
const networks_1 = require("@qevm/networks");
|
|
15
|
+
const properties_1 = require("@qevm/properties");
|
|
16
16
|
const sha2_1 = require("@qevm/sha2");
|
|
17
17
|
const strings_1 = require("@qevm/strings");
|
|
18
18
|
const web_1 = require("@qevm/web");
|
|
19
19
|
const bech32_1 = __importDefault(require("bech32"));
|
|
20
|
-
const logger_1 = require("@
|
|
20
|
+
const logger_1 = require("@qevm/logger");
|
|
21
21
|
const _version_1 = require("./_version");
|
|
22
22
|
const logger = new logger_1.Logger(_version_1.version);
|
|
23
23
|
const formatter_1 = require("./formatter");
|
|
@@ -39,7 +39,8 @@ function serializeTopics(topics) {
|
|
|
39
39
|
while (topics.length > 0 && topics[topics.length - 1] == null) {
|
|
40
40
|
topics.pop();
|
|
41
41
|
}
|
|
42
|
-
return topics
|
|
42
|
+
return topics
|
|
43
|
+
.map((topic) => {
|
|
43
44
|
if (Array.isArray(topic)) {
|
|
44
45
|
// Only track unique OR-topics
|
|
45
46
|
const unique = {};
|
|
@@ -54,7 +55,8 @@ function serializeTopics(topics) {
|
|
|
54
55
|
else {
|
|
55
56
|
return checkTopic(topic);
|
|
56
57
|
}
|
|
57
|
-
})
|
|
58
|
+
})
|
|
59
|
+
.join("&");
|
|
58
60
|
}
|
|
59
61
|
function deserializeTopics(data) {
|
|
60
62
|
if (data === "") {
|
|
@@ -65,13 +67,13 @@ function deserializeTopics(data) {
|
|
|
65
67
|
return [];
|
|
66
68
|
}
|
|
67
69
|
const comps = topic.split("|").map((topic) => {
|
|
68
|
-
return
|
|
70
|
+
return topic === "null" ? null : topic;
|
|
69
71
|
});
|
|
70
|
-
return
|
|
72
|
+
return comps.length === 1 ? comps[0] : comps;
|
|
71
73
|
});
|
|
72
74
|
}
|
|
73
75
|
function getEventTag(eventName) {
|
|
74
|
-
if (typeof
|
|
76
|
+
if (typeof eventName === "string") {
|
|
75
77
|
eventName = eventName.toLowerCase();
|
|
76
78
|
if ((0, bytes_1.hexDataLength)(eventName) === 32) {
|
|
77
79
|
return "tx:" + eventName;
|
|
@@ -87,15 +89,18 @@ function getEventTag(eventName) {
|
|
|
87
89
|
logger.warn("not implemented");
|
|
88
90
|
throw new Error("not implemented");
|
|
89
91
|
}
|
|
90
|
-
else if (eventName && typeof
|
|
91
|
-
return "filter:" +
|
|
92
|
+
else if (eventName && typeof eventName === "object") {
|
|
93
|
+
return ("filter:" +
|
|
94
|
+
(eventName.address || "*") +
|
|
95
|
+
":" +
|
|
96
|
+
serializeTopics(eventName.topics || []));
|
|
92
97
|
}
|
|
93
98
|
throw new Error("invalid event - " + eventName);
|
|
94
99
|
}
|
|
95
100
|
//////////////////////////////
|
|
96
101
|
// Helper Object
|
|
97
102
|
function getTime() {
|
|
98
|
-
return
|
|
103
|
+
return new Date().getTime();
|
|
99
104
|
}
|
|
100
105
|
function stall(duration) {
|
|
101
106
|
return new Promise((resolve) => {
|
|
@@ -165,7 +170,6 @@ class Event {
|
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
exports.Event = Event;
|
|
168
|
-
;
|
|
169
173
|
// https://github.com/satoshilabs/slips/blob/master/slip-0044.md
|
|
170
174
|
const coinInfos = {
|
|
171
175
|
"0": { symbol: "btc", p2pkh: 0x00, p2sh: 0x05, prefix: "bc" },
|
|
@@ -227,7 +231,7 @@ function numPad(value) {
|
|
|
227
231
|
return padded;
|
|
228
232
|
}
|
|
229
233
|
function bytesPad(value) {
|
|
230
|
-
if (
|
|
234
|
+
if (value.length % 32 === 0) {
|
|
231
235
|
return value;
|
|
232
236
|
}
|
|
233
237
|
const result = new Uint8Array(Math.ceil(value.length / 32) * 32);
|
|
@@ -265,12 +269,15 @@ class Resolver {
|
|
|
265
269
|
supportsWildcard() {
|
|
266
270
|
if (!this._supportsEip2544) {
|
|
267
271
|
// supportsInterface(bytes4 = selector("resolve(bytes,bytes)"))
|
|
268
|
-
this._supportsEip2544 = this.provider
|
|
272
|
+
this._supportsEip2544 = this.provider
|
|
273
|
+
.call({
|
|
269
274
|
to: this.address,
|
|
270
|
-
data: "0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"
|
|
271
|
-
})
|
|
275
|
+
data: "0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000",
|
|
276
|
+
})
|
|
277
|
+
.then((result) => {
|
|
272
278
|
return bignumber_1.BigNumber.from(result).eq(1);
|
|
273
|
-
})
|
|
279
|
+
})
|
|
280
|
+
.catch((error) => {
|
|
274
281
|
if (error.code === logger_1.Logger.errors.CALL_EXCEPTION) {
|
|
275
282
|
return false;
|
|
276
283
|
}
|
|
@@ -286,20 +293,28 @@ class Resolver {
|
|
|
286
293
|
const tx = {
|
|
287
294
|
to: this.address,
|
|
288
295
|
ccipReadEnabled: true,
|
|
289
|
-
data: (0, bytes_1.hexConcat)([
|
|
296
|
+
data: (0, bytes_1.hexConcat)([
|
|
297
|
+
selector,
|
|
298
|
+
(0, hash_1.namehash)(this.name),
|
|
299
|
+
parameters || "0x",
|
|
300
|
+
]),
|
|
290
301
|
};
|
|
291
302
|
// Wildcard support; use EIP-2544 to resolve the request
|
|
292
303
|
let parseBytes = false;
|
|
293
304
|
if (await this.supportsWildcard()) {
|
|
294
305
|
parseBytes = true;
|
|
295
306
|
// selector("resolve(bytes,bytes)")
|
|
296
|
-
tx.data = (0, bytes_1.hexConcat)([
|
|
307
|
+
tx.data = (0, bytes_1.hexConcat)([
|
|
308
|
+
"0x9061b923",
|
|
309
|
+
encodeBytes([(0, hash_1.dnsEncode)(this.name), tx.data]),
|
|
310
|
+
]);
|
|
297
311
|
}
|
|
298
312
|
try {
|
|
299
313
|
let result = await this.provider.call(tx);
|
|
300
|
-
if ((
|
|
314
|
+
if ((0, bytes_1.arrayify)(result).length % 32 === 4) {
|
|
301
315
|
logger.throwError("resolver threw error", logger_1.Logger.errors.CALL_EXCEPTION, {
|
|
302
|
-
transaction: tx,
|
|
316
|
+
transaction: tx,
|
|
317
|
+
data: result,
|
|
303
318
|
});
|
|
304
319
|
}
|
|
305
320
|
if (parseBytes) {
|
|
@@ -325,7 +340,7 @@ class Resolver {
|
|
|
325
340
|
const coinInfo = coinInfos[String(coinType)];
|
|
326
341
|
if (coinInfo == null) {
|
|
327
342
|
logger.throwError(`unsupported coin type: ${coinType}`, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
328
|
-
operation: `getAddress(${coinType})
|
|
343
|
+
operation: `getAddress(${coinType})`,
|
|
329
344
|
});
|
|
330
345
|
}
|
|
331
346
|
if (coinInfo.ilk === "eth") {
|
|
@@ -337,8 +352,10 @@ class Resolver {
|
|
|
337
352
|
const p2pkh = hexBytes.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);
|
|
338
353
|
if (p2pkh) {
|
|
339
354
|
const length = parseInt(p2pkh[1], 16);
|
|
340
|
-
if (p2pkh[2].length === length * 2 &&
|
|
341
|
-
|
|
355
|
+
if (p2pkh[2].length === length * 2 &&
|
|
356
|
+
length >= 1 &&
|
|
357
|
+
length <= 75) {
|
|
358
|
+
return base58Encode((0, bytes_1.concat)([[coinInfo.p2pkh], "0x" + p2pkh[2]]));
|
|
342
359
|
}
|
|
343
360
|
}
|
|
344
361
|
}
|
|
@@ -347,8 +364,10 @@ class Resolver {
|
|
|
347
364
|
const p2sh = hexBytes.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);
|
|
348
365
|
if (p2sh) {
|
|
349
366
|
const length = parseInt(p2sh[1], 16);
|
|
350
|
-
if (p2sh[2].length === length * 2 &&
|
|
351
|
-
|
|
367
|
+
if (p2sh[2].length === length * 2 &&
|
|
368
|
+
length >= 1 &&
|
|
369
|
+
length <= 75) {
|
|
370
|
+
return base58Encode((0, bytes_1.concat)([[coinInfo.p2sh], "0x" + p2sh[2]]));
|
|
352
371
|
}
|
|
353
372
|
}
|
|
354
373
|
}
|
|
@@ -365,7 +384,10 @@ class Resolver {
|
|
|
365
384
|
else {
|
|
366
385
|
version = -1;
|
|
367
386
|
}
|
|
368
|
-
if (version >= 0 &&
|
|
387
|
+
if (version >= 0 &&
|
|
388
|
+
bytes.length === 2 + length &&
|
|
389
|
+
length >= 1 &&
|
|
390
|
+
length <= 75) {
|
|
369
391
|
const words = bech32_1.default.toWords(bytes.slice(2));
|
|
370
392
|
words.unshift(version);
|
|
371
393
|
return bech32_1.default.encode(coinInfo.prefix, words);
|
|
@@ -407,13 +429,15 @@ class Resolver {
|
|
|
407
429
|
logger.throwError(`invalid or unsupported coin data`, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
408
430
|
operation: `getAddress(${coinType})`,
|
|
409
431
|
coinType: coinType,
|
|
410
|
-
data: hexBytes
|
|
432
|
+
data: hexBytes,
|
|
411
433
|
});
|
|
412
434
|
}
|
|
413
435
|
return address;
|
|
414
436
|
}
|
|
415
437
|
async getAvatar() {
|
|
416
|
-
const linkage = [
|
|
438
|
+
const linkage = [
|
|
439
|
+
{ type: "name", content: this.name },
|
|
440
|
+
];
|
|
417
441
|
try {
|
|
418
442
|
// test data for ricmoo.eth
|
|
419
443
|
//const avatar = "eip155:1/erc721:0x265385c7f4132228A0d54EB1A9e7460b91c0cC68/29233";
|
|
@@ -440,10 +464,10 @@ class Resolver {
|
|
|
440
464
|
case "erc721":
|
|
441
465
|
case "erc1155": {
|
|
442
466
|
// Depending on the ERC type, use tokenURI(uint256) or url(uint256)
|
|
443
|
-
const selector =
|
|
467
|
+
const selector = scheme === "erc721" ? "0xc87b56dd" : "0x0e89341c";
|
|
444
468
|
linkage.push({ type: scheme, content: avatar });
|
|
445
469
|
// The owner of this name
|
|
446
|
-
const owner =
|
|
470
|
+
const owner = this._resolvedAddress || (await this.getAddress());
|
|
447
471
|
const comps = (match[2] || "").split("/");
|
|
448
472
|
if (comps.length !== 2) {
|
|
449
473
|
return null;
|
|
@@ -454,52 +478,79 @@ class Resolver {
|
|
|
454
478
|
if (scheme === "erc721") {
|
|
455
479
|
// ownerOf(uint256 tokenId)
|
|
456
480
|
const tokenOwner = this.provider.formatter.callAddress(await this.provider.call({
|
|
457
|
-
to: addr,
|
|
481
|
+
to: addr,
|
|
482
|
+
data: (0, bytes_1.hexConcat)([
|
|
483
|
+
"0x6352211e",
|
|
484
|
+
tokenId,
|
|
485
|
+
]),
|
|
458
486
|
}));
|
|
459
487
|
if (owner !== tokenOwner) {
|
|
460
488
|
return null;
|
|
461
489
|
}
|
|
462
|
-
linkage.push({
|
|
490
|
+
linkage.push({
|
|
491
|
+
type: "owner",
|
|
492
|
+
content: tokenOwner,
|
|
493
|
+
});
|
|
463
494
|
}
|
|
464
495
|
else if (scheme === "erc1155") {
|
|
465
496
|
// balanceOf(address owner, uint256 tokenId)
|
|
466
497
|
const balance = bignumber_1.BigNumber.from(await this.provider.call({
|
|
467
|
-
to: addr,
|
|
498
|
+
to: addr,
|
|
499
|
+
data: (0, bytes_1.hexConcat)([
|
|
500
|
+
"0x00fdd58e",
|
|
501
|
+
(0, bytes_1.hexZeroPad)(owner, 32),
|
|
502
|
+
tokenId,
|
|
503
|
+
]),
|
|
468
504
|
}));
|
|
469
505
|
if (balance.isZero()) {
|
|
470
506
|
return null;
|
|
471
507
|
}
|
|
472
|
-
linkage.push({
|
|
508
|
+
linkage.push({
|
|
509
|
+
type: "balance",
|
|
510
|
+
content: balance.toString(),
|
|
511
|
+
});
|
|
473
512
|
}
|
|
474
513
|
// Call the token contract for the metadata URL
|
|
475
514
|
const tx = {
|
|
476
515
|
to: this.provider.formatter.address(comps[0]),
|
|
477
|
-
data: (0, bytes_1.hexConcat)([selector, tokenId])
|
|
516
|
+
data: (0, bytes_1.hexConcat)([selector, tokenId]),
|
|
478
517
|
};
|
|
479
518
|
let metadataUrl = _parseString(await this.provider.call(tx), 0);
|
|
480
519
|
if (metadataUrl == null) {
|
|
481
520
|
return null;
|
|
482
521
|
}
|
|
483
|
-
linkage.push({
|
|
522
|
+
linkage.push({
|
|
523
|
+
type: "metadata-url-base",
|
|
524
|
+
content: metadataUrl,
|
|
525
|
+
});
|
|
484
526
|
// ERC-1155 allows a generic {id} in the URL
|
|
485
527
|
if (scheme === "erc1155") {
|
|
486
528
|
metadataUrl = metadataUrl.replace("{id}", tokenId.substring(2));
|
|
487
|
-
linkage.push({
|
|
529
|
+
linkage.push({
|
|
530
|
+
type: "metadata-url-expanded",
|
|
531
|
+
content: metadataUrl,
|
|
532
|
+
});
|
|
488
533
|
}
|
|
489
534
|
// Transform IPFS metadata links
|
|
490
535
|
if (metadataUrl.match(/^ipfs:/i)) {
|
|
491
536
|
metadataUrl = getIpfsLink(metadataUrl);
|
|
492
537
|
}
|
|
493
|
-
linkage.push({
|
|
538
|
+
linkage.push({
|
|
539
|
+
type: "metadata-url",
|
|
540
|
+
content: metadataUrl,
|
|
541
|
+
});
|
|
494
542
|
// Get the token metadata
|
|
495
543
|
const metadata = await (0, web_1.fetchJson)(metadataUrl);
|
|
496
544
|
if (!metadata) {
|
|
497
545
|
return null;
|
|
498
546
|
}
|
|
499
|
-
linkage.push({
|
|
547
|
+
linkage.push({
|
|
548
|
+
type: "metadata",
|
|
549
|
+
content: JSON.stringify(metadata),
|
|
550
|
+
});
|
|
500
551
|
// Pull the image URL out
|
|
501
552
|
let imageUrl = metadata.image;
|
|
502
|
-
if (typeof
|
|
553
|
+
if (typeof imageUrl !== "string") {
|
|
503
554
|
return null;
|
|
504
555
|
}
|
|
505
556
|
if (imageUrl.match(/^(https:\/\/|data:)/i)) {
|
|
@@ -511,7 +562,10 @@ class Resolver {
|
|
|
511
562
|
if (ipfs == null) {
|
|
512
563
|
return null;
|
|
513
564
|
}
|
|
514
|
-
linkage.push({
|
|
565
|
+
linkage.push({
|
|
566
|
+
type: "url-ipfs",
|
|
567
|
+
content: imageUrl,
|
|
568
|
+
});
|
|
515
569
|
imageUrl = getIpfsLink(imageUrl);
|
|
516
570
|
}
|
|
517
571
|
linkage.push({ type: "url", content: imageUrl });
|
|
@@ -549,22 +603,26 @@ class Resolver {
|
|
|
549
603
|
// Swarm (CID: 1, Type: swarm-manifest; hash/length hard-coded to keccak256/32)
|
|
550
604
|
const swarm = hexBytes.match(/^0xe40101fa011b20([0-9a-f]*)$/);
|
|
551
605
|
if (swarm) {
|
|
552
|
-
if (swarm[1].length ===
|
|
606
|
+
if (swarm[1].length === 32 * 2) {
|
|
553
607
|
return "bzz:/\/" + swarm[1];
|
|
554
608
|
}
|
|
555
609
|
}
|
|
556
610
|
const skynet = hexBytes.match(/^0x90b2c605([0-9a-f]*)$/);
|
|
557
611
|
if (skynet) {
|
|
558
|
-
if (skynet[1].length ===
|
|
612
|
+
if (skynet[1].length === 34 * 2) {
|
|
559
613
|
// URL Safe base64; https://datatracker.ietf.org/doc/html/rfc4648#section-5
|
|
560
|
-
const urlSafe = {
|
|
561
|
-
|
|
614
|
+
const urlSafe = {
|
|
615
|
+
"=": "",
|
|
616
|
+
"+": "-",
|
|
617
|
+
"/": "_",
|
|
618
|
+
};
|
|
619
|
+
const hash = (0, base64_1.encode)("0x" + skynet[1]).replace(/[=+\/]/g, (a) => urlSafe[a]);
|
|
562
620
|
return "sia:/\/" + hash;
|
|
563
621
|
}
|
|
564
622
|
}
|
|
565
623
|
return logger.throwError(`invalid or unsupported content hash data`, logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
566
624
|
operation: "getContentHash()",
|
|
567
|
-
data: hexBytes
|
|
625
|
+
data: hexBytes,
|
|
568
626
|
});
|
|
569
627
|
}
|
|
570
628
|
async getText(key) {
|
|
@@ -572,10 +630,17 @@ class Resolver {
|
|
|
572
630
|
let keyBytes = (0, strings_1.toUtf8Bytes)(key);
|
|
573
631
|
// The nodehash consumes the first slot, so the string pointer targets
|
|
574
632
|
// offset 64, with the length at offset 64 and data starting at offset 96
|
|
575
|
-
keyBytes = (0, bytes_1.concat)([
|
|
633
|
+
keyBytes = (0, bytes_1.concat)([
|
|
634
|
+
bytes32ify(64),
|
|
635
|
+
bytes32ify(keyBytes.length),
|
|
636
|
+
keyBytes,
|
|
637
|
+
]);
|
|
576
638
|
// Pad to word-size (32 bytes)
|
|
577
|
-
if (
|
|
578
|
-
keyBytes = (0, bytes_1.concat)([
|
|
639
|
+
if (keyBytes.length % 32 !== 0) {
|
|
640
|
+
keyBytes = (0, bytes_1.concat)([
|
|
641
|
+
keyBytes,
|
|
642
|
+
(0, bytes_1.hexZeroPad)("0x", 32 - (key.length % 32)),
|
|
643
|
+
]);
|
|
579
644
|
}
|
|
580
645
|
const hexBytes = await this._fetchBytes("0x59d1d43c", (0, bytes_1.hexlify)(keyBytes));
|
|
581
646
|
if (hexBytes == null || hexBytes === "0x") {
|
|
@@ -607,7 +672,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
607
672
|
// If network is any, this Provider allows the underlying
|
|
608
673
|
// network to change dynamically, and we auto-detect the
|
|
609
674
|
// current network
|
|
610
|
-
(0, properties_1.defineReadOnly)(this, "anyNetwork",
|
|
675
|
+
(0, properties_1.defineReadOnly)(this, "anyNetwork", network === "any");
|
|
611
676
|
if (this.anyNetwork) {
|
|
612
677
|
network = this.detectNetwork();
|
|
613
678
|
}
|
|
@@ -674,7 +739,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
674
739
|
return network;
|
|
675
740
|
}, (error) => {
|
|
676
741
|
// If the network isn't running yet, we will wait
|
|
677
|
-
if (error.code === logger_1.Logger.errors.NETWORK_ERROR &&
|
|
742
|
+
if (error.code === logger_1.Logger.errors.NETWORK_ERROR &&
|
|
743
|
+
error.event === "noNetwork") {
|
|
678
744
|
return undefined;
|
|
679
745
|
}
|
|
680
746
|
throw error;
|
|
@@ -690,7 +756,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
690
756
|
}
|
|
691
757
|
// @TODO: Remove this and just use getNetwork
|
|
692
758
|
static getNetwork(network) {
|
|
693
|
-
return (0, networks_1.getNetwork)(
|
|
759
|
+
return (0, networks_1.getNetwork)(network == null ? "poseidon" : network);
|
|
694
760
|
}
|
|
695
761
|
async ccipReadFetch(tx, calldata, urls) {
|
|
696
762
|
if (this.disableCcipRead || urls.length === 0) {
|
|
@@ -702,9 +768,13 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
702
768
|
for (let i = 0; i < urls.length; i++) {
|
|
703
769
|
const url = urls[i];
|
|
704
770
|
// URL expansion
|
|
705
|
-
const href = url
|
|
771
|
+
const href = url
|
|
772
|
+
.replace("{sender}", sender)
|
|
773
|
+
.replace("{data}", data);
|
|
706
774
|
// If no {data} is present, use POST; otherwise GET
|
|
707
|
-
const json =
|
|
775
|
+
const json = url.indexOf("{data}") >= 0
|
|
776
|
+
? null
|
|
777
|
+
: JSON.stringify({ data, sender });
|
|
708
778
|
const result = await (0, web_1.fetchJson)({ url: href, errorPassThrough: true }, json, (value, response) => {
|
|
709
779
|
value.status = response.statusCode;
|
|
710
780
|
return value;
|
|
@@ -712,7 +782,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
712
782
|
if (result.data) {
|
|
713
783
|
return result.data;
|
|
714
784
|
}
|
|
715
|
-
const errorMessage =
|
|
785
|
+
const errorMessage = result.message || "unknown error";
|
|
716
786
|
// 4xx indicates the result is not present; stop
|
|
717
787
|
if (result.status >= 400 && result.status < 500) {
|
|
718
788
|
return logger.throwError(`response not found during CCIP fetch: ${errorMessage}`, logger_1.Logger.errors.SERVER_ERROR, { url, errorMessage });
|
|
@@ -721,7 +791,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
721
791
|
errorMessages.push(errorMessage);
|
|
722
792
|
}
|
|
723
793
|
return logger.throwError(`error encountered during CCIP fetch: ${errorMessages.map((m) => JSON.stringify(m)).join(", ")}`, logger_1.Logger.errors.SERVER_ERROR, {
|
|
724
|
-
urls,
|
|
794
|
+
urls,
|
|
795
|
+
errorMessages,
|
|
725
796
|
});
|
|
726
797
|
}
|
|
727
798
|
// Fetches the blockNumber, but will reuse any result that is less
|
|
@@ -737,7 +808,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
737
808
|
try {
|
|
738
809
|
// Check the result is not too stale
|
|
739
810
|
const result = await internalBlockNumber;
|
|
740
|
-
if (
|
|
811
|
+
if (getTime() - result.respTime <= maxAge) {
|
|
741
812
|
return result.blockNumber;
|
|
742
813
|
}
|
|
743
814
|
// Too old; fetch a new value
|
|
@@ -757,7 +828,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
757
828
|
const reqTime = getTime();
|
|
758
829
|
const checkInternalBlockNumber = (0, properties_1.resolveProperties)({
|
|
759
830
|
blockNumber: this.perform("getBlockNumber", {}),
|
|
760
|
-
networkError: this.getNetwork().then((network) =>
|
|
831
|
+
networkError: this.getNetwork().then((network) => null, (error) => error),
|
|
761
832
|
}).then(({ blockNumber, networkError }) => {
|
|
762
833
|
if (networkError) {
|
|
763
834
|
// Unremember this bad internal block number
|
|
@@ -809,12 +880,12 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
809
880
|
if (this._emitted.block === -2) {
|
|
810
881
|
this._emitted.block = blockNumber - 1;
|
|
811
882
|
}
|
|
812
|
-
if (Math.abs(
|
|
883
|
+
if (Math.abs(this._emitted.block - blockNumber) > 1000) {
|
|
813
884
|
logger.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${blockNumber})`);
|
|
814
885
|
this.emit("error", logger.makeError("network block skew detected", logger_1.Logger.errors.NETWORK_ERROR, {
|
|
815
886
|
blockNumber: blockNumber,
|
|
816
887
|
event: "blockSkew",
|
|
817
|
-
previousBlockNumber: this._emitted.block
|
|
888
|
+
previousBlockNumber: this._emitted.block,
|
|
818
889
|
}));
|
|
819
890
|
this.emit("block", blockNumber);
|
|
820
891
|
}
|
|
@@ -856,14 +927,18 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
856
927
|
switch (event.type) {
|
|
857
928
|
case "tx": {
|
|
858
929
|
const hash = event.hash;
|
|
859
|
-
let runner = this.getTransactionReceipt(hash)
|
|
930
|
+
let runner = this.getTransactionReceipt(hash)
|
|
931
|
+
.then((receipt) => {
|
|
860
932
|
if (!receipt || receipt.blockNumber == null) {
|
|
861
933
|
return null;
|
|
862
934
|
}
|
|
863
935
|
this._emitted["t:" + hash] = receipt.blockNumber;
|
|
864
936
|
this.emit(hash, receipt);
|
|
865
937
|
return null;
|
|
866
|
-
})
|
|
938
|
+
})
|
|
939
|
+
.catch((error) => {
|
|
940
|
+
this.emit("error", error);
|
|
941
|
+
});
|
|
867
942
|
runners.push(runner);
|
|
868
943
|
break;
|
|
869
944
|
}
|
|
@@ -892,7 +967,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
892
967
|
if (filter.fromBlock < 0) {
|
|
893
968
|
filter.fromBlock = 0;
|
|
894
969
|
}
|
|
895
|
-
const runner = this.getLogs(filter)
|
|
970
|
+
const runner = this.getLogs(filter)
|
|
971
|
+
.then((logs) => {
|
|
896
972
|
// Allow the next getLogs
|
|
897
973
|
event._inflight = false;
|
|
898
974
|
if (logs.length === 0) {
|
|
@@ -902,14 +978,18 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
902
978
|
// Only when we get an event for a given block number
|
|
903
979
|
// can we trust the events are indexed
|
|
904
980
|
if (log.blockNumber > event._lastBlockNumber) {
|
|
905
|
-
event._lastBlockNumber =
|
|
981
|
+
event._lastBlockNumber =
|
|
982
|
+
log.blockNumber;
|
|
906
983
|
}
|
|
907
984
|
// Make sure we stall requests to fetch blocks and txs
|
|
908
|
-
this._emitted["b:" + log.blockHash] =
|
|
909
|
-
|
|
985
|
+
this._emitted["b:" + log.blockHash] =
|
|
986
|
+
log.blockNumber;
|
|
987
|
+
this._emitted["t:" + log.transactionHash] =
|
|
988
|
+
log.blockNumber;
|
|
910
989
|
this.emit(filter, log);
|
|
911
990
|
});
|
|
912
|
-
})
|
|
991
|
+
})
|
|
992
|
+
.catch((error) => {
|
|
913
993
|
this.emit("error", error);
|
|
914
994
|
// Allow another getLogs (the range was not updated)
|
|
915
995
|
event._inflight = false;
|
|
@@ -922,9 +1002,13 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
922
1002
|
});
|
|
923
1003
|
this._lastBlockNumber = blockNumber;
|
|
924
1004
|
// Once all events for this loop have been processed, emit "didPoll"
|
|
925
|
-
Promise.all(runners)
|
|
1005
|
+
Promise.all(runners)
|
|
1006
|
+
.then(() => {
|
|
926
1007
|
this.emit("didPoll", pollId);
|
|
927
|
-
})
|
|
1008
|
+
})
|
|
1009
|
+
.catch((error) => {
|
|
1010
|
+
this.emit("error", error);
|
|
1011
|
+
});
|
|
928
1012
|
return;
|
|
929
1013
|
}
|
|
930
1014
|
// Deprecated; do not use this
|
|
@@ -941,7 +1025,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
941
1025
|
// can change, such as when connected to a JSON-RPC backend
|
|
942
1026
|
async detectNetwork() {
|
|
943
1027
|
return logger.throwError("provider does not support network detection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
944
|
-
operation: "provider.detectNetwork"
|
|
1028
|
+
operation: "provider.detectNetwork",
|
|
945
1029
|
});
|
|
946
1030
|
}
|
|
947
1031
|
async getNetwork() {
|
|
@@ -973,7 +1057,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
973
1057
|
const error = logger.makeError("underlying network changed", logger_1.Logger.errors.NETWORK_ERROR, {
|
|
974
1058
|
event: "changed",
|
|
975
1059
|
network: network,
|
|
976
|
-
detectedNetwork: currentNetwork
|
|
1060
|
+
detectedNetwork: currentNetwork,
|
|
977
1061
|
});
|
|
978
1062
|
this.emit("error", error);
|
|
979
1063
|
throw error;
|
|
@@ -984,14 +1068,16 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
984
1068
|
this._getInternalBlockNumber(100 + this.pollingInterval / 2).then((blockNumber) => {
|
|
985
1069
|
this._setFastBlockNumber(blockNumber);
|
|
986
1070
|
}, (error) => { });
|
|
987
|
-
return
|
|
1071
|
+
return this._fastBlockNumber != null ? this._fastBlockNumber : -1;
|
|
988
1072
|
}
|
|
989
1073
|
get polling() {
|
|
990
|
-
return
|
|
1074
|
+
return this._poller != null;
|
|
991
1075
|
}
|
|
992
1076
|
set polling(value) {
|
|
993
1077
|
if (value && !this._poller) {
|
|
994
|
-
this._poller = setInterval(() => {
|
|
1078
|
+
this._poller = setInterval(() => {
|
|
1079
|
+
this.poll();
|
|
1080
|
+
}, this.pollingInterval);
|
|
995
1081
|
if (!this._bootstrapPoll) {
|
|
996
1082
|
this._bootstrapPoll = setTimeout(() => {
|
|
997
1083
|
this.poll();
|
|
@@ -1018,22 +1104,27 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1018
1104
|
return this._pollingInterval;
|
|
1019
1105
|
}
|
|
1020
1106
|
set pollingInterval(value) {
|
|
1021
|
-
if (typeof
|
|
1107
|
+
if (typeof value !== "number" ||
|
|
1108
|
+
value <= 0 ||
|
|
1109
|
+
parseInt(String(value)) != value) {
|
|
1022
1110
|
throw new Error("invalid polling interval");
|
|
1023
1111
|
}
|
|
1024
1112
|
this._pollingInterval = value;
|
|
1025
1113
|
if (this._poller) {
|
|
1026
1114
|
clearInterval(this._poller);
|
|
1027
|
-
this._poller = setInterval(() => {
|
|
1115
|
+
this._poller = setInterval(() => {
|
|
1116
|
+
this.poll();
|
|
1117
|
+
}, this._pollingInterval);
|
|
1028
1118
|
}
|
|
1029
1119
|
}
|
|
1030
1120
|
_getFastBlockNumber() {
|
|
1031
1121
|
const now = getTime();
|
|
1032
1122
|
// Stale block number, request a newer value
|
|
1033
|
-
if (
|
|
1123
|
+
if (now - this._fastQueryDate > 2 * this._pollingInterval) {
|
|
1034
1124
|
this._fastQueryDate = now;
|
|
1035
1125
|
this._fastBlockNumberPromise = this.getBlockNumber().then((blockNumber) => {
|
|
1036
|
-
if (this._fastBlockNumber == null ||
|
|
1126
|
+
if (this._fastBlockNumber == null ||
|
|
1127
|
+
blockNumber > this._fastBlockNumber) {
|
|
1037
1128
|
this._fastBlockNumber = blockNumber;
|
|
1038
1129
|
}
|
|
1039
1130
|
return this._fastBlockNumber;
|
|
@@ -1043,19 +1134,21 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1043
1134
|
}
|
|
1044
1135
|
_setFastBlockNumber(blockNumber) {
|
|
1045
1136
|
// Older block, maybe a stale request
|
|
1046
|
-
if (this._fastBlockNumber != null &&
|
|
1137
|
+
if (this._fastBlockNumber != null &&
|
|
1138
|
+
blockNumber < this._fastBlockNumber) {
|
|
1047
1139
|
return;
|
|
1048
1140
|
}
|
|
1049
1141
|
// Update the time we updated the blocknumber
|
|
1050
1142
|
this._fastQueryDate = getTime();
|
|
1051
1143
|
// Newer block number, use it
|
|
1052
|
-
if (this._fastBlockNumber == null ||
|
|
1144
|
+
if (this._fastBlockNumber == null ||
|
|
1145
|
+
blockNumber > this._fastBlockNumber) {
|
|
1053
1146
|
this._fastBlockNumber = blockNumber;
|
|
1054
1147
|
this._fastBlockNumberPromise = Promise.resolve(blockNumber);
|
|
1055
1148
|
}
|
|
1056
1149
|
}
|
|
1057
1150
|
async waitForTransaction(transactionHash, confirmations, timeout) {
|
|
1058
|
-
return this._waitForTransaction(transactionHash,
|
|
1151
|
+
return this._waitForTransaction(transactionHash, confirmations == null ? 1 : confirmations, timeout || 0, null);
|
|
1059
1152
|
}
|
|
1060
1153
|
async _waitForTransaction(transactionHash, confirmations, timeout, replaceable) {
|
|
1061
1154
|
const receipt = await this.getTransactionReceipt(transactionHash);
|
|
@@ -1072,7 +1165,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1072
1165
|
return true;
|
|
1073
1166
|
}
|
|
1074
1167
|
done = true;
|
|
1075
|
-
cancelFuncs.forEach((func) => {
|
|
1168
|
+
cancelFuncs.forEach((func) => {
|
|
1169
|
+
func();
|
|
1170
|
+
});
|
|
1076
1171
|
return false;
|
|
1077
1172
|
};
|
|
1078
1173
|
const minedHandler = (receipt) => {
|
|
@@ -1085,7 +1180,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1085
1180
|
resolve(receipt);
|
|
1086
1181
|
};
|
|
1087
1182
|
this.on(transactionHash, minedHandler);
|
|
1088
|
-
cancelFuncs.push(() => {
|
|
1183
|
+
cancelFuncs.push(() => {
|
|
1184
|
+
this.removeListener(transactionHash, minedHandler);
|
|
1185
|
+
});
|
|
1089
1186
|
if (replaceable) {
|
|
1090
1187
|
let lastBlockNumber = replaceable.startBlock;
|
|
1091
1188
|
let scannedBlock = null;
|
|
@@ -1134,7 +1231,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1134
1231
|
return;
|
|
1135
1232
|
}
|
|
1136
1233
|
// Matches our transaction from and nonce; its a replacement
|
|
1137
|
-
if (tx.from === replaceable.from &&
|
|
1234
|
+
if (tx.from === replaceable.from &&
|
|
1235
|
+
tx.nonce === replaceable.nonce) {
|
|
1138
1236
|
if (done) {
|
|
1139
1237
|
return;
|
|
1140
1238
|
}
|
|
@@ -1146,19 +1244,27 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1146
1244
|
}
|
|
1147
1245
|
// The reason we were replaced
|
|
1148
1246
|
let reason = "replaced";
|
|
1149
|
-
if (tx.data === replaceable.data &&
|
|
1247
|
+
if (tx.data === replaceable.data &&
|
|
1248
|
+
tx.to === replaceable.to &&
|
|
1249
|
+
tx.value.eq(replaceable.value)) {
|
|
1150
1250
|
reason = "repriced";
|
|
1151
1251
|
}
|
|
1152
|
-
else if (tx.data === "0x" &&
|
|
1252
|
+
else if (tx.data === "0x" &&
|
|
1253
|
+
tx.from === tx.to &&
|
|
1254
|
+
tx.value.isZero()) {
|
|
1153
1255
|
reason = "cancelled";
|
|
1154
1256
|
}
|
|
1155
1257
|
// Explain why we were replaced
|
|
1156
|
-
reject(logger.makeError("transaction was replaced", logger_1.Logger.errors
|
|
1157
|
-
|
|
1258
|
+
reject(logger.makeError("transaction was replaced", logger_1.Logger.errors
|
|
1259
|
+
.TRANSACTION_REPLACED, {
|
|
1260
|
+
cancelled: reason ===
|
|
1261
|
+
"replaced" ||
|
|
1262
|
+
reason ===
|
|
1263
|
+
"cancelled",
|
|
1158
1264
|
reason,
|
|
1159
1265
|
replacement: this._wrapTransaction(tx),
|
|
1160
1266
|
hash: transactionHash,
|
|
1161
|
-
receipt
|
|
1267
|
+
receipt,
|
|
1162
1268
|
}));
|
|
1163
1269
|
return;
|
|
1164
1270
|
}
|
|
@@ -1185,7 +1291,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1185
1291
|
this.removeListener("block", replaceHandler);
|
|
1186
1292
|
});
|
|
1187
1293
|
}
|
|
1188
|
-
if (typeof
|
|
1294
|
+
if (typeof timeout === "number" && timeout > 0) {
|
|
1189
1295
|
const timer = setTimeout(() => {
|
|
1190
1296
|
if (alreadyDone()) {
|
|
1191
1297
|
return;
|
|
@@ -1195,7 +1301,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1195
1301
|
if (timer.unref) {
|
|
1196
1302
|
timer.unref();
|
|
1197
1303
|
}
|
|
1198
|
-
cancelFuncs.push(() => {
|
|
1304
|
+
cancelFuncs.push(() => {
|
|
1305
|
+
clearTimeout(timer);
|
|
1306
|
+
});
|
|
1199
1307
|
}
|
|
1200
1308
|
});
|
|
1201
1309
|
}
|
|
@@ -1211,7 +1319,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1211
1319
|
catch (error) {
|
|
1212
1320
|
return logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
|
|
1213
1321
|
method: "getGasPrice",
|
|
1214
|
-
result,
|
|
1322
|
+
result,
|
|
1323
|
+
error,
|
|
1215
1324
|
});
|
|
1216
1325
|
}
|
|
1217
1326
|
}
|
|
@@ -1219,7 +1328,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1219
1328
|
await this.getNetwork();
|
|
1220
1329
|
const params = await (0, properties_1.resolveProperties)({
|
|
1221
1330
|
address: this._getAddress(addressOrName),
|
|
1222
|
-
blockTag: this._getBlockTag(blockTag)
|
|
1331
|
+
blockTag: this._getBlockTag(blockTag),
|
|
1223
1332
|
});
|
|
1224
1333
|
const result = await this.perform("getBalance", params);
|
|
1225
1334
|
try {
|
|
@@ -1228,7 +1337,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1228
1337
|
catch (error) {
|
|
1229
1338
|
return logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
|
|
1230
1339
|
method: "getBalance",
|
|
1231
|
-
params,
|
|
1340
|
+
params,
|
|
1341
|
+
result,
|
|
1342
|
+
error,
|
|
1232
1343
|
});
|
|
1233
1344
|
}
|
|
1234
1345
|
}
|
|
@@ -1236,7 +1347,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1236
1347
|
await this.getNetwork();
|
|
1237
1348
|
const params = await (0, properties_1.resolveProperties)({
|
|
1238
1349
|
address: this._getAddress(addressOrName),
|
|
1239
|
-
blockTag: this._getBlockTag(blockTag)
|
|
1350
|
+
blockTag: this._getBlockTag(blockTag),
|
|
1240
1351
|
});
|
|
1241
1352
|
const result = await this.perform("getTransactionCount", params);
|
|
1242
1353
|
try {
|
|
@@ -1245,7 +1356,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1245
1356
|
catch (error) {
|
|
1246
1357
|
return logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
|
|
1247
1358
|
method: "getTransactionCount",
|
|
1248
|
-
params,
|
|
1359
|
+
params,
|
|
1360
|
+
result,
|
|
1361
|
+
error,
|
|
1249
1362
|
});
|
|
1250
1363
|
}
|
|
1251
1364
|
}
|
|
@@ -1253,7 +1366,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1253
1366
|
await this.getNetwork();
|
|
1254
1367
|
const params = await (0, properties_1.resolveProperties)({
|
|
1255
1368
|
address: this._getAddress(addressOrName),
|
|
1256
|
-
blockTag: this._getBlockTag(blockTag)
|
|
1369
|
+
blockTag: this._getBlockTag(blockTag),
|
|
1257
1370
|
});
|
|
1258
1371
|
const result = await this.perform("getCode", params);
|
|
1259
1372
|
try {
|
|
@@ -1262,7 +1375,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1262
1375
|
catch (error) {
|
|
1263
1376
|
return logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
|
|
1264
1377
|
method: "getCode",
|
|
1265
|
-
params,
|
|
1378
|
+
params,
|
|
1379
|
+
result,
|
|
1380
|
+
error,
|
|
1266
1381
|
});
|
|
1267
1382
|
}
|
|
1268
1383
|
}
|
|
@@ -1271,7 +1386,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1271
1386
|
const params = await (0, properties_1.resolveProperties)({
|
|
1272
1387
|
address: this._getAddress(addressOrName),
|
|
1273
1388
|
blockTag: this._getBlockTag(blockTag),
|
|
1274
|
-
position: Promise.resolve(position).then((p) => (0, bytes_1.hexValue)(p))
|
|
1389
|
+
position: Promise.resolve(position).then((p) => (0, bytes_1.hexValue)(p)),
|
|
1275
1390
|
});
|
|
1276
1391
|
const result = await this.perform("getStorageAt", params);
|
|
1277
1392
|
try {
|
|
@@ -1280,7 +1395,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1280
1395
|
catch (error) {
|
|
1281
1396
|
return logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
|
|
1282
1397
|
method: "getStorageAt",
|
|
1283
|
-
params,
|
|
1398
|
+
params,
|
|
1399
|
+
result,
|
|
1400
|
+
error,
|
|
1284
1401
|
});
|
|
1285
1402
|
}
|
|
1286
1403
|
}
|
|
@@ -1310,7 +1427,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1310
1427
|
nonce: tx.nonce,
|
|
1311
1428
|
to: tx.to,
|
|
1312
1429
|
value: tx.value,
|
|
1313
|
-
startBlock
|
|
1430
|
+
startBlock,
|
|
1314
1431
|
};
|
|
1315
1432
|
}
|
|
1316
1433
|
const receipt = await this._waitForTransaction(tx.hash, confirms, timeout, replacement);
|
|
@@ -1323,7 +1440,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1323
1440
|
logger.throwError("transaction failed", logger_1.Logger.errors.CALL_EXCEPTION, {
|
|
1324
1441
|
transactionHash: tx.hash,
|
|
1325
1442
|
transaction: tx,
|
|
1326
|
-
receipt: receipt
|
|
1443
|
+
receipt: receipt,
|
|
1327
1444
|
});
|
|
1328
1445
|
}
|
|
1329
1446
|
return receipt;
|
|
@@ -1332,14 +1449,16 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1332
1449
|
}
|
|
1333
1450
|
async sendTransaction(signedTransaction) {
|
|
1334
1451
|
await this.getNetwork();
|
|
1335
|
-
const hexTx = await Promise.resolve(signedTransaction).then(t => (0, bytes_1.hexlify)(t));
|
|
1452
|
+
const hexTx = await Promise.resolve(signedTransaction).then((t) => (0, bytes_1.hexlify)(t));
|
|
1336
1453
|
const tx = this.formatter.transaction(signedTransaction);
|
|
1337
1454
|
if (tx.confirmations == null) {
|
|
1338
1455
|
tx.confirmations = 0;
|
|
1339
1456
|
}
|
|
1340
1457
|
const blockNumber = await this._getInternalBlockNumber(100 + 2 * this.pollingInterval);
|
|
1341
1458
|
try {
|
|
1342
|
-
const hash = await this.perform("sendTransaction", {
|
|
1459
|
+
const hash = await this.perform("sendTransaction", {
|
|
1460
|
+
signedTransaction: hexTx,
|
|
1461
|
+
});
|
|
1343
1462
|
return this._wrapTransaction(tx, hash, blockNumber);
|
|
1344
1463
|
}
|
|
1345
1464
|
catch (error) {
|
|
@@ -1355,19 +1474,25 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1355
1474
|
if (values[key] == null) {
|
|
1356
1475
|
return;
|
|
1357
1476
|
}
|
|
1358
|
-
tx[key] = Promise.resolve(values[key]).then((v) =>
|
|
1477
|
+
tx[key] = Promise.resolve(values[key]).then((v) => v ? this._getAddress(v) : null);
|
|
1359
1478
|
});
|
|
1360
|
-
[
|
|
1479
|
+
[
|
|
1480
|
+
"gasLimit",
|
|
1481
|
+
"gasPrice",
|
|
1482
|
+
"maxFeePerGas",
|
|
1483
|
+
"maxPriorityFeePerGas",
|
|
1484
|
+
"value",
|
|
1485
|
+
].forEach((key) => {
|
|
1361
1486
|
if (values[key] == null) {
|
|
1362
1487
|
return;
|
|
1363
1488
|
}
|
|
1364
|
-
tx[key] = Promise.resolve(values[key]).then((v) =>
|
|
1489
|
+
tx[key] = Promise.resolve(values[key]).then((v) => v ? bignumber_1.BigNumber.from(v) : null);
|
|
1365
1490
|
});
|
|
1366
1491
|
["type"].forEach((key) => {
|
|
1367
1492
|
if (values[key] == null) {
|
|
1368
1493
|
return;
|
|
1369
1494
|
}
|
|
1370
|
-
tx[key] = Promise.resolve(values[key]).then((v) =>
|
|
1495
|
+
tx[key] = Promise.resolve(values[key]).then((v) => v != null ? v : null);
|
|
1371
1496
|
});
|
|
1372
1497
|
if (values.accessList) {
|
|
1373
1498
|
tx.accessList = this.formatter.accessList(values.accessList);
|
|
@@ -1376,7 +1501,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1376
1501
|
if (values[key] == null) {
|
|
1377
1502
|
return;
|
|
1378
1503
|
}
|
|
1379
|
-
tx[key] = Promise.resolve(values[key]).then((v) =>
|
|
1504
|
+
tx[key] = Promise.resolve(values[key]).then((v) => v ? (0, bytes_1.hexlify)(v) : null);
|
|
1380
1505
|
});
|
|
1381
1506
|
return this.formatter.transactionRequest(await (0, properties_1.resolveProperties)(tx));
|
|
1382
1507
|
}
|
|
@@ -1403,13 +1528,18 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1403
1528
|
async _call(transaction, blockTag, attempt) {
|
|
1404
1529
|
if (attempt >= MAX_CCIP_REDIRECTS) {
|
|
1405
1530
|
logger.throwError("CCIP read exceeded maximum redirections", logger_1.Logger.errors.SERVER_ERROR, {
|
|
1406
|
-
redirects: attempt,
|
|
1531
|
+
redirects: attempt,
|
|
1532
|
+
transaction,
|
|
1407
1533
|
});
|
|
1408
1534
|
}
|
|
1409
1535
|
const txSender = transaction.to;
|
|
1410
1536
|
const result = await this.perform("call", { transaction, blockTag });
|
|
1411
1537
|
// CCIP Read request via OffchainLookup(address,string[],bytes,bytes4,bytes)
|
|
1412
|
-
if (attempt >= 0 &&
|
|
1538
|
+
if (attempt >= 0 &&
|
|
1539
|
+
blockTag === "latest" &&
|
|
1540
|
+
txSender != null &&
|
|
1541
|
+
result.substring(0, 10) === "0x556f1830" &&
|
|
1542
|
+
(0, bytes_1.hexDataLength)(result) % 32 === 4) {
|
|
1413
1543
|
try {
|
|
1414
1544
|
const data = (0, bytes_1.hexDataSlice)(result, 4);
|
|
1415
1545
|
// Check the sender of the OffchainLookup matches the transaction
|
|
@@ -1418,7 +1548,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1418
1548
|
logger.throwError("CCIP Read sender did not match", logger_1.Logger.errors.CALL_EXCEPTION, {
|
|
1419
1549
|
name: "OffchainLookup",
|
|
1420
1550
|
signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
|
|
1421
|
-
transaction,
|
|
1551
|
+
transaction,
|
|
1552
|
+
data: result,
|
|
1422
1553
|
});
|
|
1423
1554
|
}
|
|
1424
1555
|
// Read the URLs from the response
|
|
@@ -1432,7 +1563,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1432
1563
|
logger.throwError("CCIP Read contained corrupt URL string", logger_1.Logger.errors.CALL_EXCEPTION, {
|
|
1433
1564
|
name: "OffchainLookup",
|
|
1434
1565
|
signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
|
|
1435
|
-
transaction,
|
|
1566
|
+
transaction,
|
|
1567
|
+
data: result,
|
|
1436
1568
|
});
|
|
1437
1569
|
}
|
|
1438
1570
|
urls.push(url);
|
|
@@ -1444,7 +1576,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1444
1576
|
logger.throwError("CCIP Read callback selector included junk", logger_1.Logger.errors.CALL_EXCEPTION, {
|
|
1445
1577
|
name: "OffchainLookup",
|
|
1446
1578
|
signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
|
|
1447
|
-
transaction,
|
|
1579
|
+
transaction,
|
|
1580
|
+
data: result,
|
|
1448
1581
|
});
|
|
1449
1582
|
}
|
|
1450
1583
|
const callbackSelector = (0, bytes_1.hexDataSlice)(data, 96, 100);
|
|
@@ -1455,12 +1588,16 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1455
1588
|
logger.throwError("CCIP Read disabled or provided no URLs", logger_1.Logger.errors.CALL_EXCEPTION, {
|
|
1456
1589
|
name: "OffchainLookup",
|
|
1457
1590
|
signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
|
|
1458
|
-
transaction,
|
|
1591
|
+
transaction,
|
|
1592
|
+
data: result,
|
|
1459
1593
|
});
|
|
1460
1594
|
}
|
|
1461
1595
|
const tx = {
|
|
1462
1596
|
to: txSender,
|
|
1463
|
-
data: (0, bytes_1.hexConcat)([
|
|
1597
|
+
data: (0, bytes_1.hexConcat)([
|
|
1598
|
+
callbackSelector,
|
|
1599
|
+
encodeBytes([ccipResult, extraData]),
|
|
1600
|
+
]),
|
|
1464
1601
|
};
|
|
1465
1602
|
return this._call(tx, blockTag, attempt + 1);
|
|
1466
1603
|
}
|
|
@@ -1476,7 +1613,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1476
1613
|
catch (error) {
|
|
1477
1614
|
return logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
|
|
1478
1615
|
method: "call",
|
|
1479
|
-
params: { transaction, blockTag },
|
|
1616
|
+
params: { transaction, blockTag },
|
|
1617
|
+
result,
|
|
1618
|
+
error,
|
|
1480
1619
|
});
|
|
1481
1620
|
}
|
|
1482
1621
|
}
|
|
@@ -1485,14 +1624,14 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1485
1624
|
const resolved = await (0, properties_1.resolveProperties)({
|
|
1486
1625
|
transaction: this._getTransactionRequest(transaction),
|
|
1487
1626
|
blockTag: this._getBlockTag(blockTag),
|
|
1488
|
-
ccipReadEnabled: Promise.resolve(transaction.ccipReadEnabled)
|
|
1627
|
+
ccipReadEnabled: Promise.resolve(transaction.ccipReadEnabled),
|
|
1489
1628
|
});
|
|
1490
1629
|
return this._call(resolved.transaction, resolved.blockTag, resolved.ccipReadEnabled ? 0 : -1);
|
|
1491
1630
|
}
|
|
1492
1631
|
async estimateGas(transaction) {
|
|
1493
1632
|
await this.getNetwork();
|
|
1494
1633
|
const params = await (0, properties_1.resolveProperties)({
|
|
1495
|
-
transaction: this._getTransactionRequest(transaction)
|
|
1634
|
+
transaction: this._getTransactionRequest(transaction),
|
|
1496
1635
|
});
|
|
1497
1636
|
const result = await this.perform("estimateGas", params);
|
|
1498
1637
|
try {
|
|
@@ -1501,19 +1640,21 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1501
1640
|
catch (error) {
|
|
1502
1641
|
return logger.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, {
|
|
1503
1642
|
method: "estimateGas",
|
|
1504
|
-
params,
|
|
1643
|
+
params,
|
|
1644
|
+
result,
|
|
1645
|
+
error,
|
|
1505
1646
|
});
|
|
1506
1647
|
}
|
|
1507
1648
|
}
|
|
1508
1649
|
async _getAddress(addressOrName) {
|
|
1509
1650
|
addressOrName = await addressOrName;
|
|
1510
|
-
if (typeof
|
|
1651
|
+
if (typeof addressOrName !== "string") {
|
|
1511
1652
|
logger.throwArgumentError("invalid address or ENS name", "name", addressOrName);
|
|
1512
1653
|
}
|
|
1513
1654
|
const address = await this.resolveName(addressOrName);
|
|
1514
1655
|
if (address == null) {
|
|
1515
1656
|
logger.throwError("ENS name not configured", logger_1.Logger.errors.UNSUPPORTED_OPERATION, {
|
|
1516
|
-
operation: `resolveName(${JSON.stringify(addressOrName)})
|
|
1657
|
+
operation: `resolveName(${JSON.stringify(addressOrName)})`,
|
|
1517
1658
|
});
|
|
1518
1659
|
}
|
|
1519
1660
|
return address;
|
|
@@ -1524,7 +1665,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1524
1665
|
// If blockTag is a number (not "latest", etc), this is the block number
|
|
1525
1666
|
let blockNumber = -128;
|
|
1526
1667
|
const params = {
|
|
1527
|
-
includeTransactions: !!includeTransactions
|
|
1668
|
+
includeTransactions: !!includeTransactions,
|
|
1528
1669
|
};
|
|
1529
1670
|
if ((0, bytes_1.isHexString)(blockHashOrBlockTag, 32)) {
|
|
1530
1671
|
params.blockHash = blockHashOrBlockTag;
|
|
@@ -1571,10 +1712,11 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1571
1712
|
}
|
|
1572
1713
|
else if (tx.confirmations == null) {
|
|
1573
1714
|
if (blockNumber == null) {
|
|
1574
|
-
blockNumber =
|
|
1715
|
+
blockNumber =
|
|
1716
|
+
await this._getInternalBlockNumber(100 + 2 * this.pollingInterval);
|
|
1575
1717
|
}
|
|
1576
1718
|
// Add the confirmations using the fast block number (pessimistic)
|
|
1577
|
-
let confirmations =
|
|
1719
|
+
let confirmations = blockNumber - tx.blockNumber + 1;
|
|
1578
1720
|
if (confirmations <= 0) {
|
|
1579
1721
|
confirmations = 1;
|
|
1580
1722
|
}
|
|
@@ -1589,7 +1731,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1589
1731
|
}, { oncePoll: this });
|
|
1590
1732
|
}
|
|
1591
1733
|
getBlock(blockHashOrBlockTag) {
|
|
1592
|
-
return
|
|
1734
|
+
return this._getBlock(blockHashOrBlockTag, false);
|
|
1593
1735
|
}
|
|
1594
1736
|
getBlockWithTransactions(blockHashOrBlockTag) {
|
|
1595
1737
|
return (this._getBlock(blockHashOrBlockTag, true));
|
|
@@ -1597,7 +1739,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1597
1739
|
async getTransaction(transactionHash) {
|
|
1598
1740
|
await this.getNetwork();
|
|
1599
1741
|
transactionHash = await transactionHash;
|
|
1600
|
-
const params = {
|
|
1742
|
+
const params = {
|
|
1743
|
+
transactionHash: this.formatter.hash(transactionHash, true),
|
|
1744
|
+
};
|
|
1601
1745
|
return (0, web_1.poll)(async () => {
|
|
1602
1746
|
const result = await this.perform("getTransaction", params);
|
|
1603
1747
|
if (result == null) {
|
|
@@ -1613,7 +1757,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1613
1757
|
else if (tx.confirmations == null) {
|
|
1614
1758
|
const blockNumber = await this._getInternalBlockNumber(100 + 2 * this.pollingInterval);
|
|
1615
1759
|
// Add the confirmations using the fast block number (pessimistic)
|
|
1616
|
-
let confirmations =
|
|
1760
|
+
let confirmations = blockNumber - tx.blockNumber + 1;
|
|
1617
1761
|
if (confirmations <= 0) {
|
|
1618
1762
|
confirmations = 1;
|
|
1619
1763
|
}
|
|
@@ -1625,7 +1769,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1625
1769
|
async getTransactionReceipt(transactionHash) {
|
|
1626
1770
|
await this.getNetwork();
|
|
1627
1771
|
transactionHash = await transactionHash;
|
|
1628
|
-
const params = {
|
|
1772
|
+
const params = {
|
|
1773
|
+
transactionHash: this.formatter.hash(transactionHash, true),
|
|
1774
|
+
};
|
|
1629
1775
|
return (0, web_1.poll)(async () => {
|
|
1630
1776
|
const result = await this.perform("getTransactionReceipt", params);
|
|
1631
1777
|
if (result == null) {
|
|
@@ -1645,7 +1791,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1645
1791
|
else if (receipt.confirmations == null) {
|
|
1646
1792
|
const blockNumber = await this._getInternalBlockNumber(100 + 2 * this.pollingInterval);
|
|
1647
1793
|
// Add the confirmations using the fast block number (pessimistic)
|
|
1648
|
-
let confirmations =
|
|
1794
|
+
let confirmations = blockNumber - receipt.blockNumber + 1;
|
|
1649
1795
|
if (confirmations <= 0) {
|
|
1650
1796
|
confirmations = 1;
|
|
1651
1797
|
}
|
|
@@ -1656,7 +1802,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1656
1802
|
}
|
|
1657
1803
|
async getLogs(filter) {
|
|
1658
1804
|
await this.getNetwork();
|
|
1659
|
-
const params = await (0, properties_1.resolveProperties)({
|
|
1805
|
+
const params = await (0, properties_1.resolveProperties)({
|
|
1806
|
+
filter: this._getFilter(filter),
|
|
1807
|
+
});
|
|
1660
1808
|
const logs = await this.perform("getLogs", params);
|
|
1661
1809
|
logs.forEach((log) => {
|
|
1662
1810
|
if (log.removed == null) {
|
|
@@ -1671,7 +1819,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1671
1819
|
}
|
|
1672
1820
|
async _getBlockTag(blockTag) {
|
|
1673
1821
|
blockTag = await blockTag;
|
|
1674
|
-
if (typeof
|
|
1822
|
+
if (typeof blockTag === "number" && blockTag < 0) {
|
|
1675
1823
|
if (blockTag % 1) {
|
|
1676
1824
|
logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag);
|
|
1677
1825
|
}
|
|
@@ -1701,7 +1849,8 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1701
1849
|
if (addr != null) {
|
|
1702
1850
|
const resolver = new Resolver(this, addr, name);
|
|
1703
1851
|
// Legacy resolver found, using EIP-2544 so it isn't safe to use
|
|
1704
|
-
if (currentName !== name &&
|
|
1852
|
+
if (currentName !== name &&
|
|
1853
|
+
!(await resolver.supportsWildcard())) {
|
|
1705
1854
|
return null;
|
|
1706
1855
|
}
|
|
1707
1856
|
return resolver;
|
|
@@ -1723,7 +1872,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1723
1872
|
// keccak256("resolver(bytes32)")
|
|
1724
1873
|
const addrData = await this.call({
|
|
1725
1874
|
to: network.ensAddress,
|
|
1726
|
-
data:
|
|
1875
|
+
data: "0x0178b8bf" + (0, hash_1.namehash)(name).substring(2),
|
|
1727
1876
|
});
|
|
1728
1877
|
return this.formatter.callAddress(addrData);
|
|
1729
1878
|
}
|
|
@@ -1744,7 +1893,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1744
1893
|
throw error;
|
|
1745
1894
|
}
|
|
1746
1895
|
}
|
|
1747
|
-
if (typeof
|
|
1896
|
+
if (typeof name !== "string") {
|
|
1748
1897
|
logger.throwArgumentError("invalid ENS name", "name", name);
|
|
1749
1898
|
}
|
|
1750
1899
|
// Get the addr from the resolver
|
|
@@ -1765,7 +1914,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1765
1914
|
// keccak("name(bytes32)")
|
|
1766
1915
|
const name = _parseString(await this.call({
|
|
1767
1916
|
to: resolverAddr,
|
|
1768
|
-
data:
|
|
1917
|
+
data: "0x691f3431" + (0, hash_1.namehash)(node).substring(2),
|
|
1769
1918
|
}), 0);
|
|
1770
1919
|
const addr = await this.resolveName(name);
|
|
1771
1920
|
if (addr != address) {
|
|
@@ -1801,7 +1950,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1801
1950
|
// keccak("name(bytes32)")
|
|
1802
1951
|
const name = _parseString(await this.call({
|
|
1803
1952
|
to: resolverAddress,
|
|
1804
|
-
data:
|
|
1953
|
+
data: "0x691f3431" + (0, hash_1.namehash)(node).substring(2),
|
|
1805
1954
|
}), 0);
|
|
1806
1955
|
resolver = await this.getResolver(name);
|
|
1807
1956
|
}
|
|
@@ -1829,10 +1978,10 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1829
1978
|
return logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method });
|
|
1830
1979
|
}
|
|
1831
1980
|
_startEvent(event) {
|
|
1832
|
-
this.polling =
|
|
1981
|
+
this.polling = this._events.filter((e) => e.pollable()).length > 0;
|
|
1833
1982
|
}
|
|
1834
1983
|
_stopEvent(event) {
|
|
1835
|
-
this.polling =
|
|
1984
|
+
this.polling = this._events.filter((e) => e.pollable()).length > 0;
|
|
1836
1985
|
}
|
|
1837
1986
|
_addEventListener(eventName, listener, once) {
|
|
1838
1987
|
const event = new Event(getEventTag(eventName), listener, once);
|
|
@@ -1864,7 +2013,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1864
2013
|
}
|
|
1865
2014
|
return true;
|
|
1866
2015
|
});
|
|
1867
|
-
stopped.forEach((event) => {
|
|
2016
|
+
stopped.forEach((event) => {
|
|
2017
|
+
this._stopEvent(event);
|
|
2018
|
+
});
|
|
1868
2019
|
return result;
|
|
1869
2020
|
}
|
|
1870
2021
|
listenerCount(eventName) {
|
|
@@ -1873,7 +2024,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1873
2024
|
}
|
|
1874
2025
|
let eventTag = getEventTag(eventName);
|
|
1875
2026
|
return this._events.filter((event) => {
|
|
1876
|
-
return
|
|
2027
|
+
return event.tag === eventTag;
|
|
1877
2028
|
}).length;
|
|
1878
2029
|
}
|
|
1879
2030
|
listeners(eventName) {
|
|
@@ -1882,7 +2033,7 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1882
2033
|
}
|
|
1883
2034
|
let eventTag = getEventTag(eventName);
|
|
1884
2035
|
return this._events
|
|
1885
|
-
.filter((event) =>
|
|
2036
|
+
.filter((event) => event.tag === eventTag)
|
|
1886
2037
|
.map((event) => event.listener);
|
|
1887
2038
|
}
|
|
1888
2039
|
off(eventName, listener) {
|
|
@@ -1903,7 +2054,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1903
2054
|
stopped.push(event);
|
|
1904
2055
|
return false;
|
|
1905
2056
|
});
|
|
1906
|
-
stopped.forEach((event) => {
|
|
2057
|
+
stopped.forEach((event) => {
|
|
2058
|
+
this._stopEvent(event);
|
|
2059
|
+
});
|
|
1907
2060
|
return this;
|
|
1908
2061
|
}
|
|
1909
2062
|
removeAllListeners(eventName) {
|
|
@@ -1922,7 +2075,9 @@ class BaseProvider extends abstract_provider_1.Provider {
|
|
|
1922
2075
|
return false;
|
|
1923
2076
|
});
|
|
1924
2077
|
}
|
|
1925
|
-
stopped.forEach((event) => {
|
|
2078
|
+
stopped.forEach((event) => {
|
|
2079
|
+
this._stopEvent(event);
|
|
2080
|
+
});
|
|
1926
2081
|
return this;
|
|
1927
2082
|
}
|
|
1928
2083
|
}
|