@@ -50,44 +50,29 @@ pub fn instantiate(
50
50
51
51
#[ cw_serde]
52
52
pub struct MigrateMsg {
53
- /// Update admins of these contracts to the `new_admin`
54
- pub cw20_contracts : Vec < cosmwasm_std:: Addr > ,
53
+ /// Update the admin for all *new* cw20 token contracts.
54
+ #[ serde( default ) ]
55
+ pub new_admin : Option < cosmwasm_std:: Addr > ,
55
56
56
- /// BE VERY CATIOUS WITH WHO TO BE THE ADMIN
57
- pub new_admin : cosmwasm_std:: Addr ,
58
-
59
- /// New cw20 code id that we are gonna migrate all `cw2_contracts`
60
- pub new_cw20_code_id : u64 ,
57
+ /// New code id to store for all *new* cw20 token contracts.
58
+ #[ serde( default ) ]
59
+ pub new_cw20_code_id : Option < u64 > ,
61
60
}
62
61
63
62
#[ entry_point]
64
63
pub fn migrate ( deps : DepsMut , _: Env , msg : MigrateMsg ) -> StdResult < Response > {
65
- // Save the admin for the future instantiates
66
- CW20_ADMIN . save ( deps. storage , & msg. new_admin ) ?;
67
-
68
- CONFIG . update :: < _ , cosmwasm_std:: StdError > ( deps. storage , |mut c| {
69
- c. cw20_base_code_id = msg. new_cw20_code_id ;
70
- Ok ( c)
71
- } ) ?;
64
+ if let Some ( new_admin) = msg. new_admin {
65
+ CW20_ADMIN . save ( deps. storage , & new_admin) ?;
66
+ }
72
67
73
- // let migrate_msg = to_json_binary(&UpgradeMsg::<Empty, _>::Migrate(Empty {}))?;
68
+ if let Some ( new_cw20_code_id) = msg. new_cw20_code_id {
69
+ CONFIG . update :: < _ , cosmwasm_std:: StdError > ( deps. storage , |mut c| {
70
+ c. cw20_base_code_id = new_cw20_code_id;
71
+ Ok ( c)
72
+ } ) ?;
73
+ }
74
74
75
- // Update all the owned cw20s
76
- Ok (
77
- Response :: new ( ) . add_messages ( msg. cw20_contracts . into_iter ( ) . flat_map ( |contract| {
78
- [
79
- // WasmMsg::Migrate {
80
- // contract_addr: contract.to_string(),
81
- // new_code_id: msg.new_cw20_code_id,
82
- // msg: migrate_msg.clone(),
83
- // },
84
- WasmMsg :: UpdateAdmin {
85
- contract_addr : contract. to_string ( ) ,
86
- admin : msg. new_admin . to_string ( ) ,
87
- } ,
88
- ]
89
- } ) ) ,
90
- )
75
+ Ok ( Response :: new ( ) )
91
76
}
92
77
93
78
#[ entry_point]
0 commit comments