chiru-labs / ERC721A

https://ERC721A.org
MIT License
2.51k stars 842 forks source link

Fix "error:0308010C:digital envelope routines::unsupported" #388

Closed nazariyv closed 2 years ago

nazariyv commented 2 years ago

When I have cloned the repo, I proceeded to use node versions 18 and 17 to run tests. Which both failed due to the SSL breaking change in 17 & 18.

Solution is to use node version 16.

Vectorized commented 2 years ago

I prefer adding this chunk of code to hardhat.config.js instead of enforcing the version to 16 in the package.json.

This is so that we can keep compatibility across node 14, 16, 17, 18.

Adapted from https://stackoverflow.com/a/72219174/3686594.

// The "ripemd160" algorithm is not available anymore in NodeJS 17+ (because of lib SSL 3).
// The following code replaces it with "sha256" instead.

const crypto = require('crypto');

try {
  crypto.createHash('ripemd160');
} catch (e) {
  const origCreateHash = crypto.createHash;
  crypto.createHash = (alg, opts) => {
    return origCreateHash(alg === 'ripemd160' ? 'sha256' : alg, opts);
  };
}
cygaar commented 2 years ago

Can you add node 17 or 18 to the github action: https://github.com/chiru-labs/ERC721A/blob/main/.github/workflows/run_tests.yml#L21