Skip to content
Snippets Groups Projects
Commit b9cc9284 authored by asynchronous rob's avatar asynchronous rob
Browse files

update the WASM runtime imports

parent ce5f4da9
No related merge requests found
......@@ -16,6 +16,7 @@
//! Environment API: Allows certain information to be accessed throughout the runtime.
use runtime_support::boxed::Box;
use runtime_support::mem;
use runtime_support::cell::RefCell;
use runtime_support::rc::Rc;
......
......@@ -8,11 +8,19 @@ extern crate alloc;
pub use alloc::vec;
pub use alloc::boxed;
pub use alloc::rc::Rc;
pub use alloc::rc;
pub use core::mem;
pub use core::slice;
pub use core::cell;
/// Common re-exports that are useful to have in scope.
pub mod prelude {
pub use alloc::vec::Vec;
pub use alloc::boxed::Box;
}
use alloc::vec::Vec;
extern crate pwasm_libc;
extern crate pwasm_alloc;
......@@ -68,7 +76,7 @@ pub fn chain_id() -> u64 {
/// Conduct a 256-bit Blake2 hash.
pub fn blake2_256(data: &[u8]) -> [u8; 32] {
unsafe {
let mut result: [u8; 32] = uninitialized();
let mut result: [u8; 32] = Default::default();
// guaranteed to write into result.
ext_blake2_256(&data[0], data.len() as u32, &mut result[0]);
result
......@@ -78,7 +86,7 @@ pub fn blake2_256(data: &[u8]) -> [u8; 32] {
/// Conduct four XX hashes to give a 256-bit result.
pub fn twox_256(data: &[u8]) -> [u8; 32] {
unsafe {
let mut result: [u8; 32] = uninitialized();
let mut result: [u8; 32] = Default::default();
// guaranteed to write into result.
ext_twox_256(&data[0], data.len() as u32, &mut result[0]);
result
......@@ -88,7 +96,7 @@ pub fn twox_256(data: &[u8]) -> [u8; 32] {
/// Conduct two XX hashes to give a 256-bit result.
pub fn twox_128(data: &[u8]) -> [u8; 16] {
unsafe {
let mut result: [u8; 16] = uninitialized();
let mut result: [u8; 16] = Default::default();
// guaranteed to write into result.
ext_twox_128(&data[0], data.len() as u32, &mut result[0]);
result
......@@ -132,7 +140,7 @@ macro_rules! impl_stubs {
#[no_mangle]
pub fn $name(input_data: *mut u8, input_len: usize) -> u64 {
let input = unsafe {
$crate::Vec::from_raw_parts(input_data, input_len, input_len)
$crate::vec::Vec::from_raw_parts(input_data, input_len, input_len)
};
let output = super::$name(input);
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment