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
It is not clear how to represent a Rust Option type in XDR. The custom-types documentation does not include any information about Option types.
Also, it would be helpful to have more tooling or at least a link to a reference implementation which converts Soroban types into their corresponding XDR structures. Otherwise, you are left guessing at how values should be encoded as SCVals.
How is the status on this Issue? We have had some updates since it was opened and I'm thinking that things may have changed or it this issue has been resolved.
I would appreciate an update when you get a chance
stellar/stellar-xdr#70 completely overhauled the scval system since this issue was written. There are two ways Option is represented in xdr.
In the ContractSpec (what you get if you do a soroban contract inspect), there is an ScSpecTypeOption type, which acts like rust's Option<T>
In the actual invocation xdr, there is no explicit Option type. Instead there is an ScVoid value, which you can pass for any value that should be None. This roughly means that in the arguments every argument is implicitly optional. But if you make the wrong one optional the transaction will be rejected.
We should probably think of a good way to explain this to people.
Activity
Julian-dev28 commentedon May 17, 2023
@tamirms @paulbellamy
How is the status on this Issue? We have had some updates since it was opened and I'm thinking that things may have changed or it this issue has been resolved.
I would appreciate an update when you get a chance
Thanks!
paulbellamy commentedon May 22, 2023
stellar/stellar-xdr#70 completely overhauled the scval system since this issue was written. There are two ways
Optionis represented in xdr.In the ContractSpec (what you get if you do a
soroban contract inspect), there is an ScSpecTypeOption type, which acts like rust'sOption<T>In the actual invocation xdr, there is no explicit Option type. Instead there is an ScVoid value, which you can pass for any value that should be
None. This roughly means that in the arguments every argument is implicitly optional. But if you make the wrong one optional the transaction will be rejected.We should probably think of a good way to explain this to people.
Good luck 🤷
janewang commentedon Apr 25, 2024
Add to this page https://developers.stellar.org/docs/smart-contracts/example-contracts/custom-types
leighmcculloch commentedon May 16, 2024
Should add to this page too: https://developers.stellar.org/docs/tools/sdks/build-your-own
Add Option type (#1232)
carstenjacobsen commentedon Feb 10, 2025
Closed by #1232