From 7a77b1967cf679b0da347e985c5c082d91ca9bb2 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 3 May 2022 19:47:36 +0300 Subject: [PATCH 01/23] first iteration of the BIOC --- examples/bioc/.gitignore | 12 +++++ examples/bioc/Cargo.toml | 37 +++++++++++++ examples/bioc/lib.rs | 113 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100755 examples/bioc/.gitignore create mode 100755 examples/bioc/Cargo.toml create mode 100755 examples/bioc/lib.rs diff --git a/examples/bioc/.gitignore b/examples/bioc/.gitignore new file mode 100755 index 00000000000..d25982675a1 --- /dev/null +++ b/examples/bioc/.gitignore @@ -0,0 +1,12 @@ +# 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 diff --git a/examples/bioc/Cargo.toml b/examples/bioc/Cargo.toml new file mode 100755 index 00000000000..3fbae445698 --- /dev/null +++ b/examples/bioc/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "bioc" +version = "3.0.1" +authors = ["Parity Technologies "] +edition = "2021" +publish = false + +[dependencies] +ink_primitives = { version = "3.0", default-features = false } +ink_metadata = { version = "3.0", default-features = false, features = ["derive"], optional = true } +ink_env = { version = "3.0", default-features = false } +ink_storage = { version = "3.0", default-features = false } +ink_lang = { version = "3.0", default-features = false } +ink_prelude = { version = "3.0", default-features = false } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } + +[lib] +name = "bioc" +path = "lib.rs" +crate-type = [ + # Used for normal contract Wasm blobs. + "cdylib", +] + +[features] +default = ["std"] +std = [ + "ink_metadata/std", + "ink_env/std", + "ink_storage/std", + "ink_primitives/std", + "scale/std", + "scale-info/std", +] +ink-as-dependency = [] diff --git a/examples/bioc/lib.rs b/examples/bioc/lib.rs new file mode 100755 index 00000000000..1d9576c7c63 --- /dev/null +++ b/examples/bioc/lib.rs @@ -0,0 +1,113 @@ +//! # Basic Input Output Contract (BIOC) +//! +//! This is a Basic Input Output Contract (BIOC), which is intented to +//! demonstrate rich i\o posibilties of ink! contracts, namely: +//! +//! 1. Use complicated nested input and ouput types. +//! This is done through the real use case example of data structure +//! needed to store a candle auction data. +//! 2. Make contract fail with `ContractTrapped`. +//! 3. Make contract fail with returning an Error. +//! 4. Perform debug printing from contract into node's log. + +#![cfg_attr(not(feature = "std"), no_std)] + +use ink_lang as ink; + +#[ink::contract] +mod bioc { + use ink_prelude::{ + string::String, + vec::Vec, + }; + + /// No storage is needed for this contract. + #[ink(storage)] + pub struct Bioc {} + + /// Struct for storing winning bids per bidding sample (a block). + /// Vector index corresponds to sample number. + #[derive(scale::Encode, scale::Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub struct Bids(Vec>); + + /// Auction statuses. + /// Logic inspired by + /// [Parachain Auction](https://github.com/paritytech/polkadot/blob/master/runtime/common/src/traits.rs#L160) + #[derive(scale::Encode, scale::Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub enum Status { + /// An auction has not started yet. + NotStarted, + /// We are in the starting period of the auction, collecting initial bids. + OpeningPeriod, + /// We are in the ending period of the auction, where we are taking snapshots of the winning + /// bids. Snapshots are taken currently on per-block basis, but this logic could be later evolve + /// to take snapshots of on arbitrary length (in blocks) + EndingPeriod(BlockNumber), + /// Candle was blown + Ended, + /// We have completed the bidding process and are waiting for the Random Function to return some acceptable + /// randomness to select the winner. The number represents how many blocks we have been waiting. + RfDelay(BlockNumber), + } + + /// Struct for storing auction data. + #[derive(scale::Encode, scale::Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub struct Auction { + /// Branded name of the auction event + name: String, + /// Some hash identifiyng the auction subject + subject: Hash, + /// Structure storing the bids being made + bids: Bids, + /// Auction terms encoded as: + /// [start_block, opening_period, closing_period] + terms: [BlockNumber; 3], + /// Auction status + status: Status, + /// Candle auction can have no winner. + /// If auction is finalized, that means that the winner is determined. + finalized: bool, + } + + /// Way to fail a contract execution. + #[derive(scale::Encode, scale::Decode)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + pub enum Failure { + Revert, + Panic, + } + + impl Bioc { + #[ink(constructor)] + pub fn new() -> Self { + Self {} + } + + /// Takes an auction data struct as input and returns it back. + #[ink(message)] + pub fn echo_auction(&mut self, auction: Auction) -> Auction { + auction + } + + /// Fails contract execution in the required way. + #[ink(message)] + pub fn revert_or_trap(&mut self, fail: Option) -> Result<(), Failure> { + match fail { + Some(Failure::Revert) => Err(Failure::Revert), + Some(Failure::Panic) => { + panic!("Trapping on user demand!") + } + None => Ok(()), + } + } + + /// Prints the specified string into node's debug log. + #[ink(message)] + pub fn debug_log(&mut self, str: String) { + ink_env::debug_println!("debug_log: {:?}", str); + } + } +} From 7e9f2d46acdcc19a5e55a32bb0c18453637e0ad5 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 9 May 2022 13:51:35 +0300 Subject: [PATCH 02/23] clippy fixes --- examples/bioc/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/bioc/lib.rs b/examples/bioc/lib.rs index 1d9576c7c63..bdd9f2660d5 100755 --- a/examples/bioc/lib.rs +++ b/examples/bioc/lib.rs @@ -23,6 +23,7 @@ mod bioc { /// No storage is needed for this contract. #[ink(storage)] + #[derive(Default)] pub struct Bioc {} /// Struct for storing winning bids per bidding sample (a block). @@ -107,7 +108,7 @@ mod bioc { /// Prints the specified string into node's debug log. #[ink(message)] pub fn debug_log(&mut self, str: String) { - ink_env::debug_println!("debug_log: {:?}", str); + ink_env::debug_println!("debug_log: {}", str); } } } From fad2a83ca759924a1b4b661589ed8bf266535665 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 9 May 2022 13:55:21 +0300 Subject: [PATCH 03/23] suppress unused var warning for debug fn --- examples/bioc/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/bioc/lib.rs b/examples/bioc/lib.rs index bdd9f2660d5..8fd0b65c95a 100755 --- a/examples/bioc/lib.rs +++ b/examples/bioc/lib.rs @@ -107,6 +107,7 @@ mod bioc { /// Prints the specified string into node's debug log. #[ink(message)] + #[allow(dead_code)] pub fn debug_log(&mut self, str: String) { ink_env::debug_println!("debug_log: {}", str); } From cb625f65724e5f9570e70a453332ee5bc128d0fa Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 9 May 2022 14:00:48 +0300 Subject: [PATCH 04/23] suppress unused var warning 2nd try --- examples/bioc/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/bioc/lib.rs b/examples/bioc/lib.rs index 8fd0b65c95a..762cbc5d827 100755 --- a/examples/bioc/lib.rs +++ b/examples/bioc/lib.rs @@ -107,9 +107,8 @@ mod bioc { /// Prints the specified string into node's debug log. #[ink(message)] - #[allow(dead_code)] - pub fn debug_log(&mut self, str: String) { - ink_env::debug_println!("debug_log: {}", str); + pub fn debug_log(&mut self, _str: String) { + ink_env::debug_println!("debug_log: {}", _str); } } } From f7daf11d84cddbfc8a0a5cdfcc29ad9a8c197984 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Mon, 9 May 2022 14:44:39 +0300 Subject: [PATCH 05/23] + tests --- examples/bioc/lib.rs | 51 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/examples/bioc/lib.rs b/examples/bioc/lib.rs index 762cbc5d827..5f909c40383 100755 --- a/examples/bioc/lib.rs +++ b/examples/bioc/lib.rs @@ -28,14 +28,14 @@ mod bioc { /// Struct for storing winning bids per bidding sample (a block). /// Vector index corresponds to sample number. - #[derive(scale::Encode, scale::Decode)] + #[derive(scale::Encode, scale::Decode, PartialEq, Debug, Clone)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub struct Bids(Vec>); /// Auction statuses. /// Logic inspired by /// [Parachain Auction](https://github.com/paritytech/polkadot/blob/master/runtime/common/src/traits.rs#L160) - #[derive(scale::Encode, scale::Decode)] + #[derive(scale::Encode, scale::Decode, PartialEq, Debug, Clone)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub enum Status { /// An auction has not started yet. @@ -54,7 +54,7 @@ mod bioc { } /// Struct for storing auction data. - #[derive(scale::Encode, scale::Decode)] + #[derive(Debug, PartialEq, scale::Encode, scale::Decode, Clone)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub struct Auction { /// Branded name of the auction event @@ -74,7 +74,7 @@ mod bioc { } /// Way to fail a contract execution. - #[derive(scale::Encode, scale::Decode)] + #[derive(scale::Encode, scale::Decode, Debug, PartialEq)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub enum Failure { Revert, @@ -111,4 +111,47 @@ mod bioc { ink_env::debug_println!("debug_log: {}", _str); } } + + #[cfg(test)] + mod tests { + use super::*; + use ink_lang as ink; + + #[ink::test] + fn echo_auction_works() { + let accounts = ink_env::test::default_accounts::(); + let bids = Bids( + [Some((accounts.alice, 100)), None, Some((accounts.bob, 101))].to_vec(), + ); + + let auction = Auction { + name: "Some NFT Auction".to_string(), + subject: Hash::default(), + bids, + terms: [1245, 10, 100], + status: Status::OpeningPeriod, + finalized: false, + }; + + let mut contract = Bioc::new(); + assert_eq!(contract.echo_auction(auction.clone()), auction); + } + + #[ink::test] + fn revert_works() { + let mut contract = Bioc::new(); + assert_eq!( + contract.revert_or_trap(Some(Failure::Revert)), + Err(Failure::Revert) + ); + contract.revert_or_trap(None).expect("asd"); + } + + #[ink::test] + #[should_panic] + fn trap_works() { + let mut contract = Bioc::new(); + let _ = contract.revert_or_trap(Some(Failure::Panic)); + } + } } From 6432506bf8f0e30f679b13e69e907cb2b2510d95 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 10 May 2022 12:57:22 +0300 Subject: [PATCH 06/23] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- examples/bioc/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/bioc/lib.rs b/examples/bioc/lib.rs index 5f909c40383..edfb96839b8 100755 --- a/examples/bioc/lib.rs +++ b/examples/bioc/lib.rs @@ -77,7 +77,7 @@ mod bioc { #[derive(scale::Encode, scale::Decode, Debug, PartialEq)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub enum Failure { - Revert, + Revert(String), Panic, } @@ -97,7 +97,7 @@ mod bioc { #[ink(message)] pub fn revert_or_trap(&mut self, fail: Option) -> Result<(), Failure> { match fail { - Some(Failure::Revert) => Err(Failure::Revert), + Some(Failure::Revert) => Err(Failure::Revert("Reverting on user demand!".to_string()), Some(Failure::Panic) => { panic!("Trapping on user demand!") } @@ -107,8 +107,8 @@ mod bioc { /// Prints the specified string into node's debug log. #[ink(message)] - pub fn debug_log(&mut self, _str: String) { - ink_env::debug_println!("debug_log: {}", _str); + pub fn debug_log(&mut self, message: String) { + ink_env::debug_println!("debug_log: {}", message); } } From b7f136b19de86f6292d8d8950754095f325b3586 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 10 May 2022 17:11:53 +0300 Subject: [PATCH 07/23] renamed to `mother`; added storage --- examples/bioc/Cargo.toml | 37 ----------- examples/{bioc => mother}/.gitignore | 0 examples/mother/Cargo.toml | 38 +++++++++++ examples/{bioc => mother}/lib.rs | 95 ++++++++++++++++------------ 4 files changed, 93 insertions(+), 77 deletions(-) delete mode 100755 examples/bioc/Cargo.toml rename examples/{bioc => mother}/.gitignore (100%) create mode 100755 examples/mother/Cargo.toml rename examples/{bioc => mother}/lib.rs (72%) diff --git a/examples/bioc/Cargo.toml b/examples/bioc/Cargo.toml deleted file mode 100755 index 3fbae445698..00000000000 --- a/examples/bioc/Cargo.toml +++ /dev/null @@ -1,37 +0,0 @@ -[package] -name = "bioc" -version = "3.0.1" -authors = ["Parity Technologies "] -edition = "2021" -publish = false - -[dependencies] -ink_primitives = { version = "3.0", default-features = false } -ink_metadata = { version = "3.0", default-features = false, features = ["derive"], optional = true } -ink_env = { version = "3.0", default-features = false } -ink_storage = { version = "3.0", default-features = false } -ink_lang = { version = "3.0", default-features = false } -ink_prelude = { version = "3.0", default-features = false } - -scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } -scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } - -[lib] -name = "bioc" -path = "lib.rs" -crate-type = [ - # Used for normal contract Wasm blobs. - "cdylib", -] - -[features] -default = ["std"] -std = [ - "ink_metadata/std", - "ink_env/std", - "ink_storage/std", - "ink_primitives/std", - "scale/std", - "scale-info/std", -] -ink-as-dependency = [] diff --git a/examples/bioc/.gitignore b/examples/mother/.gitignore similarity index 100% rename from examples/bioc/.gitignore rename to examples/mother/.gitignore diff --git a/examples/mother/Cargo.toml b/examples/mother/Cargo.toml new file mode 100755 index 00000000000..15a3bcb6d5c --- /dev/null +++ b/examples/mother/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "mother" +description = "Mother of all contracts" +version = "3.0.1" +authors = ["Parity Technologies "] +edition = "2021" +publish = false + +[dependencies] +ink_primitives = { version = "3.0.1", path = "../../crates/primitives", default-features = false } +ink_metadata = { version = "3.0.1", path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true } +ink_env = { version = "3.0.1", path = "../../crates/env", default-features = false } +ink_storage = { version = "3.0.1", path = "../../crates/storage", default-features = false } +ink_lang = { version = "3.0.1", path = "../../crates/lang", default-features = false } +ink_prelude = { version = "3.0", path = "../../crates/prelude", default-features = false } + +scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } +scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } + +[lib] +name = "bioc" +path = "lib.rs" +crate-type = [ + # Used for normal contract Wasm blobs. + "cdylib", +] + +[features] +default = ["std"] +std = [ + "ink_metadata/std", + "ink_env/std", + "ink_storage/std", + "ink_primitives/std", + "scale/std", + "scale-info/std", +] +ink-as-dependency = [] diff --git a/examples/bioc/lib.rs b/examples/mother/lib.rs similarity index 72% rename from examples/bioc/lib.rs rename to examples/mother/lib.rs index edfb96839b8..8d579b8a9e8 100755 --- a/examples/bioc/lib.rs +++ b/examples/mother/lib.rs @@ -1,7 +1,7 @@ -//! # Basic Input Output Contract (BIOC) +//! # Mother of All Contracts //! -//! This is a Basic Input Output Contract (BIOC), which is intented to -//! demonstrate rich i\o posibilties of ink! contracts, namely: +//! This contracts is intented to +//! demonstrate rich I/O posibilities of ink! contracts, namely: //! //! 1. Use complicated nested input and ouput types. //! This is done through the real use case example of data structure @@ -15,28 +15,30 @@ use ink_lang as ink; #[ink::contract] -mod bioc { +mod mother { use ink_prelude::{ string::String, vec::Vec, }; - /// No storage is needed for this contract. - #[ink(storage)] - #[derive(Default)] - pub struct Bioc {} + use ink_storage::{ + traits::{ + PackedLayout, + SpreadLayout, + StorageLayout, + }}; /// Struct for storing winning bids per bidding sample (a block). /// Vector index corresponds to sample number. - #[derive(scale::Encode, scale::Decode, PartialEq, Debug, Clone)] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + #[derive(Default, scale::Encode, scale::Decode, PartialEq, Debug, Clone, SpreadLayout, PackedLayout)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] pub struct Bids(Vec>); - + /// Auction statuses. /// Logic inspired by /// [Parachain Auction](https://github.com/paritytech/polkadot/blob/master/runtime/common/src/traits.rs#L160) - #[derive(scale::Encode, scale::Decode, PartialEq, Debug, Clone)] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + #[derive(scale::Encode, scale::Decode, PartialEq, Debug, Clone, SpreadLayout, PackedLayout)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] pub enum Status { /// An auction has not started yet. NotStarted, @@ -54,8 +56,8 @@ mod bioc { } /// Struct for storing auction data. - #[derive(Debug, PartialEq, scale::Encode, scale::Decode, Clone)] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] + #[derive(Debug, PartialEq, scale::Encode, scale::Decode, Clone, SpreadLayout, PackedLayout)] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] pub struct Auction { /// Branded name of the auction event name: String, @@ -73,18 +75,40 @@ mod bioc { finalized: bool, } + /// TODO: refactor + impl Default for Auction { + fn default() -> Auction { + let bids = Bids::default(); + + Auction { + name: "Some NFT Auction".to_string(), + subject: Hash::default(), + bids, + terms: [1245, 10, 100], + status: Status::OpeningPeriod, + finalized: false, + }} + } + /// Way to fail a contract execution. #[derive(scale::Encode, scale::Decode, Debug, PartialEq)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub enum Failure { - Revert(String), + Revert, Panic, } - impl Bioc { + /// Storage of the contract. + #[ink(storage)] + #[derive(Default)] + pub struct Mother { + auction: Auction + } + + impl Mother { #[ink(constructor)] - pub fn new() -> Self { - Self {} + pub fn new(auction: Auction) -> Self { + Self { auction } } /// Takes an auction data struct as input and returns it back. @@ -97,7 +121,7 @@ mod bioc { #[ink(message)] pub fn revert_or_trap(&mut self, fail: Option) -> Result<(), Failure> { match fail { - Some(Failure::Revert) => Err(Failure::Revert("Reverting on user demand!".to_string()), + Some(Failure::Revert) => Err(Failure::Revert), Some(Failure::Panic) => { panic!("Trapping on user demand!") } @@ -107,8 +131,8 @@ mod bioc { /// Prints the specified string into node's debug log. #[ink(message)] - pub fn debug_log(&mut self, message: String) { - ink_env::debug_println!("debug_log: {}", message); + pub fn debug_log(&mut self, _str: String) { + ink_env::debug_println!("debug_log: {}", _str); } } @@ -117,40 +141,31 @@ mod bioc { use super::*; use ink_lang as ink; + fn default_auction() -> Auction { + Auction::default() + } + #[ink::test] fn echo_auction_works() { - let accounts = ink_env::test::default_accounts::(); - let bids = Bids( - [Some((accounts.alice, 100)), None, Some((accounts.bob, 101))].to_vec(), - ); - - let auction = Auction { - name: "Some NFT Auction".to_string(), - subject: Hash::default(), - bids, - terms: [1245, 10, 100], - status: Status::OpeningPeriod, - finalized: false, - }; - - let mut contract = Bioc::new(); + let auction = default_auction(); + let mut contract = Mother::new(auction.clone()); assert_eq!(contract.echo_auction(auction.clone()), auction); } #[ink::test] fn revert_works() { - let mut contract = Bioc::new(); + let mut contract = Mother::new(default_auction()); assert_eq!( contract.revert_or_trap(Some(Failure::Revert)), Err(Failure::Revert) ); - contract.revert_or_trap(None).expect("asd"); + contract.revert_or_trap(None).expect("Contract unexpected failure!"); } #[ink::test] #[should_panic] fn trap_works() { - let mut contract = Bioc::new(); + let mut contract = Mother::new(default_auction()); let _ = contract.revert_or_trap(Some(Failure::Panic)); } } From 6b89f7da9236bd7c3456ba661baf324c6c826d51 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 10 May 2022 17:15:56 +0300 Subject: [PATCH 08/23] refactor --- examples/mother/lib.rs | 66 +++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 8d579b8a9e8..314857ee055 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -21,23 +21,33 @@ mod mother { vec::Vec, }; - use ink_storage::{ - traits::{ - PackedLayout, - SpreadLayout, - StorageLayout, - }}; + use ink_storage::traits::{ + PackedLayout, + SpreadLayout, + StorageLayout, + }; /// Struct for storing winning bids per bidding sample (a block). /// Vector index corresponds to sample number. - #[derive(Default, scale::Encode, scale::Decode, PartialEq, Debug, Clone, SpreadLayout, PackedLayout)] + #[derive( + Default, + scale::Encode, + scale::Decode, + PartialEq, + Debug, + Clone, + SpreadLayout, + PackedLayout, + )] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] pub struct Bids(Vec>); - + /// Auction statuses. /// Logic inspired by /// [Parachain Auction](https://github.com/paritytech/polkadot/blob/master/runtime/common/src/traits.rs#L160) - #[derive(scale::Encode, scale::Decode, PartialEq, Debug, Clone, SpreadLayout, PackedLayout)] + #[derive( + scale::Encode, scale::Decode, PartialEq, Debug, Clone, SpreadLayout, PackedLayout, + )] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] pub enum Status { /// An auction has not started yet. @@ -56,7 +66,9 @@ mod mother { } /// Struct for storing auction data. - #[derive(Debug, PartialEq, scale::Encode, scale::Decode, Clone, SpreadLayout, PackedLayout)] + #[derive( + Debug, PartialEq, scale::Encode, scale::Decode, Clone, SpreadLayout, PackedLayout, + )] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] pub struct Auction { /// Branded name of the auction event @@ -75,21 +87,19 @@ mod mother { finalized: bool, } - /// TODO: refactor impl Default for Auction { - fn default() -> Auction { - let bids = Bids::default(); - - Auction { - name: "Some NFT Auction".to_string(), + fn default() -> Auction { + Auction { + name: String::default(), subject: Hash::default(), - bids, - terms: [1245, 10, 100], + bids: Bids::default(), + terms: <[BlockNumber; 3]>::default(), status: Status::OpeningPeriod, finalized: false, - }} + } + } } - + /// Way to fail a contract execution. #[derive(scale::Encode, scale::Decode, Debug, PartialEq)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] @@ -102,7 +112,7 @@ mod mother { #[ink(storage)] #[derive(Default)] pub struct Mother { - auction: Auction + auction: Auction, } impl Mother { @@ -141,31 +151,29 @@ mod mother { use super::*; use ink_lang as ink; - fn default_auction() -> Auction { - Auction::default() - } - #[ink::test] fn echo_auction_works() { - let auction = default_auction(); + let auction = Auction::default(); let mut contract = Mother::new(auction.clone()); assert_eq!(contract.echo_auction(auction.clone()), auction); } #[ink::test] fn revert_works() { - let mut contract = Mother::new(default_auction()); + let mut contract = Mother::new(Auction::default()); assert_eq!( contract.revert_or_trap(Some(Failure::Revert)), Err(Failure::Revert) ); - contract.revert_or_trap(None).expect("Contract unexpected failure!"); + contract + .revert_or_trap(None) + .expect("Contract unexpected failure!"); } #[ink::test] #[should_panic] fn trap_works() { - let mut contract = Mother::new(default_auction()); + let mut contract = Mother::new(Auction::default()); let _ = contract.revert_or_trap(Some(Failure::Panic)); } } From 2fe986cda95786ca33bb9bf422eb1e2027ebc460 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 10 May 2022 17:56:33 +0300 Subject: [PATCH 09/23] added a Mapping into contract storage --- examples/mother/lib.rs | 43 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 314857ee055..3373e887a2d 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -21,12 +21,18 @@ mod mother { vec::Vec, }; - use ink_storage::traits::{ - PackedLayout, - SpreadLayout, - StorageLayout, + use ink_lang::utils::initialize_contract; + use ink_storage::{ + traits::{ + PackedLayout, + SpreadAllocate, + SpreadLayout, + StorageLayout, + }, + Mapping, }; + use ink_storage::traits::KeyPtr; /// Struct for storing winning bids per bidding sample (a block). /// Vector index corresponds to sample number. #[derive( @@ -39,7 +45,10 @@ mod mother { SpreadLayout, PackedLayout, )] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] + #[cfg_attr( + feature = "std", + derive(scale_info::TypeInfo, StorageLayout, SpreadAllocate,) + )] pub struct Bids(Vec>); /// Auction statuses. @@ -65,9 +74,23 @@ mod mother { RfDelay(BlockNumber), } + impl SpreadAllocate for Status { + #[inline] + fn allocate_spread(ptr: &mut KeyPtr) -> Self { + ptr.advance_by(::FOOTPRINT * 2); + Self::NotStarted + } + } /// Struct for storing auction data. #[derive( - Debug, PartialEq, scale::Encode, scale::Decode, Clone, SpreadLayout, PackedLayout, + Debug, + PartialEq, + scale::Encode, + scale::Decode, + Clone, + SpreadLayout, + PackedLayout, + SpreadAllocate, )] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] pub struct Auction { @@ -110,15 +133,19 @@ mod mother { /// Storage of the contract. #[ink(storage)] - #[derive(Default)] + #[derive(Default, SpreadAllocate)] pub struct Mother { auction: Auction, + balances: Mapping, } impl Mother { #[ink(constructor)] pub fn new(auction: Auction) -> Self { - Self { auction } + initialize_contract(|c: &mut Self| { + c.balances = >::default(); + c.auction = auction; + }) } /// Takes an auction data struct as input and returns it back. From 70340ff6c5c10354ea2ed57bedd370e2790021e5 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 10 May 2022 18:00:52 +0300 Subject: [PATCH 10/23] default constructor --- examples/mother/lib.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 3373e887a2d..4ab722a459e 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -148,6 +148,14 @@ mod mother { }) } + #[ink(constructor)] + pub fn default() -> Self { + initialize_contract(|c: &mut Self| { + c.balances = >::default(); + c.auction = Auction::default(); + }) + } + /// Takes an auction data struct as input and returns it back. #[ink(message)] pub fn echo_auction(&mut self, auction: Auction) -> Auction { @@ -181,13 +189,13 @@ mod mother { #[ink::test] fn echo_auction_works() { let auction = Auction::default(); - let mut contract = Mother::new(auction.clone()); + let mut contract = Mother::default(); assert_eq!(contract.echo_auction(auction.clone()), auction); } #[ink::test] fn revert_works() { - let mut contract = Mother::new(Auction::default()); + let mut contract = Mother::default(); assert_eq!( contract.revert_or_trap(Some(Failure::Revert)), Err(Failure::Revert) @@ -200,7 +208,7 @@ mod mother { #[ink::test] #[should_panic] fn trap_works() { - let mut contract = Mother::new(Auction::default()); + let mut contract = Mother::default(); let _ = contract.revert_or_trap(Some(Failure::Panic)); } } From 13f54c61434977c17e433d3a1161a3e8dbc59fc9 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 10 May 2022 18:05:34 +0300 Subject: [PATCH 11/23] reverted fix --- examples/mother/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 4ab722a459e..b4e931f136b 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -127,7 +127,7 @@ mod mother { #[derive(scale::Encode, scale::Decode, Debug, PartialEq)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub enum Failure { - Revert, + Revert(String), Panic, } @@ -166,7 +166,7 @@ mod mother { #[ink(message)] pub fn revert_or_trap(&mut self, fail: Option) -> Result<(), Failure> { match fail { - Some(Failure::Revert) => Err(Failure::Revert), + Some(Failure::Revert) => Err(Failure::Revert("Reverting on user demand!".to_string()), Some(Failure::Panic) => { panic!("Trapping on user demand!") } @@ -176,8 +176,8 @@ mod mother { /// Prints the specified string into node's debug log. #[ink(message)] - pub fn debug_log(&mut self, _str: String) { - ink_env::debug_println!("debug_log: {}", _str); + pub fn debug_log(&mut self, message: String) { + ink_env::debug_println!("debug_log: {}", message); } } From 0cd95fbf2a2107f61fbcb3136ea3b4bb63418b1e Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 10 May 2022 18:11:24 +0300 Subject: [PATCH 12/23] fix --- examples/mother/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index b4e931f136b..08242b4f77b 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -166,7 +166,9 @@ mod mother { #[ink(message)] pub fn revert_or_trap(&mut self, fail: Option) -> Result<(), Failure> { match fail { - Some(Failure::Revert) => Err(Failure::Revert("Reverting on user demand!".to_string()), + Some(Failure::Revert(_)) => { + Err(Failure::Revert("Reverting on user demand!".to_string())) + } Some(Failure::Panic) => { panic!("Trapping on user demand!") } @@ -197,8 +199,10 @@ mod mother { fn revert_works() { let mut contract = Mother::default(); assert_eq!( - contract.revert_or_trap(Some(Failure::Revert)), - Err(Failure::Revert) + contract.revert_or_trap(Some(Failure::Revert( + "Testing reverting on demand!".to_string() + ))), + Err(Failure::Revert("Reverting on user demand!".to_string())) ); contract .revert_or_trap(None) From 898089ffb40e184062ec9ee7ec00d1637882961e Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 12 May 2022 20:35:34 +0300 Subject: [PATCH 13/23] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- examples/mother/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/mother/Cargo.toml b/examples/mother/Cargo.toml index 15a3bcb6d5c..dac3dedc8ab 100755 --- a/examples/mother/Cargo.toml +++ b/examples/mother/Cargo.toml @@ -12,13 +12,13 @@ ink_metadata = { version = "3.0.1", path = "../../crates/metadata", default-feat ink_env = { version = "3.0.1", path = "../../crates/env", default-features = false } ink_storage = { version = "3.0.1", path = "../../crates/storage", default-features = false } ink_lang = { version = "3.0.1", path = "../../crates/lang", default-features = false } -ink_prelude = { version = "3.0", path = "../../crates/prelude", default-features = false } +ink_prelude = { version = "3.0.1", path = "../../crates/prelude", default-features = false } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } [lib] -name = "bioc" +name = "mother" path = "lib.rs" crate-type = [ # Used for normal contract Wasm blobs. From 0e2d9a9754b3413ebc8605d44518406e21d616bd Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 12 May 2022 20:50:01 +0300 Subject: [PATCH 14/23] make it build (but not instantiate) --- examples/mother/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 08242b4f77b..8e76ef330f7 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -1,7 +1,7 @@ //! # Mother of All Contracts //! //! This contracts is intented to -//! demonstrate rich I/O posibilities of ink! contracts, namely: +//! demonstrate rich posibilities of ink! contracts, namely: //! //! 1. Use complicated nested input and ouput types. //! This is done through the real use case example of data structure @@ -17,7 +17,7 @@ use ink_lang as ink; #[ink::contract] mod mother { use ink_prelude::{ - string::String, + string::{String, ToString}, vec::Vec, }; @@ -44,10 +44,11 @@ mod mother { Clone, SpreadLayout, PackedLayout, + SpreadAllocate, )] #[cfg_attr( feature = "std", - derive(scale_info::TypeInfo, StorageLayout, SpreadAllocate,) + derive(scale_info::TypeInfo, StorageLayout,) )] pub struct Bids(Vec>); From 040a2589923ce3557a00e82d6bc460d01fd84c03 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 12 May 2022 20:58:06 +0300 Subject: [PATCH 15/23] fmt --- examples/mother/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 8e76ef330f7..a7000f6273b 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -17,7 +17,10 @@ use ink_lang as ink; #[ink::contract] mod mother { use ink_prelude::{ - string::{String, ToString}, + string::{ + String, + ToString, + }, vec::Vec, }; @@ -44,12 +47,9 @@ mod mother { Clone, SpreadLayout, PackedLayout, - SpreadAllocate, - )] - #[cfg_attr( - feature = "std", - derive(scale_info::TypeInfo, StorageLayout,) + SpreadAllocate, )] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout,))] pub struct Bids(Vec>); /// Auction statuses. From e7fb691d1b8bc13139ae7beda07d3d5f0a0adc8b Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Thu, 12 May 2022 21:32:13 +0300 Subject: [PATCH 16/23] Update examples/mother/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- examples/mother/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index a7000f6273b..c94f724eb52 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -151,10 +151,7 @@ mod mother { #[ink(constructor)] pub fn default() -> Self { - initialize_contract(|c: &mut Self| { - c.balances = >::default(); - c.auction = Auction::default(); - }) + Self::new(Auction::default()) } /// Takes an auction data struct as input and returns it back. From e8fd72d4c9c0b530d262c2b3ef7f7d094239ecfc Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 17 May 2022 16:01:35 +0300 Subject: [PATCH 17/23] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- examples/mother/Cargo.toml | 12 ++++++------ examples/mother/lib.rs | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/mother/Cargo.toml b/examples/mother/Cargo.toml index dac3dedc8ab..acf7a85dc24 100755 --- a/examples/mother/Cargo.toml +++ b/examples/mother/Cargo.toml @@ -7,12 +7,12 @@ edition = "2021" publish = false [dependencies] -ink_primitives = { version = "3.0.1", path = "../../crates/primitives", default-features = false } -ink_metadata = { version = "3.0.1", path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true } -ink_env = { version = "3.0.1", path = "../../crates/env", default-features = false } -ink_storage = { version = "3.0.1", path = "../../crates/storage", default-features = false } -ink_lang = { version = "3.0.1", path = "../../crates/lang", default-features = false } -ink_prelude = { version = "3.0.1", path = "../../crates/prelude", default-features = false } +ink_primitives = { path = "../../crates/primitives", default-features = false } +ink_metadata = { path = "../../crates/metadata", default-features = false, features = ["derive"], optional = true } +ink_env = { path = "../../crates/env", default-features = false } +ink_storage = { path = "../../crates/storage", default-features = false } +ink_lang = { path = "../../crates/lang", default-features = false } +ink_prelude = { path = "../../crates/prelude", default-features = false } scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index c94f724eb52..6dc746f9453 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -1,7 +1,9 @@ //! # Mother of All Contracts //! -//! This contracts is intented to -//! demonstrate rich posibilities of ink! contracts, namely: +//! This contracts is intended to make use of all features that are observable +//! by off chain tooling (for example UIs). It doesn't do anything useful beyond +//! serving off chain tooling developers with a contract to test their software against. +//! Currently, this includes the following: //! //! 1. Use complicated nested input and ouput types. //! This is done through the real use case example of data structure @@ -9,6 +11,7 @@ //! 2. Make contract fail with `ContractTrapped`. //! 3. Make contract fail with returning an Error. //! 4. Perform debug printing from contract into node's log. +//! 5. Use complicated types in storage. #![cfg_attr(not(feature = "std"), no_std)] From 06852341163f42b605547e2c2567f64eaee8ca25 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 17 May 2022 16:06:16 +0300 Subject: [PATCH 18/23] reverted constructor delegation to satisfy CI (until #1259 fixed) --- examples/mother/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 6dc746f9453..028cc04639b 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -154,7 +154,10 @@ mod mother { #[ink(constructor)] pub fn default() -> Self { - Self::new(Auction::default()) + initialize_contract(|c: &mut Self| { + c.balances = >::default(); + c.auction = Auction::default(); + }) } /// Takes an auction data struct as input and returns it back. From b6046172a75bd719c9b05dcde679ee59b1857bf0 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 17 May 2022 16:18:18 +0300 Subject: [PATCH 19/23] added required input types --- examples/mother/lib.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 028cc04639b..0be02a3a2ba 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -41,6 +41,7 @@ mod mother { use ink_storage::traits::KeyPtr; /// Struct for storing winning bids per bidding sample (a block). /// Vector index corresponds to sample number. + /// Wrapping vector just added for testing UI components. #[derive( Default, scale::Encode, @@ -53,7 +54,18 @@ mod mother { SpreadAllocate, )] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout,))] - pub struct Bids(Vec>); + pub struct Bids(Vec>>); + + /// Auction outline. + #[derive( + scale::Encode, scale::Decode, PartialEq, Debug, Clone, SpreadLayout, PackedLayout, + )] + #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] + pub enum Outline { + NoWinner, + WinnerDetected, + PayoutCompleted, + } /// Auction statuses. /// Logic inspired by @@ -72,7 +84,7 @@ mod mother { /// to take snapshots of on arbitrary length (in blocks) EndingPeriod(BlockNumber), /// Candle was blown - Ended, + Ended(Outline), /// We have completed the bidding process and are waiting for the Random Function to return some acceptable /// randomness to select the winner. The number represents how many blocks we have been waiting. RfDelay(BlockNumber), @@ -112,6 +124,8 @@ mod mother { /// Candle auction can have no winner. /// If auction is finalized, that means that the winner is determined. finalized: bool, + /// Just a vector for UI tests + vector: Vec, } impl Default for Auction { @@ -123,6 +137,7 @@ mod mother { terms: <[BlockNumber; 3]>::default(), status: Status::OpeningPeriod, finalized: false, + vector: >::default(), } } } From 4d641a3f3c6295479bea3dfaa8effcb25af2e1c7 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 17 May 2022 16:27:57 +0300 Subject: [PATCH 20/23] custom event added --- examples/mother/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 0be02a3a2ba..58acde04673 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -150,6 +150,12 @@ mod mother { Panic, } + /// Event emitted when an auction being echoed. + #[ink(event)] + pub struct AuctionEchoed { + auction: Auction, + } + /// Storage of the contract. #[ink(storage)] #[derive(Default, SpreadAllocate)] @@ -178,6 +184,9 @@ mod mother { /// Takes an auction data struct as input and returns it back. #[ink(message)] pub fn echo_auction(&mut self, auction: Auction) -> Auction { + self.env().emit_event(AuctionEchoed { + auction: auction.clone(), + }); auction } From 6d8e3488a1afda8abac46b03d70bae0fec329d18 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 17 May 2022 17:35:48 +0300 Subject: [PATCH 21/23] CI clippy satisfaction --- examples/mother/lib.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 58acde04673..2cb756e7a33 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -33,7 +33,6 @@ mod mother { PackedLayout, SpreadAllocate, SpreadLayout, - StorageLayout, }, Mapping, }; @@ -53,14 +52,20 @@ mod mother { PackedLayout, SpreadAllocate, )] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout,))] + #[cfg_attr( + feature = "std", + derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout,) + )] pub struct Bids(Vec>>); /// Auction outline. #[derive( scale::Encode, scale::Decode, PartialEq, Debug, Clone, SpreadLayout, PackedLayout, )] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] + #[cfg_attr( + feature = "std", + derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout,) + )] pub enum Outline { NoWinner, WinnerDetected, @@ -73,7 +78,10 @@ mod mother { #[derive( scale::Encode, scale::Decode, PartialEq, Debug, Clone, SpreadLayout, PackedLayout, )] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] + #[cfg_attr( + feature = "std", + derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout,) + )] pub enum Status { /// An auction has not started yet. NotStarted, @@ -108,7 +116,10 @@ mod mother { PackedLayout, SpreadAllocate, )] - #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, StorageLayout))] + #[cfg_attr( + feature = "std", + derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout,) + )] pub struct Auction { /// Branded name of the auction event name: String, From 3491cfd1a56a9677ccc1edc7185aeb4a41266422 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Tue, 17 May 2022 17:39:53 +0300 Subject: [PATCH 22/23] trick to satisfy the CI until #1258 is fixed --- examples/mother/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 2cb756e7a33..47f74765b2b 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -218,6 +218,7 @@ mod mother { /// Prints the specified string into node's debug log. #[ink(message)] pub fn debug_log(&mut self, message: String) { + let _ = message; ink_env::debug_println!("debug_log: {}", message); } } From ca2963f3fba108b2b6d9b722a59c70ce486fde13 Mon Sep 17 00:00:00 2001 From: Alexander Gryaznov Date: Wed, 18 May 2022 16:00:30 +0300 Subject: [PATCH 23/23] Revert "trick to satisfy the CI until #1258 is fixed" This reverts commit 3491cfd1a56a9677ccc1edc7185aeb4a41266422. --- examples/mother/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/mother/lib.rs b/examples/mother/lib.rs index 47f74765b2b..2cb756e7a33 100755 --- a/examples/mother/lib.rs +++ b/examples/mother/lib.rs @@ -218,7 +218,6 @@ mod mother { /// Prints the specified string into node's debug log. #[ink(message)] pub fn debug_log(&mut self, message: String) { - let _ = message; ink_env::debug_println!("debug_log: {}", message); } }