-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] How to “pretty easily” implement (De)/serialize for DynSolValue with serde(with=…) #614
Comments
Two cents: Alloy claims it follows rust code of conduct. So I expect:
|
As a more complete example, I made you a struct following @DaniPopes recommendation to serialize the type alongside the value. This is strictly better than the requested serde_with, as it ensures that type info can never be lost (as serializing a Please do not keep opening new issues or PRs for this.
|
Thanks for the concrete sample. This looks much better. Here are a few comments:
As stated, it's obviously well supported without any extra efforts by
This seems weird to me because
I expect to have a healthy discussion environment instead of closing issues all of a sudden. Thanks again for your efforts. |
Yes, But more importantly, the Long story short, it's necessary to keep the sol type info even if we were to encode the recursive structure of |
Thanks for the feedback. I understand the motivation. I just mean I would implement this exactly as serde auto derivation does: get a tag for each enum variant (so the type information is not saved as the canonical type string, but recursive mapping instead). But anyway, as stated, my ideal solution is not bloating extra code. |
The point is that the serde derived implementation would fail for some class of valid objects. and any user easily construct a object that triggers that failure |
I fail to get this. Why it would fail for some class of valid objects? |
Suppose you make an abi encoding service (e.g. anything that provides |
I can’t get it. Why not just use: https://docs.rs/alloy-dyn-abi/latest/alloy_dyn_abi/enum.DynSolValue.html#method.abi_encode for any DynSolValue? I can get that for deserializing abi encoded bytes without type information is not possible but for encoding DynSolValue, it should be fine without type information? The two array cases you mentioned are due to the lack of element types. But since they have 0 length, it should produce the correct bytes anyway? I don’t have my laptop at this moment but I will try to confirm. |
Okay, I see after some quick testing. Did you mean that, it's possible for users to provide some data like: However, shall |
Component
dyn-abi
Describe the feature you would like
As title, I want to know how to “pretty easily” do this? Is there any one-line solution with this?
Additional context
#612
gakonst/ethers-rs#2667
I might be dumb at serde but I think it is offensive to mark the issue “pretty easy” and close it without any concrete solution. Therefore, I reopen one to ask for an “easy” solution cuz I can’t get why it is “easy” compared to deriving the attributes with two more english words.
The text was updated successfully, but these errors were encountered: