Skip to content

Commit

Permalink
fix: node 20 support (#141)
Browse files Browse the repository at this point in the history
* fdp-play fx, works well with node 20

* Update package-lock.json
  • Loading branch information
TheBojda authored Jun 13, 2024
1 parent 147d41d commit d615c01
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ docs
.vscode

generator/build
yarn.lock
174 changes: 155 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dockerode": "^4.0.2",
"ethers": "^5.7.2",
"furious-commander": "^1.7.1",
"node-fetch": "3.0.0-beta.9",
"node-fetch": "3.3.2",
"ora": "^5.3.0"
},
"devDependencies": {
Expand Down
8 changes: 7 additions & 1 deletion src/shim/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,11 @@ const getRandomValuesNode = <T extends ArrayBufferView | null>(array: T): T => {
}

if (isNode && globalThis) {
globalThis.crypto = { ...globalThis.crypto, getRandomValues: getRandomValuesNode }
if (!globalThis.crypto) {
globalThis.crypto = {} as Crypto;

Check failure on line 25 in src/shim/crypto.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Delete `;`
}

if (!globalThis.crypto.getRandomValues) {
globalThis.crypto.getRandomValues = getRandomValuesNode;

Check failure on line 29 in src/shim/crypto.ts

View workflow job for this annotation

GitHub Actions / check (16.x)

Delete `;`
}
}
4 changes: 2 additions & 2 deletions src/utils/wait.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetch, { FetchError } from 'node-fetch'
import { default as __fetch, FetchError } from 'node-fetch'
import { sleep } from './index'
import { TimeoutError } from './error'
import { BeeDebug } from '@ethersphere/bee-js'
Expand Down Expand Up @@ -40,7 +40,7 @@ function isAllowedError(e: FetchError): boolean {
export async function waitForBlockchain(waitingIterations = 30): Promise<void> {
for (let i = 0; i < waitingIterations; i++) {
try {
const request = await fetch('http://127.0.0.1:9545', {
const request = await __fetch('http://127.0.0.1:9545', {
method: 'POST',
body: BLOCKCHAIN_BODY_REQUEST,
headers: { 'Content-Type': 'application/json' },
Expand Down

0 comments on commit d615c01

Please sign in to comment.