Skip to content
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

Add dynamic BurnParameters for Kusama Treasury #511

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

pandres95
Copy link
Contributor

@pandres95 pandres95 commented Dec 17, 2024

This Pull Request resolves the signal raised by the Kusama Ref. #437, setting both Burn and BurnDestination parameters in Kusama's pallet-treasury as a structure (both of them need to be set to prevent some unwanted behaviour) that can be parametrized via OpenGov.

Default (when set to None) configuration behaves like what's already out there: 0%, no account.

  • Does not require a CHANGELOG entry

@pandres95 pandres95 force-pushed the kusama-treasury-burn-parameters branch from bc40137 to db30521 Compare December 17, 2024 02:28
@pandres95 pandres95 mentioned this pull request Jan 7, 2025
6 tasks
Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

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

@pandres95 can you please add some tests?

…eparate values, to be more ergonomic with `set_parameters` usage.

Note: while `BurnDestinationAccount` is not as ergonomic since it comprises of an `Option<AccountId>` value, it's more ergonomic than comparing against an arbitrary `AccountId::from([0u8; 32])`.

Note 2: The `BurnDestinationAccount` wrapper is unfortunately necessary, as explicitly stating `AccountId` failed. Need to report an issue on PSDK about this.
@pandres95 pandres95 force-pushed the kusama-treasury-burn-parameters branch from 0f10245 to d24ea09 Compare January 14, 2025 05:13
@pandres95 pandres95 requested a review from acatangiu January 14, 2025 05:14
@pandres95
Copy link
Contributor Author

@acatangiu tests are ready

Comment on lines 874 to 876
let account = account.0.expect("given `account.0.is_some`; qed");
// Must resolve into existing but better to be safe.
Balances::resolve_creating(&account, amount);
Copy link
Contributor

Choose a reason for hiding this comment

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

you can refactor to avoid the expect:

Suggested change
let account = account.0.expect("given `account.0.is_some`; qed");
// Must resolve into existing but better to be safe.
Balances::resolve_creating(&account, amount);
if let Some(account) = account.0.as_ref() {
// Must resolve into existing but better to be safe.
Balances::resolve_creating(account, amount);
}

no need for else branch since you know it will always be Some

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