fix most issues with compiling on WASM

This commit is contained in:
Robert Habermeier
2018-02-06 12:02:03 +01:00
parent b58df7892f
commit 5a675e9c64
18 changed files with 220 additions and 357 deletions
+11 -1
View File
@@ -15,9 +15,19 @@ polkadot-state-machine = { path = "../state-machine", version = "0.1", optional
polkadot-primitives = { path = "../primitives", version = "0.1", default_features = false }
polkadot-runtime-codec = { path = "../runtime-codec", version = "0.1", default_features = false }
triehash = { version = "0.1", optional = true }
ring = { version = "0.12", optional = true }
untrusted = { version = "0.5", optional = true }
[features]
default = ["std"]
std = ["environmental", "polkadot-state-machine", "triehash", "polkadot-primitives/std", "polkadot-runtime-codec/std"]
std = [
"environmental",
"polkadot-state-machine",
"triehash",
"polkadot-primitives/std",
"polkadot-runtime-codec/std",
"ring",
"untrusted"
]
nightly = []
strict = []
+13 -4
View File
@@ -20,8 +20,8 @@ extern crate environmental;
extern crate polkadot_state_machine;
extern crate polkadot_primitives as primitives;
extern crate triehash;
use primitives::ed25519;
extern crate ring;
extern crate untrusted;
pub use std::vec;
pub use std::rc;
@@ -93,7 +93,16 @@ pub fn enumerated_trie_root(serialised_values: &[&[u8]]) -> [u8; 32] {
/// Verify a ed25519 signature.
pub fn ed25519_verify(sig: &[u8; 64], msg: &[u8], pubkey: &[u8; 32]) -> bool {
ed25519::verify(&sig[..], msg, &pubkey[..])
use ring::signature;
let public_key = untrusted::Input::from(pubkey);
let msg = untrusted::Input::from(msg);
let sig = untrusted::Input::from(sig);
match signature::verify(&signature::ED25519, public_key, msg, sig) {
Ok(_) => true,
_ => false,
}
}
/// Execute the given closure with global function available whose functionality routes into the
@@ -136,7 +145,7 @@ macro_rules! impl_stubs {
}
#[cfg(test)]
mod tests {
mod std_tests {
use super::*;
macro_rules! map {
+1 -1
View File
@@ -6,7 +6,7 @@ extern crate pwasm_libc;
#[cfg(feature = "nightly")]
extern crate pwasm_alloc;
extern crate polkadot_primitives as primitives;;
extern crate polkadot_primitives as primitives;
pub use alloc::vec;
pub use alloc::boxed;