diff --git a/packages/council-core/src/models/proposal/ReadProposal.ts b/packages/council-core/src/models/proposal/ReadProposal.ts index 7be6a9df..d453b601 100644 --- a/packages/council-core/src/models/proposal/ReadProposal.ts +++ b/packages/council-core/src/models/proposal/ReadProposal.ts @@ -422,12 +422,24 @@ export class ReadProposal extends Model { protected async _getExecutedEvents(): Promise< Event[] > { - const lastCallBlock = await this.getLastCallBlock(); + let toBlock = await this.getLastCallBlock(); + const latestBlock = await this.network.getBlock(); + + // Ensure we don't try to fetch a block range including blocks that don't + // exist yet. + if ( + typeof toBlock === "bigint" && + typeof latestBlock?.blockNumber === "bigint" && + latestBlock.blockNumber < toBlock + ) { + toBlock = latestBlock.blockNumber; + } + const events = await this.coreVoting.contract.getEvents( "ProposalExecuted", { fromBlock: this.created, - toBlock: lastCallBlock, + toBlock, }, );