Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(status-page): show latest proof reward #13842

Merged
merged 7 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/status-page/src/components/StatusIndicator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
}

if (watchStatusFunc) {
statusValue = "Waiting for event...";
cancelFunc = watchStatusFunc(
provider,
contractAddress,
Expand Down
2 changes: 1 addition & 1 deletion packages/status-page/src/domain/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type StatusIndicatorProp = {
provider: ethers.providers.JsonRpcProvider,
contractAddress: string,
onEvent: (value: Status) => void
) => () => void;
) => Promise<() => void>;
provider: ethers.providers.JsonRpcProvider;
contractAddress: string;
header: string;
Expand Down
39 changes: 18 additions & 21 deletions packages/status-page/src/utils/buildStatusIndicators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,33 +310,28 @@ export async function buildStatusIndicators(
"The current fee to propose a block to the TaikoL1 smart contract.",
});
indicators.push({
statusFunc: async (
watchStatusFunc: async (
provider: ethers.providers.JsonRpcProvider,
contractAddress: string
): Promise<string> => {
const contract: Contract = new Contract(
contractAddress,
TaikoL1,
provider
);
const averageProofTime = await getAverageProofTime(
config.eventIndexerApiUrl
);
const fee = await contract.getProofReward(Number(averageProofTime));
return `${ethers.utils.formatUnits(fee, decimals)} ${
import.meta.env.VITE_FEE_TOKEN_SYMBOL ?? "TKO"
}`;
address: string,
onEvent: (value: Status) => void
) => {
const contract = new Contract(address, TaikoL1, provider);
const listener = (id, blockHash, reward, ...args) => {
onEvent(`${ethers.utils.parseUnits(reward, decimals)} TKO`);
};
contract.on("BlockVerified", listener);

return () => contract.off("BlockVerified", listener);
},
watchStatusFunc: null,
provider: config.l1Provider,
contractAddress: config.l1TaikoAddress,
header: "Proof Reward",
intervalInMs: 15000,
header: "Latest Proof Reward",
intervalInMs: 0,
status: "Waiting for event...",
colorFunc: function (status: Status) {
return "green"; // todo: whats green, yellow, red?
},
tooltip:
"The current reward for successfully submitting a proof for a proposed block on the TaikoL1 smart contract, given the proof time is equal to average proof time.",
tooltip: "The most recent proof reward, updated on block being verified.",
});
indicators.push({
provider: config.l1Provider,
Expand Down Expand Up @@ -368,7 +363,9 @@ export async function buildStatusIndicators(
};
contract.on("BlockProven", listener);

return () => contract.off("BlockProven", listener);
return () => {
contract.off("BlockProven", listener);
};
},
colorFunc: function (status: Status) {
return "green"; // todo: whats green, yellow, red?
Expand Down