Skip to content
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

Sudo over no new_with_sudo contract wrapper error message #278

Closed
maurolacy opened this issue Apr 19, 2021 · 2 comments · Fixed by #279
Closed

Sudo over no new_with_sudo contract wrapper error message #278

maurolacy opened this issue Apr 19, 2021 · 2 comments · Fixed by #279
Milestone

Comments

@maurolacy
Copy link
Contributor

maurolacy commented Apr 19, 2021

In the multi-test context, to send the Sudo message to a contract requires creating the contract wrapper with new_with_sudo.
This is obvious, but when you forget to do it, the resulting error message is not clear / obvious at all:

`Result::unwrap()` on an `Err` value: "Error parsing into type alloc::string::String: Invalid type"

Consider improving on the error message, so a contract / test writer has a better grasp on what's failing when forgetting / not knowing about new_with_sudo.

@ethanfrey
Copy link
Member

I agree with a better error message here.

@ethanfrey ethanfrey added this to the 0.6.0 milestone Apr 19, 2021
@ethanfrey
Copy link
Member

Huh, I did leave an error message:

    // this returns an error if the contract doesn't implement sudo
    fn sudo(&self, deps: DepsMut, env: Env, msg: Vec<u8>) -> Result<Response<C>, String> {
        let msg: T4 = from_slice(&msg).map_err(|e| e.to_string())?;
        let res = match &self.sudo_fn {
            Some(sudo) => sudo(deps, env, msg),
            None => return Err("sudo not implemented for contract".to_string()),
        };
        res.map_err(|e| e.to_string())
    }

Ah, it seems T4 is String, which doesn't let us parse in. I guess we should use {} or such

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants