-
Notifications
You must be signed in to change notification settings - Fork 67
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
Support variants with multiple fields in UDTs #850
Conversation
I think this will result in code generated that doens't match the original code. For example: type Enum enum {
Variant(A1, A2)
} Will result inthe following being code generated: type Enum enum {
Variant((A1, A2))
} So I think we need to change the XDR so that the |
The smallest diff we could make to the spec to support it is: diff --git a/Stellar-contract-spec.x b/Stellar-contract-spec.x
index 56c3adf..d26c169 100644
--- a/Stellar-contract-spec.x
+++ b/Stellar-contract-spec.x
@@ -139,7 +139,7 @@ struct SCSpecUDTUnionCaseV0
{
string doc<SC_SPEC_DOC_LIMIT>;
string name<60>;
- SCSpecTypeDef *type;
+ SCSpecTypeDef type<12>;
};
struct SCSpecUDTUnionV0 But maybe we should make that struct a union, and explicitly distinguish between unit and tuple variants. |
I'm making some changes to the spec xdr to support multiple tuples in the spec itself: stellar/stellar-xdr#67. |
Thanks for making the XDR changes for me. I started upgrading rs-soroban-sdk to the latest XDR until I discovered the new |
Sorry about that, the docs changes are in #841 which I plan to finish and need on Monday. You could base your changes on that PR though if you wanted to move ahead. |
Rebased. |
What
Add support for UDT enums with variants containing up to 12 fields.
Add more test cases.
Why
UDT enum variants are currently limited to a single field, which seems arbitrary and surprising.
Known limitations
This does not add support for struct-like variants.
The spec for tuple-like variants is now a ScpSpecUdtUnionCaseV0 of ScSpecTypeTuple:
Please consider whether this is correct. I am not sure.
This patch requires updates to rs-stellar-xdr and rs-soroban-sdk to support conversions of 13-tuples:
This patch went through a lot of iteration and ended up making a bigger diff than necessary.
cc #153