o1-labs / o1js

TypeScript framework for zk-SNARKs and zkApps
https://docs.minaprotocol.com/en/zkapps/how-to-write-a-zkapp
Apache License 2.0
530 stars 121 forks source link

Remove isomorphic-fetch dependency #1904

Open hattyhattington17 opened 6 days ago

hattyhattington17 commented 6 days ago

Isomorphic-fetch is no longer being maintained and is causing a deprecation warning on node v22.11.0 by pulling in punycode.

From the zkapp-cli:

> node --trace-deprecation src/bin/index.js project test
? Create an accompanying UI project too? …  (node:2145) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    at node:punycode:3:9
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:399:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:338:10)
    at loadBuiltinModule (node:internal/modules/helpers:114:7)
    at Function._load (node:internal/modules/cjs/loader:1100:17)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Module.require (node:internal/modules/cjs/loader:1340:12)
    at require (node:internal/modules/helpers:141:16)
    at Object.<anonymous> (zkapp-cli/node_modules/whatwg-url/lib/url-state-machine.js:2:18)

> npm ls whatwg-url
zkapp-cli@0.22.0
└─┬ o1js@2.0.0
  └─┬ isomorphic-fetch@3.0.0
    └─┬ node-fetch@2.7.0
      └── whatwg-url@5.0.0

When this is done, remove the whatwg-url version override from zkapp-cli's package.json https://github.com/o1-labs/zkapp-cli/pull/707

mitschabaude commented 5 days ago

yup, and we can simply remove isomorphic-fetch because all it does is add a shim for fetch() in node versions lower than 18. In node >= 18, fetch() is a builtin global that we should be able to use directly. I don't think we care about lower node versions anymore