UNPKG

zkverifyjs

Version:

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

38 lines 1.4 kB
/** * 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 async function fetchRuntimeVersionFromProvider(provider) { await provider.isReady; const version = (await provider.send('state_getRuntimeVersion', [])); return { specVersion: typeof version.specVersion === 'string' ? Number(version.specVersion) : version.specVersion, specName: version.specName, }; } 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`); } } //# sourceMappingURL=index.js.map