From 09807153768897dab4f060d3ad977309114d772a Mon Sep 17 00:00:00 2001 From: Nenad Date: Thu, 19 Sep 2024 09:16:37 +0200 Subject: [PATCH] Use function_selector to get the appropriate value --- contracts/src/token/erc20/utils/safe_erc20.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts/src/token/erc20/utils/safe_erc20.rs b/contracts/src/token/erc20/utils/safe_erc20.rs index 20264c6f..0d7292b6 100644 --- a/contracts/src/token/erc20/utils/safe_erc20.rs +++ b/contracts/src/token/erc20/utils/safe_erc20.rs @@ -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}; @@ -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();