diff --git a/CHANGELOG.md b/CHANGELOG.md index 0993e3f88..ed37b7e94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,17 +5,26 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased v4.0.0] +## [v4.0.0-beta] +## Changes ### Added -- [*BREAKING*] `implementation`, `override` macros: [78](https://github.com/Brushfam/openbrush-contracts/pull/78) -- [*BREAKING*] `storage_item` macro, new OB feature: `Upgradeable`, which implements `set_code_hash` functionality [99](https://github.com/Brushfam/openbrush-contracts/pull/99) -- `UI` tests [77](https://github.com/Brushfam/openbrush-contracts/pull/77) -- `openbrush::accessors` macro for automatic generation of getters/setters for storage items: [66](https://github.com/Brushfam/openbrush-contracts/pull/66) and [61](https://github.com/Brushfam/openbrush-contracts/pull/61) +- [*BREAKING*] `implementation`, `override`, `default_impl` macros: [#78](https://github.com/Brushfam/openbrush-contracts/pull/78) +- [*BREAKING*] `storage_item` macro, which implements `#[ink::storage_item]` macro, but also allows to make field of struct upgradeable by using `#[lazy]` attribute. For all fields that + are either `Lazy`/`Mapping`/`MultiMapping` is generated it's own constant storage key. Also it allows OpenBrush to work correctly with every default implementation [#99](https://github.com/Brushfam/openbrush-contracts/pull/99) +- New OB feature: `Upgradeable`, which implements `set_code_hash` functionality [#99](https://github.com/Brushfam/openbrush-contracts/pull/99) +- `UI` tests for testing different scenarios for macros [#77](https://github.com/Brushfam/openbrush-contracts/pull/77) +- `openbrush::accessors` macro for automatic generation of getters/setters for storage items: [#66](https://github.com/Brushfam/openbrush-contracts/pull/66) and [61](https://github.com/Brushfam/openbrush-contracts/pull/61) ### Removed -- [*BREAKING*] `min_specilization`, now openbrush is `stable`: [78](https://github.com/Brushfam/openbrush-contracts/pull/78) -- `ZERO_ADDRESS`, now using `Option` instead: [98](https://github.com/Brushfam/openbrush-contracts/pull/98) +- [*BREAKING*] `upgradeable_storage` macro, `OccupyStorage` trait [#99](https://github.com/Brushfam/openbrush-contracts/pull/99) +- [*BREAKING*] `min_specilization`, now OpenBrush can be used with `stable` toolchain: [#78](https://github.com/Brushfam/openbrush-contracts/pull/78) +- [*BREAKING*] `ZERO_ADDRESS`, now using `Option` instead: [#98](https://github.com/Brushfam/openbrush-contracts/pull/98) + +### Changed + +- [*BREAKING*] Now every field in OpenBrush's types that is not read/written directly in storage, is wrapped in `Lazy`, so all the types in OpenBrush can be considered upgradeable: [#99](https://github.com/Brushfam/openbrush-contracts/pull/99) ### Fixed - Fixed reentrancy guard problem: [#88](https://github.com/Brushfam/openbrush-contracts/pull/88) +- Updated reentrancy example: [#108](https://github.com/Brushfam/openbrush-contracts/pull/108) \ No newline at end of file diff --git a/examples/payment_splitter/lib.rs b/examples/payment_splitter/lib.rs index 9247fb5b6..ccf008750 100644 --- a/examples/payment_splitter/lib.rs +++ b/examples/payment_splitter/lib.rs @@ -3,7 +3,6 @@ #[openbrush::implementation(PaymentSplitter)] #[openbrush::contract] pub mod my_payment_splitter { - use ink::prelude::vec::Vec; use openbrush::traits::Storage; #[ink(storage)] diff --git a/examples/reentrancy_guard/contracts/flip_on_me/lib.rs b/examples/reentrancy_guard/contracts/flip_on_me/lib.rs index 03c343229..340b7bdc6 100644 --- a/examples/reentrancy_guard/contracts/flip_on_me/lib.rs +++ b/examples/reentrancy_guard/contracts/flip_on_me/lib.rs @@ -1,9 +1,13 @@ #![cfg_attr(not(feature = "std"), no_std, no_main)] +pub use openbrush::examples::contracts::reentrancy_guard::flip_on_me::*; + #[openbrush::contract] pub mod flip_on_me { + use flipper::traits::flipper::*; use flipper::traits::flip_on_me::*; - use ink::codegen::Env; + use ink::env::CallFlags; + use openbrush::traits::DefaultEnv; #[ink(storage)] #[derive(Default)] @@ -17,16 +21,14 @@ pub mod flip_on_me { } impl FlipOnMe for FlipOnMeContract { - #[ink(message)] - fn flip_on_me(&mut self) -> Result<(), ReentrancyGuardError> { - let caller = self.env().caller(); - self.flip_on_target(caller) - } - #[ink(message)] fn flip_on_target(&mut self, callee: AccountId) -> Result<(), ReentrancyGuardError> { // This method does a cross-contract call to caller contract and calls the `flip` method. - flipper::traits::flipper::FlipperRef::flip(&callee) + FlipperRef::flip_builder(&callee) + .call_flags(CallFlags::default().set_allow_reentry(true)) + .invoke() + .unwrap(); + Ok(()) } } } diff --git a/examples/reentrancy_guard/contracts/flipper/lib.rs b/examples/reentrancy_guard/contracts/flipper/lib.rs index d795bfcc0..581117019 100644 --- a/examples/reentrancy_guard/contracts/flipper/lib.rs +++ b/examples/reentrancy_guard/contracts/flipper/lib.rs @@ -1,12 +1,18 @@ #![cfg_attr(not(feature = "std"), no_std, no_main)] +pub use openbrush::examples::contracts::reentrancy_guard::my_flipper_guard::*; + #[openbrush::contract] pub mod my_flipper_guard { use flipper::traits::flipper::*; + use flipper::traits::flip_on_me::*; use openbrush::{ modifiers, traits::Storage, }; + use ink::env::CallFlags; + use openbrush::traits::DefaultEnv; + #[ink(storage)] #[derive(Default, Storage)] @@ -43,7 +49,11 @@ pub mod my_flipper_guard { // Callee contract during execution of `flip_on_me` will call `flip` of this contract. // `call_flip_on_me` and `flip` are marked with `non_reentrant` modifier. It means, // that call of `flip` after `call_flip_on_me` must fail. - flipper::traits::flip_on_me::FlipOnMeRef::flip_on_me(&callee) + FlipOnMeRef::flip_on_target_builder(&callee, Self::env().account_id()) + .call_flags(CallFlags::default().set_allow_reentry(true)) + .invoke() + .unwrap(); + Ok(()) } } } diff --git a/examples/reentrancy_guard/traits/flip_on_me.rs b/examples/reentrancy_guard/traits/flip_on_me.rs index 1472c260b..74e1f1a1c 100644 --- a/examples/reentrancy_guard/traits/flip_on_me.rs +++ b/examples/reentrancy_guard/traits/flip_on_me.rs @@ -6,9 +6,6 @@ pub type FlipOnMeRef = dyn FlipOnMe; #[openbrush::trait_definition] pub trait FlipOnMe { - #[ink(message)] - fn flip_on_me(&mut self) -> Result<(), ReentrancyGuardError>; - #[ink(message)] fn flip_on_target(&mut self, callee: AccountId) -> Result<(), ReentrancyGuardError>; } diff --git a/examples/timelock_controller/lib.rs b/examples/timelock_controller/lib.rs index 77053bcf6..b1f4d312c 100644 --- a/examples/timelock_controller/lib.rs +++ b/examples/timelock_controller/lib.rs @@ -3,7 +3,6 @@ #[openbrush::implementation(AccessControl, TimelockController)] #[openbrush::contract] pub mod my_timelock_controller { - use ink::prelude::vec::Vec; use openbrush::traits::Storage; #[ink(storage)]