From 37976d657c7a1e84391627e921de7106f605943f Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Fri, 25 Oct 2024 16:25:35 +0300 Subject: [PATCH] Add epoch info to the UI --- src/lib/aesdk/contractState.ts | 10 +++++----- src/routes/+page.svelte | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/aesdk/contractState.ts b/src/lib/aesdk/contractState.ts index cde3d60..78272d9 100644 --- a/src/lib/aesdk/contractState.ts +++ b/src/lib/aesdk/contractState.ts @@ -5,17 +5,17 @@ export const getContractState = async ( sdkInstance: SdkInstance ): Promise<[MainStakingState, HCElectionState]> => { // console.log('staking contract', sdkInstance.stakingContract); - console.log('Call MainStaking:get_state'); + // console.log('Call MainStaking:get_state'); const resp = await sdkInstance.stakingContract.$call('get_state', [], { callStatic: true }); - console.log('MainStaking state', resp.decodedResult); + // console.log('MainStaking state', resp.decodedResult); const msState = MainStakingState.parse(resp.decodedResult); - console.log('Get HCElection state'); + // console.log('Get HCElection state'); const hcElectionState = await sdkInstance.hcElectionContract.$call('get_state', [], { callStatic: true }); - console.log('HCElection state', hcElectionState.decodedResult); + // console.log('HCElection state', hcElectionState.decodedResult); const hcState = HCElectionState.parse(hcElectionState.decodedResult); // console.log('Call HCElection:leader'); // const leader = await sdkInstance.hcElectionContract.$call('leader', [], { @@ -83,7 +83,7 @@ export const MainStakingState = z .strict(); export type MainStakingState = z.infer; -export const HCElectionState = z.object({ leader: z.string() }); +export const HCElectionState = z.object({ leader: z.string(), epoch: z.bigint() }); export type HCElectionState = z.infer; export const ContractState = z.object({ diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index e60ec87..de75b88 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -57,9 +57,10 @@ {#if st}
-
+

Stats

Block Height: {st.height}

+

Epoch: {st.hcElection.epoch}

Current Leader: {leader?.state.name}