Midnight.js v4.0.3 release notes
For the complete documentation index, see llms.txt
- Version: v4.0.3
- Date: March 27, 2026
- Node.js requirement: >=22
High-level summary
This release introduces two new packages. A barrel package gives you a single import surface for the core Midnight.js modules. A proof provider delegates proving to a connected wallet instead of a standalone proof server. The release also lands a broad reliability pass on testkit-js.
The v4.0.3 publish did not complete. The maintainers recorded in the v4.0.4 notes that v4.0.3 "was not published due to release pipeline issues", and that v4.0.4 carries all of the v4.0.3 changes. On npm, only the two new packages carry a 4.0.3 version, and each one pins its internal dependencies to 4.0.3 versions that the pipeline never published. Neither package installs. Use v4.0.4 or later to pick up everything described here.
Audience
This release note is most relevant for developers who:
- Want a single import point for the core Midnight.js packages instead of importing each one separately.
- Build browser DApps and want the connected wallet to generate proofs rather than running a proof server.
- Write integration tests with
testkit-jsand depend on its assertions, error propagation, and environment variable handling. - Are tracing the Midnight.js version history and need to know why the npm registry skips from 4.0.2 to 4.0.4.
Summary of updates
- Added the
@midnight-ntwrk/midnight-jsbarrel package. - Added the
@midnight-ntwrk/midnight-js-dapp-connector-proof-providerpackage. - Fixed 15 bugs in
testkit-jscovering missing assertions, swallowed errors, and stale environment variables. - Added tests that reproduce the
sendUnshieldedfailure reported in issue 720. - Consolidated development dependency updates.
- Refreshed the generated API documentation.
New features
@midnight-ntwrk/midnight-js barrel package
This package re-exports the core Midnight.js packages under namespaces, so you can pull them in from one dependency. The barrel deliberately omits the provider packages and the Compact CLI tool. That keeps it light and avoids pulling in environment-specific HTTP and filesystem dependencies.
Namespace imports:
import { contracts, networkId, types, utils } from '@midnight-ntwrk/midnight-js';
networkId.setNetworkId('preprod');
const deployed = await contracts.deployContract(/* ... */);
Subpath imports:
import { deployContract } from '@midnight-ntwrk/midnight-js/contracts';
import { setNetworkId } from '@midnight-ntwrk/midnight-js/network-id';
Re-export namespaces:
contractsfrom@midnight-ntwrk/midnight-js-contractsnetworkIdfrom@midnight-ntwrk/midnight-js-network-idtypesfrom@midnight-ntwrk/midnight-js-typesutilsfrom@midnight-ntwrk/midnight-js-utils
To free the package name, the repository root workspace took the name @midnight-ntwrk/midnight-js-monorepo. This affects contributors working in the repository, not consumers of the published packages.
@midnight-ntwrk/midnight-js-dapp-connector-proof-provider package
This package wraps the DApp Connector getProvingProvider API in the Midnight.js ProofProvider interface. A connected wallet then generates the proofs, so your DApp does not need its own proof server.
import { dappConnectorProofProvider } from '@midnight-ntwrk/midnight-js-dapp-connector-proof-provider';
const proofProvider = await dappConnectorProofProvider(
walletConnectedAPI,
zkConfigProvider,
costModel
);
Exports:
dappConnectorProofProviderbuilds a fullProofProviderfrom a DApp Connector wallet API.dappConnectorProvingProviderbuilds the lower-levelProvingProvideronly.DAppConnectorProvingAPIis a type alias forPick<WalletConnectedAPI, 'getProvingProvider'>. It builds on theWalletConnectedAPItype from@midnight-ntwrk/dapp-connector-api, so it tracks changes to that type.
Breaking changes
No breaking API changes are introduced in v4.0.3.
Bug fixes and quality improvements
Testkit-js reliability fixes
This release fixes 15 bugs and design issues in testkit-js:
expectSuccessfulDeployTxandexpectSuccessfulCallTxcalledexpect()with no matcher, so they asserted nothing.ledgerStateBlobandledgerVersionignored theblockHashparameter in their RPC calls.waitForFundsreturned either abigintor a wallet state object. It now always returns abigint.BigInt.prototype.toJSONusedNumber(this), which loses precision on large values. It now usestoString().FaucetClient.requestTokens,ProofServerClient.proveTx, everyhealth()method, andWalletSaveStateProvider.savecaught and logged errors instead of propagating them. They now propagate.health()methods hardcodedhttps://orhttp://instead of deriving the protocol from the configured URL. AbuildUrlWithPathhelper now handles this.- Module-level constants such as
MN_TEST_INDEXERcaptured environment variables at import time. Getter functions replace them, so the code now reads a value you set after import. - Tests mutated
process.envwithout restoring it. AnafterEachcleanup now resets it. WalletSaveStateProvider.saveused.replaceAll('.gz', ''), which could corrupt a path containing that string elsewhere. It now checks.endsWith('.gz')and slices.FluentWalletBuilder.build()mutated the builder's internalseedsstate. It now uses a local constant.TestEnvironmentno longer carries the unusedenvConfigurationfield.deleteDirectorybecomestryDeleteDirectory, a name that makes its error-swallowing behavior explicit.
Additional test coverage
This release adds unit tests that reproduce issue 720, where sendUnshielded fails when the target user address differs from the wallet's own address. The tests capture the behavior. They do not change it.
Development dependency updates
A single change consolidates eight outstanding dependency update PRs covering ESLint, jsdom, Turbo, TypeDoc, Allure, and two GitHub Actions. All are development dependencies, so published package behavior does not change.
Known issues
The v4.0.3 npm publish is incomplete. npm carries a 4.0.3 version only for @midnight-ntwrk/midnight-js and @midnight-ntwrk/midnight-js-dapp-connector-proof-provider. Every package that already existed at 4.0.2 went straight to 4.0.4. Both 4.0.3 packages declare exact dependencies on 4.0.3 versions that the registry does not hold, so installing either one fails to resolve.
Install v4.0.4 or later instead. It contains every change listed on this page.
Links and references
- GitHub: Midnight.js repository
- Release: v4.0.3 on GitHub
- API reference: Midnight.js API documentation
- Next release: Midnight.js v4.0.4 release notes