mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 02:57:57 +00:00
Rename: primitives/sr-io -> primitives/sp-io (#4328)
* primitives/sr-io -> primitives/io * fix * rename * runtime-io -> sp-io * git mv * fix ci * remove package name * fix * fix * try minimizing diff * try minimizing diff again * try minimizing diff again
This commit is contained in:
committed by
Bastian Köcher
parent
1f84d6d41d
commit
4f2cdb20c1
@@ -7,7 +7,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
derive_more = "0.99.2"
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0" }
|
||||
runtime_io = { package = "sp-io", path = "../../primitives/sr-io" }
|
||||
sp-io = { path = "../../primitives/io" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
trie = { package = "sp-trie", path = "../../primitives/trie" }
|
||||
serializer = { package = "sp-serializer", path = "../../primitives/serializer" }
|
||||
|
||||
@@ -7,7 +7,7 @@ build = "build.rs"
|
||||
|
||||
[dependencies]
|
||||
sp-std = { path = "../../../primitives/std", default-features = false }
|
||||
runtime_io = { package = "sp-io", path = "../../../primitives/sr-io", default-features = false }
|
||||
sp-io = { path = "../../../primitives/io", default-features = false }
|
||||
sandbox = { package = "sp-sandbox", path = "../../../primitives/sr-sandbox", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false }
|
||||
sp-runtime = { package = "sp-runtime", path = "../../../primitives/runtime", default-features = false }
|
||||
@@ -17,4 +17,4 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../..
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
std = ["runtime_io/std", "sandbox/std", "sp-std/std"]
|
||||
std = ["sp-io/std", "sandbox/std", "sp-std/std"]
|
||||
|
||||
@@ -9,7 +9,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
use sp_std::{vec::Vec, vec};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use runtime_io::{
|
||||
use sp_io::{
|
||||
storage, hashing::{blake2_128, blake2_256, sha2_256, twox_128, twox_256},
|
||||
crypto::{ed25519_verify, sr25519_verify},
|
||||
};
|
||||
@@ -146,49 +146,49 @@ primitives::wasm_export_functions! {
|
||||
|
||||
fn test_offchain_local_storage() -> bool {
|
||||
let kind = primitives::offchain::StorageKind::PERSISTENT;
|
||||
assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), None);
|
||||
runtime_io::offchain::local_storage_set(kind, b"test", b"asd");
|
||||
assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), Some(b"asd".to_vec()));
|
||||
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None);
|
||||
sp_io::offchain::local_storage_set(kind, b"test", b"asd");
|
||||
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), Some(b"asd".to_vec()));
|
||||
|
||||
let res = runtime_io::offchain::local_storage_compare_and_set(
|
||||
let res = sp_io::offchain::local_storage_compare_and_set(
|
||||
kind,
|
||||
b"test",
|
||||
Some(b"asd".to_vec()),
|
||||
b"",
|
||||
);
|
||||
assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), Some(b"".to_vec()));
|
||||
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), Some(b"".to_vec()));
|
||||
res
|
||||
}
|
||||
|
||||
fn test_offchain_local_storage_with_none() {
|
||||
let kind = primitives::offchain::StorageKind::PERSISTENT;
|
||||
assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), None);
|
||||
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None);
|
||||
|
||||
let res = runtime_io::offchain::local_storage_compare_and_set(kind, b"test", None, b"value");
|
||||
let res = sp_io::offchain::local_storage_compare_and_set(kind, b"test", None, b"value");
|
||||
assert_eq!(res, true);
|
||||
assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), Some(b"value".to_vec()));
|
||||
assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), Some(b"value".to_vec()));
|
||||
}
|
||||
|
||||
fn test_offchain_http() -> bool {
|
||||
use primitives::offchain::HttpRequestStatus;
|
||||
let run = || -> Option<()> {
|
||||
let id = runtime_io::offchain::http_request_start(
|
||||
let id = sp_io::offchain::http_request_start(
|
||||
"POST",
|
||||
"http://localhost:12345",
|
||||
&[],
|
||||
).ok()?;
|
||||
runtime_io::offchain::http_request_add_header(id, "X-Auth", "test").ok()?;
|
||||
runtime_io::offchain::http_request_write_body(id, &[1, 2, 3, 4], None).ok()?;
|
||||
runtime_io::offchain::http_request_write_body(id, &[], None).ok()?;
|
||||
let status = runtime_io::offchain::http_response_wait(&[id], None);
|
||||
sp_io::offchain::http_request_add_header(id, "X-Auth", "test").ok()?;
|
||||
sp_io::offchain::http_request_write_body(id, &[1, 2, 3, 4], None).ok()?;
|
||||
sp_io::offchain::http_request_write_body(id, &[], None).ok()?;
|
||||
let status = sp_io::offchain::http_response_wait(&[id], None);
|
||||
assert!(status == vec![HttpRequestStatus::Finished(200)], "Expected Finished(200) status.");
|
||||
let headers = runtime_io::offchain::http_response_headers(id);
|
||||
let headers = sp_io::offchain::http_response_headers(id);
|
||||
assert_eq!(headers, vec![(b"X-Auth".to_vec(), b"hello".to_vec())]);
|
||||
let mut buffer = vec![0; 64];
|
||||
let read = runtime_io::offchain::http_response_read_body(id, &mut buffer, None).ok()?;
|
||||
let read = sp_io::offchain::http_response_read_body(id, &mut buffer, None).ok()?;
|
||||
assert_eq!(read, 3);
|
||||
assert_eq!(&buffer[0..read as usize], &[1, 2, 3]);
|
||||
let read = runtime_io::offchain::http_response_read_body(id, &mut buffer, None).ok()?;
|
||||
let read = sp_io::offchain::http_response_read_body(id, &mut buffer, None).ok()?;
|
||||
assert_eq!(read, 0);
|
||||
|
||||
Some(())
|
||||
|
||||
@@ -168,20 +168,20 @@ impl_wasm_host_interface! {
|
||||
|
||||
ext_print_utf8(utf8_data: Pointer<u8>, utf8_len: WordSize) {
|
||||
if let Ok(utf8) = context.read_memory(utf8_data, utf8_len) {
|
||||
runtime_io::misc::print_utf8(&utf8);
|
||||
sp_io::misc::print_utf8(&utf8);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
ext_print_hex(data: Pointer<u8>, len: WordSize) {
|
||||
if let Ok(hex) = context.read_memory(data, len) {
|
||||
runtime_io::misc::print_hex(&hex);
|
||||
sp_io::misc::print_hex(&hex);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
ext_print_num(number: u64) {
|
||||
runtime_io::misc::print_num(number);
|
||||
sp_io::misc::print_num(number);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ impl_wasm_host_interface! {
|
||||
let target_str = std::str::from_utf8(&target)
|
||||
.map_err(|_| "Target invalid utf8 in ext_log")?;
|
||||
|
||||
runtime_io::logging::log(level.into(), &target_str, &message);
|
||||
sp_io::logging::log(level.into(), &target_str, &message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ impl_wasm_host_interface! {
|
||||
.map_err(|_| "Invalid attempt to determine key in ext_set_storage")?;
|
||||
let value = context.read_memory(value_data, value_len)
|
||||
.map_err(|_| "Invalid attempt to determine value in ext_set_storage")?;
|
||||
Ok(runtime_io::storage::set(&key, &value))
|
||||
Ok(sp_io::storage::set(&key, &value))
|
||||
}
|
||||
|
||||
ext_set_child_storage(
|
||||
@@ -232,7 +232,7 @@ impl_wasm_host_interface! {
|
||||
let value = context.read_memory(value_data, value_len)
|
||||
.map_err(|_| "Invalid attempt to determine value in ext_set_child_storage")?;
|
||||
|
||||
Ok(runtime_io::storage::child_set(&storage_key, &key, &value))
|
||||
Ok(sp_io::storage::child_set(&storage_key, &key, &value))
|
||||
}
|
||||
|
||||
ext_clear_child_storage(
|
||||
@@ -246,19 +246,19 @@ impl_wasm_host_interface! {
|
||||
let key = context.read_memory(key_data, key_len)
|
||||
.map_err(|_| "Invalid attempt to determine key in ext_clear_child_storage")?;
|
||||
|
||||
Ok(runtime_io::storage::child_clear(&storage_key, &key))
|
||||
Ok(sp_io::storage::child_clear(&storage_key, &key))
|
||||
}
|
||||
|
||||
ext_clear_storage(key_data: Pointer<u8>, key_len: WordSize) {
|
||||
let key = context.read_memory(key_data, key_len)
|
||||
.map_err(|_| "Invalid attempt to determine key in ext_clear_storage")?;
|
||||
Ok(runtime_io::storage::clear(&key))
|
||||
Ok(sp_io::storage::clear(&key))
|
||||
}
|
||||
|
||||
ext_exists_storage(key_data: Pointer<u8>, key_len: WordSize) -> u32 {
|
||||
let key = context.read_memory(key_data, key_len)
|
||||
.map_err(|_| "Invalid attempt to determine key in ext_exists_storage")?;
|
||||
Ok(if runtime_io::storage::exists(&key) { 1 } else { 0 })
|
||||
Ok(if sp_io::storage::exists(&key) { 1 } else { 0 })
|
||||
}
|
||||
|
||||
ext_exists_child_storage(
|
||||
@@ -272,13 +272,13 @@ impl_wasm_host_interface! {
|
||||
let key = context.read_memory(key_data, key_len)
|
||||
.map_err(|_| "Invalid attempt to determine key in ext_exists_child_storage")?;
|
||||
|
||||
Ok(if runtime_io::storage::child_exists(&storage_key, &key) { 1 } else { 0 })
|
||||
Ok(if sp_io::storage::child_exists(&storage_key, &key) { 1 } else { 0 })
|
||||
}
|
||||
|
||||
ext_clear_prefix(prefix_data: Pointer<u8>, prefix_len: WordSize) {
|
||||
let prefix = context.read_memory(prefix_data, prefix_len)
|
||||
.map_err(|_| "Invalid attempt to determine prefix in ext_clear_prefix")?;
|
||||
Ok(runtime_io::storage::clear_prefix(&prefix))
|
||||
Ok(sp_io::storage::clear_prefix(&prefix))
|
||||
}
|
||||
|
||||
ext_clear_child_prefix(
|
||||
@@ -291,13 +291,13 @@ impl_wasm_host_interface! {
|
||||
.map_err(|_| "Invalid attempt to determine storage_key in ext_clear_child_prefix")?;
|
||||
let prefix = context.read_memory(prefix_data, prefix_len)
|
||||
.map_err(|_| "Invalid attempt to determine prefix in ext_clear_child_prefix")?;
|
||||
Ok(runtime_io::storage::child_clear_prefix(&storage_key, &prefix))
|
||||
Ok(sp_io::storage::child_clear_prefix(&storage_key, &prefix))
|
||||
}
|
||||
|
||||
ext_kill_child_storage(storage_key_data: Pointer<u8>, storage_key_len: WordSize) {
|
||||
let storage_key = context.read_memory(storage_key_data, storage_key_len)
|
||||
.map_err(|_| "Invalid attempt to determine storage_key in ext_kill_child_storage")?;
|
||||
Ok(runtime_io::storage::child_storage_kill(&storage_key))
|
||||
Ok(sp_io::storage::child_storage_kill(&storage_key))
|
||||
}
|
||||
|
||||
ext_get_allocated_storage(
|
||||
@@ -308,7 +308,7 @@ impl_wasm_host_interface! {
|
||||
let key = context.read_memory(key_data, key_len)
|
||||
.map_err(|_| "Invalid attempt to determine key in ext_get_allocated_storage")?;
|
||||
|
||||
if let Some(value) = runtime_io::storage::get(&key) {
|
||||
if let Some(value) = sp_io::storage::get(&key) {
|
||||
let offset = context.allocate_memory(value.len() as u32)?;
|
||||
context.write_memory(offset, &value)
|
||||
.map_err(|_| "Invalid attempt to set memory in ext_get_allocated_storage")?;
|
||||
@@ -334,7 +334,7 @@ impl_wasm_host_interface! {
|
||||
let key = context.read_memory(key_data, key_len)
|
||||
.map_err(|_| "Invalid attempt to determine key in ext_get_allocated_child_storage")?;
|
||||
|
||||
if let Some(value) = runtime_io::storage::child_get(&storage_key, &key) {
|
||||
if let Some(value) = sp_io::storage::child_get(&storage_key, &key) {
|
||||
let offset = context.allocate_memory(value.len() as u32)?;
|
||||
context.write_memory(offset, &value)
|
||||
.map_err(|_| "Invalid attempt to set memory in ext_get_allocated_child_storage")?;
|
||||
@@ -358,7 +358,7 @@ impl_wasm_host_interface! {
|
||||
let key = context.read_memory(key_data, key_len)
|
||||
.map_err(|_| "Invalid attempt to get key in ext_get_storage_into")?;
|
||||
|
||||
if let Some(value) = runtime_io::storage::get(&key) {
|
||||
if let Some(value) = sp_io::storage::get(&key) {
|
||||
let data = &value[value.len().min(value_offset as usize)..];
|
||||
let written = std::cmp::min(value_len as usize, data.len());
|
||||
context.write_memory(value_data, &data[..written])
|
||||
@@ -383,7 +383,7 @@ impl_wasm_host_interface! {
|
||||
let key = context.read_memory(key_data, key_len)
|
||||
.map_err(|_| "Invalid attempt to get key in ext_get_child_storage_into")?;
|
||||
|
||||
if let Some(value) = runtime_io::storage::child_get(&storage_key, &key) {
|
||||
if let Some(value) = sp_io::storage::child_get(&storage_key, &key) {
|
||||
let data = &value[value.len().min(value_offset as usize)..];
|
||||
let written = std::cmp::min(value_len as usize, data.len());
|
||||
context.write_memory(value_data, &data[..written])
|
||||
@@ -395,7 +395,7 @@ impl_wasm_host_interface! {
|
||||
}
|
||||
|
||||
ext_storage_root(result: Pointer<u8>) {
|
||||
context.write_memory(result, runtime_io::storage::root().as_ref())
|
||||
context.write_memory(result, sp_io::storage::root().as_ref())
|
||||
.map_err(|_| "Invalid attempt to set memory in ext_storage_root".into())
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ impl_wasm_host_interface! {
|
||||
) -> Pointer<u8> {
|
||||
let storage_key = context.read_memory(storage_key_data, storage_key_len)
|
||||
.map_err(|_| "Invalid attempt to determine storage_key in ext_child_storage_root")?;
|
||||
let value = runtime_io::storage::child_root(&storage_key);
|
||||
let value = sp_io::storage::child_root(&storage_key);
|
||||
|
||||
let offset = context.allocate_memory(value.len() as u32)?;
|
||||
context.write_memory(offset, &value)
|
||||
@@ -425,7 +425,7 @@ impl_wasm_host_interface! {
|
||||
context.read_memory_into(parent_hash_data, &mut parent_hash[..])
|
||||
.map_err(|_| "Invalid attempt to get parent_hash in ext_storage_changes_root")?;
|
||||
|
||||
if let Some(r) = runtime_io::storage::changes_root(&parent_hash) {
|
||||
if let Some(r) = sp_io::storage::changes_root(&parent_hash) {
|
||||
context.write_memory(result, &r[..])
|
||||
.map_err(|_| "Invalid attempt to set memory in ext_storage_changes_root")?;
|
||||
Ok(1)
|
||||
@@ -459,7 +459,7 @@ impl_wasm_host_interface! {
|
||||
}
|
||||
|
||||
ext_chain_id() -> u64 {
|
||||
Ok(runtime_io::misc::chain_id())
|
||||
Ok(sp_io::misc::chain_id())
|
||||
}
|
||||
|
||||
ext_twox_64(data: Pointer<u8>, len: WordSize, out: Pointer<u8>) {
|
||||
@@ -555,7 +555,7 @@ impl_wasm_host_interface! {
|
||||
.map_err(|_| "Invalid attempt to get id in ext_ed25519_public_keys")?;
|
||||
let key_type = KeyTypeId(id);
|
||||
|
||||
let keys = runtime_io::crypto::ed25519_public_keys(key_type).encode();
|
||||
let keys = sp_io::crypto::ed25519_public_keys(key_type).encode();
|
||||
|
||||
let len = keys.len() as u32;
|
||||
let offset = context.allocate_memory(len)?;
|
||||
@@ -610,7 +610,7 @@ impl_wasm_host_interface! {
|
||||
)
|
||||
};
|
||||
|
||||
let pubkey = runtime_io::crypto::ed25519_generate(key_type, seed);
|
||||
let pubkey = sp_io::crypto::ed25519_generate(key_type, seed);
|
||||
|
||||
context.write_memory(out, pubkey.as_ref())
|
||||
.map_err(|_| "Invalid attempt to set out in ext_ed25519_generate".into())
|
||||
@@ -638,7 +638,7 @@ impl_wasm_host_interface! {
|
||||
let pub_key = ed25519::Public::try_from(pubkey.as_ref())
|
||||
.map_err(|_| "Invalid `ed25519` public key")?;
|
||||
|
||||
let signature = runtime_io::crypto::ed25519_sign(key_type, &pub_key, &msg);
|
||||
let signature = sp_io::crypto::ed25519_sign(key_type, &pub_key, &msg);
|
||||
|
||||
match signature {
|
||||
Some(signature) => {
|
||||
@@ -656,7 +656,7 @@ impl_wasm_host_interface! {
|
||||
.map_err(|_| "Invalid attempt to get id in ext_sr25519_public_keys")?;
|
||||
let key_type = KeyTypeId(id);
|
||||
|
||||
let keys = runtime_io::crypto::sr25519_public_keys(key_type).encode();
|
||||
let keys = sp_io::crypto::sr25519_public_keys(key_type).encode();
|
||||
|
||||
let len = keys.len() as u32;
|
||||
let offset = context.allocate_memory(len)?;
|
||||
@@ -710,7 +710,7 @@ impl_wasm_host_interface! {
|
||||
)
|
||||
};
|
||||
|
||||
let pubkey = runtime_io::crypto::sr25519_generate(key_type, seed);
|
||||
let pubkey = sp_io::crypto::sr25519_generate(key_type, seed);
|
||||
|
||||
context.write_memory(out, pubkey.as_ref())
|
||||
.map_err(|_| "Invalid attempt to set out in ext_sr25519_generate".into())
|
||||
@@ -738,7 +738,7 @@ impl_wasm_host_interface! {
|
||||
let pub_key = sr25519::Public::try_from(pubkey.as_ref())
|
||||
.map_err(|_| "Invalid `sr25519` public key")?;
|
||||
|
||||
let signature = runtime_io::crypto::sr25519_sign(key_type, &pub_key, &msg);
|
||||
let signature = sp_io::crypto::sr25519_sign(key_type, &pub_key, &msg);
|
||||
|
||||
match signature {
|
||||
Some(signature) => {
|
||||
@@ -781,20 +781,20 @@ impl_wasm_host_interface! {
|
||||
}
|
||||
|
||||
ext_is_validator() -> u32 {
|
||||
if runtime_io::offchain::is_validator() { Ok(1) } else { Ok(0) }
|
||||
if sp_io::offchain::is_validator() { Ok(1) } else { Ok(0) }
|
||||
}
|
||||
|
||||
ext_submit_transaction(msg_data: Pointer<u8>, len: WordSize) -> u32 {
|
||||
let extrinsic = context.read_memory(msg_data, len)
|
||||
.map_err(|_| "OOB while ext_submit_transaction: wasm")?;
|
||||
|
||||
let res = runtime_io::offchain::submit_transaction(extrinsic);
|
||||
let res = sp_io::offchain::submit_transaction(extrinsic);
|
||||
|
||||
Ok(if res.is_ok() { 0 } else { 1 })
|
||||
}
|
||||
|
||||
ext_network_state(written_out: Pointer<u32>) -> Pointer<u8> {
|
||||
let res = runtime_io::offchain::network_state();
|
||||
let res = sp_io::offchain::network_state();
|
||||
|
||||
let encoded = res.encode();
|
||||
let len = encoded.len() as u32;
|
||||
@@ -809,17 +809,17 @@ impl_wasm_host_interface! {
|
||||
}
|
||||
|
||||
ext_timestamp() -> u64 {
|
||||
Ok(runtime_io::offchain::timestamp().unix_millis())
|
||||
Ok(sp_io::offchain::timestamp().unix_millis())
|
||||
}
|
||||
|
||||
ext_sleep_until(deadline: u64) {
|
||||
runtime_io::offchain::sleep_until(offchain::Timestamp::from_unix_millis(deadline));
|
||||
sp_io::offchain::sleep_until(offchain::Timestamp::from_unix_millis(deadline));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
ext_random_seed(seed_data: Pointer<u8>) {
|
||||
// NOTE the runtime as assumptions about seed size.
|
||||
let seed = runtime_io::offchain::random_seed();
|
||||
let seed = sp_io::offchain::random_seed();
|
||||
|
||||
context.write_memory(seed_data, &seed)
|
||||
.map_err(|_| "Invalid attempt to set value in ext_random_seed")?;
|
||||
@@ -840,7 +840,7 @@ impl_wasm_host_interface! {
|
||||
let value = context.read_memory(value, value_len)
|
||||
.map_err(|_| "OOB while ext_local_storage_set: wasm")?;
|
||||
|
||||
runtime_io::offchain::local_storage_set(kind, &key, &value);
|
||||
sp_io::offchain::local_storage_set(kind, &key, &value);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -856,7 +856,7 @@ impl_wasm_host_interface! {
|
||||
let key = context.read_memory(key, key_len)
|
||||
.map_err(|_| "OOB while ext_local_storage_get: wasm")?;
|
||||
|
||||
let maybe_value = runtime_io::offchain::local_storage_get(kind, &key);
|
||||
let maybe_value = sp_io::offchain::local_storage_get(kind, &key);
|
||||
|
||||
let (offset, len) = if let Some(value) = maybe_value {
|
||||
let offset = context.allocate_memory(value.len() as u32)?;
|
||||
@@ -898,7 +898,7 @@ impl_wasm_host_interface! {
|
||||
)
|
||||
};
|
||||
|
||||
let res = runtime_io::offchain::local_storage_compare_and_set(
|
||||
let res = sp_io::offchain::local_storage_compare_and_set(
|
||||
kind,
|
||||
&key,
|
||||
old_value,
|
||||
@@ -928,7 +928,7 @@ impl_wasm_host_interface! {
|
||||
let url_str = str::from_utf8(&url)
|
||||
.map_err(|_| "invalid str while ext_http_request_start: wasm")?;
|
||||
|
||||
let id = runtime_io::offchain::http_request_start(method_str, url_str, &meta);
|
||||
let id = sp_io::offchain::http_request_start(method_str, url_str, &meta);
|
||||
|
||||
if let Ok(id) = id {
|
||||
Ok(id.into())
|
||||
@@ -954,7 +954,7 @@ impl_wasm_host_interface! {
|
||||
let value_str = str::from_utf8(&value)
|
||||
.map_err(|_| "Invalid str while ext_http_request_add_header: wasm")?;
|
||||
|
||||
let res = runtime_io::offchain::http_request_add_header(
|
||||
let res = sp_io::offchain::http_request_add_header(
|
||||
offchain::HttpRequestId(request_id as u16),
|
||||
name_str,
|
||||
value_str,
|
||||
@@ -972,7 +972,7 @@ impl_wasm_host_interface! {
|
||||
let chunk = context.read_memory(chunk, chunk_len)
|
||||
.map_err(|_| "OOB while ext_http_request_write_body: wasm")?;
|
||||
|
||||
let res = runtime_io::offchain::http_request_write_body(
|
||||
let res = sp_io::offchain::http_request_write_body(
|
||||
offchain::HttpRequestId(request_id as u16),
|
||||
&chunk,
|
||||
deadline_to_timestamp(deadline),
|
||||
@@ -998,7 +998,7 @@ impl_wasm_host_interface! {
|
||||
)
|
||||
.collect::<std::result::Result<Vec<_>, _>>()?;
|
||||
|
||||
let res = runtime_io::offchain::http_response_wait(&ids, deadline_to_timestamp(deadline))
|
||||
let res = sp_io::offchain::http_response_wait(&ids, deadline_to_timestamp(deadline))
|
||||
.into_iter()
|
||||
.map(|status| u32::from(status))
|
||||
.enumerate()
|
||||
@@ -1019,7 +1019,7 @@ impl_wasm_host_interface! {
|
||||
) -> Pointer<u8> {
|
||||
use codec::Encode;
|
||||
|
||||
let headers = runtime_io::offchain::http_response_headers(
|
||||
let headers = sp_io::offchain::http_response_headers(
|
||||
offchain::HttpRequestId(request_id as u16),
|
||||
);
|
||||
|
||||
@@ -1044,7 +1044,7 @@ impl_wasm_host_interface! {
|
||||
let mut internal_buffer = Vec::with_capacity(buffer_len as usize);
|
||||
internal_buffer.resize(buffer_len as usize, 0);
|
||||
|
||||
let res = runtime_io::offchain::http_response_read_body(
|
||||
let res = sp_io::offchain::http_response_read_body(
|
||||
offchain::HttpRequestId(request_id as u16),
|
||||
&mut internal_buffer,
|
||||
deadline_to_timestamp(deadline),
|
||||
@@ -1072,4 +1072,3 @@ fn deadline_to_timestamp(deadline: u64) -> Option<offchain::Timestamp> {
|
||||
Some(offchain::Timestamp::from_unix_millis(deadline))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ fn call_in_wasm<E: Externalities>(
|
||||
code: &[u8],
|
||||
heap_pages: u64,
|
||||
) -> crate::error::Result<Vec<u8>> {
|
||||
crate::call_in_wasm::<E, runtime_io::SubstrateHostFunctions>(
|
||||
crate::call_in_wasm::<E, sp_io::SubstrateHostFunctions>(
|
||||
function,
|
||||
call_data,
|
||||
execution_method,
|
||||
@@ -492,4 +492,3 @@ fn offchain_http_should_work(wasm_method: WasmExecutionMethod) {
|
||||
true.encode(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,13 +94,13 @@ pub trait RuntimeInfo {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use runtime_test::WASM_BINARY;
|
||||
use runtime_io::TestExternalities;
|
||||
use sp_io::TestExternalities;
|
||||
|
||||
#[test]
|
||||
fn call_in_interpreted_wasm_works() {
|
||||
let mut ext = TestExternalities::default();
|
||||
let mut ext = ext.ext();
|
||||
let res = call_in_wasm::<_, runtime_io::SubstrateHostFunctions>(
|
||||
let res = call_in_wasm::<_, sp_io::SubstrateHostFunctions>(
|
||||
"test_empty_return",
|
||||
&[],
|
||||
WasmExecutionMethod::Interpreted,
|
||||
|
||||
@@ -98,7 +98,7 @@ impl<D: NativeExecutionDispatch> NativeExecutor<D> {
|
||||
/// `default_heap_pages` - Number of 64KB pages to allocate for Wasm execution.
|
||||
/// Defaults to `DEFAULT_HEAP_PAGES` if `None` is provided.
|
||||
pub fn new(fallback_method: WasmExecutionMethod, default_heap_pages: Option<u64>) -> Self {
|
||||
let mut host_functions = runtime_io::SubstrateHostFunctions::host_functions();
|
||||
let mut host_functions = sp_io::SubstrateHostFunctions::host_functions();
|
||||
// Add the old and deprecated host functions as well, so that we support old wasm runtimes.
|
||||
host_functions.extend(
|
||||
crate::deprecated_host_interface::SubstrateExternals::host_functions(),
|
||||
|
||||
@@ -263,7 +263,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn host_functions_are_equal() {
|
||||
let host_functions = runtime_io::SubstrateHostFunctions::host_functions();
|
||||
let host_functions = sp_io::SubstrateHostFunctions::host_functions();
|
||||
|
||||
let equal = &host_functions[..] == &host_functions[..];
|
||||
assert!(equal, "Host functions are not equal");
|
||||
|
||||
Reference in New Issue
Block a user