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/index.ts

15 lines
461 B
TypeScript
Raw Normal View History

2022-04-13 19:36:07 +00:00
import type {IBls} from "./interface.js";
2022-04-13 16:59:25 +00:00
import {getImplementation} from "./getImplementation.js";
2020-11-25 15:03:11 +00:00
2022-04-13 19:36:07 +00:00
// Thanks https://github.com/iliakan/detect-node/blob/master/index.esm.js
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
2020-11-29 18:54:33 +00:00
2022-04-13 19:36:07 +00:00
let bls: IBls;
try {
bls = await getImplementation(isNode ? "blst-native" : "herumi");
} catch (e) {
bls = await getImplementation("herumi");
2020-11-25 15:03:11 +00:00
}
2022-04-13 19:36:07 +00:00
export default bls;