Skip to content

Commit

Permalink
Work-around for Cloudflare not offering eth_blockNumber.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Apr 23, 2020
1 parent 71d03c6 commit 8cf4b3c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/providers/src.ts/cloudflare-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 8cf4b3c

Please sign in to comment.