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

Execute message derive macro #21

Merged
merged 5 commits into from Nov 29, 2022
Merged

Execute message derive macro #21

merged 5 commits into from Nov 29, 2022

Conversation

CyberHoward
Copy link
Contributor

@CyberHoward CyberHoward commented Nov 23, 2022

📢 Type of change

▫️ Bugfix
▫️ New feature
▫️ Enhancement
▫️ Refactoring
▫️ Maintenance

📜 Description and Motivation

A derive macro that can be added to an ExecuteMsg struct to generate functions that can be called on the associated boot object.

Example:

#[cw_serde]
#[derive(ExecuteFns)]
pub enum ExecuteMsg{
    /// Freeze will make a mutable contract immutable, must be called by an admin
    Freeze {},
    /// UpdateAdmins will change the admin set of the contract, must be called by an existing admin,
    /// and only works if the contract is mutable
    UpdateAdmins { admins: Vec<String> },
    #[payable]
    Deposit {}
}

#[boot_contract(Empty,ExecuteMsg,Empty,Empty)]
struct Cw1

impl<Chain: BootEnvironment + Clone> Cw1<Chain> {
    pub fn test_macro(&self) {
        self.freeze().unwrap();
        self.update_admins(vec![]).unwrap(); 
        self.deposit(&[Coin::new(13,"juno")]).unwrap();
    }
}

🛠️ How to test (if applicable)

📝 Checklist

  • Add flag for coins instead of optionals.

▫️ Reviewed submitted code
▫️ Added tests to verify changes
▫️ Updated docs
▫️ Verified on testnet

@adairrr
Copy link
Contributor

adairrr commented Nov 23, 2022

Woah this is awesome!

@CyberHoward CyberHoward merged commit ab06e20 into main Nov 29, 2022
@CyberHoward CyberHoward deleted the derive-marco branch November 29, 2022 10:53
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.

None yet

2 participants