Closed sampocs closed 11 months ago
Hi @sampocs! would you mind making this automated? With the current change, it will be replaced when type gets regenerated.
This is similar to https://github.com/osmosis-labs/osmosis-rust/blob/5489d6f29cf739bbc2635622aa073bde4a479732/packages/proto-build/src/transformers.rs#L150
So we can add another transformer function next to allow_serde_int_as_str
and register it here: https://github.com/osmosis-labs/osmosis-rust/blob/5489d6f29cf739bbc2635622aa073bde4a479732/packages/proto-build/src/transform.rs#L164
Sorry for the delay @iboss-ptk! Please see the above commit and let me know if this addresses it for you.
Also, how can I test this?
@sampocs sorry for late response, you can unit test the transformer logic similar to these tests (basically test if the transformed tokens match expectation).
To see if actual code generation works as expected, you can cd packages/proto-build && cargo run
(note that cargo run -p proto-build
does not work for some reason I haven't investigated).
The changes and the fix is already in main https://github.com/osmosis-labs/osmosis-rust/commit/473d53917ec594872674b0d8b99f992a7d6b806a
Context
The stableswap pool type has a scaling factor attribute of type
Vec<u64>
; however, the json schema defines the same field as an array of Strings. As a result, when querying this pool, the deserialization fails. This PR adds a custom serializer/deserializer to safely convert theVec<String>
type from the query response into the preferredVec<u64>
type.Brief Changelog
as_str_vec
serializers and deserializersCode to reproduce the error
Error message before fix