Skip to content

Commit

Permalink
checks and updates examples against cargo-stylus v0.4.2, and v0.5.00
Browse files Browse the repository at this point in the history
  • Loading branch information
mahsamoosavi committed Aug 28, 2024
1 parent 17fc86a commit ba3d773
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 28 deletions.
19 changes: 15 additions & 4 deletions examples/erc20/Cargo.lock

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

2 changes: 2 additions & 0 deletions examples/erc20/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.80.0"
2 changes: 1 addition & 1 deletion examples/erc20/src/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl<T: Erc20Params> Erc20<T> {

// These methods are external to other contracts
// Note: modifying storage will become much prettier soon
#[external]
#[public]
impl<T: Erc20Params> Erc20<T> {
/// Immutable token name
pub fn name() -> String {
Expand Down
6 changes: 1 addition & 5 deletions examples/erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ use stylus_sdk::{
};
use crate::erc20::{Erc20, Erc20Params, Erc20Error};

/// Initializes a custom, global allocator for Rust programs compiled to WASM.
#[global_allocator]
static ALLOC: mini_alloc::MiniAlloc = mini_alloc::MiniAlloc::INIT;

/// Immutable definitions
struct StylusTestTokenParams;
impl Erc20Params for StylusTestTokenParams {
Expand All @@ -36,7 +32,7 @@ sol_storage! {
}
}

#[external]
#[public]
#[inherit(Erc20<StylusTestTokenParams>)]
impl StylusTestToken {
/// Mints tokens
Expand Down
19 changes: 15 additions & 4 deletions examples/erc721/Cargo.lock

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

2 changes: 2 additions & 0 deletions examples/erc721/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.80.0"
2 changes: 1 addition & 1 deletion examples/erc721/src/erc721.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl<T: Erc721Params> Erc721<T> {
}

// these methods are external to other contracts
#[external]
#[public]
impl<T: Erc721Params> Erc721<T> {
/// Immutable NFT name.
pub fn name() -> Result<String, Erc721Error> {
Expand Down
6 changes: 1 addition & 5 deletions examples/erc721/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ use stylus_sdk::{
};
use crate::erc721::{Erc721, Erc721Params, Erc721Error};

/// Initializes a custom, global allocator for Rust programs compiled to WASM.
#[global_allocator]
static ALLOC: mini_alloc::MiniAlloc = mini_alloc::MiniAlloc::INIT;

/// Immutable definitions
struct StylusTestNFTParams;
impl Erc721Params for StylusTestNFTParams {
Expand All @@ -38,7 +34,7 @@ sol_storage! {
}
}

#[external]
#[public]
#[inherit(Erc721<StylusTestNFTParams>)]
impl StylusTestNFT {
/// Mints an NFT
Expand Down
19 changes: 15 additions & 4 deletions examples/single_call/Cargo.lock

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

2 changes: 2 additions & 0 deletions examples/single_call/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.80.0"
6 changes: 2 additions & 4 deletions examples/single_call/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#![cfg_attr(not(feature = "export-abi"), no_main)]
extern crate alloc;

#[global_allocator]
static ALLOC: mini_alloc::MiniAlloc = mini_alloc::MiniAlloc::INIT;

use stylus_sdk::{abi::Bytes, alloy_primitives::Address, call::RawCall, prelude::*};

#[solidity_storage]
#[storage]
#[entrypoint]
pub struct SingleCall;

#[external]
#[public]
impl SingleCall {
pub fn execute(&self, target: Address, data: Bytes) -> Bytes {
let result = RawCall::new().call(target, data.to_vec().as_slice());
Expand Down

0 comments on commit ba3d773

Please sign in to comment.