Skip to content

Add optional executor restriction to cw3-flex#741

Merged
ethanfrey merged 5 commits intomainfrom
739-add-optional-executor-to-cw3-flex
Jun 19, 2022
Merged

Add optional executor restriction to cw3-flex#741
ethanfrey merged 5 commits intomainfrom
739-add-optional-executor-to-cw3-flex

Conversation

@ueco-jb
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

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
Copy Markdown
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?

pub group_addr: Cw4Contract,
// who is able to execute passed proposals
// None means that anyone can execute
pub executor: Option<Executor>,
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice

pub executor: Option<Executor>,
}

impl Config {
Copy link
Copy Markdown
Contributor

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