Skip to content

Conversation

@mnaamani
Copy link
Member

@mnaamani mnaamani commented Mar 27, 2020

Implements #242 and #244

  • Adding a mint to the council, initialized at genesis
  • Migration step at runtime upgrade to create the council mint
  • root dispatchable methods for proposal
    • spend_from_council_mint() - fails if no mint exists
    • set_council_mint_capacity() - creates mint if it doesn't exist

// Initializes a new mint
pub fn create_new_council_mint() -> T::MintId {
let mint_id = <minting::Module<T>>::add_mint(minting::BalanceOf::<T>::zero(), None)
.expect("Failed to create a mint for the council");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not happy with panic in the runtime. Can we put mint only on successful creation and during the setting mint parameters - introduce another "ensure_*"? check on whether mint actually exist?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a fair point. I originally had this expect() inside the build() method before refactoring, where it was okay to panic while constructing genesis.

Given that add_mint can fail and we call it in the migration, I will have to make the mint an Option<MintId>

Let me revise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to make the mint an Option so it doesn't need to be created at genesis and we can avoid panic. The mint can be automatically created when setting capacity if it doesn't exist.

// ...

// Create the Council mint. If it fails, we can't do anything about it here.
let _ = governance::council::Module::<T>::create_new_council_mint(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agreed to print an error message in such cases. Don't we?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a6148b9

@shamil-gadelshin
Copy link
Contributor

Single error message comment. Will be fixed later.

LGTM

@shamil-gadelshin shamil-gadelshin merged commit da0f4f4 into Joystream:development Mar 30, 2020
@mnaamani mnaamani deleted the council-mint branch May 21, 2020 16:20
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.

2 participants