Skip to content
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

mStructs with encodingKey (integrated with source-mapping branch) #130

Merged
merged 8 commits into from
Oct 6, 2024

Conversation

rjharmon
Copy link
Contributor

@rjharmon rjharmon commented Oct 5, 2024

Helios up until v0.17.0.98 allowed definition of a string-mapped struct (aka mStruct) in this form

struct MyStructDef {
  name: String
  description: String  "descr"
  otherField: Int "ofld"  // one field needs an explicit encoding key defined
}

This was encoded as a ConstrData(0, MapData), and it worked fine when a script's Datum was itself defined as an mStruct such as this myStructDef, and not an enum with a variant having field1: mStruct. Using that definition inside an enum variant would produce a second layer of ConstrData.

This change establishes:

  • Datum enum variants with field1 as an mStruct will match the CIP-68 requirements (the Enum's ConstrData element provides that aspect of the requirement)
  • Use of an mStruct in any position does no longer have a ConstrData wrapper, because it would be redundant

This represents a behavioral change versus version 0.16 (which expects a ConstrData in all cases when decoding an mStruct). Developers using such a struct as their Datum can continue getting CIP-68-compliant encoding by changing to an enum:

enum Datum {
  ForCip68 {
    data: MyStructDef
    version: String
    extraData: <any type>
  }
}

Randall added 8 commits September 30, 2024 19:02
 - moves Cip68 support to developer side (use enum::Variant{data: mStruct})
 - combines earlier commits into one
 - undo attempt to export test/utils.js
 - moved pre-push-hook install out of "post-install"
   (was happening at downstream client-install time)
   ... added to before-tests to make it more likely to happen magically
 - removed .only modifiers on test cases
# Conflicts:
#	src/statements/StructStatement.js
 - added eval() results to factoried runner return in utils: compileForRun()
 - added tests for logged details
 - warnings and errors show field names
 - mStruct tests look for specific log entries, not just "it errors when..."
 - mStruct equality tests changed to not use ::from_data() (optimized version)
Copy link
Contributor

@christianschmitz christianschmitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution, great work!

@christianschmitz christianschmitz merged commit 9209caf into HeliosLang:source-mapping Oct 6, 2024
@rjharmon rjharmon deleted the mse2 branch October 6, 2024 19:03
@rjharmon
Copy link
Contributor Author

rjharmon commented Oct 6, 2024

thanks for the guidance on the Expr bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants