Skip to content

Commit

Permalink
fetchNetworkStatus with L1 finalized bn
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Oct 26, 2024
1 parent a0a2302 commit 6cb9596
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ const shieldAmount = ref(11.0);
const unshieldAmount = ref(10.0);
const guess = ref(null);
const guessTheNumberInfo = ref(null);
const parentchainsInfo = ref(null);
const scanResult = ref("No QR code data yet");

const faucetUrl = ref(null);
Expand Down Expand Up @@ -1386,7 +1387,7 @@ const fetchIncogniteeBalance = async () => {

const fetchGuessTheNumberInfo = async () => {
if (!incogniteeStore.apiReady) return;
console.log("TODO: fetch guess the number info");
console.log("fetch guess the number info");
const getter = incogniteeStore.api.guessTheNumberInfoGetter(
incogniteeStore.shard,
);
Expand All @@ -1396,10 +1397,30 @@ const fetchGuessTheNumberInfo = async () => {
});
};

const fetchNetworkStatus = async () => {
if (!incogniteeStore.apiReady) return;
console.debug("fetch network status info");
const getter = incogniteeStore.api.parentchainsInfoGetter(
incogniteeShard.value,
);
getter.send().then((info) => {
console.log(`parentchains info: ${info}`);
parentchainsInfo.value = info;
});
api.rpc.chain.getFinalizedHead().then((head) => {
api.rpc.chain.getBlock(head).then((block) => {
console.log(
`finalized L1 block number, according to L1 api: ${block.block.header.number}`,
);
});
});
};

const pollCounter = useInterval(2000);

watch(pollCounter, async () => {
await fetchIncogniteeBalance();
fetchIncogniteeBalance();
fetchNetworkStatus();
});

watch(accountStore, async () => {
Expand Down

0 comments on commit 6cb9596

Please sign in to comment.