diff --git a/integration-tests/public/complex-storage-structures/.gitignore b/integration-tests/public/complex-storage-structures/.gitignore deleted file mode 100755 index 8de8f877e4..0000000000 --- a/integration-tests/public/complex-storage-structures/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# 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 diff --git a/integration-tests/public/complex-storage-structures/Cargo.toml b/integration-tests/public/complex-storage-structures/Cargo.toml index 8c637882cf..934a1ec064 100644 --- a/integration-tests/public/complex-storage-structures/Cargo.toml +++ b/integration-tests/public/complex-storage-structures/Cargo.toml @@ -6,10 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../crates/ink", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } +scale = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] } +scale-info = { version = "2.11", default-features = false } [dev-dependencies] -ink_e2e = { path = "../../crates/e2e" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/integration-tests/public/complex-storage-structures/lib.rs b/integration-tests/public/complex-storage-structures/lib.rs index 37d832067d..6193ce0771 100644 --- a/integration-tests/public/complex-storage-structures/lib.rs +++ b/integration-tests/public/complex-storage-structures/lib.rs @@ -1,4 +1,4 @@ -#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(not(feature = "std"), no_std, no_main)] #[ink::contract] pub mod complex_structures { @@ -18,7 +18,7 @@ pub mod complex_structures { #[derive(Storable, StorableHint, StorageKey, Default, Debug)] #[cfg_attr( feature = "std", - derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout) + derive(ink::scale_info::TypeInfo, ink::storage::traits::StorageLayout) )] pub struct TokenManagement { balances: Balances, @@ -31,10 +31,10 @@ pub mod complex_structures { allowances: Mapping<(AccountId, AccountId), Balance, AutoKey>, } - #[derive(scale::Encode, scale::Decode, Default, Debug)] + #[derive(ink::scale::Encode, ink::scale::Decode, Default, Debug)] #[cfg_attr( feature = "std", - derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout) + derive(ink::scale_info::TypeInfo, ink::storage::traits::StorageLayout) )] pub struct Balances { pub balance_state: u128, @@ -42,7 +42,7 @@ pub mod complex_structures { impl Allowances { fn get_allowance(&self, owner: AccountId, spender: AccountId) -> Balance { - self.allowances.get(&(owner, spender)).unwrap_or(0) + self.allowances.get((owner, spender)).unwrap_or(0) } fn set_allowance( @@ -51,7 +51,7 @@ pub mod complex_structures { spender: AccountId, value: Balance, ) { - self.allowances.insert(&(owner, spender), &value); + self.allowances.insert((owner, spender), &value); } } @@ -69,12 +69,20 @@ pub mod complex_structures { #[ink(message)] pub fn increase_balances_state(&mut self, amount: u128) { - self.token_management.balances.balance_state += amount; + self.token_management + .balances + .balance_state + .checked_add(amount) + .expect("addition failed"); } #[ink(message)] pub fn decrease_balances_state(&mut self, amount: u128) { - self.token_management.balances.balance_state -= amount; + self.token_management + .balances + .balance_state + .checked_sub(amount) + .expect("subtraction failed"); } #[ink(message)]