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

Fix: getrandom dependency issue in WASM build #213

Merged
merged 7 commits into from
Apr 16, 2024

Conversation

kobby-pentangeli
Copy link
Contributor

Motivation

The ic-crypto-getrandom-for-wasm package, which is a workaround for the getrandom dependency issues in WASM environments, doesn't work in all cases. Sometimes, just including the package in Cargo.toml isn't enough.

This PR provides a fix that changes how this package is consumed...
To register this new custom implementation, call the function inside of your canister's init method or wherever canister initialization happens, with conditional compilation, like this:

#[init]
pub fn init(&mut self) {
    #[cfg(target_family = "wasm")]
    ic_crypto_getrandom_for_wasm::register_custom_getrandom();
}

Changes

  • Refactored implementation and export of ic-crypto-getrandom-for-wasm::register_custom_getrandom function.
  • Updated crate-level doc to reflect usage example.

Closes

NOTE

  • This implementation has only been tested against a couple of canisters locally. Thorough testing against other canisters is highly recommended.

ic-crypto-getrandom-for-wasm/Cargo.toml Outdated Show resolved Hide resolved
@ufoscout ufoscout merged commit 424db87 into main Apr 16, 2024
1 check passed
@ufoscout ufoscout deleted the eprod-828-fix-getrandom-dependency-issue branch April 16, 2024 14:32
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

Successfully merging this pull request may close these issues.

5 participants