8000 Fix: Voting on referenda breaks Apps by ap211unitech · Pull Request #11344 · polkadot-js/apps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Voting on referenda breaks Apps #11344

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

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/page-referenda/src/Referenda/useVotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ function filterEvents (records: EventRecord[], _: ApiPromise, id?: BN): Changes<

function useVotesImpl (palletVote: PalletVote, id: BN, isConvictionVote: boolean): Record<string, PalletRankedCollectiveVoteRecord> | undefined {
const { api } = useApi();
const startAccounts = useMapKeys(isConvictionVote === false && api.query[palletVote].voting, [id], OPT_ACCOUNTID);

// After v1.4.0 runtime upgrade, Relay chains i.e. Kusama and Polkadot, or other parachains chains, replaced `voting` method with `votingFor`.
// Adding a safety check here so that app doesn't break
const query = useMemo(() => api.query[palletVote].voting ?? api.query[palletVote].votingFor, [api.query, palletVote]);

const startAccounts = useMapKeys(isConvictionVote === false && query, [id], OPT_ACCOUNTID);
const allAccounts = useEventChanges([
api.events[palletVote].Voted
], filterEvents, startAccounts, id);
Expand All @@ -54,7 +59,7 @@ function useVotesImpl (palletVote: PalletVote, id: BN, isConvictionVote: boolean
[allAccounts, id]
);

return useCall(params && api.query[palletVote].voting.multi, [params], OPT_VOTES);
return useCall(params && query?.multi, [params], OPT_VOTES);
}

export default createNamedHook('useVotes', useVotesImpl);
0