0xSpaceShard / starknet-devnet-rs

A local testnet for Starknet... in Rust
https://0xspaceshard.github.io/starknet-devnet-rs/
MIT License
107 stars 62 forks source link

account_balance format #429

Closed qperrot closed 6 months ago

qperrot commented 6 months ago

Describe the bug (observed vs expected behavior)

When calling /account_balance?address= it returns me an array of 3 int (ex: array[34, 7834, 984]). It should be low and high like for cairo, but it turns out the array returned by /account_balance consists of 32-bit parts of the number.

Not reproducible on testnet

Devnet version

FabijanC commented 6 months ago

@marioiordanov perhaps we should have made amount have type String. It was discussed here: https://github.com/0xSpaceShard/starknet-devnet-rs/pull/394#discussion_r1538928072. Rationale for using the String type: it's also used in e.g. /predeployed_accounts, and we don't have to force our users to do BigUint deserialization on their end.

Unfortunately the tests I wrote only load the amount using BigUint deserialization. And on creating the response the value is serialized from BigUint directly, so the fact that it gets converted to an array of u32 values was never discovered. I'll improve the tests.