-
Notifications
You must be signed in to change notification settings - Fork 7
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
Example loading NPM module #84
base: master
Are you sure you want to change the base?
Conversation
const wsProvider = new WsProvider('wss://rpc.polkadot.io'); | ||
const api = await ApiPromise.create({ provider: wsProvider }); | ||
|
||
return api.genesisHash.toHex(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the type of genesisHash
? You could potentially send raw binary from Uint8Array
to Rust via &[u8]
or Vec<u8>
much more cheaply than via string (no Utf16 to Utf8 conversion necessary).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's of type Hash that extends H256, and H256 extends U8aFixed, and U8aFixed extends Raw, which is a wrapper
around Uint8Array that implements IU8a.
i tried to send Uint8Array
as you mentioned in this commit d921638, but not sure how to convert the bytes to string.
i also tried https://crates.io/crates/serde-wasm-bindgen/0.4.2 serde_wasm_bindgen::from_value
without any luck
error handling outside of the update Co-authored-by: Maciej Hirsz <[email protected]>
Co-authored-by: Maciej Hirsz <[email protected]>
Usage:
cd examples/npm_lib nvm use yarn yarn run esbuild RUST_LOG=info trunk serve --address=127.0.0.1 --open
cargo test --target wasm32-unknown-unknown
ISSUES
yarn run esbuild
Perhaps I need a#[allow(???)]
https://doc.rust-lang.org/rustc/lints/listing/index.htmlwasm_bindgen_test
it says "One other difference is that the tests must be in the root of the crate, or within a pub mod" and the implementation is in src/