-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(status-page): Status page slots (#13605)
- Loading branch information
1 parent
9301ac4
commit f0c291f
Showing
1 changed file
with
4 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
import { Contract, ethers } from "ethers"; | ||
import TaikoL1 from "../constants/abi/TaikoL1"; | ||
import { getConfig } from "./getConfig"; | ||
|
||
export const getAvailableSlots = async ( | ||
provider: ethers.providers.JsonRpcProvider, | ||
contractAddress: string | ||
): Promise<number> => { | ||
const contract: Contract = new Contract(contractAddress, TaikoL1, provider); | ||
const stateVariables = await contract.getStateVariables(); | ||
const config = await getConfig(provider, contractAddress); | ||
|
||
const nextBlockId = stateVariables.nextBlockId; | ||
const latestVerifiedId = stateVariables.latestVerifiedId; | ||
const pendingBlocks = nextBlockId - latestVerifiedId - 1; | ||
return Math.abs(pendingBlocks - 2048); | ||
return Math.abs(pendingBlocks - config.maxNumBlocks); | ||
}; |