pub fn execute_migrations(
    deps: DepsMut,
    info: MessageInfo,
    env: Env,
    migrations: Vec<(String, u64, Binary)>,
) -> Result<Response, ContractError> {
    let config: Config = CONFIG.load(deps.storage)?;
    let sender_raw: CanonicalAddr = deps.api.addr_canonicalize(info.sender.as_str())?;

    if sender_raw != config.owner {
        return Err(ContractError::Unauthorized {});
    }

    let mut migration_msgs: Vec<CosmosMsg> = vec![];
    let mut migrations_raw: Vec<(CanonicalAddr, u64, Binary)> = vec![];

    for migration in migrations.iter() {
        migration_msgs.push(CosmosMsg::Wasm(WasmMsg::Migrate {
            contract_addr: migration.0.to_string(),
            new_code_id: migration.1,
            msg: migration.2.clone(),
        }));

        let contract_addr_raw: CanonicalAddr = deps.api.addr_canonicalize(migration.0.as_str())?;
        migrations_raw.push((contract_addr_raw, migration.1, migration.2.clone()));
    }

    let migration_record = MigrationRecord {
        executor: sender_raw,
        time: env.block.time.seconds(),
        migrations: migrations_raw,
    };
    MIGRATION_RECORDS_BY_TIME.save(
        deps.storage,
        env.block.time.seconds().into(),
        &migration_record,
    )?;

    Ok(Response::new()
        .add_messages(migration_msgs)
        .add_attribute("action", "execute_migrations"))
}
/// Owner (gov contract) can execute_migrations on any of the managed contracts, creating a migration_record
Owner (gov contract) can execute_migrations on any of the managed contracts, creating a migration_record
Owner ( gov contract ) can execute_migrations on any of the managed contracts creating a migration_record
pub fn execute_migrations(
    deps: DepsMut,
    info: MessageInfo,
    env: Env,
    migrations: Vec<(String, u64, Binary)>,
) -> Result<Response, ContractError> {
    let config: Config = CONFIG.load(deps.storage)?;
    let sender_raw: CanonicalAddr = deps.api.addr_canonicalize(info.sender.as_str())?;
    if sender_raw != config.owner {
        return Err(ContractError::Unauthorized {});
    }
    let mut migration_msgs: Vec<CosmosMsg> = vec![];
    let mut migrations_raw: Vec<(CanonicalAddr, u64, Binary)> = vec![];
    for migration in migrations.iter() {
        migration_msgs.push(CosmosMsg::Wasm(WasmMsg::Migrate {
            contract_addr: migration.0.to_string(),
            new_code_id: migration.1,
            msg: migration.2.clone(),
        }));
        let contract_addr_raw: CanonicalAddr = deps.api.addr_canonicalize(migration.0.as_str())?;
        migrations_raw.push((contract_addr_raw, migration.1, migration.2.clone()));
    }
    let migration_record = MigrationRecord {
        executor: sender_raw,
        time: env.block.time.seconds(),
        migrations: migrations_raw,
    };
    MIGRATION_RECORDS_BY_TIME.save(
        deps.storage,
        env.block.time.seconds().into(),
        &migration_record,
    )?;
    Ok(Response::new()
        .add_messages(migration_msgs)
        .add_attribute("action", "execute_migrations"))
}
pub fn execute_migrations ( deps : DepsMut , info : MessageInfo , env : Env , migrations : Vec < ( String , u64 , Binary ) > , ) -> Result < Response , ContractError > { let config : Config = CONFIG . load ( deps . storage ) ? ; let sender_raw : CanonicalAddr = deps . api . addr_canonicalize ( info . sender . as_str ( ) ) ? ; if sender_raw != config . owner { return Err ( ContractError :: Unauthorized { } ) ; } let mut migration_msgs : Vec < CosmosMsg > = vec ! [ ] ; let mut migrations_raw : Vec < ( CanonicalAddr , u64 , Binary ) > = vec ! [ ] ; for migration in migrations . iter ( ) { migration_msgs . push ( CosmosMsg :: Wasm ( WasmMsg :: Migrate { contract_addr : migration . 0 . to_string ( ) , new_code_id : migration . 1 , msg : migration . 2 . clone ( ) , } ) ) ; let contract_addr_raw : CanonicalAddr = deps . api . addr_canonicalize ( migration . 0 . as_str ( ) ) ? ; migrations_raw . push ( ( contract_addr_raw , migration . 1 , migration . 2 . clone ( ) ) ) ; } let migration_record = MigrationRecord { executor : sender_raw , time : env . block . time . seconds ( ) , migrations : migrations_raw , } ; MIGRATION_RECORDS_BY_TIME . save ( deps . storage , env . block . time . seconds ( ) . into ( ) , & migration_record , ) ? ; Ok ( Response :: new ( ) . add_messages ( migration_msgs ) . add_attribute ( " " , " " ) ) }
Owner (gov contract) can execute_migrations on any of the managed contracts, creating a migration_record
Owner ( gov contract ) can execute_migrations on any of the managed contracts creating a migration_record
deps
DepsMut
info
MessageInfo
env
Env
migrations
Vec<(String, u64, Binary)>
deps
DepsMut
info
MessageInfo
env
Env
migrations
Vec<(String, u64, Binary)>