rooch icon indicating copy to clipboard operation
rooch copied to clipboard

[Type] The field type returned by AnnotatedMoveValueView is inconsistent with the actual type

Open baichuan3 opened this issue 2 years ago • 1 comments

The current implementation of AnnotatedMoveValueView may be flawed. Coin balance defines the U256 type, but the type obtained from AnnotatedMoveValueView is U64(StrView(10000), and the expected type is U256(StrView(10000).

Guess AnnotatedMoveValueView May return U128(StrView(value) type if the coin value big enough.

The Case

value: {Identifier("value"): U64(StrView(10000))} })

relative of https://github.com/rooch-network/rooch/pull/760 https://github.com/rooch-network/rooch/blob/467707e7f294d23277ac8aa7fd026fd0aea7354f/crates/rooch-rpc-api/src/jsonrpc_types/rooch_types.rs#L193-L221

baichuan3 avatar Sep 07 '23 03:09 baichuan3

Because the U64, U128, and U256 in AnnotatedMoveValueView all represent via StrView.

And the AnnotatedMoveValueView is #[serde(untagged)], so we will lose the type when serializing to JSON.

https://github.com/rooch-network/rooch/blob/a63525896448ae9da62600c0f1fe86926f122883/crates/rooch-rpc-api/src/jsonrpc_types/move_types.rs#L119-L136

jolestar avatar Sep 11 '23 04:09 jolestar