stellar / rs-soroban-sdk

Rust SDK for Soroban contracts.
Apache License 2.0
128 stars 67 forks source link

Contract Spec: Fill in more edge cases of macro code generation of types and fns #153

Open leighmcculloch opened 2 years ago

leighmcculloch commented 2 years ago

Lots of TODOs in this file: https://github.com/stellar/rs-stellar-contract-sdk/blob/main/macros/src/derive_type.rs

leighmcculloch commented 2 years ago

Also missing behavior is noted here too: https://github.com/stellar/rs-stellar-contract-sdk/issues/24#issuecomment-1180899140

leighmcculloch commented 2 years ago

I'm going to move this to the August iteration and just accept that the edge cases not covered are just that, not covered right now.

sisuresh commented 1 year ago

@leighmcculloch Should this issue still be open? Th contract spec code has changed quite a bit so it's not clear to me what needs to be done here.

leighmcculloch commented 1 year ago

Yup. There's plenty of little edge cases where errors show up. @brson just ran into some recently and was opening PRs for the ones he saw.

anupsdf commented 7 months ago

Passing to @leighmcculloch to assess if anything more is needed here.

leighmcculloch commented 7 months ago

There are quite a few TODO items still left in the soroban-sdk-macros crate that I think need addressing.

jayz22 commented 7 months ago

Here are the outstanding TODOs in the soroban-sdk-macros, most of them are pretty old. @leighmcculloch can you take a look at them and give guidance on whether they are still applicable/needed?

  1. derive_enum_int.rs Add conversions to/from ScVal types. I think this was is already done.
  2. derive_enum.rs Choose discriminant type based on repr type of enum.. Not sure if still applicable. Seems to be describing enum int, but also not sure what's the benefit.
  3. derive_enum.rs Use attributes tagged on variant to control whether field is included.. Not sure what's the use case. An example would be nice.
  4. derive_struct.rs Add field attribute for including/excluding fields in types.. Same as above, not sure why it is needed. Explanation with example would be helpful.
  5. derive_struct.rs Better handling of partial types and types without all their fields and types with private fields.. Need more specifics on how partial private fields should be handled.
  6. lib.rs Use imp.trait_ in generating the client ident, to create a unique client for each trait impl for a contract, to avoid conflicts.
  7. map_type.rs Implement conversion to VecM from iters to omit this collect.. This needs to done on the rs-stellar-xdr to add the convert from iter to VecM, don't feel it's worth it to save one line of macro code here (unless the same pattern is used a lot elsewhere).