Skip to content

Commit

Permalink
chore: use stylus-proc indirectly (#298)
Browse files Browse the repository at this point in the history
`stylus-sdk` already reexports matching `stylus-proc` version. Make
sense to simplify dependencies a bit and use reexported library
everywhere.
  • Loading branch information
qalisander authored Oct 2, 2024
1 parent c40dc8e commit dce09d3
Show file tree
Hide file tree
Showing 32 changed files with 44 additions and 53 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ all = "warn"
[workspace.dependencies]
# stylus-related
stylus-sdk = { version = "=0.6.0", default-features = false }
stylus-proc = { version = "=0.6.0", default-features = false }
mini-alloc = "0.4.2"

alloy = { version = "0.1.4", features = [
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@
- [Unit] and [integration] test affordances, used in our own tests.

[`openzeppelin-contracts`]: https://github.com/OpenZeppelin/openzeppelin-contracts

[`koba`]: https://github.com/OpenZeppelin/koba

[Unit]: ./lib/motsu/README.md

[integration]: ./lib/e2e/README.md

## Usage

You can import OpenZeppelin Contracts from crates.io by adding the following line to your `Cargo.toml` (We recommend pinning to a specific version):
You can import OpenZeppelin Contracts from crates.io by adding the following
line to your `Cargo.toml` (We recommend pinning to a specific version):

```toml
[dependencies]
openzeppelin-stylus = "0.1.0-rc"
```

Optionally,you can specify a git dependency if you want to have the latest changes from the `main` branch:
Optionally, you can specify a git dependency if you want to have the latest
changes from the `main` branch:

```toml
[dependencies]
Expand All @@ -53,7 +58,7 @@ sol_storage! {

#[external]
#[inherit(Erc20)]
impl Erc20Example { }
impl Erc20Example {}
```

For a more complex display of what this library offers, refer to our
Expand All @@ -66,6 +71,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/1

## Contribute
Expand All @@ -85,4 +91,5 @@ Refer to our [Security Policy](SECURITY.md) for more details.

## License

OpenZeppelin Contracts for Stylus is released under the [MIT License](./LICENSE).
OpenZeppelin Contracts for Stylus is released under
the [MIT License](./LICENSE).
1 change: 0 additions & 1 deletion contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ version.workspace = true
alloy-primitives.workspace = true
alloy-sol-types.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true
keccak-const.workspace = true
openzeppelin-stylus-proc.workspace = true
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/access/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@
//! this role.
use alloy_primitives::{Address, B256};
use alloy_sol_types::sol;
use stylus_proc::SolidityError;
use stylus_sdk::{
evm, msg,
stylus_proc::{public, sol_storage},
stylus_proc::{public, sol_storage, SolidityError},
};

sol! {
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/access/ownable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
//! to the owner.
use alloy_primitives::Address;
use alloy_sol_types::sol;
use stylus_proc::SolidityError;
use stylus_sdk::{
evm, msg,
stylus_proc::{public, sol_storage},
stylus_proc::{public, sol_storage, SolidityError},
};

sol! {
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/token/erc20/extensions/capped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use alloy_primitives::U256;
use alloy_sol_types::sol;
use stylus_proc::{public, sol_storage, SolidityError};
use stylus_sdk::stylus_proc::{public, sol_storage, SolidityError};

sol! {
/// Indicates an error related to the operation that failed
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/token/erc20/extensions/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::string::String;

use alloy_primitives::FixedBytes;
use openzeppelin_stylus_proc::interface_id;
use stylus_proc::{public, sol_storage};
use stylus_sdk::stylus_proc::{public, sol_storage};

use crate::utils::introspection::erc165::IErc165;

Expand Down
8 changes: 6 additions & 2 deletions contracts/src/token/erc20/extensions/permit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
//! and thus is not required to hold Ether at all.
use alloy_primitives::{b256, keccak256, Address, B256, U256};
use alloy_sol_types::{sol, SolType};
use stylus_proc::{public, sol_storage, SolidityError};
use stylus_sdk::{block, prelude::StorageType, storage::TopLevelStorage};
use stylus_sdk::{
block,
prelude::StorageType,
storage::TopLevelStorage,
stylus_proc::{public, sol_storage, SolidityError},
};

use crate::{
token::erc20::{self, Erc20, IErc20},
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/token/erc20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
use alloy_primitives::{Address, FixedBytes, U256};
use alloy_sol_types::sol;
use openzeppelin_stylus_proc::interface_id;
use stylus_proc::SolidityError;
use stylus_sdk::{
call::MethodError,
evm, msg,
stylus_proc::{public, sol_storage},
stylus_proc::{public, sol_storage, SolidityError},
};

use crate::utils::introspection::erc165::{Erc165, IErc165};
Expand Down
8 changes: 6 additions & 2 deletions contracts/src/token/erc721/extensions/consecutive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ use alloc::vec;

use alloy_primitives::{uint, Address, U256};
use alloy_sol_types::sol;
use stylus_proc::{public, sol_storage, SolidityError};
use stylus_sdk::{abi::Bytes, evm, msg, prelude::TopLevelStorage};
use stylus_sdk::{
abi::Bytes,
evm, msg,
prelude::TopLevelStorage,
stylus_proc::{public, sol_storage, SolidityError},
};

use crate::{
token::{
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/token/erc721/extensions/enumerable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use alloy_primitives::{uint, Address, FixedBytes, U256};
use alloy_sol_types::sol;
use openzeppelin_stylus_proc::interface_id;
use stylus_proc::{public, sol_storage, SolidityError};
use stylus_sdk::stylus_proc::{public, sol_storage, SolidityError};

use crate::{
token::{erc721, erc721::IErc721},
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/token/erc721/extensions/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::string::String;

use alloy_primitives::FixedBytes;
use openzeppelin_stylus_proc::interface_id;
use stylus_proc::{public, sol_storage};
use stylus_sdk::stylus_proc::{public, sol_storage};

use crate::utils::{introspection::erc165::IErc165, Metadata};

Expand Down
6 changes: 4 additions & 2 deletions contracts/src/token/erc721/extensions/uri_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ use alloc::string::String;

use alloy_primitives::U256;
use alloy_sol_types::sol;
use stylus_proc::{public, sol_storage};
use stylus_sdk::evm;
use stylus_sdk::{
evm,
stylus_proc::{public, sol_storage},
};

sol! {
/// This event gets emitted when the metadata of a token is changed.
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/utils/cryptography/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use alloc::vec::Vec;

use alloy_primitives::{address, uint, Address, B256, U256};
use alloy_sol_types::{sol, SolType};
use stylus_proc::SolidityError;
use stylus_sdk::{
call::{self, Call, MethodError},
storage::TopLevelStorage,
stylus_proc::SolidityError,
};

use crate::utils::cryptography::ecdsa;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/utils/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Common Metadata Smart Contract.
use alloc::string::String;

use stylus_proc::{public, sol_storage};
use stylus_sdk::stylus_proc::{public, sol_storage};

sol_storage! {
/// Metadata of the token.
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/utils/nonces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use alloy_primitives::{uint, Address, U256};
use alloy_sol_types::sol;
use stylus_proc::{public, sol_storage, SolidityError};
use stylus_sdk::stylus_proc::{public, sol_storage, SolidityError};

const ONE: U256 = uint!(1_U256);

Expand Down
6 changes: 4 additions & 2 deletions contracts/src/utils/pausable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
//! only once the modifiers are put in place.

use alloy_sol_types::sol;
use stylus_proc::{public, sol_storage, SolidityError};
use stylus_sdk::{evm, msg};
use stylus_sdk::{
evm, msg,
stylus_proc::{public, sol_storage, SolidityError},
};

sol! {
/// Emitted when pause is triggered by `account`.
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/utils/structs/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//!
//! [merkle-distributor]: https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol
use alloy_primitives::{uint, U256};
use stylus_proc::sol_storage;
use stylus_sdk::stylus_proc::sol_storage;

const ONE: U256 = uint!(0x1_U256);
const HEX_FF: U256 = uint!(0xff_U256);
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/utils/structs/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//! block using the [`Trace160::push`] function.
use alloy_primitives::{uint, Uint, U256, U32};
use alloy_sol_types::sol;
use stylus_proc::{sol_storage, SolidityError};
use stylus_sdk::{
call::MethodError,
storage::{StorageGuard, StorageGuardMut},
stylus_proc::{sol_storage, SolidityError},
};

use crate::utils::math::alloy::Math;
Expand Down
1 change: 0 additions & 1 deletion examples/access-control/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.workspace = true
openzeppelin-stylus.workspace = true
alloy-primitives.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true

[dev-dependencies]
Expand Down
1 change: 0 additions & 1 deletion examples/basic/token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.workspace = true
openzeppelin-stylus.workspace = true
alloy-primitives.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true

[features]
Expand Down
1 change: 0 additions & 1 deletion examples/ecdsa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.workspace = true
openzeppelin-stylus.workspace = true
alloy-primitives.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true

[dev-dependencies]
Expand Down
1 change: 0 additions & 1 deletion examples/erc20-permit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.workspace = true
openzeppelin-stylus.workspace = true
alloy-primitives = { workspace = true, features = ["tiny-keccak"] }
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true

[dev-dependencies]
Expand Down
1 change: 0 additions & 1 deletion examples/erc20/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.workspace = true
openzeppelin-stylus.workspace = true
alloy-primitives.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true

[dev-dependencies]
Expand Down
1 change: 0 additions & 1 deletion examples/erc721-consecutive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ openzeppelin-stylus.workspace = true
alloy-primitives.workspace = true
alloy-sol-types.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true

[dev-dependencies]
Expand Down
1 change: 0 additions & 1 deletion examples/erc721-metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ version.workspace = true
openzeppelin-stylus.workspace = true
alloy-primitives.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true

[dev-dependencies]
Expand Down
Loading

0 comments on commit dce09d3

Please sign in to comment.