Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[feature request] Add voting hooks #14559

Open
2 tasks done
enthusiastmartin opened this issue Jul 12, 2023 · 0 comments
Open
2 tasks done

[feature request] Add voting hooks #14559

enthusiastmartin opened this issue Jul 12, 2023 · 0 comments
Labels
J0-enhancement An additional feature request. J2-unconfirmed Issue might be valid, but it’s not yet known.

Comments

@enthusiastmartin
Copy link

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Motivation

We, in HydraDX, would need to execute additional custom logic when referendum vote is added or removed.

Currently, there does not seem to be a way where we can easily add a hook which would execute when a vote is added or removed.

Request

We would like to propose adding hooks into “old” democracy pallet as well as to conviction-voting pallet.

We can easily prepare a PR with such change, but i figured i would open an issue first to discuss if this is something that can be added and/or hear anything against it.

Solution

We would imagine having a trait similar to this one:

pub trait VotingHooks<AccountId, Balance> {
	fn on_vote(who: &AccountId, ref_index: ReferendumIndex, vote: AccountVote<Balance>) -> DispatchResult;
	fn on_remove_vote(who: &AccountId, ref_index: ReferendumIndex) -> DispatchResult;
}

// Pallet's Config

/// Hooks are actions that are executed on certain events - on_vote, on_remove_vote
type VotingHooks: VotingHooks<Self::AccountId, BalanceOf<Self>>;

The hooks would be executed in try_vote and try_remove_vote.

Perhaps , ReferendumIndex would need to be generic as well, to have only one trait used in both democracy pallet and conviction-voting pallet.

Regarding benchmarking and weights - special trait functions can be added to prepare worst case scenario.

Are you willing to help with this request?

Yes!

@enthusiastmartin enthusiastmartin added the J0-enhancement An additional feature request. label Jul 12, 2023
@github-actions github-actions bot added the J2-unconfirmed Issue might be valid, but it’s not yet known. label Jul 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. J2-unconfirmed Issue might be valid, but it’s not yet known.
Projects
None yet
Development

No branches or pull requests

1 participant