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

BigNumFinalization.unregister is not a function when running CSL built with WASM_BINDGEN_WEAKREF #647

Open
elkorn opened this issue Sep 27, 2023 · 1 comment

Comments

@elkorn
Copy link

elkorn commented Sep 27, 2023

Hi!
I read #542 and would like to avoid having to call .free on everything if possible.

So I built CSL 11.5.0 with WASM_BINDGEN_WEAKREF=1 (or so I hope).
I strayed from the official docs since with nvm use it would have made me install node 12.18.1, which is causing some issues on Mac M1 - hoped I can get a pass on this, since it seems to build fine on node 16 as well.

This is the process I followed:

# 1. install rustup and wasm-pack
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo 'export PATH=$HOME/.cargo/bin/:$PATH' >> $BASH_ENV
rustup install stable
rustup target add wasm32-unknown-unknown --toolchain stable
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

# 2. install cmake
brew install cmake

# 3. get CSL source code
git clone https://github.com/Emurgo/cardano-serialization-lib.git

# 4. build CSL
cd ./cardano-serialization-lib
git submodule update --init --recursive
npm install
WASM_BINDGEN_WEAKREF=1 npm run rust:build-nodejs

Then I copy and link the built pkg locally.
Most things seem to work fine, however I'm running into this issue:

 TypeError  BigNumFinalization.unregister is not a function
error stack:
• cardano_serialization_lib.js:2688 __destroy_into_raw
    node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js:2688:24

• cardano_serialization_lib.js:12159 set_asset
    node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js:12159:22

• task_queues:96 processTicksAndRejections
    node:internal/process/task_queues:96:5

The "offending" code:

  const policyHash = CSL.ScriptHash.from_hex(myPolicyId)
  const tokenName = CSL.AssetName.new(Buffer.from("myname"))
  const tokenAmount = CSL.BigNum.from_str("1")
  myTokens.set_asset(policyHash, tokenName, tokenAmount)

FWIW, my app runs on node 16 as well.

Any advice on this? And am I building the package right?

@elkorn elkorn changed the title BigNumFinalization.unregister is not a function when running CSL built with BigNumFinalization.unregister is not a function when running CSL built with WASM_BINDGEN_WEAKREF Sep 27, 2023
@lisicky
Copy link
Contributor

lisicky commented Nov 7, 2023

Hi @elkorn ! It's better to check wasm bingen, because we generate all js side code by wasm bingen. You can try to upgrade or downgrade the version probably current one has a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants