Skip to content

Commit

Permalink
Add epoch info to the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
dincho committed Oct 25, 2024
1 parent 66cd120 commit 37976d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/lib/aesdk/contractState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', [], {
Expand Down Expand Up @@ -83,7 +83,7 @@ export const MainStakingState = z
.strict();
export type MainStakingState = z.infer<typeof MainStakingState>;

export const HCElectionState = z.object({ leader: z.string() });
export const HCElectionState = z.object({ leader: z.string(), epoch: z.bigint() });
export type HCElectionState = z.infer<typeof HCElectionState>;

export const ContractState = z.object({
Expand Down
3 changes: 2 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@
</div>
{#if st}
<div class="card border border-primary">
<div class="card-body p-3">
<div class="card-body p-4">
<div class=" card-title"><h3>Stats</h3></div>
<p>Block Height: {st.height}</p>
<p>Epoch: {st.hcElection.epoch}</p>
<p>
Current Leader: <a class="link link-primary" href={`/validator/${leader?.address}`}>
{leader?.state.name}</a
Expand Down

0 comments on commit 37976d6

Please sign in to comment.