/// Create the initial configuration state and propose the dcc marker.
Create the initial configuration state and propose the dcc marker.
Create the initial configuration state and propose the dcc marker .
pub fn instantiate(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    msg: InitMsg,
) -> Result<Response<ProvenanceMsg>, ContractError> {
    // Validate params
    if !info.funds.is_empty() {
        return Err(contract_err("no funds should be sent during instantiate"));
    }
    if msg.quorum_pct.is_zero() || msg.quorum_pct > Decimal::percent(100) {
        return Err(contract_err("invalid quorum percent"));
    }
    if msg.vote_duration.is_zero() {
        return Err(contract_err("invalid vote duration"));
    }
    // Remove any kyc attribute dups
    let mut kyc_attrs = msg.kyc_attrs;
    kyc_attrs.sort();
    kyc_attrs.dedup();
    // Create and store config state.
    let state = State {
        admin: info.sender.clone(),
        quorum_pct: msg.quorum_pct,
        dcc_denom: msg.dcc_denom.clone(),
        vote_duration: msg.vote_duration,
        kyc_attrs,
        admin_weight: Uint128::zero(),
    };
    config(deps.storage).save(&state)?;
    // Create the dcc marker and grant permissions if it doesn't exist.
    let mut res = Response::new();
    if !marker_exists(deps.as_ref(), &msg.dcc_denom) {
        // If we need to create the marker, validate denom length.
        if msg.dcc_denom.len() < MIN_DENOM_LEN {
            return Err(contract_err("invalid denom length"));
        }
        res = res
            .add_message(create_marker(
                0,
                msg.dcc_denom.clone(),
                MarkerType::Restricted,
            )?)
            .add_message(grant_marker_access(
                &msg.dcc_denom,
                env.contract.address,
                MarkerAccess::all(),
            )?)
            .add_message(grant_marker_access(
                &msg.dcc_denom,
                info.sender,
                vec![MarkerAccess::Admin], // The contract admin is also a dcc marker admin
            )?)
            .add_message(finalize_marker(&msg.dcc_denom)?)
            .add_message(activate_marker(&msg.dcc_denom)?);
    }
    Ok(res)
}
pub fn instantiate ( deps : DepsMut , env : Env , info : MessageInfo , msg : InitMsg , ) -> Result < Response < ProvenanceMsg > , ContractError > { // Validate params if ! info . funds . is_empty ( ) { return Err ( contract_err ( " " ) ) ; } if msg . quorum_pct . is_zero ( ) || msg . quorum_pct > Decimal :: percent ( 100 ) { return Err ( contract_err ( " " ) ) ; } if msg . vote_duration . is_zero ( ) { return Err ( contract_err ( " " ) ) ; } // Remove any kyc attribute dups let mut kyc_attrs = msg . kyc_attrs ; kyc_attrs . sort ( ) ; kyc_attrs . dedup ( ) ; // Create and store config state. let state = State { admin : info . sender . clone ( ) , quorum_pct : msg . quorum_pct , dcc_denom : msg . dcc_denom . clone ( ) , vote_duration : msg . vote_duration , kyc_attrs , admin_weight : Uint128 :: zero ( ) , } ; config ( deps . storage ) . save ( & state ) ? ; // Create the dcc marker and grant permissions if it doesn't exist. let mut res = Response :: new ( ) ; if ! marker_exists ( deps . as_ref ( ) , & msg . dcc_denom ) { // If we need to create the marker, validate denom length. if msg . dcc_denom . len ( ) < MIN_DENOM_LEN { return Err ( contract_err ( " " ) ) ; } res = res . add_message ( create_marker ( 0 , msg . dcc_denom . clone ( ) , MarkerType :: Restricted , ) ? ) . add_message ( grant_marker_access ( & msg . dcc_denom , env . contract . address , MarkerAccess :: all ( ) , ) ? ) . add_message ( grant_marker_access ( & msg . dcc_denom , info . sender , vec ! [ MarkerAccess Admin ] , // The contract admin is also a dcc marker admin ) ? ) . add_message ( finalize_marker ( & msg . dcc_denom ) ? ) . add_message ( activate_marker ( & msg . dcc_denom ) ? ) ; } Ok ( res ) }
Create the initial configuration state and propose the dcc marker.
Create the initial configuration state and propose the dcc marker .
deps
DepsMut
env
Env
info
MessageInfo
msg
InitMsg