Struct cw20_base::msg::InstantiateMsg
source · pub struct InstantiateMsg {
pub name: String,
pub symbol: String,
pub decimals: u8,
pub initial_balances: Vec<Cw20Coin>,
pub mint: Option<MinterResponse>,
pub marketing: Option<InstantiateMarketingInfo>,
}Fields§
§name: String§symbol: String§decimals: u8§initial_balances: Vec<Cw20Coin>§mint: Option<MinterResponse>§marketing: Option<InstantiateMarketingInfo>Implementations§
source§impl InstantiateMsg
impl InstantiateMsg
sourcepub fn get_cap(&self) -> Option<Uint128>
pub fn get_cap(&self) -> Option<Uint128>
Examples found in repository?
src/contract.rs (line 107)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
pub fn instantiate(
mut deps: DepsMut,
_env: Env,
_info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
// check valid token info
msg.validate()?;
// create initial accounts
let total_supply = create_accounts(&mut deps, &msg.initial_balances)?;
if let Some(limit) = msg.get_cap() {
if total_supply > limit {
return Err(StdError::generic_err("Initial supply greater than cap").into());
}
}
let mint = match msg.mint {
Some(m) => Some(MinterData {
minter: deps.api.addr_validate(&m.minter)?,
cap: m.cap,
}),
None => None,
};
// store token info
let data = TokenInfo {
name: msg.name,
symbol: msg.symbol,
decimals: msg.decimals,
total_supply,
mint,
};
TOKEN_INFO.save(deps.storage, &data)?;
if let Some(marketing) = msg.marketing {
let logo = if let Some(logo) = marketing.logo {
verify_logo(&logo)?;
LOGO.save(deps.storage, &logo)?;
match logo {
Logo::Url(url) => Some(LogoInfo::Url(url)),
Logo::Embedded(_) => Some(LogoInfo::Embedded),
}
} else {
None
};
let data = MarketingInfoResponse {
project: marketing.project,
description: marketing.description,
marketing: marketing
.marketing
.map(|addr| deps.api.addr_validate(&addr))
.transpose()?,
logo,
};
MARKETING_INFO.save(deps.storage, &data)?;
}
Ok(Response::default())
}sourcepub fn validate(&self) -> StdResult<()>
pub fn validate(&self) -> StdResult<()>
Examples found in repository?
src/contract.rs (line 103)
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
pub fn instantiate(
mut deps: DepsMut,
_env: Env,
_info: MessageInfo,
msg: InstantiateMsg,
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
// check valid token info
msg.validate()?;
// create initial accounts
let total_supply = create_accounts(&mut deps, &msg.initial_balances)?;
if let Some(limit) = msg.get_cap() {
if total_supply > limit {
return Err(StdError::generic_err("Initial supply greater than cap").into());
}
}
let mint = match msg.mint {
Some(m) => Some(MinterData {
minter: deps.api.addr_validate(&m.minter)?,
cap: m.cap,
}),
None => None,
};
// store token info
let data = TokenInfo {
name: msg.name,
symbol: msg.symbol,
decimals: msg.decimals,
total_supply,
mint,
};
TOKEN_INFO.save(deps.storage, &data)?;
if let Some(marketing) = msg.marketing {
let logo = if let Some(logo) = marketing.logo {
verify_logo(&logo)?;
LOGO.save(deps.storage, &logo)?;
match logo {
Logo::Url(url) => Some(LogoInfo::Url(url)),
Logo::Embedded(_) => Some(LogoInfo::Embedded),
}
} else {
None
};
let data = MarketingInfoResponse {
project: marketing.project,
description: marketing.description,
marketing: marketing
.marketing
.map(|addr| deps.api.addr_validate(&addr))
.transpose()?,
logo,
};
MARKETING_INFO.save(deps.storage, &data)?;
}
Ok(Response::default())
}Trait Implementations§
source§impl Clone for InstantiateMsg
impl Clone for InstantiateMsg
source§fn clone(&self) -> InstantiateMsg
fn clone(&self) -> InstantiateMsg
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for InstantiateMsg
impl Debug for InstantiateMsg
source§impl<'de> Deserialize<'de> for InstantiateMsg
impl<'de> Deserialize<'de> for InstantiateMsg
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl JsonSchema for InstantiateMsg
impl JsonSchema for InstantiateMsg
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moresource§impl PartialEq<InstantiateMsg> for InstantiateMsg
impl PartialEq<InstantiateMsg> for InstantiateMsg
source§fn eq(&self, other: &InstantiateMsg) -> bool
fn eq(&self, other: &InstantiateMsg) -> bool
This method tests for
self and other values to be equal, and is used
by ==.