Skip to content

feat: update SafeErc20 to newer Solidity version #652

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
7888698
feat: SafeErc20.rs match the solidity version
simon0x1800 May 2, 2025
06565ee
refactor: Update force_approve method in ISafeErc20 trait to include …
simon0x1800 May 2, 2025
c193733
feat: Update SafeErc20 to match the new Solidity version of the Contract
simon0x1800 May 2, 2025
8d99290
refactor: Simplify force_approve method and improve code readability …
simon0x1800 May 2, 2025
2457829
refactor: Rename 'to' parameter to 'spender' in approve_and_call_rela…
simon0x1800 May 2, 2025
84bd984
refactor: Remove SafeErc20 trait and related tests to streamline the …
simon0x1800 May 5, 2025
b96f2e5
Update contracts/src/token/erc20/utils/safe_erc20.rs
simon0x1800 May 5, 2025
b81ad53
Update contracts/src/token/erc20/utils/safe_erc20.rs
simon0x1800 May 5, 2025
6765b4d
Update contracts/src/token/erc20/utils/safe_erc20.rs
simon0x1800 May 5, 2025
342d74c
refactor: Update safe_erc20.rs to improve method calls and code clarity
simon0x1800 May 5, 2025
174b634
Merge branch 'feature/620-update-safe-erc20' of https://github.com/si…
simon0x1800 May 5, 2025
10840e1
Update contracts/src/token/erc20/utils/safe_erc20.rs
simon0x1800 May 5, 2025
46ea88f
Update contracts/src/token/erc20/utils/safe_erc20.rs
simon0x1800 May 5, 2025
e88951a
refactor: Enhance SafeErc20 method calls by replacing RawCall encodin…
simon0x1800 May 6, 2025
d19173a
Merge branch 'feature/620-update-safe-erc20' of https://github.com/si…
simon0x1800 May 6, 2025
49f9b00
refactor: Update SafeErc20 method calls to use data conversion for im…
simon0x1800 May 8, 2025
aa2a535
feat: Update SafeERC20 to match latest Solidity version
simon0x1800 May 8, 2025
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
8 changes: 4 additions & 4 deletions contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ impl MyContract { }
*/

#![allow(
clippy::module_name_repetitions,
clippy::used_underscore_items,
deprecated
clippy::module_name_repetitions,
clippy::used_underscore_items,
deprecated
)]
#![cfg_attr(not(feature = "std"), no_std, no_main)]
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
Expand All @@ -51,4 +51,4 @@ extern crate alloc;
pub mod access;
pub mod finance;
pub mod token;
pub mod utils;
pub mod utils;
15 changes: 13 additions & 2 deletions contracts/src/token/erc20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
//! revert instead of returning `false` on failure. This behavior is
//! nonetheless conventional and does not conflict with the expectations of
//! [`Erc20`] applications.
//!
//! # SafeERC20
//!
//! The `utils::safe_erc20` module provides wrappers around ERC-20 operations that throw on failure
//! (when the token contract returns false). Tokens that return no value (and instead revert or
//! throw on failure) are also supported, non-reverting calls are assumed to be successful.
//!
//! To use this library, you can add a `#[inherit(SafeErc20)]` attribute to your contract,
//! which allows you to call the safe operations as `contract.safe_transfer(token_addr, ...)`, etc.
use alloc::{vec, vec::Vec};

use alloy_primitives::{Address, FixedBytes, U256};
Expand All @@ -24,6 +33,8 @@ pub mod extensions;
pub mod interface;
pub mod utils;

pub use utils::safe_erc20::{ISafeErc20, SafeErc20};

pub use sol::*;
#[cfg_attr(coverage_nightly, coverage(off))]
mod sol {
Expand Down Expand Up @@ -66,7 +77,7 @@ mod sol {
#[derive(Debug)]
#[allow(missing_docs)]
error ERC20InvalidReceiver(address receiver);
/// Indicates a failure with the `spender`s `allowance`. Used in
/// Indicates a failure with the `spender`'s `allowance`. Used in
/// transfers.
///
/// * `spender` - Address that may be allowed to operate on tokens without
Expand Down Expand Up @@ -109,7 +120,7 @@ pub enum Error {
InvalidSender(ERC20InvalidSender),
/// Indicates a failure with the token `receiver`. Used in transfers.
InvalidReceiver(ERC20InvalidReceiver),
/// Indicates a failure with the `spender`s `allowance`. Used in
/// Indicates a failure with the `spender`'s `allowance`. Used in
/// transfers.
InsufficientAllowance(ERC20InsufficientAllowance),
/// Indicates a failure with the `spender` to be approved. Used in
Expand Down
Loading