Skip to content

Commit

Permalink
Use function_selector to get the appropriate value
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Sep 19, 2024
1 parent 9e449f4 commit 025564a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions contracts/src/token/erc20/utils/safe_erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

use alloc::vec::Vec;

use alloy_primitives::{keccak256, Address, U256};
use alloy_primitives::{Address, U256};
use alloy_sol_types::{
sol,
sol_data::{Address as SOLAddress, Uint},
SolType,
};
use stylus_proc::SolidityError;
use stylus_sdk::{
call::RawCall, contract::address, storage::TopLevelStorage,
types::AddressVM,
call::RawCall, contract::address, function_selector,
storage::TopLevelStorage, types::AddressVM,
};

use crate::token::{erc20, erc20::Erc20};
Expand Down Expand Up @@ -67,7 +67,8 @@ impl SafeErc20 for Erc20 {
type TransferType = (SOLAddress, Uint<256>);
let tx_data = (to, value);
let data = TransferType::abi_encode_params(&tx_data);
let hashed_function_selector = keccak256("transfer".as_bytes());
let hashed_function_selector =
function_selector!("transfer", Address, U256);
// Combine function selector and input data (use abi_packed way)
let calldata = [&hashed_function_selector[..4], &data].concat();

Expand Down

0 comments on commit 025564a

Please sign in to comment.