Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: bump Stylus SDK to v0.7.0-beta.1 and alloy to v0.8.13 #433

Draft
wants to merge 30 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2b688ce
build: bump Stylus SDK and alloy versions
bidzyyys Nov 29, 2024
ddef560
fix: move const value in AccessControl
bidzyyys Nov 29, 2024
1d27f6c
ref: move interfaces to base modules
bidzyyys Dec 2, 2024
c3cc640
ref: fix AccessControl example
bidzyyys Dec 2, 2024
e0e71ba
fix: add missing Vec imports
bidzyyys Dec 2, 2024
b24bcdf
build: use koba with updated alloy
bidzyyys Dec 4, 2024
0f40dc4
build: update E2E crate with new alloy
bidzyyys Dec 3, 2024
3c909bf
ref: extract v as u8 from Signature
bidzyyys Dec 3, 2024
1acaa4c
fix: use proper data type for U96
bidzyyys Dec 3, 2024
fa476f1
fix: benches
bidzyyys Dec 3, 2024
1078a12
fix: constrain storage ints
bidzyyys Dec 4, 2024
a9c3fbe
build: update koba to v0.3.0
bidzyyys Dec 5, 2024
94cb034
remove not used Provider
qalisander Dec 6, 2024
06945d6
add stylus-sdk patch for external calls
qalisander Dec 6, 2024
3a6e6bd
retrieve tx hashes for block timestamp
qalisander Dec 7, 2024
d33bdc3
fix run_check_release test for vesting_wallet
qalisander Dec 7, 2024
a580f98
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 7, 2024
eb5cc95
update alloy to 0.8.14
qalisander Dec 9, 2024
378da95
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 10, 2024
e7d074f
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 11, 2024
c255a90
++
qalisander Dec 11, 2024
f8b7645
import alloc::vec::Vec for permit
qalisander Dec 11, 2024
0f2a246
remove unused code
qalisander Dec 11, 2024
74b4672
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 13, 2024
b6898fc
post merge fix
qalisander Dec 13, 2024
a16de97
++
qalisander Dec 13, 2024
acd843a
++
qalisander Dec 13, 2024
6661c5a
bump stylus sdk 0.7.0-rc.1
qalisander Dec 23, 2024
f6e7c5f
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 23, 2024
dafd146
patch motsu
qalisander Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
630 changes: 415 additions & 215 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 23 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ pedantic = "warn"
all = "warn"

[workspace.dependencies]
# stylus-related
stylus-sdk = "0.6.0"
# Stylus SDK related
stylus-sdk = "0.7.0-rc.1"

alloy = { version = "=0.1.4", features = [
alloy = { version = "=0.7.2", features = [
"contract",
"network",
"providers",
Expand All @@ -86,16 +86,16 @@ alloy = { version = "=0.1.4", features = [
# Even though `alloy` includes `alloy-primitives` and `alloy-sol-types` we need
# to keep both versions for compatibility with the Stylus SDK. Once they start
# using `alloy` we can remove these.
alloy-primitives = { version = "=0.7.6", default-features = false }
alloy-sol-types = { version = "=0.7.6", default-features = false }
alloy-sol-macro = { version = "=0.7.6", default-features = false }
alloy-sol-macro-expander = { version = "=0.7.6", default-features = false }
alloy-sol-macro-input = { version = "=0.7.6", default-features = false }
alloy-primitives = { version = "=0.8.14", default-features = false }
alloy-sol-types = { version = "=0.8.14", default-features = false }
alloy-sol-macro = { version = "=0.8.14", default-features = false }
alloy-sol-macro-expander = { version = "=0.8.14", default-features = false }
alloy-sol-macro-input = { version = "=0.8.14", default-features = false }

const-hex = { version = "1.11.1", default-features = false }
eyre = "0.6.8"
keccak-const = "0.2.0"
koba = "0.2.0"
koba = "0.3.0"
once_cell = "1.19.0"
rand = "0.8.5"
regex = "1.10.4"
Expand Down Expand Up @@ -147,3 +147,17 @@ default = { extend-ignore-identifiers-re = [
"[0-9a-fA-F][0-9a-fA-F]",
] }
files = { extend-exclude = [] }

# TODO#q: remove stylus sdk patch once the fix is released
[patch.crates-io.stylus-sdk]
git = "https://github.com/OffchainLabs/stylus-sdk-rs"
branch = "rel/0.7.0-rc.1"

[patch.crates-io.stylus-proc]
git = "https://github.com/OffchainLabs/stylus-sdk-rs"
branch = "rel/0.7.0-rc.1"

# TODO#q: remove motsu patch once update is released
[patch.crates-io.motsu]
git = "https://github.com/OpenZeppelin/stylus-test-helpers"
branch = "build/stylus-v0.7.0-rc.1"
4 changes: 2 additions & 2 deletions benches/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process::Command;
use alloy::{
primitives::Address,
rpc::types::{
serde_helpers::WithOtherFields, AnyReceiptEnvelope, Log,
serde_helpers::WithOtherFields, AnyReceiptEnvelope, Log, Receipt,
TransactionReceipt,
},
};
Expand Down Expand Up @@ -42,7 +42,7 @@ pub enum CacheOpt {
}

type ArbTxReceipt =
WithOtherFields<TransactionReceipt<AnyReceiptEnvelope<Log>>>;
WithOtherFields<TransactionReceipt<AnyReceiptEnvelope<Receipt<Log>>>>;

async fn deploy(
account: &Account,
Expand Down
8 changes: 5 additions & 3 deletions contracts/src/access/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
//! accounts that have been granted it. We recommend using
//! `AccessControlDefaultAdminRules` to enforce additional security measures for
//! this role.
use alloc::vec::Vec;

use alloy_primitives::{Address, FixedBytes, B256};
pub use sol::*;
use stylus_sdk::{
Expand Down Expand Up @@ -124,9 +126,6 @@ pub struct AccessControl {

#[public]
impl AccessControl {
/// The default admin role. `[0; 32]` by default.
pub const DEFAULT_ADMIN_ROLE: [u8; 32] = [0; 32];

/// Returns `true` if `account` has been granted `role`.
///
/// # Arguments
Expand Down Expand Up @@ -278,6 +277,9 @@ impl AccessControl {
}

impl AccessControl {
/// The default admin role. `[0; 32]` by default.
pub const DEFAULT_ADMIN_ROLE: [u8; 32] = [0; 32];

/// Sets `admin_role` as `role`'s admin role.
///
/// # Arguments
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/access/ownable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//! This module is used through inheritance. It will make available the
//! [`Ownable::only_owner`] function, which can be called to restrict operations
//! to the owner.
use alloc::vec::Vec;

use alloy_primitives::Address;
use openzeppelin_stylus_proc::interface_id;
pub use sol::*;
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/access/ownable_two_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
//! This module uses [`Ownable`] as a member, and makes all its public functions
//! available.

use alloc::vec::Vec;

use alloy_primitives::Address;
pub use sol::*;
use stylus_sdk::{
Expand Down
18 changes: 8 additions & 10 deletions contracts/src/finance/vesting_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
//! adjustment in the vesting schedule to ensure the vested amount is as
//! intended.

use alloc::{vec, vec::Vec};

use alloy_primitives::{Address, U256, U64};
use openzeppelin_stylus_proc::interface_id;
pub use sol::*;
use stylus_sdk::{
block,
call::{self, call, Call},
contract, evm, function_selector,
prelude::storage,
prelude::{sol_interface, storage},
storage::{StorageMap, StorageU256, StorageU64, TopLevelStorage},
stylus_proc::{public, SolidityError},
};
Expand Down Expand Up @@ -89,15 +91,11 @@ pub enum Error {
InvalidToken(InvalidToken),
}

pub use token::IErc20;
mod token {
#![allow(missing_docs)]
#![cfg_attr(coverage_nightly, coverage(off))]
stylus_sdk::stylus_proc::sol_interface! {
/// Interface of the ERC-20 token.
interface IErc20 {
function balanceOf(address account) external view returns (uint256);
}
sol_interface! {
/// Interface of the ERC-20 token.
#[allow(missing_docs)]
interface IErc20 {
function balanceOf(address account) external view returns (uint256);
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/token/erc1155/extensions/metadata_uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!
//! [ERC]: https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions

use alloc::string::String;
use alloc::{string::String, vec::Vec};

use alloy_primitives::{FixedBytes, U256};
use openzeppelin_stylus_proc::interface_id;
Expand Down
60 changes: 56 additions & 4 deletions contracts/src/token/erc1155/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
abi::Bytes,
call::{self, Call, MethodError},
evm, function_selector, msg,
prelude::{public, storage, AddressVM, SolidityError},
prelude::{public, sol_interface, storage, AddressVM, SolidityError},
storage::{StorageBool, StorageMap, StorageU256, TopLevelStorage},
};

Expand All @@ -18,9 +18,6 @@

pub mod extensions;

mod receiver;
pub use receiver::IERC1155Receiver;

const SINGLE_TRANSFER_FN_SELECTOR: [u8; 4] = function_selector!(
"onERC1155Received",
Address,
Expand Down Expand Up @@ -184,6 +181,61 @@
}
}

sol_interface! {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it back into the main file after all :D

/// Interface that must be implemented by smart contracts
/// in order to receive ERC-1155 token transfers.
#[allow(missing_docs)]
interface IERC1155Receiver {
/// Handles the receipt of a single ERC-1155 token type.
/// This function is called at the end of a
/// [`IErc1155::safe_batch_transfer_from`]
/// after the balance has been updated.
///
/// NOTE: To accept the transfer,
/// this must return [`SINGLE_TRANSFER_FN_SELECTOR`],
/// or its own function selector.
///
/// * `operator` - The address which initiated the transfer.
/// * `from` - The address which previously owned the token.
/// * `id` - The ID of the token being transferred.
/// * `value` - The amount of tokens being transferred.
/// * `data` - Additional data with no specified format.
#[allow(missing_docs)]
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);

/// Handles the receipt of multiple ERC-1155 token types.
/// This function is called at the end of a
/// [`IErc1155::safe_batch_transfer_from`]
/// after the balances have been updated.
///
/// NOTE: To accept the transfer(s),
/// this must return [`BATCH_TRANSFER_FN_SELECTOR`],
/// or its own function selector.
///
/// * `operator` - The address which initiated the batch transfer.
/// * `from` - The address which previously owned the token.
/// * `ids` - An array containing ids of each token being transferred
/// (order and length must match values array).
/// * `values` - An array containing amounts of each token
/// being transferred (order and length must match ids array).
/// * `data` - Additional data with no specified format.
#[allow(missing_docs)]
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
}

/// State of an [`Erc1155`] token.
#[storage]
pub struct Erc1155 {
Expand Down Expand Up @@ -275,7 +327,7 @@
/// * `operator` - Account to be checked.
fn is_approved_for_all(&self, account: Address, operator: Address) -> bool;

/// Transfers a `value` amount of tokens of type `id` from `from` to

Check warning on line 330 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

public documentation for `safe_transfer_from` links to private item `IERC1155Receiver::on_erc_1155_received`

Check warning on line 330 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

public documentation for `safe_transfer_from` links to private item `IERC1155Receiver::on_erc_1155_received`
/// `to`.
///
/// # Arguments
Expand Down Expand Up @@ -330,7 +382,7 @@
data: Bytes,
) -> Result<(), Self::Error>;

/// Batched version of [`IErc1155::safe_transfer_from`].

Check warning on line 385 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

public documentation for `safe_batch_transfer_from` links to private item `IERC1155Receiver::on_erc_1155_batch_received`

Check warning on line 385 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

public documentation for `safe_batch_transfer_from` links to private item `IERC1155Receiver::on_erc_1155_batch_received`
///
/// # Arguments
///
Expand Down Expand Up @@ -590,7 +642,7 @@
///
/// If `to` is `Address::ZERO`, then the error
/// [`Error::InvalidReceiver`] is returned.
/// If [`IERC1155Receiver::on_erc_1155_received`] hasn't returned its

Check warning on line 645 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

public documentation for `_mint` links to private item `IERC1155Receiver::on_erc_1155_received`
/// interface id or returned with error, then the error
/// [`Error::InvalidReceiver`] is returned.
///
Expand Down Expand Up @@ -628,10 +680,10 @@
/// [`Error::InvalidReceiver`] is returned.
/// If length of `ids` is not equal to length of `values`, then the
/// error [`Error::InvalidArrayLength`] is returned.
/// If [`IERC1155Receiver::on_erc_1155_received`] hasn't returned its

Check warning on line 683 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

public documentation for `_mint_batch` links to private item `IERC1155Receiver::on_erc_1155_received`
/// interface id or returned with error, then the error
/// [`Error::InvalidReceiver`] is returned.
/// If [`IERC1155Receiver::on_erc_1155_batch_received`] hasn't returned its

Check warning on line 686 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

public documentation for `_mint_batch` links to private item `IERC1155Receiver::on_erc_1155_batch_received`
/// interface id or returned with error, then the error
/// [`Error::InvalidReceiver`] is returned.
///
Expand Down
60 changes: 0 additions & 60 deletions contracts/src/token/erc1155/receiver.rs
Original file line number Diff line number Diff line change
@@ -1,60 +0,0 @@
#![allow(missing_docs)]
#![cfg_attr(coverage_nightly, coverage(off))]
//! Module with an interface required for smart contract
//! in order to receive ERC-1155 token transfers.

use stylus_sdk::stylus_proc::sol_interface;

sol_interface! {
/// Interface that must be implemented by smart contracts
/// in order to receive ERC-1155 token transfers.
interface IERC1155Receiver {
/// Handles the receipt of a single ERC-1155 token type.
/// This function is called at the end of a
/// [`IErc1155::safe_batch_transfer_from`]
/// after the balance has been updated.
///
/// NOTE: To accept the transfer,
/// this must return [`SINGLE_TRANSFER_FN_SELECTOR`],
/// or its own function selector.
///
/// * `operator` - The address which initiated the transfer.
/// * `from` - The address which previously owned the token.
/// * `id` - The ID of the token being transferred.
/// * `value` - The amount of tokens being transferred.
/// * `data` - Additional data with no specified format.
#[allow(missing_docs)]
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);

/// Handles the receipt of multiple ERC-1155 token types.
/// This function is called at the end of a
/// [`IErc1155::safe_batch_transfer_from`]
/// after the balances have been updated.
///
/// NOTE: To accept the transfer(s),
/// this must return [`BATCH_TRANSFER_FN_SELECTOR`],
/// or its own function selector.
///
/// * `operator` - The address which initiated the batch transfer.
/// * `from` - The address which previously owned the token.
/// * `ids` - An array containing ids of each token being transferred
/// (order and length must match values array).
/// * `values` - An array containing amounts of each token
/// being transferred (order and length must match ids array).
/// * `data` - Additional data with no specified format.
#[allow(missing_docs)]
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
}
2 changes: 2 additions & 0 deletions contracts/src/token/erc20/extensions/capped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//! Note that they will not be capped by simply including this module,
//! but only once the checks are put in place.

use alloc::vec::Vec;

use alloy_primitives::U256;
pub use sol::*;
use stylus_sdk::{
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/token/erc20/extensions/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use crate::utils::introspection::erc165::IErc165;
/// Number of decimals used by default on implementors of [`Metadata`].
pub const DEFAULT_DECIMALS: u8 = 18;

use alloc::vec::Vec;

use crate::utils::Metadata;

/// Metadata of the [`super::super::Erc20`] token.
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/token/erc20/extensions/permit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
//!
//! [ERC]: https://eips.ethereum.org/EIPS/eip-2612

use alloc::vec::Vec;

use alloy_primitives::{b256, keccak256, Address, B256, U256};
use alloy_sol_types::SolType;
use stylus_sdk::{
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/token/erc20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! revert instead of returning `false` on failure. This behavior is
//! nonetheless conventional and does not conflict with the expectations of
//! [`Erc20`] applications.
use alloc::vec::Vec;

use alloy_primitives::{Address, FixedBytes, U256};
use openzeppelin_stylus_proc::interface_id;
use stylus_sdk::{
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/token/erc20/utils/safe_erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//! your contract, which allows you to call the safe operations as
//! `contract.safe_transfer(token_addr, ...)`, etc.

use alloc::vec::Vec;

use alloy_primitives::{Address, U256};
use alloy_sol_types::SolCall;
pub use sol::*;
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/token/erc721/extensions/consecutive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//!
//! [ERC]: https://eips.ethereum.org/EIPS/eip-2309

use alloc::vec;
use alloc::{vec, vec::Vec};

use alloy_primitives::{uint, Address, U256};
use stylus_sdk::{
Expand Down Expand Up @@ -65,7 +65,7 @@
pub _sequential_ownership: Trace<S160>,
/// BitMap library contract for sequential burn of tokens.
pub _sequential_burn: BitMap,
/// Used to offset the first token id in

Check warning on line 68 in contracts/src/token/erc721/extensions/consecutive.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

public documentation for `_first_consecutive_id` links to private item `Erc721Consecutive::_next_consecutive_id`
/// [`Erc721Consecutive::_next_consecutive_id`].
pub _first_consecutive_id: StorageU96,
/// Maximum size of a batch of consecutive tokens. This is designed to
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/token/erc721/extensions/enumerable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//! interfere with enumerability and should not be used together with
//! [`Erc721Enumerable`].

use alloc::vec::Vec;

use alloy_primitives::{uint, Address, FixedBytes, U256};
use openzeppelin_stylus_proc::interface_id;
pub use sol::*;
Expand Down
5 changes: 4 additions & 1 deletion contracts/src/token/erc721/extensions/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//! Optional Metadata of the ERC-721 standard.

use alloc::string::{String, ToString};
use alloc::{
string::{String, ToString},
vec::Vec,
};

use alloy_primitives::{FixedBytes, U256};
use openzeppelin_stylus_proc::interface_id;
Expand Down
Loading
Loading