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

Parse enum structs #2

Merged
merged 5 commits into from
Oct 26, 2019
Merged

Parse enum structs #2

merged 5 commits into from
Oct 26, 2019

Conversation

ethanfrey
Copy link
Member

This adds support for serializing and deserializing more complex structs as I use in my app. This does add some code-size unfortunately, but gives us the full expressiveness of serde-json.

It let's us handle structs like this:

pub enum ContractResult {
    Ok(Response),
    Err(String),
}

#[derive(Serialize, Deserialize, Default)]
pub struct Response {
    pub messages: Vec<CosmosMsg>,
    pub log: Option<String>,
    pub data: Option<String>,
}

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum CosmosMsg {
    Send {
        from_address: String,
        to_address: String,
        amount: Vec<Coin>,
    },
    Contract {
        contract_addr: String,
        msg: String,
    },
    Opaque {
        data: String,
    },
}

@ethanfrey ethanfrey added this to In progress in CosmWasm development via automation Oct 26, 2019
@ethanfrey ethanfrey merged commit d02fac7 into master Oct 26, 2019
CosmWasm development automation moved this from In progress to Done Oct 26, 2019
@ethanfrey ethanfrey deleted the parse-enum-structs branch October 26, 2019 22:11
@ethanfrey ethanfrey removed this from Done in CosmWasm development Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant