Skip to content

Commit

Permalink
feat: ignore sol items in vesting-wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Nov 29, 2024
1 parent 1244d38 commit f837803
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 61 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ version = "0.2.0-alpha.1"
missing_docs = "warn"
unreachable_pub = "warn"
rust_2021_compatibility = { level = "warn", priority = -1 }
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)'] }

[workspace.lints.clippy]
pedantic = "warn"
Expand Down Expand Up @@ -102,7 +103,9 @@ tiny-keccak = { version = "2.0.2", features = ["keccak"] }
tokio = { version = "1.12.0", features = ["full"] }
futures = "0.3.30"
dashmap = "6.1.0"
crypto-bigint = { version = "0.5.5", default-features = false, features = ["zeroize"] }
crypto-bigint = { version = "0.5.5", default-features = false, features = [
"zeroize",
] }
num-traits = "0.2.14"
zeroize = { version = "1.8.1", features = ["derive"] }
proptest = "1"
Expand Down
135 changes: 75 additions & 60 deletions contracts/src/finance/vesting_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,97 @@
//! intended.

use alloy_primitives::{Address, U256, U64};
use alloy_sol_types::sol;
use openzeppelin_stylus_proc::interface_id;
use stylus_sdk::{
block,
call::{self, call, Call},
call::{call, Call},
contract, evm, function_selector,
storage::TopLevelStorage,
stylus_proc::{public, sol_storage, SolidityError},
stylus_proc::public,
};

use crate::{
access::ownable::{self, IOwnable, Ownable},
token::erc20::utils::safe_erc20::{self, ISafeErc20, SafeErc20},
access::ownable::IOwnable, token::erc20::utils::safe_erc20::ISafeErc20,
};

sol! {
/// Emitted when `amount` of Ether has been released.
///
/// * `amount` - Total Ether released.
#[allow(missing_docs)]
event EtherReleased(uint256 amount);
#[cfg_attr(coverage, coverage(off))]
mod sol_defs {
use alloy_sol_types::sol;
use stylus_sdk::{
call,
stylus_proc::{sol_storage, SolidityError},
};

use crate::{
access::ownable::{self, Ownable},
token::erc20::utils::safe_erc20::{self, SafeErc20},
};

sol! {
/// Emitted when `amount` of Ether has been released.
///
/// * `amount` - Total Ether released.
#[allow(missing_docs)]
event EtherReleased(uint256 amount);

/// Emitted when `amount` of ERC-20 `token` has been released.
///
/// * `token` - Address of the token being released.
/// * `amount` - Number of tokens released.
#[allow(missing_docs)]
event ERC20Released(address indexed token, uint256 amount);
}

/// Emitted when `amount` of ERC-20 `token` has been released.
///
/// * `token` - Address of the token being released.
/// * `amount` - Number of tokens released.
#[allow(missing_docs)]
event ERC20Released(address indexed token, uint256 amount);
}
sol! {
/// Indicates an error related to the underlying Ether transfer.
#[derive(Debug)]
#[allow(missing_docs)]
error ReleaseEtherFailed();

/// The token address is not valid (eg. `Address::ZERO`).
///
/// * `token` - Address of the token being released.
#[derive(Debug)]
#[allow(missing_docs)]
error InvalidToken(address token);
}

sol! {
/// Indicates an error related to the underlying Ether transfer.
#[derive(Debug)]
#[allow(missing_docs)]
error ReleaseEtherFailed();
/// An error that occurred in the [`VestingWallet`] contract.
#[derive(SolidityError, Debug)]
pub enum Error {
/// Error type from [`Ownable`] contract [`ownable::Error`].
Ownable(ownable::Error),
/// Indicates an error related to the underlying Ether transfer.
ReleaseEtherFailed(call::Error),
/// Error type from [`SafeErc20`] contract [`safe_erc20::Error`].
SafeErc20(safe_erc20::Error),
/// The token address is not valid. (eg. `Address::ZERO`).
InvalidToken(InvalidToken),
}

/// The token address is not valid (eg. `Address::ZERO`).
///
/// * `token` - Address of the token being released.
#[derive(Debug)]
#[allow(missing_docs)]
error InvalidToken(address token);
sol_storage! {
/// State of the [`VestingWallet`] Contract.
pub struct VestingWallet {
/// [`Ownable`] contract.
Ownable ownable;
/// Amount of Ether already released.
uint256 _released;
/// Amount of ERC-20 tokens already released.
mapping(address => uint256) _erc20_released;
/// Start timestamp.
uint64 _start;
/// Vesting duration.
uint64 _duration;
/// [`SafeErc20`] contract.
SafeErc20 safe_erc20;
}
}
}

/// An error that occurred in the [`VestingWallet`] contract.
#[derive(SolidityError, Debug)]
pub enum Error {
/// Error type from [`Ownable`] contract [`ownable::Error`].
Ownable(ownable::Error),
/// Indicates an error related to the underlying Ether transfer.
ReleaseEtherFailed(call::Error),
/// Error type from [`SafeErc20`] contract [`safe_erc20::Error`].
SafeErc20(safe_erc20::Error),
/// The token address is not valid. (eg. `Address::ZERO`).
InvalidToken(InvalidToken),
}
pub use sol_defs::VestingWallet;
use sol_defs::*;

Check warning on line 114 in contracts/src/finance/vesting_wallet.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] contracts/src/finance/vesting_wallet.rs#L114

warning: usage of wildcard import --> contracts/src/finance/vesting_wallet.rs:114:5 | 114 | use sol_defs::*; | ^^^^^^^^^^^ help: try: `sol_defs::{ERC20Released, Error, EtherReleased, InvalidToken}` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports = note: `-W clippy::wildcard-imports` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::wildcard_imports)]`
Raw output
contracts/src/finance/vesting_wallet.rs:114:5:w:warning: usage of wildcard import
   --> contracts/src/finance/vesting_wallet.rs:114:5
    |
114 | use sol_defs::*;
    |     ^^^^^^^^^^^ help: try: `sol_defs::{ERC20Released, Error, EtherReleased, InvalidToken}`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports
    = note: `-W clippy::wildcard-imports` implied by `-W clippy::pedantic`
    = help: to override `-W clippy::pedantic` add `#[allow(clippy::wildcard_imports)]`


__END__
use token::IErc20;

pub use token::IErc20;
#[allow(missing_docs)]
mod token {
stylus_sdk::stylus_proc::sol_interface! {
Expand All @@ -91,24 +124,6 @@ mod token {
}
}

sol_storage! {
/// State of the [`VestingWallet`] Contract.
pub struct VestingWallet {
/// [`Ownable`] contract.
Ownable ownable;
/// Amount of Ether already released.
uint256 _released;
/// Amount of ERC-20 tokens already released.
mapping(address => uint256) _erc20_released;
/// Start timestamp.
uint64 _start;
/// Vesting duration.
uint64 _duration;
/// [`SafeErc20`] contract.
SafeErc20 safe_erc20;
}
}

/// NOTE: Implementation of [`TopLevelStorage`] to be able use `&mut self` when
/// calling other contracts and not `&mut (impl TopLevelStorage +
/// BorrowMut<Self>)`. Should be fixed in the future by the Stylus team.
Expand Down
1 change: 1 addition & 0 deletions contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl MyContract { }
)]
#![cfg_attr(not(feature = "std"), no_std, no_main)]
#![deny(rustdoc::broken_intra_doc_links)]
#![cfg_attr(coverage, feature(coverage_attribute))]

Check failure on line 49 in contracts/src/lib.rs

View workflow job for this annotation

GitHub Actions / ubuntu / stable / coverage

`#![feature]` may not be used on the stable release channel
extern crate alloc;

pub mod access;
Expand Down

0 comments on commit f837803

Please sign in to comment.