CosmWasm / cw-plus

Production Quality contracts under open source licenses
Apache License 2.0
504 stars 353 forks source link

Issue in providing cw4_stake.wasm contract values for initiating #878

Closed golnarmordadi closed 1 year ago

golnarmordadi commented 1 year ago

Hi, I'm facing with issue for prepare denom for initiating cw4_stake.wasm contract?

These are properties which are need for initiaing:

pub struct InstantiateMsg {
    /// denom of the token to stake
    pub denom: Denom,
    pub tokens_per_weight: Uint128,
    pub min_bond: Uint128,
    pub unbonding_period: Duration,
}

I've provided blow INIT but I'm getting error for providing denom value.

INIT='{"denom":"native","tokens_per_weight":1,"min_bond":1,"unbonding_period":{"time":3600}}'

My denum is udmotus but when I use it I get error as well.

Error: Error: rpc error: code = InvalidArgument desc = failed to execute message; message index: 0: Error parsing into type cw4_stake::msg::InstantiateMsg: Invalid type: instantiate wasm contract failed: invalid request

ueco-jb commented 1 year ago

Your both Denom and Uitn128 type usage is incorrect. If you want to see how it supposed to be used, generate schema for that contract and pay attention to the types. Correct form would be:

{
   "denom": {
      "native": "ujuno"
   },
   "tokens_per_weight": "1",
   "min_bond": "1",
   "unbonding_period": {
      "time": 3600
   }
}

Also, next time please just questions on discord instead of creating an issue: https://discord.gg/b28Q7EvNGY

golnarmordadi commented 1 year ago

Hi, I changed the denom as you said but still there is an issue: For bellow params:

INIT='{"denom":{"native":"utmotus"},"tokens_per_weight": 1,"min_bond": 1,"unbonding_period":{"time":3600}}'

I'm getting below issue:

Error: rpc error: code = InvalidArgument desc = failed to execute message; message index: 0: Error parsing into type cw4_stake::msg::InstantiateMsg: Invalid type: instantiate wasm contract failed: invalid request

ueco-jb commented 1 year ago

Because Uint128 is parsed from String. You're missing quotation marks next to min_bond and tokens_per_weight.

golnarmordadi commented 1 year ago

Yea, I see types in this link and they are not string, but after settin up those as string, issue fixed. Thank you so much

https://github.com/CosmWasm/cw-plus/blob/dd2ca3dd5558b4a65ca112b2f655ae043d956c20/contracts/cw4-stake/src/msg.rs#L12

I will close this conversation as answered and solved.