Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: node fetch #144

Merged
merged 10 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-npmjs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish --access public
Expand Down
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
11,084 changes: 5,379 additions & 5,705 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 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": "^2",
"ora": "^5.3.0"
},
"devDependencies": {
Expand All @@ -66,6 +66,7 @@
"@types/dockerode": "^3.3.24",
"@types/jest": "^27.4.1",
"@types/node": "^18.11.8",
"@types/node-fetch": "^2.6.11",
"@types/terser-webpack-plugin": "^5.2.0",
"@types/webpack": "^5.28.0",
"@types/webpack-bundle-analyzer": "^4.4.1",
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;
}

if (!globalThis.crypto.getRandomValues) {
globalThis.crypto.getRandomValues = getRandomValuesNode;
}
}
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
Loading