From 3ad1e7de14388cadc1ee1e1c7e750971fd9e4b80 Mon Sep 17 00:00:00 2001 From: green Date: Thu, 29 Sep 2022 13:59:33 +0100 Subject: [PATCH] Adapted `flush` and `load` for ink! 4.0 --- contracts/callee/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/contracts/callee/lib.rs b/contracts/callee/lib.rs index 0f03c8f..8393180 100755 --- a/contracts/callee/lib.rs +++ b/contracts/callee/lib.rs @@ -215,8 +215,11 @@ mod callee { /// So if you want to flush the correct state of the contract, /// you have to this method on storage struct. fn flush(&self) { - let root_key = ::ink_primitives::Key::from(12); - ::ink_storage::traits::push_spread_root::(self, &root_key); + let root_key = ::KEY; + ::ink::env::set_contract_storage::<::ink::primitives::Key, Self>( + &root_key, + self, + ); } /// Method loads the current state of `Self` from storage. @@ -224,8 +227,8 @@ mod callee { /// So if you want to load the correct state of the contract, /// you have to this method on storage struct. fn load(&mut self) { - let root_key = ::ink_primitives::Key::from(12); - let mut state = ::ink_storage::traits::pull_spread_root::(&root_key); + let root_key = ::KEY; + let mut state = ::ink::env::get_contract_storage(&root_key).unwrap().unwrap(); core::mem::swap(self, &mut state); let _ = core::mem::ManuallyDrop::new(state); }