mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 00:44:06 +00:00
Use blockHash for eth_calls in watchers (#283)
This commit is contained in:
@@ -134,17 +134,14 @@ export class Indexer {
|
||||
{{#if (compare query.mode @root.constants.MODE_ETH_CALL)}}
|
||||
const contract = new ethers.Contract(contractAddress, this._abi, this._ethProvider);
|
||||
|
||||
const { block: { number } } = await this._ethClient.getBlockByHash(blockHash);
|
||||
const blockNumber = ethers.BigNumber.from(number).toNumber();
|
||||
|
||||
{{#if (compare query.returnType 'bigint')}}
|
||||
let value = await contract.{{query.name}}(
|
||||
{{~#each query.params}}{{this.name}}, {{/each}}{ blockTag: blockNumber });
|
||||
{{~#each query.params}}{{this.name}}, {{/each}}{ blockTag: blockHash });
|
||||
value = value.toString();
|
||||
value = BigInt(value);
|
||||
{{else}}
|
||||
const value = await contract.{{query.name}}(
|
||||
{{~#each query.params}}{{this.name}}, {{/each}}{ blockTag: blockNumber });
|
||||
{{~#each query.params}}{{this.name}}, {{/each}}{ blockTag: blockHash });
|
||||
{{/if}}
|
||||
|
||||
const result: ValueResult = { value };
|
||||
|
||||
Reference in New Issue
Block a user