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 0980715
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contracts/src/token/erc20/utils/safe_erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use alloy_sol_types::{
};
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 0980715

Please sign in to comment.