Skip to content

Create high level object save trait for all Requestsย #41

@0xForerunner

Description

@0xForerunner

Something that I find I would like to do often is bundle multiple types of messages together inside a vec and send them off. May want to send a wasm store_code, instantiate, then execute for example. It would be even better if this was inside the same tx. This could be achieved with a trait that look like this:

pub trait Request {
    fn to_any(&self, sender_addr: Address) -> DeployResult<Any>;
}

impl<S> Request for ExecRequest<S>
where
    S: Serialize + Clone + 'static,
{
    fn to_any(&self, sender_addr: Address) -> DeployResult<Any> {
        let proto = self.clone().to_proto(sender_addr)?;
        let any = proto.to_any()?;
        Ok(any)
    }
}

impl<S> Request for StoreCodeRequest<S> {
...
}

Then one could simply pass a vec of these Request objects to an execute function that takes in a Vec<&dyn Request>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions