asset.amount should be stored as int and not string
Maybe related to: helpy#5 (since after this solved, we can access Assets via another layer)
This comes from the fact AssetHF26 has amount as AssetNaiAmount which adds the string conversion in its __get_validators__
-> __stringify
method (but it also inherits from HiveInt
, which is a ConstrainedInt
, so it should be a regular int
..)
As @kmochocki said it was done because of problems with serialization (hived cannot take this as an integer in some APIS probably, and str serialization is needed)
This is not an elegant solution, but rather a workaround and should be corrected because it causes problems in accessing this variable - we have to cast to an int in every place that needs an amount.
I think this should be solved in another way - by doing it at a later stage, adding a serialization instead of storing this value all the time like it was a string
Looks like in the newer version of pydantic (2.x) this can be done in a nice way via field_serializer: https://docs.pydantic.dev/latest/api/functional_serializers/#pydantic.functional_serializers.field_serializer
But in our version (1.x) we have json_encoders for that: https://docs.pydantic.dev/1.10/usage/exporting_models/#json_encoders