Skip to content

Conversation

@4meta5
Copy link
Contributor

@4meta5 4meta5 commented Feb 11, 2023

Exposes referendum{Status, Info} in precompiles

We have the following enum for ReferendumInfo:

{
	/// Referendum has been submitted and is being voted on.
	Ongoing(
		ReferendumStatus<
			TrackId,
			RuntimeOrigin,
			Moment,
			Call,
			Balance,
			Tally,
			AccountId,
			ScheduleAddress,
		>,
	),
	/// Referendum finished with approval. Submission deposit is held.
	Approved(Moment, Option<Deposit<AccountId, Balance>>, Option<Deposit<AccountId, Balance>>),
	/// Referendum finished with rejection. Submission deposit is held.
	Rejected(Moment, Option<Deposit<AccountId, Balance>>, Option<Deposit<AccountId, Balance>>),
	/// Referendum finished with cancellation. Submission deposit is held.
	Cancelled(Moment, Option<Deposit<AccountId, Balance>>, Option<Deposit<AccountId, Balance>>),
	/// Referendum finished and was never decided. Submission deposit is held.
	TimedOut(Moment, Option<Deposit<AccountId, Balance>>, Option<Deposit<AccountId, Balance>>),
	/// Referendum finished with a kill.
	Killed(Moment),
}

So we expose this by adding a precompile getter for referendumStatus that tells us which variant the enum is. Then we have 3 more getters for each unique variant structure:

  • ongoing_referendum_info for ReferendumInfo::Ongoing
  • closed_referendum_info for ReferendumInfo::{Approved, Rejected, Cancelled, TimedOut} and returns the ReferendumStatus as well as the inner data
  • killed_referendum_block for ReferendumInfo::Killed

@4meta5 4meta5 added A3-inprogress Pull request is in progress. No review needed at this stage. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit breaking Needs to be mentioned in breaking changes labels Feb 11, 2023
Base automatically changed from upgrade-v0.9.37 to master February 13, 2023 14:54
@librelois librelois mentioned this pull request Feb 20, 2023
19 tasks
@4meta5 4meta5 added A0-pleasereview Pull request needs code review. and removed A3-inprogress Pull request is in progress. No review needed at this stage. labels Feb 20, 2023
@4meta5 4meta5 merged commit 2227d98 into master Feb 21, 2023
@4meta5 4meta5 deleted the amar-referendum-info branch February 21, 2023 15:12
@crystalin crystalin changed the title referendumStatus, referendumInfo Add getters referendumStatus, referendumInfo for referenda precompile Feb 22, 2023
imstar15 pushed a commit to AvaProtocol/moonbeam that referenced this pull request May 16, 2023
* upgrade to v0.9.37

* fix tests

* fix tests, update frontier

* update frontier

* update frontier

* fix batch precompile tests

* fix lint

* fix tests

* add root-testing pallet

* fix length fees test

* fix length fees test

* fix ts tests

* fmt

* fix typo

* fix statemine tests

* fix ts test

* fix tests

* fix test

* change test name

* remove dev_mode, add call_index

* bump

* init

* closed referendum info getter

* make closed referendum info into a struct

* init ongoing referendum info

* everything but schedule address works

* fix schedule address which does implement encode even if it is not transparent

* fix comment

---------

Co-authored-by: Nisheeth Barthwal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-pleasereview Pull request needs code review. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes D3-trivial PR contains trivial changes in a runtime directory that do not require an audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants