You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we try to "extend" structs, especially those we serialize but don't deserialize (query responses), rather than copy the definition and add more fields, we could embed it.
This PR should not only worry about the code compiling and working in Rust, but also check the JSON schema we expose externally. This can be demo-ed on a few values like above and then we can see if this works at all, and if it works, if it simplifies or complicates things.
Note: This may not work with the custom serde-json-wasm library we use. If flatten is not supported, or raises errors, then please raise an issue on that repo (our custom json lib) and close this issue. (We are unlikely to implement it)
Deliverables:
Update AllowanceInfo as defined
Update all contracts to use it properly
Check generated json schema (should be the same) and manually print out an example of serializing it
Test serializing/deserializing with this struct
In addition, please provide a short response if this seems to make the coding simpler (extending single query to enumerable) and if you feel it improves code quality, a list of other structs to consider in future issues. (This may just add confusion, and we may not make this change, but I wanted to try it out before building too many List queries)
The text was updated successfully, but these errors were encountered:
https://serde.rs/attr-flatten.html
When we try to "extend" structs, especially those we serialize but don't deserialize (query responses), rather than copy the definition and add more fields, we could embed it.
Here is an example to explain what I mean.
AllowanceResponse
is extended toAllowanceInfo
. Currently that looks like:Maybe it would be possible to do:
This PR should not only worry about the code compiling and working in Rust, but also check the JSON schema we expose externally. This can be demo-ed on a few values like above and then we can see if this works at all, and if it works, if it simplifies or complicates things.
Note: This may not work with the custom serde-json-wasm library we use. If flatten is not supported, or raises errors, then please raise an issue on that repo (our custom json lib) and close this issue. (We are unlikely to implement it)
Deliverables:
AllowanceInfo
as definedIn addition, please provide a short response if this seems to make the coding simpler (extending single query to enumerable) and if you feel it improves code quality, a list of other structs to consider in future issues. (This may just add confusion, and we may not make this change, but I wanted to try it out before building too many List queries)
The text was updated successfully, but these errors were encountered: