fix metadata cache overflow, aura block time, update polkadot-api

This commit is contained in:
Victor Oliva
2024-11-07 10:47:38 +01:00
parent fa3ff036f6
commit 9f2423bbfb
4 changed files with 101 additions and 411 deletions
+7 -3
View File
@@ -1,5 +1,6 @@
import { chainHead$, runtimeCtx$ } from "@/chain.state"
import { CircularProgress } from "@/components/CircularProgress"
import { groupBy } from "@/lib/groupBy"
import { state, useStateObservable } from "@react-rxjs/core"
import {
animationFrames,
@@ -22,9 +23,12 @@ const bestBlockTime$ = best$.pipeState(
const targetTime$ = state(
runtimeCtx$.pipe(
map(({ dynamicBuilder, lookup }) => {
const ct = lookup.metadata.pallets
.find((p) => p.name === "Babe")
?.constants.find((ct) => ct.name === "ExpectedBlockTime")
const palletsByName = groupBy(lookup.metadata.pallets, (p) => p.name)
const getConstant = (pallet: string, constant: string) =>
palletsByName[pallet]?.[0]?.constants.find((ct) => ct.name === constant)
const ct =
getConstant("Babe", "ExpectedBlockTime") ??
getConstant("Aura", "SlotDuration")
if (!ct) return null
try {
const res = dynamicBuilder.buildDefinition(ct.type).dec(ct.value)