HomePhabricator

[ecash-lib] Enable NodeJS support

Description

[ecash-lib] Enable NodeJS support

Summary:
Currently, the library is (pretty much) not usable in a NodeJS context, as it requires manually loading the WASM file, which is what we're currently doing in the tests.

However, it would be great if this library could also frictionlessly be used in a Node context.

This is done by changing initWasm to be its own funciton instead of just forwarding what is generated by wasm-bindgen, and then, on node, to use readFile to read the WASM file, which is then fed to wbg_init, or on the browser, to use the wbg_init without params, which will handle the loading internally.

The implication is that the tests now don't have to load the WASM themselves anymore, and we can remove this code from the tests.

Test Plan: npm run test && npm run build && npm run integration-tests

Reviewers: bytesofman, #bitcoin_abc

Reviewed By: bytesofman, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D16053

Details

Provenance
tobias_ruckAuthored on Apr 25 2024, 16:19
tobias_ruckPushed on Apr 25 2024, 23:10
Reviewer
Restricted Project
Differential Revision
D16053: [ecash-lib] Enable NodeJS support
Parents
rABC2324879c48f3: [ecash-lib] Move ecash-lib-wasm back to root workspace
Branches
Unknown
Tags
Unknown