diff --git a/packages/neutron-test-tube/src/module/adminmodule.rs b/packages/neutron-test-tube/src/module/adminmodule.rs new file mode 100644 index 0000000..f6851a4 --- /dev/null +++ b/packages/neutron-test-tube/src/module/adminmodule.rs @@ -0,0 +1,25 @@ +use neutron_std::types::cosmos::adminmodule::adminmodule::{MsgSubmitProposal, MsgSubmitProposalResponse}; + +use test_tube_ntrn::{fn_execute}; +use test_tube_ntrn::module::Module; +use test_tube_ntrn::runner::Runner; + +pub struct Adminmodule<'a, R: Runner<'a>> { + runner: &'a R, +} + +impl<'a, R: Runner<'a>> Module<'a, R> for Adminmodule<'a, R> { + fn new(runner: &'a R) -> Self { + Self { runner } + } +} + +impl<'a, R> Adminmodule<'a, R> +where + R: Runner<'a>, +{ + fn_execute! { + pub submit_proposal: MsgSubmitProposal ["/cosmos.adminmodule.adminmodule.MsgSubmitProposal"] => MsgSubmitProposalResponse + } + +} diff --git a/packages/neutron-test-tube/src/module/mod.rs b/packages/neutron-test-tube/src/module/mod.rs index 4ca3ca9..4f40907 100644 --- a/packages/neutron-test-tube/src/module/mod.rs +++ b/packages/neutron-test-tube/src/module/mod.rs @@ -6,6 +6,7 @@ mod marketmap; mod oracle; mod tokenfactory; mod wasm; +mod adminmodule; pub use test_tube_ntrn::macros; pub use test_tube_ntrn::module::Module; @@ -17,3 +18,4 @@ pub use marketmap::Marketmap; pub use oracle::Oracle; pub use tokenfactory::TokenFactory; pub use wasm::Wasm; +pub use adminmodule::Adminmodule; diff --git a/packages/neutron-test-tube/src/module/tokenfactory.rs b/packages/neutron-test-tube/src/module/tokenfactory.rs index 2dd0e59..6a67f5d 100644 --- a/packages/neutron-test-tube/src/module/tokenfactory.rs +++ b/packages/neutron-test-tube/src/module/tokenfactory.rs @@ -4,7 +4,7 @@ use neutron_std::types::osmosis::tokenfactory::v1beta1::{ MsgSetDenomMetadataResponse, MsgUpdateParams, MsgUpdateParamsResponse, QueryDenomAuthorityMetadataRequest, QueryDenomAuthorityMetadataResponse, QueryDenomsFromCreatorRequest, QueryDenomsFromCreatorResponse, QueryParamsRequest, - QueryParamsResponse, + QueryParamsResponse }; use test_tube_ntrn::module::Module; @@ -66,14 +66,15 @@ where mod tests { use cosmos_sdk_proto::cosmos::bank::v1beta1::QueryBalanceRequest; use cosmwasm_std::{coins, Coin, Uint128}; - use neutron_std::types::osmosis::tokenfactory::v1beta1::{ - MsgBurn, MsgCreateDenom, MsgMint, MsgUpdateParams, QueryDenomsFromCreatorRequest, - }; - // use neutron_sdk::proto_types::osmosis::tokenfactory::Params as TokenFactoryParams; + use neutron_std::shim::Any; + use neutron_std::types::cosmos::adminmodule::adminmodule::MsgSubmitProposal; + use neutron_std::types::osmosis::tokenfactory::v1beta1::{MsgBurn, MsgCreateDenom, MsgMint, MsgUpdateParams, QueryDenomsFromCreatorRequest}; + use neutron_std::types::osmosis::tokenfactory::Params; + use prost::Message; use test_tube_ntrn::Module; - use crate::{Account, Bank, NeutronTestApp, TokenFactory}; + use crate::{Account, Adminmodule, Bank, NeutronTestApp, TokenFactory}; #[test] fn tokenfactory_integration() { @@ -171,27 +172,42 @@ mod tests { assert_eq!(coin.denom, balance.denom); } - // #[test] - // fn test_set_bank_hook() { - // let app = NeutronTestApp::default(); - // let tf = TokenFactory::new(&app); - // - // let admin = app - // .init_account(&coins(1_000_000_000_000u128, "untrn"), true) - // .unwrap(); - // let adminmodule_addr = "neutron1hxskfdxpp5hqgtjj6am6nkjefhfzj359x0ar3z"; - // tf.update_params( - // MsgUpdateParams { - // authority: adminmodule_addr.to_string(), - // params: Some(TokenFactoryParams { - // denom_creation_fee: vec![], - // denom_creation_gas_consume: 0, - // fee_collector_address: "".to_string(), - // whitelisted_hooks: vec![], - // }), - // }, - // &admin, - // ) - // .unwrap(); - // } + #[test] + fn test_set_bank_hook() { + let app = NeutronTestApp::default(); + let adm = Adminmodule::new(&app); + + // we creating an addr which could send proposals directly + let admin = app + .init_account(&coins(1_000_000_000_000u128, "untrn"), true) + .unwrap(); + // address of admin moule. it is an authority for all modules + let adminmodule_addr = "neutron1hxskfdxpp5hqgtjj6am6nkjefhfzj359x0ar3z"; + // tokenfactory update params + let tfmsg = MsgUpdateParams { + authority: adminmodule_addr.to_string(), + params: Some(Params { + // set proper params & hooks below + denom_creation_fee: vec![], + denom_creation_gas_consume: Some(0), + fee_collector_address: "".to_string(), + whitelisted_hooks: vec![], + }), + }; + + // encode it to Any + let tfmsg_any = Any { + type_url: "/osmosis.tokenfactory.v1beta1.MsgUpdateParams".to_string(), + value: tfmsg.encode_to_vec(), + }; + + // submit as a proposal + let msg = MsgSubmitProposal{messages: vec![tfmsg_any], proposer: admin.address()}; + + adm.submit_proposal( + msg, + &admin, + ) + .unwrap(); + } }