Skip to content

Commit

Permalink
fix(status-page): Status page slots (#13605)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Apr 15, 2023
1 parent 9301ac4 commit f0c291f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/status-page/src/utils/getAvailableSlots.ts
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);
};

0 comments on commit f0c291f

Please sign in to comment.