ethabi icon indicating copy to clipboard operation
ethabi copied to clipboard

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

Open Autoparallel opened this issue 2 years ago • 2 comments

https://github.com/rust-ethereum/ethabi/blob/a148a4ae0625208946477522bac69eee51602208/ethabi/src/lib.rs#L94

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.

Autoparallel avatar May 10 '23 22:05 Autoparallel

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

cliff0412 avatar Jul 04 '23 07:07 cliff0412

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

Akagi201 avatar Aug 15 '23 03:08 Akagi201