Skip to content

Commit

Permalink
chore: only node 18 and 20
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluard committed Apr 2, 2024
1 parent f63ad3e commit cb10792
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup Nodejs
uses: actions/setup-node@v1
with:
node-version: "14.x"
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: yarn install --non-interactive --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [14, 16]
node: [18, 20]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
4 changes: 2 additions & 2 deletions benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"exports": "./index.js",
"license": "MIT",
"scripts": {
"benchmark": "ts-node-esm index",
"benchmark:all": "ts-node-esm index && ts-node-esm noble && ts-node-esm verifyMultipleSignaturesSavings"
"benchmark": "node --loader ts-node/esm index",
"benchmark:all": "node --loader ts-node/esm index.ts && node --loader ts-node/esm noble.ts && node --loader ts-node/esm verifyMultipleSignaturesSavings.ts"
},
"dependencies": {
"noble-bls12-381": "^0.7.2"
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "7.1.3",
"description": "Implementation of bls signature verification for ethereum 2.0",
"engines": {
"node": ">=14.8.0"
"node": ">=18"
},
"type": "module",
"exports": {
Expand Down Expand Up @@ -72,9 +72,9 @@
"test:coverage": "nyc --cache-dir .nyc_output/.cache -r lcov -e .ts mocha 'test/unit/**/*.test.ts' && nyc report",
"test:spec": "mocha 'test/spec/**/*.test.ts'",
"test": "yarn run test:unit && yarn run test:spec",
"download-test-cases": "ts-node-esm test/downloadSpecTests.ts",
"download-test-cases": "node --loader ts-node/esm test/downloadSpecTests.ts",
"coverage": "codecov -F bls",
"benchmark": "ts-node-esm benchmark",
"benchmark": "node --loader ts-node/esm benchmark/index.ts",
"benchmark:all": "cd benchmark && yarn install && yarn benchmark:all"
},
"dependencies": {
Expand Down Expand Up @@ -107,6 +107,7 @@
"mocha": "^10.0.0",
"nyc": "^15.0.0",
"prettier": "^2.1.2",
"process": "^0.11.10",
"resolve-typescript-plugin": "^1.2.0",
"ts-loader": "^9.3.1",
"ts-node": "^10.9.1",
Expand Down
15 changes: 0 additions & 15 deletions src/herumi/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,10 @@ type Bls = typeof bls;
let blsGlobal: Bls | null = null;
let blsGlobalPromise: Promise<void> | null = null;

// Patch to fix multiVerify() calls on a browser with polyfilled NodeJS crypto
declare global {
interface Window {
msCrypto: typeof window["crypto"];
}
}

export async function setupBls(): Promise<void> {
if (!blsGlobal) {
await bls.init(bls.BLS12_381);

// Patch to fix multiVerify() calls on a browser with polyfilled NodeJS crypto
if (typeof window === "object") {
const crypto = window.crypto || window.msCrypto;
// getRandomValues is not typed in `bls-eth-wasm` because it's not meant to be exposed
// @ts-ignore
bls.getRandomValues = (x) => crypto.getRandomValues(x);
}

blsGlobal = bls;
}
}
Expand Down
21 changes: 4 additions & 17 deletions test/switch.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import blst from "../src/blst-native/index.js";
import herumi from "../src/herumi/index.js";
import {IBls} from "../src/types.js";

export type Implementation = "blst" | "herumi";

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function getBls(implementation: Implementation): IBls {
switch (implementation) {
case "blst":
return blst;
case "herumi":
return herumi;
}
}
import {getImplementation} from "../src/getImplementation.js";
import {IBls, Implementation} from "../src/types.js";

export async function runForAllImplementations(
callback: (bls: IBls, implementation: Implementation) => void
): Promise<void> {
for (const implementation of ["blst", "herumi"] as Implementation[]) {
const bls = getBls(implementation);
for (const implementation of ["blst-native", "herumi"] as Implementation[]) {
const bls = await getImplementation(implementation);
callback(bls, implementation);
}
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4082,6 +4082,11 @@ process-on-spawn@^1.0.0:
dependencies:
fromentries "^1.2.0"

process@^0.11.10:
version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==

progress@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
Expand Down

0 comments on commit cb10792

Please sign in to comment.