Skip to content

Wasm compatibility: use of undeclared crate or module platform #17

@mkarimim71

Description

@mkarimim71

I'm using drand-core in my smart contract based on cosmwasm that has ureq in dependencies and it has rustls-native-certs in the dependencies.

It compile successfully on running cargo test but after compile the project with this command:

docker run --rm -v "$(pwd)":/code --network="host" \
 --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
 --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
 cosmwasm/workspace-optimizer:0.15.1

I get this error:

error[E0433]: failed to resolve: use of undeclared crate or module `platform`
 --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-native-certs-0.7.0/src/lib.rs:58:42
  |
58 |     load_certs_from_env().unwrap_or_else(platform::load_native_certs)
  |                                          ^^^^^^^^ use of undeclared crate or module `platform`

In the description of this repo, I found wasm32 compatible library but I found that ureq used in dependencies not support wasm based on this issue and rustls-native-certs not support wasm based on this issue.

What should I do for this issue, It seems platform not clear in workspace-optimizer?

To reproduce the problem, do the following:

  1. run this to create project from template:
$ cargo generate --git https://github.com/CosmWasm/cw-template.git --branch 1.0 --name project
$ cd project
  1. Add drand_core = { version = "0.0.16" } to dependency of Cargo.toml
  2. run this:
$ docker run --rm -v "$(pwd)":/code --network="host" \                                        
  --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
  --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
  cosmwasm/rust-optimizer:0.15.1

Or

$ cargo wasm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions