Work-around for Cloudflare not offering eth_blockNumber.
This commit is contained in:
parent
71d03c6e3c
commit
8cf4b3cf45
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user