diff --git a/contracts/bob/Cargo.toml b/contracts/bob/Cargo.toml index cf51e94249..066f612cce 100644 --- a/contracts/bob/Cargo.toml +++ b/contracts/bob/Cargo.toml @@ -8,4 +8,5 @@ resolver = "2" crate-type = ["cdylib", "rlib"] [dependencies] -rusk-abi = { version = "0.13.0-rc", path = "../../rusk-abi", features = ["debug"] } +execution-core = { version = "0.1.0", path = "../../execution-core" } +rusk-abi = { version = "0.13.0-rc", path = "../../rusk-abi" } diff --git a/contracts/bob/src/lib.rs b/contracts/bob/src/lib.rs index c439622bd7..453c4d181d 100644 --- a/contracts/bob/src/lib.rs +++ b/contracts/bob/src/lib.rs @@ -39,4 +39,9 @@ mod wasm { unsafe fn value(arg_len: u32) -> u32 { rusk_abi::wrap_call(arg_len, |()| STATE.value()) } + + #[no_mangle] + unsafe fn recv_transfer(arg_len: u32) -> u32 { + rusk_abi::wrap_call(arg_len, |arg| STATE.recv_transfer(arg)) + } } diff --git a/contracts/bob/src/state.rs b/contracts/bob/src/state.rs index b60be17941..19c4d9b6f4 100644 --- a/contracts/bob/src/state.rs +++ b/contracts/bob/src/state.rs @@ -4,15 +4,21 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. +use execution_core::transfer::ReceiveFromContract; + /// Bob contract. #[derive(Debug, Clone)] pub struct Bob { value: u8, + total_dusk: u64, } impl Bob { pub const fn new() -> Self { - Self { value: 0 } + Self { + value: 0, + total_dusk: 0, + } } #[allow(dead_code)] @@ -35,4 +41,8 @@ impl Bob { pub fn value(&mut self) -> u8 { self.value } + + pub fn recv_transfer(&mut self, recv: ReceiveFromContract) { + self.total_dusk += recv.value; + } }