24 lines
982 B
JavaScript
24 lines
982 B
JavaScript
import useSWR from "swr"
|
|
import { getDynamicBuilder, getLookupFn } from "@polkadot-api/metadata-builders"
|
|
|
|
import { useUnstableProvider } from "./UnstableProvider"
|
|
import { useMetadata } from "./MetadataProvider"
|
|
|
|
export const useApplauseThreshold = () => {
|
|
const { chainId } = useUnstableProvider()
|
|
const metadata = useMetadata()
|
|
const { data: existentialDeposit } = useSWR(
|
|
chainId && metadata
|
|
? ["ApplauseThreshold", chainId, metadata]
|
|
: null,
|
|
([_, chainId, metadata]) => {
|
|
const builder = getDynamicBuilder(getLookupFn(metadata))
|
|
const codec = builder.buildConstant("GhostSlowClaps", "ApplauseThreshold")
|
|
const constants = metadata?.pallets?.find(obj => obj.name === "GhostSlowClaps")?.constants
|
|
const value = constants?.find(obj => obj.name === "ApplauseThreshold")?.value
|
|
return value ? codec.dec(value) : undefined
|
|
}
|
|
)
|
|
return existentialDeposit
|
|
}
|