Skip to content

Commit

Permalink
chore: update stylus-sdk-rs to v0.5.0 (#58)
Browse files Browse the repository at this point in the history
Fixes #57 

This also removes our dependency on `derive_more`.
  • Loading branch information
alexfertel authored May 13, 2024
1 parent 4f78b0d commit d2e6f96
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
9 changes: 4 additions & 5 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ repository = "https://github.com/OpenZeppelin/rust-contracts-stylus"
[workspace.dependencies]
alloy-primitives = { version = "0.3.1", default-features = false }
alloy-sol-types = { version = "0.3.1", default-features = false }
stylus-sdk = { version = "0.4.3", default-features = false }
stylus-proc = { version = "0.4.3", default-features = false }
stylus-sdk = { version = "0.5.0", default-features = false }
stylus-proc = { version = "0.5.0", default-features = false }
mini-alloc = "0.4.2"

[profile.release]
Expand Down
1 change: 0 additions & 1 deletion contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ alloy-sol-types.workspace = true
stylus-sdk.workspace = true
stylus-proc.workspace = true
mini-alloc.workspace = true
derive_more = "0.99.17"
cfg-if = "1.0"

[dev-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions contracts/src/erc721/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use alloc::vec;

use alloy_primitives::{fixed_bytes, Address, FixedBytes, U128, U256};
use derive_more::From;
use stylus_sdk::{
abi::Bytes, alloy_sol_types::sol, call::Call, evm, msg, prelude::*,
};
Expand Down Expand Up @@ -91,7 +90,7 @@ sol! {
/// An ERC-721 error defined as described in [ERC-6093].
///
/// [ERC-6093]: https://eips.ethereum.org/EIPS/eip-6093
#[derive(SolidityError, Debug, From)]
#[derive(SolidityError, Debug)]
pub enum Error {
/// Indicates that an address can't be an owner.
/// For example, `address(0)` is a forbidden owner in ERC-721. Used in
Expand Down
24 changes: 16 additions & 8 deletions lib/grip/src/shims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,18 @@ pub unsafe extern "C" fn storage_load_bytes32(key: *const u8, out: *mut u8) {
unsafe { write_bytes32(out, value) };
}

/// Stores a 32-byte value to permanent storage. Stylus's storage format is
/// identical to that of the EVM. This means that, under the hood, this hostio
/// is storing a 32-byte value into the EVM state trie at offset `key`.
/// Furthermore, refunds are tabulated exactly as in the EVM. The semantics,
/// Writes a 32-byte value to the permanent storage cache. Stylus's storage
/// format is identical to that of the EVM. This means that, under the hood,
/// this hostio represents storing a 32-byte value into the EVM state trie at
/// offset `key`. Refunds are tabulated exactly as in the EVM. The semantics,
/// then, are equivalent to that of the EVM's [`SSTORE`] opcode.
///
/// Note: we require the [`SSTORE`] sentry per EVM rules. The `gas_cost`
/// returned by the EVM API may exceed this amount, but that's ok because the
/// predominant cost is due to state bloat concerns.
/// Note: because the value is cached, one must call `storage_flush_cache` to
/// persist it.
///
/// [`SSTORE`]: https://www.evm.codes/#55
#[no_mangle]
pub unsafe extern "C" fn storage_store_bytes32(
pub unsafe extern "C" fn storage_cache_bytes32(
key: *const u8,
value: *const u8,
) {
Expand All @@ -141,6 +140,15 @@ pub unsafe extern "C" fn storage_store_bytes32(
STORAGE.lock().unwrap().insert(key, value);
}

/// Persists any dirty values in the storage cache to the EVM state trie,
/// dropping the cache entirely if requested. Analogous to repeated invocations
/// of [`SSTORE`].
///
/// [`SSTORE`]: https://www.evm.codes/#55
pub fn storage_flush_cache(_: bool) {
// No-op: we don't use the cache in our unit-tests.
}

/// Dummy msg sender set for tests.
pub const MSG_SENDER: &[u8; 42] = b"0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF";

Expand Down

0 comments on commit d2e6f96

Please sign in to comment.