This repository has been archived on 2023-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
chainsafe-bls/src/context.ts

21 lines
495 B
TypeScript
Raw Normal View History

import blsWasmWrapper from "@chainsafe/eth2-bls-wasm";
let blsWrapper: typeof blsWasmWrapper | null = null;
export async function init(): Promise<typeof blsWasmWrapper> {
2019-11-28 11:13:20 +00:00
if(blsWrapper) return blsWrapper;
await blsWasmWrapper.init();
blsWrapper = blsWasmWrapper;
return blsWrapper;
}
export function destroy(): void {
blsWrapper = null;
}
export function getContext(): typeof blsWasmWrapper{
if(blsWrapper) {
return blsWrapper;
}
throw new Error("BLS not initialized");
}