-
Notifications
You must be signed in to change notification settings - Fork 355
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
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
#[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>, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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)?; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
closes #739
Test are bloated, but all of them are... Some proper refactoring would be useful here.