Skip to content

fix: Type-Aware SCALE-to-JSON Serializer#312

Open
eugypalu wants to merge 2 commits intomainfrom
eugenio/type-aware-scale-to-json-serializer
Open

fix: Type-Aware SCALE-to-JSON Serializer#312
eugypalu wants to merge 2 commits intomainfrom
eugenio/type-aware-scale-to-json-serializer

Conversation

@eugypalu
Copy link
Copy Markdown
Collaborator

Replaces the two-phase event serialization pipeline (decode → post-process) with the same single-phase, type-aware ScaleVisitor already used by extrinsics.

What changed

decode/args.rs

  • Added a second const generic PRESERVE_ENUM_CASE to ScaleVisitor to control basic enum variant casing
  • New EventJsonVisitor type alias: ScaleVisitor<true, true> — camelCase keys + preserved enum casing (e.g. "Mandatory", "Yes" instead of "mandatory", "yes")
  • Existing JsonVisitor and CallArgsVisitor behavior unchanged (PRESERVE_ENUM_CASE = false)

decode/events.rs

  • Removed FieldWithTypeExtractor, ValueExtractor, EventField, is_basic_enum, lowercase_first_char
  • Removed all post-processing functions: convert_bytes_to_hex, transform_json_unified, try_convert_accountid_to_ss58
  • Threaded ss58_prefix through the visitor chain (EventsVisitorEventRecordVisitorPalletEventVisitorActualEventVisitor)
  • ActualEventVisitor now decodes fields directly with EventJsonVisitor

processing/events.rs

  • Removed all post-processing logic (AccountId32/MultiAddress/RewardDestination special-casing, transform_json_unified calls)
  • Event fields arrive fully transformed from the decoder — no second pass needed

closes #41

@eugypalu eugypalu marked this pull request as draft March 27, 2026 13:33
@eugypalu eugypalu marked this pull request as ready for review March 30, 2026 11:49
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.

Type-Aware SCALE-to-JSON Serializer

1 participant