fix: 🐛 resolve RewardDestination from its camel-cased toJSON key - #350
Merged
polymesh-bot merged 1 commit intoSep 9, 2026
Merged
Conversation
F-OBrien
force-pushed
the
fix/staking-reward-destination-casing
branch
from
September 9, 2026 17:11
9c9ba22 to
828a7d1
Compare
F-OBrien
changed the base branch from
redesign/03-infrastructure
to
redesign/04-polyx-ledger
September 9, 2026 17:11
`Enum#toJSON()` camel-cases the variant name, so an 8.x `Rewarded` with an
`Account` payee arrives as `{ account: "5..." }` and never matched the
`'Account'` comparison: the row stored `rewardDestination: 'account'` with no
destination account. Every object form was affected, `{ staked: null }`
included, so no destination account was resolved for any of them.
The parse now lives once in `utils/staking.ts`, shared with the pre-v8
`staking.payee` read. It takes `AnyJson` and narrows rather than casting
`toJSON()` to a hand-written shape, and `rewardDestination` is a union of the
variant names instead of `string`.
`.toJSON()` stays in place of the generated `Option<PalletStakingRewardDestination>`
accessors: those describe the current metadata only, while both callers read
older runtimes, and the reason is now recorded at the helper.
prashantasdeveloper
force-pushed
the
fix/staking-reward-destination-casing
branch
from
September 9, 2026 19:21
828a7d1 to
e27ebd8
Compare
prashantasdeveloper
approved these changes
Sep 9, 2026
|
Contributor
|
/fast-forward |
prashantasdeveloper
added a commit
that referenced
this pull request
Sep 10, 2026
…was right CHANGES.md, entity-review.md and 02-polyx-ledger.md each asserted [V] that get8xStakingEventDetails resolved the RewardDestination correctly. PR #350 showed it did not - the object form never matched. Corrected in the repo's usual style.
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.



Found while reviewing #349.
Enum#toJSON()camel-cases the variant name (stringCamelCase(this.type)in@polkadot/types-codec), butgetRewardDestinationDetailscompared the key against'Account'. So an 8.xRewardedwith an explicitAccountpayee arrived as{ account: "5..." }, the branch never fired, and the row was stored asrewardDestination: 'account'withrewardDestinationAccountundefined. Every object form was affected —{ staked: null }stored'staked'and resolved no account either.The parse now lives once in
utils/staking.ts, shared with the pre-v8staking.payeeread that had it right. Along the way:AnyJsonand narrows, instead of castingtoJSON()tostring | Record<string, unknown> | nullrewardDestinationis a union of the variant names, notstring.toJSON()stays in place of the generatedOption<PalletStakingRewardDestination>accessors, and the reason is recorded at the helper: the generated types describe the current metadata only, while both callers read older runtimes, so.unwrap()would throw into acatchon a block where the entry decodes as a bareRewardDestinationTests cover
{ account },{ staked: null }and the bare-string form on the 8.x path; the object-form cases fail without the fix.