From 3a7bc3bdd26a8dda89d2e36034e9ccaab3ec0c9d Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Wed, 11 Dec 2024 13:42:47 +0400 Subject: [PATCH] migrate readme's to #[storage] macro --- README.md | 21 ++++++++++++--------- contracts/src/lib.rs | 10 ++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 4eeb8d7bd..bf9da4168 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,10 @@ openzeppelin-stylus = { git = "https://github.com/OpenZeppelin/rust-contracts-st ``` > [!NOTE] -> This library is designed to be `no_std`, which helps reduce wasm size. If you want your project to be `no_std` as well, ensure that your dependencies are not importing the standard library. ->You can achieve this by setting `default-features = false` for relevant dependencies in your `Cargo.toml`. For example: +> This library is designed to be `no_std`, which helps reduce wasm size. If you want your project to be `no_std` as +> well, ensure that your dependencies are not importing the standard library. +> You can achieve this by setting `default-features = false` for relevant dependencies in your `Cargo.toml`. For +> example: > > ```toml > [dependencies] @@ -58,20 +60,20 @@ openzeppelin-stylus = { git = "https://github.com/OpenZeppelin/rust-contracts-st > } > ``` > -> The library also works on an `std` environment, without the need to define a panic handler or making extra changes to your project. +> The library also works on an `std` environment, without the need to define a panic handler or making extra changes to +> your project. Once defined as a dependency, use one of our pre-defined implementations by importing them: ```rust +use stylus_sdk::prelude::*; use openzeppelin_stylus::token::erc20::Erc20; -sol_storage! { - #[entrypoint] - struct Erc20Example { - #[borrow] - Erc20 erc20; - } +#[storage] +struct Erc20Example { + #[borrow] + pub erc20: Erc20, } #[public] @@ -89,6 +91,7 @@ For more information on what this library will include in the future, see our [roadmap]. [basic]: ./examples/basic + [roadmap]: https://github.com/OpenZeppelin/rust-contracts-stylus/milestone/2 ## Contribute diff --git a/contracts/src/lib.rs b/contracts/src/lib.rs index bf3f9e25a..654488ce0 100644 --- a/contracts/src/lib.rs +++ b/contracts/src/lib.rs @@ -25,12 +25,10 @@ importing them: use stylus_sdk::prelude::*; use openzeppelin_stylus::token::erc20::Erc20; -sol_storage! { - #[entrypoint] - struct MyContract { - #[borrow] - Erc20 erc20; - } +#[storage] +struct MyContract { + #[borrow] + pub erc20: Erc20, } #[public]