11use anyhow:: { Context , Result } ;
22use cosmos:: {
3- proto:: cosmos:: bank:: v1beta1:: MsgSend , Address , ContractAdmin , Cosmos , HasAddress ,
4- HasAddressHrp , ParsedCoin , TxBuilder ,
3+ proto:: cosmos:: bank:: v1beta1:: MsgSend , Address , ContractAdmin , ContractType , Cosmos ,
4+ HasAddress , HasAddressHrp , ParsedCoin , TxBuilder ,
55} ;
66use cosmwasm_std:: { to_json_binary, CosmosMsg , Decimal , Empty , WasmMsg } ;
77use cw3:: { ProposalListResponse , ProposalResponse } ;
@@ -10,30 +10,6 @@ use cw_utils::Threshold;
1010
1111use crate :: { cli:: TxOpt , my_duration:: MyDuration } ;
1212
13- #[ derive( Clone , Copy , Debug ) ]
14- enum ContractType {
15- Cw3Flex ,
16- Cw4Group ,
17- }
18-
19- fn get_code_id ( chain_id : & str , contract_type : ContractType ) -> Result < u64 > {
20- match ( chain_id, contract_type) {
21- ( "osmo-test-5" , ContractType :: Cw3Flex ) => Ok ( 1519 ) ,
22- ( "osmo-test-5" , ContractType :: Cw4Group ) => Ok ( 1521 ) ,
23- ( "osmosis-1" , ContractType :: Cw3Flex ) => Ok ( 100 ) ,
24- ( "osmosis-1" , ContractType :: Cw4Group ) => Ok ( 101 ) ,
25- ( "pacific-1" , ContractType :: Cw3Flex ) => Ok ( 46 ) ,
26- ( "pacific-1" , ContractType :: Cw4Group ) => Ok ( 47 ) ,
27- ( "injective-1" , ContractType :: Cw3Flex ) => Ok ( 124 ) ,
28- ( "injective-1" , ContractType :: Cw4Group ) => Ok ( 125 ) ,
29- ( "neutron-1" , ContractType :: Cw3Flex ) => Ok ( 1189 ) ,
30- ( "neutron-1" , ContractType :: Cw4Group ) => Ok ( 1190 ) ,
31- _ => Err ( anyhow:: anyhow!(
32- "No code ID found for combo {chain_id}/{contract_type:?}"
33- ) ) ,
34- }
35- }
36-
3713#[ derive( clap:: Parser ) ]
3814pub ( crate ) struct Opt {
3915 #[ clap( subcommand) ]
@@ -124,6 +100,12 @@ struct NewFlexOpt {
124100 /// Duration. Accepts s, m, h, and d suffixes for seconds, minutes, hours, and days
125101 #[ clap( long) ]
126102 duration : MyDuration ,
103+ /// Code ID for the CW3 flex contract
104+ #[ clap( long) ]
105+ cw3_flex_code_id : Option < u64 > ,
106+ /// Code ID for the CW4 group contract
107+ #[ clap( long) ]
108+ cw4_group_code_id : Option < u64 > ,
127109}
128110
129111async fn new_flex (
@@ -135,12 +117,17 @@ async fn new_flex(
135117 cw4_label,
136118 weight_needed,
137119 duration,
120+ cw3_flex_code_id,
121+ cw4_group_code_id,
138122 } : NewFlexOpt ,
139123) -> Result < ( ) > {
140- let chain_id = cosmos. get_cosmos_builder ( ) . chain_id ( ) ;
141124 let wallet = tx_opt. get_wallet ( cosmos. get_address_hrp ( ) ) ?;
142- let cw3 = cosmos. make_code_id ( get_code_id ( chain_id, ContractType :: Cw3Flex ) ?) ;
143- let cw4 = cosmos. make_code_id ( get_code_id ( chain_id, ContractType :: Cw4Group ) ?) ;
125+ let cw3 = cosmos. make_code_id (
126+ cw3_flex_code_id. map_or_else ( || cosmos. get_code_id_for ( ContractType :: Cw3Flex ) , Ok ) ?,
127+ ) ;
128+ let cw4 = cosmos. make_code_id (
129+ cw4_group_code_id. map_or_else ( || cosmos. get_code_id_for ( ContractType :: Cw4Group ) , Ok ) ?,
130+ ) ;
144131
145132 anyhow:: ensure!( !members. is_empty( ) , "Must provide at least one member" ) ;
146133
0 commit comments