Hi. I am trying to create an optimized version of my contract.rs file using the command:
docker run --rm -v "$(pwd)":/contract --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry enigmampc/secret-contract-optimizer:1.0.9
but I keep getting the error
Finished release [optimized] target(s) in 56.54s
Failed opening './target/wasm32-unknown-unknown/release/*.wasm'
Even though i havent used any sudo commands . The way I run this is
cargo build
docker run --rm -v "$(pwd)":/contract --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry enigmampc/secret-contract-optimizer:1.0.9.
After the second command it gives error.
This is my code GitHub - mahamzaidi/secret
mahamzaidi:
cargo build
Try replacing this with cargo build --release
Also, might be useful to show the output of:
find ./target/wasm32-unknown-unknown/
Tried this and got the same error.
Can you change that line to:
cargo build --target=wasm32-unknown-unknown --release
and then show the output of find ./target/wasm32-unknown-unknown/
again ?
Are you calling 'cargo build' from anywhere else ?
Can you run:
cargo build --target=wasm32-unknown-unknown --release
find ./target | grep wasm$
env | grep CARGO_TARGET_DIR
without running any of the docker commands? This bisects the problem into "cargo build" vs "docker"
WASM requires the crate be a binary or of cdylib type - the latter being the actually supported, sensible type. Ensure you have cdylib
in your manifest: Cargo.toml - Hello wasm-pack!
1 Like
Thanks! Adding this solved the issue
1 Like
system
Closed
December 1, 2022, 11:41am
12
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.