Work-around for Cloudflare not offering eth_blockNumber.

This commit is contained in:
Richard Moore 2020-04-23 08:13:53 -04:00
parent 71d03c6e3c
commit 8cf4b3cf45
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

@ -28,4 +28,15 @@ export class CloudflareProvider extends UrlJsonRpcProvider {
return host;
}
async perform(method: string, params: any): Promise<any> {
// The Cloudflare provider does not support eth_blockNumber,
// so we get the latest block and pull it from that
if (method === "getBlockNumber") {
const block = await super.perform("getBlock", { blockTag: "latest" });
return block.number;
}
return super.perform(method, params);
}
}