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

feat: Add DynamicMap type #638

Merged

Conversation

mattjohnsonpint
Copy link
Member

@mattjohnsonpint mattjohnsonpint commented Dec 7, 2024

Description

This adds a DynamicMap type to the Modus AssemblyScript SDK. It allows a user (or another sdk function) to have the equivalent of Map<string, any> in AssemblyScript, with some caveats:

  • Only string is supported for the map key
  • Any value must be JSON serializable, either by being a primitive type or being decorated with @json
  • Iterating map values with .values() will return the raw JSON value for each item, since it's not possible to infer the type.

Note, the bug described in JairusSW/as-json#98 required some extensive workarounds in the implementation that may be buggy, but have passed the basic tests. We'll want to remove the workarounds when the bug is fixed upstream.

Checklist

  • Code compiles correctly and linting passes locally
  • For all code changes, an entry added to the CHANGELOG.md file describing and linking to this PR
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

@mattjohnsonpint mattjohnsonpint requested a review from a team as a code owner December 7, 2024 00:12
@mattjohnsonpint mattjohnsonpint enabled auto-merge (squash) December 7, 2024 00:16
@mattjohnsonpint mattjohnsonpint merged commit f86dcc5 into main Dec 7, 2024
32 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/hyp-2741-add-assemblyscript-dynamic-map-type branch December 7, 2024 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants