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 optional executor restriction to cw3-flex #741

Merged
merged 5 commits into from
Jun 19, 2022

Conversation

ueco-jb
Copy link
Contributor

@ueco-jb ueco-jb commented Jun 18, 2022

closes #739

Test are bloated, but all of them are... Some proper refactoring would be useful here.

@ueco-jb ueco-jb requested a review from ethanfrey June 18, 2022 11:49
@ueco-jb ueco-jb self-assigned this Jun 18, 2022
@ueco-jb ueco-jb removed the request for review from ethanfrey June 18, 2022 11:49
@ueco-jb ueco-jb marked this pull request as ready for review June 18, 2022 11:52
@ueco-jb ueco-jb requested a review from ethanfrey June 18, 2022 11:52
Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

Wow. Thanks for the quick reaction here.

Code looks good. I had an idea how to extend it a bit, left comments on the Executor variant and making the check a method.

The other idea (for a different PR) was to use the same pattern for who can submit a proposal, but have that default to "Member" rather than "Everyone" if the InstantiateMsg has None in the field.

// - None: Anyone can execute message
let cfg = CONFIG.load(deps.storage)?;
if let Some(executor) = cfg.executor {
match executor {
Copy link
Member

Choose a reason for hiding this comment

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

Is this something that could be pulled out to a method on Executor?
Already thinking of reusing it for who can make proposals. (but default is Member)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved it under Config struct. I think it's more versatile this way.
What do you think?

contracts/cw3-flex-multisig/src/contract.rs Show resolved Hide resolved
contracts/cw3-flex-multisig/src/state.rs Show resolved Hide resolved
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct Config {
pub threshold: Threshold,
pub max_voting_period: Duration,
// Total weight and voters are queried from this contract
pub group_addr: Cw4Contract,
// who is able to execute passed proposals
// None means that anyone can execute
pub executor: Option<Executor>,
Copy link
Member

Choose a reason for hiding this comment

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

Disregard the above comment. This is great as it is drop-in state compatible with previous version, not requiring an explicit migration (we should have some placeholder migrate function, but no state change needed). No need to make breaking changes for some aesthetic opinion of mine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I considered that but as you pointed out - this way it's completely backward compatible.

Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

thanks

}
}
}
cfg.authorize(&deps.querier, &info.sender)?;
Copy link
Member

Choose a reason for hiding this comment

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

nice

@@ -26,5 +28,29 @@ pub struct Config {
pub executor: Option<Executor>,
}

impl Config {
Copy link
Member

Choose a reason for hiding this comment

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

looks good

@ethanfrey ethanfrey merged commit 14f4e92 into main Jun 19, 2022
@ethanfrey ethanfrey deleted the 739-add-optional-executor-to-cw3-flex branch June 19, 2022 16:31
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.

Add optional executor restriction to cw3-flex
2 participants