Unverified Commit c7dd722f authored by Robin Freyler's avatar Robin Freyler
Browse files

[examples/core/erc20] Make compile again

parent d0c5f0ae
[package]
name = "erc20_token"
name = "erc20"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......@@ -9,7 +9,7 @@ pdsl_core = { path = "../../../core" }
parity-codec = { version = "3.0", default-features = false, features = ["derive"] }
[lib]
name = "erc20_token"
name = "erc20"
crate-type = ["cdylib"]
[features]
......
......@@ -5,9 +5,11 @@
# resulting from the cargo build in the first step expects to find it
# under target/release/wasm32-unknown-unknown/ in the cwd.
PROJNAME=erc20_token
#cargo clean
#rm Cargo.lock
PROJNAME=erc20
cargo clean
rm Cargo.lock
CARGO_INCREMENTAL=0 cargo +nightly build --release --target=wasm32-unknown-unknown --verbose
wasm2wat -o target/$PROJNAME.wat target/wasm32-unknown-unknown/release/$PROJNAME.wasm
cat target/$PROJNAME.wat | sed "s/(import \"env\" \"memory\" (memory (;0;) 2))/(import \"env\" \"memory\" (memory (;0;) 2 16))/" > target/$PROJNAME-fixed.wat
......
......@@ -22,12 +22,9 @@ use parity_codec::{
};
use pdsl_core::{
env::{
srml::{
Address,
Balance,
},
ContractEnv,
Env,
self,
Address,
Balance,
},
storage::{
self,
......@@ -75,7 +72,7 @@ impl Erc20Token {
/// Transfers token from the sender to the `to` address.
pub fn transfer(&mut self, to: Address, value: Balance) -> bool {
self.transfer_impl(ContractEnv::caller(), to, value);
self.transfer_impl(env::caller(), to, value);
true
}
......@@ -91,7 +88,7 @@ impl Erc20Token {
/// the spender's allowance to 0 and set the desired value afterwards:
/// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
pub fn approve(&mut self, spender: Address, value: Balance) -> bool {
let owner = ContractEnv::caller();
let owner = env::caller();
self.allowances.insert((owner, spender), value);
// emit event (not ready yet)
true
......@@ -185,7 +182,7 @@ fn ret<T>(val: T) -> !
where
T: parity_codec::Encode,
{
ContractEnv::return_(&val.encode())
unsafe { env::r#return(&val.encode()) }
}
fn instantiate() -> Erc20Token {
......@@ -201,7 +198,7 @@ pub extern "C" fn deploy() {
}
fn decode_params() -> Action {
let input = ContractEnv::input();
let input = env::input();
Action::decode(&mut &input[..]).unwrap()
}
......
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