Hi guys, do you have a Uint256 number crate that you recommend to work with CosmWasm?
- Orkun Külçe @orkunkl2020-07-27 10:40:53.670Z
So far we did not need one. But it would not be too hard creating one based on Uint128 from cosmwasm-std. What’s the use case for this?
- In reply toorkunkl⬆:Orkun Külçe @orkunkl2020-07-27 10:41:00.559Z
Looking to port some ethereum contracts and looking for 100% structural compatibility
- In reply toorkunkl⬆:Orkun Külçe @orkunkl2020-07-27 10:41:23.136Z
Yes makes sense. This should be done. It should be in cosmwasm-std in order to get the best possible JSON developer experience. This probably won’t work well with an external crate.
It would be a bit trickier to implement than Uint128 cuz there we can wrap rust's native u128 type and logic. There is no native u256 type.
Honestly, for most numeric math, u256 is likely unneeded. U128 offers 18 decimal places and 18 digits before the dot.
I think some crate that handles arbitrary precision fixed point math would be more useful (if you want to before more calculations), like "bigint" or such