-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: added rpc method to deal ERC20 tokens #10495
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
Conversation
@@ -359,6 +359,10 @@ pub enum EthRequest { | |||
#[serde(rename = "anvil_setBalance", alias = "hardhat_setBalance")] | |||
SetBalance(Address, #[serde(deserialize_with = "deserialize_number")] U256), | |||
|
|||
/// Modifies the ERC20 balance of an account. | |||
#[serde(rename = "anvil_dealERC20", alias = "hardhat_dealERC20")] | |||
DealERC20(Address, #[serde(deserialize_with = "deserialize_number")] U256, Address), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's swap the order here, similar to setBalance
|
||
let calldata = IERC20::balanceOfCall { target: address }.abi_encode(); | ||
let tx = TransactionRequest::default().with_input(calldata); | ||
let access_list_result = self.create_access_list(WithOtherFields::new(tx), None).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great
let access_list = access_list_result.access_list; | ||
for item in access_list.0 { | ||
if item.address != token_address { | ||
continue; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now here we need to loop over all slots and send an ethcall with a stateoverride for the slot in order to find the slot that has the balance:
and then finally we need to call set storage for that slot and value
closes #8956