-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MockApi's addr_humanize incompatible with instantiate2_address #1648
Comments
Just changing the length won't work, since we don't always get valid utf8 from the bech32 data. So, we would have to do some kind of different encoding that covers string input (to allow addresses like "alice"), but that also decodes the bech32 data (not necessarily to the real bech32 human readable version, but some valid string) One option would be to just try to encode bech32 in One thing to keep in mind is that with this kind of special handling, they won't be inverse functions anymore (at least for the addr from |
See also CosmWasm/cw-multi-test#39. Removing this from the milestone for now since it is unclear how to best solve it. |
This is a workaround I use in one project (https://github.com/noislabs/nois-contracts/blob/v0.15.1/contracts/nois-gateway/src/contract.rs#L272-L283): #[allow(unused)]
let address = instantiate2_address(&checksum, &creator, &salt)
.map_err(|e| StdError::generic_err(format!("Cound not generate address: {}", e)))?;
let address = {
#[cfg(not(test))]
{
deps.api.addr_humanize(&address)?
}
#[cfg(test)]
cosmwasm_std::Addr::unchecked("some payment address")
}; The idea is pretty much that in the test case, instantiate2_address+addr_humanize does not work together. So we don't use |
instantiate2_address
returns aCanonicalAddr
of 32 bytes. However, this check prevents the use ofIn the virus contract we already have this pattern. However, it is not unit tested there, so this was missed.
The text was updated successfully, but these errors were encountered: