diff --git a/registry/contract/README.md b/registry/contract/README.md index 556bd3c39..55e0e5785 100644 --- a/registry/contract/README.md +++ b/registry/contract/README.md @@ -38,3 +38,43 @@ Add multisig deployment administration for Data team and SREs (DAO?). ./build.sh near deploy --wasmFile ./target/wasm32-unknown-unknown/release/registry.wasm --accountId registry.queryapi.testnet ``` + +## Issues encountered while building + +### Clang + +The default version of `clang` on MacOS cannot build `wasm32-unknown-unknown`, therefore another version must be installed: +```sh +brew install llvm +``` +and can be used via setting the `CC` environment variable: +```sh +CC="/opt/homebrew/Cellar/llvm/17.0.6/bin/clang" cargo build --target wasm32-unknown-unknown +``` + +### near-primitives usize +The `near-primitives` crate internally hard-codes `usize` as 8bits, this becomes a problem when targetting 32bit architecture (wasm32), which expects a `usize` of 4bits. To Bypass this issue the following patch can be applied to the local version of the crate in `~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/near-primitives-0.17.0/src/rand.rs`: +```patch +diff --git a/core/primitives/src/rand.rs b/core/primitives/src/rand.rs +index a79c8fd1b..17978a199 100644 +--- a/core/primitives/src/rand.rs ++++ b/core/primitives/src/rand.rs +@@ -57,16 +57,7 @@ impl WeightedIndex { + } + + pub fn sample(&self, seed: [u8; 32]) -> usize { +- let usize_seed = Self::copy_8_bytes(&seed[0..8]); +- let balance_seed = Self::copy_16_bytes(&seed[8..24]); +- let uniform_index = usize::from_le_bytes(usize_seed) % self.aliases.len(); +- let uniform_weight = Balance::from_le_bytes(balance_seed) % self.weight_sum; +- +- if uniform_weight < self.no_alias_odds[uniform_index] { +- uniform_index +- } else { +- self.aliases[uniform_index] as usize +- } ++ 0 + } + + pub fn get_aliases(&self) -> &[u64] { +```