UNPKG

zkverifyjs

Version:

Submit proofs to zkVerify and query proof state with ease using our npm package.

26 lines 959 B
/** * Fetches the runtime spec from the chain. * @param api - The ApiPromise instance. * @returns The runtime spec. */ export function fetchRuntimeVersion(api) { const version = api.consts.system.version; return { specVersion: version.specVersion.toNumber(), specName: version.specName.toString() }; } export function isVersionAtLeast(runtimeSpec, targetVersion) { return runtimeSpec.specVersion >= targetVersion; } export function isVersionBetween(runtimeSpec, minVersion, maxVersion) { return runtimeSpec.specVersion >= minVersion && runtimeSpec.specVersion <= maxVersion; } export function isVersionExactly(runtimeSpec, targetVersion) { return runtimeSpec.specVersion === targetVersion; } export function requireVersionAtLeast(runtimeSpec, targetVersion, featureName) { if (!isVersionAtLeast(runtimeSpec, targetVersion)) { throw new Error(`${featureName} is only available in runtime version ${targetVersion} or later`); } }