// ANCHOR: impl_into use cw_orch::interface; use cw_orch::prelude::*; // An execute message that is generic. #[cosmwasm_schema::cw_serde] pub enum GenericExecuteMsg { Generic(T), Nested(NestedMessageType), } // This is the message that will be used on our contract type ExecuteMsg = GenericExecuteMsg; #[cosmwasm_schema::cw_serde] #[derive(cw_orch::ExecuteFns)] #[impl_into(ExecuteMsg)] pub enum Foo { Bar { a: String }, } impl From for ExecuteMsg { fn from(msg: Foo) -> Self { ExecuteMsg::Generic(msg) } } #[cosmwasm_schema::cw_serde] #[derive(cw_orch::ExecuteFns)] #[impl_into(ExecuteMsg)] pub enum NestedMessageType { Test { b: u64 }, } impl From for ExecuteMsg { fn from(msg: NestedMessageType) -> Self { ExecuteMsg::Nested(msg) } } #[interface(Empty, ExecuteMsg, Empty, Empty)] struct Example; impl Example { pub fn test_macro(&self) { // function `bar` is available because of the `impl_into` attribute! self.bar("hello".to_string()).unwrap(); // function `test` is available because of the `impl_into` attribute! self.test(65).unwrap(); } } // ANCHOR_END: impl_into