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

Create high level object save trait for all Requests #41

Open
0xForerunner opened this issue Feb 28, 2023 · 1 comment
Open

Create high level object save trait for all Requests #41

0xForerunner opened this issue Feb 28, 2023 · 1 comment

Comments

@0xForerunner
Copy link
Contributor

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>

@de-husk
Copy link
Owner

de-husk commented May 5, 2023

Great point! It would be really cool to be able to batch different operation types under the same transaction.

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

No branches or pull requests

2 participants