From dc6697c92bbd633e78af20bf4a02ddc964c0511f Mon Sep 17 00:00:00 2001 From: Alisander Qoshqosh Date: Thu, 16 May 2024 18:37:22 +0400 Subject: [PATCH] fix fmt --- Cargo.lock | 12 +++++++++++- contracts/src/erc721/mod.rs | 6 ++++-- examples/erc20/src/lib.rs | 8 ++------ examples/erc721/src/lib.rs | 15 +++++++++++---- integration/src/erc20.rs | 12 ++++++------ integration/src/erc721.rs | 2 +- integration/src/infrastructure/erc721.rs | 3 ++- integration/src/infrastructure/mod.rs | 5 ++--- integration/src/lib.rs | 4 ++-- 9 files changed, 41 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be76ef68..910948ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -452,7 +452,6 @@ dependencies = [ "alloy-primitives", "alloy-sol-types", "cfg-if 1.0.0", - "derive_more", "grip", "mini-alloc", "once_cell", @@ -1991,6 +1990,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ownable-example" +version = "0.0.0" +dependencies = [ + "alloy-primitives", + "contracts", + "mini-alloc", + "stylus-proc", + "stylus-sdk", +] + [[package]] name = "parity-scale-codec" version = "3.6.12" diff --git a/contracts/src/erc721/mod.rs b/contracts/src/erc721/mod.rs index dc7e7f5b..b3f5d3c3 100644 --- a/contracts/src/erc721/mod.rs +++ b/contracts/src/erc721/mod.rs @@ -1,7 +1,9 @@ //! Implementation of the ERC-721 token standard. use alloc::vec; -use alloy_primitives::{fixed_bytes, Address, FixedBytes, U128, U256}; +use alloy_primitives::{ + fixed_bytes, private::derive_more::From, Address, FixedBytes, U128, U256, +}; use stylus_sdk::{ abi::Bytes, alloy_sol_types::sol, call::Call, evm, msg, prelude::*, }; @@ -101,7 +103,7 @@ sol! { /// An ERC-721 error defined as described in [ERC-6093]. /// /// [ERC-6093]: https://eips.ethereum.org/EIPS/eip-6093 -#[derive(SolidityError, Debug)] +#[derive(SolidityError, Debug, From)] pub enum Error { /// Indicates that an address can't be an owner. /// For example, `Address::ZERO` is a forbidden owner in ERC-721. Used in diff --git a/examples/erc20/src/lib.rs b/examples/erc20/src/lib.rs index 9b6c0567..32501f00 100644 --- a/examples/erc20/src/lib.rs +++ b/examples/erc20/src/lib.rs @@ -5,7 +5,7 @@ use alloc::string::String; use alloy_primitives::{Address, U256}; use contracts::{ - erc20::{extensions::ERC20Metadata, ERC20, Error, ERC20InvalidReceiver}, + erc20::{extensions::ERC20Metadata, ERC20InvalidReceiver, Error, ERC20}, erc20_burnable_impl, }; use stylus_sdk::prelude::{entrypoint, external, sol_storage}; @@ -41,11 +41,7 @@ impl Token { DECIMALS } - pub fn mint( - &mut self, - account: Address, - value: U256, - ) -> Result<(), Error> { + pub fn mint(&mut self, account: Address, value: U256) -> Result<(), Error> { // TODO: create function _mint at erc20 similar to solidity if account.is_zero() { return Err(Error::InvalidReceiver(ERC20InvalidReceiver { diff --git a/examples/erc721/src/lib.rs b/examples/erc721/src/lib.rs index a39e1e1d..28b2321c 100644 --- a/examples/erc721/src/lib.rs +++ b/examples/erc721/src/lib.rs @@ -2,10 +2,13 @@ extern crate alloc; use alloc::string::String; -use contracts::erc721::{extensions::ERC721Metadata, ERC721}; + use alloy_primitives::Address; -use stylus_sdk::alloy_sol_types::private::U256; -use stylus_sdk::prelude::{entrypoint, external, sol_storage}; +use contracts::erc721::{extensions::ERC721Metadata, ERC721}; +use stylus_sdk::{ + alloy_sol_types::private::U256, + prelude::{entrypoint, external, sol_storage}, +}; sol_storage! { #[entrypoint] @@ -33,7 +36,11 @@ impl Token { self.metadata.constructor(name, symbol, base_uri); } - pub fn mint(&mut self, to: Address, token_id: U256) -> Result<(), contracts::erc721::Error> { + pub fn mint( + &mut self, + to: Address, + token_id: U256, + ) -> Result<(), contracts::erc721::Error> { self.erc721._mint(to, token_id) } } diff --git a/integration/src/erc20.rs b/integration/src/erc20.rs index c48396e7..53638235 100644 --- a/integration/src/erc20.rs +++ b/integration/src/erc20.rs @@ -10,13 +10,13 @@ async fn mint() -> Result<()> { let initial_balance = infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; - let initial_supply = - infra.alice.total_supply().ctx_call().await?; - + let initial_supply = infra.alice.total_supply().ctx_call().await?; + let _ = infra.alice.mint(infra.alice.wallet.address(), one).ctx_send().await?; - - let new_balance = infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; + + let new_balance = + infra.alice.balance_of(infra.alice.wallet.address()).ctx_call().await?; let new_supply = infra.alice.total_supply().ctx_call().await?; assert_eq!(initial_balance + one, new_balance); @@ -24,4 +24,4 @@ async fn mint() -> Result<()> { Ok(()) } -// TODO: add rest of the tests for erc20 base implementation \ No newline at end of file +// TODO: add rest of the tests for erc20 base implementation diff --git a/integration/src/erc721.rs b/integration/src/erc721.rs index 07b922dc..7effe881 100644 --- a/integration/src/erc721.rs +++ b/integration/src/erc721.rs @@ -5,7 +5,7 @@ use crate::infrastructure::{erc721::*, *}; // TODO: add isolation with mutex per contract -// TODO#q: refactor these tests similarly to unit tests +// TODO#q: refactor these tests similarly to unit tests #[tokio::test] async fn mint_nft_and_check_balance() -> Result<()> { diff --git a/integration/src/infrastructure/erc721.rs b/integration/src/infrastructure/erc721.rs index 0f83a6cc..50ad21ba 100644 --- a/integration/src/infrastructure/erc721.rs +++ b/integration/src/infrastructure/erc721.rs @@ -47,7 +47,8 @@ abigen!( pub type Erc721 = Erc721Token; impl Token for Erc721 { - const STYLUS_PROGRAM_ADDRESS: &'static str = "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"; + const STYLUS_PROGRAM_ADDRESS: &'static str = + "ERC721_EXAMPLE_DEPLOYMENT_ADDRESS"; fn new(address: Address, client: Arc) -> Self { Self::new(address, client) diff --git a/integration/src/infrastructure/mod.rs b/integration/src/infrastructure/mod.rs index 9cfa58aa..17fd112c 100644 --- a/integration/src/infrastructure/mod.rs +++ b/integration/src/infrastructure/mod.rs @@ -18,7 +18,6 @@ const ALICE_PRIV_KEY: &str = "ALICE_PRIV_KEY"; const BOB_PRIV_KEY: &str = "BOB_PRIV_KEY"; const RPC_URL: &str = "RPC_URL"; - /// Integration testing infrastructure that allows to act on behalf of `alice` /// and `bob` accounts. pub struct Infrastructure { @@ -60,7 +59,8 @@ impl Infrastructure { } } -/// Client of participant that allows to check wallet address and call contract functions. +/// Client of participant that allows to check wallet address and call contract +/// functions. pub struct Client { pub wallet: LocalWallet, pub caller: T, @@ -75,7 +75,6 @@ impl Deref for Client { } } - /// Abstraction for the deployed contract. pub trait Token { /// Deployed program address environment variable name for the contract. diff --git a/integration/src/lib.rs b/integration/src/lib.rs index 237f59ba..5ea0b88b 100644 --- a/integration/src/lib.rs +++ b/integration/src/lib.rs @@ -1,3 +1,3 @@ -mod erc721; mod erc20; -mod infrastructure; \ No newline at end of file +mod erc721; +mod infrastructure;