Commit 55041d5e authored by Andrew Jones's avatar Andrew Jones

Remove ink 1.0 impl

parent 866d2bed
Pipeline #69427 canceled with stages
......@@ -245,13 +245,4 @@ where
<Self as EnvTypes>::AccountId::decode(&mut &read_scratch_buffer()[..])
.map_err(|_| CreateError)
}
fn runtime_get_storage<U: Decode>(key: &[u8]) -> Option<Result<U, scale::Error>> {
const SUCCESS: u32 = 0;
let result = unsafe { sys::ext_get_runtime_storage(key.as_ptr() as u32, key.len() as u32) };
if result == SUCCESS {
return Some(U::decode(&mut &read_scratch_buffer()[..]))
}
None
}
}
......@@ -82,10 +82,6 @@ extern "C" {
/// stored at the given key into the scratch buffer.
pub fn ext_get_storage(key_ptr: u32) -> u32;
/// Tells the execution environment to load the contents
/// stored in the runtime storage at the given key into the scratch buffer.
pub fn ext_get_runtime_storage(key_ptr: u32, key_len: u32) -> u32;
/// Returns the length in bytes of the scratch buffer.
pub fn ext_scratch_size() -> u32;
......
[target.wasm32-unknown-unknown]
rustflags = [
"-C", "link-args=-z stack-size=65536 --import-memory"
]
\ No newline at end of file
# Ignore build artifacts from the local tests sub-crate.
/target/
# Ignore backup files creates by cargo fmt.
**/*.rs.bk
# Remove Cargo.lock when creating an executable, leave it for libraries
# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock
Cargo.lock
\ No newline at end of file
[package]
name = "abi-gen"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
publish = false
[[bin]]
name = "abi-gen"
path = "main.rs"
[dependencies]
contract = { path = "../..", package = "runtime", features = ["ink-generate-abi", "test-env"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
fn main() -> Result<(), std::io::Error> {
let abi = contract::ink_generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
Ok(())
}
[package]
name = "runtime"
version = "0.1.0"
authors = ["[your_name] <[your_email]>"]
edition = "2018"
[dependencies]
ink_abi = { path = "../../../abi", default-features = false, features = ["derive"], optional = true }
ink_core = { path = "../../../core", default-features = false }
ink_model = { path = "../../../model", default-features = false }
ink_lang = { path = "../../../lang", default-features = false }
scale = { package = "parity-scale-codec", version = "1.0", default-features = false, features = ["derive"] }
type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
[lib]
name = "runtime"
crate-type = [
# Used for normal contract Wasm blobs.
"cdylib",
# Used for ABI generation.
"rlib",
]
[features]
default = ["test-env"]
std = [
"ink_abi/std",
"ink_core/std",
"ink_model/std",
"ink_lang/std",
"scale/std",
"type-metadata/std",
]
test-env = [
"std",
"ink_core/test-env",
"ink_model/test-env",
"ink_lang/test-env",
]
ink-generate-abi = [
"std",
"ink_abi",
"type-metadata",
"ink_core/ink-generate-abi",
"ink_lang/ink-generate-abi",
]
ink-as-dependency = []
[profile.release]
panic = "abort"
lto = true
opt-level = "z"
overflow-checks = true
[workspace]
members = [
".ink/abi_gen"
]
exclude = [
".ink"
]
#![cfg_attr(not(feature = "std"), no_std)]
use ink_lang::contract;
use scale::KeyedVec as _;
contract! {
#![env = ink_core::env::DefaultSrmlTypes]
/// This simple contract reads a value from runtime storage
struct Runtime {
}
impl Deploy for Runtime {
fn deploy(&mut self) {
}
}
impl Runtime {
/// Returns the account balance, read directly from runtime storage
pub(external) fn get_balance(&self, account: AccountId) -> Balance {
const BALANCE_OF: &[u8] = b"balance:";
let key = account.to_keyed_vec(BALANCE_OF);
match env.runtime_get_storage::<Balance>(&key) {
Some(Ok(balance)) => balance,
Some(Err(_)) => {
env.println("Error decoding balance");
0
},
None => {
env.println("Balance for account not found");
0
}
}
}
}
}
#[cfg(all(test, feature = "test-env"))]
mod tests {
use super::*;
#[test]
fn it_works() {
let mut contract = Runtime::deploy_mock();
assert_eq!(contract.get(), false);
contract.flip();
assert_eq!(contract.get(), true);
}
}
Markdown is supported
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