feat: implement StateTransitionJsonConvert and fix PlatformAddress map key serialization#3110
Open
feat: implement StateTransitionJsonConvert and fix PlatformAddress map key serialization#3110
Conversation
…for StateTransition enum Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix state transition JSON conversion for enum variants
feat: implement StateTransitionJsonConvert for top-level StateTransition enum
Feb 19, 2026
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Copilot
AI
changed the title
feat(dpp): implement StateTransitionJsonConvert for top-level StateTransition enum
feat: implement StateTransitionJsonConvert for top-level StateTransition enum
Feb 19, 2026
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Copilot
AI
changed the title
feat: implement StateTransitionJsonConvert for top-level StateTransition enum
feat: implement StateTransitionJsonConvert and fix PlatformAddress map key serialization
Feb 19, 2026
shumkov
requested changes
Feb 20, 2026
Collaborator
shumkov
left a comment
There was a problem hiding this comment.
Please update wasm-dpp2 as well then
Contributor
|
@copilot Please update wasm-dpp2 to match changes in this PR. |
Co-authored-by: lklimek <842586+lklimek@users.noreply.github.com>
Contributor
Author
Updated in commit 314a1c6. Added
Done in commit 314a1c6. Added |
…then docs Replace verbose println-based tests with proper assertion-based tests that validate both to_json() and serde_json serialization paths produce correct string keys for BTreeMap<PlatformAddress, V> fields. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
61a90c0 to
5a43766
Compare
Remove duplicated test functions, keep the consolidated versions with shared helper, proper assertions, and given/when/then docstrings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that StateTransition::to_json() and serde_json serialization work correctly in the wasm-dpp2 context with its enabled features, including string keys for BTreeMap<PlatformAddress, V> fields. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
StateTransitionenum lackedStateTransitionJsonConvertimplementation, forcing manual variant matching. Additionally, JSON serialization failed for address-based state transitions containingBTreeMap<PlatformAddress, V>with error "key must be a string" becausePlatformAddress(enum with data) serializes as a complex object, violating JSON's string-key requirement.Investigation revealed both
serde_json::to_string_pretty()andto_json()fail identically sinceto_json()usesplatform_value::to_value()internally, which relies on serde.Changes
StateTransition trait implementations:
json_conversion.rs- dispatchesto_json()to variant implementationsvalue_conversion.rs- dispatches conversion methods to variantsStateTransitionFieldTypesreturning empty vectors (paths are variant-specific)state-transition-json-conversiontodash-sdk-featuresPlatformAddress map key serialization fix:
platform_address_map_serde.rs- custom serde helpers that serializePlatformAddresskeys as Display strings ("P2PKH(hex...)") and deserialize viaFromStrBTreeMap<PlatformAddress, ...>:AddressFundsTransferTransitionV0(inputs, outputs)AddressFundingFromAssetLockTransitionV0(inputs, outputs)AddressCreditWithdrawalTransitionV0(inputs)IdentityTopUpFromAddressesTransitionV0(inputs)IdentityCreateFromAddressesTransitionV0(inputs)IdentityCreditTransferToAddressesTransitionV0(recipient_addresses)WASM bindings update:
state-transition-json-conversionfeature towasm-dpp2Cargo.toml to maintain feature parity withwasm-dppResult
Both serialization paths now work:
{ "inputs": { "P2PKH(0101010101010101010101010101010101010101)": [1, 1000] } }Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.