rust-ethereum / ethabi

Encode and decode smart contract invocations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace `pub type Int = ethereum_types::U256` with an `I256`

Autoparallel opened this issue · comments

pub type Int = ethereum_types::U256;

Can this be replaced with something like an ethereum_types::I256?

It seems like that is valid. In ethers-rs there is a I256 type that this would be handy to interface with directly. Upon parsing some events in revm, the fact that Int is really a U256 under the hood is not optimal.

you can use I256 and convert to bytes; then use U256::from(bytes).
the raw slot is 256 bits, which can be represented by U256 actually; just ensure that the raw bytes are correct

I found the solution: Token::Int(I256::from_dec_str(&a_string_type).unwrap().into_raw())