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

Provide StateUtils in with_state and with_mut_state #5

Open
mustermeiszer opened this issue Feb 11, 2022 · 0 comments
Open

Provide StateUtils in with_state and with_mut_state #5

mustermeiszer opened this issue Feb 11, 2022 · 0 comments
Labels
I8-enhancement An additional feature. P2-nice-to-have Issue is worth doing.

Comments

@mustermeiszer
Copy link
Collaborator

mustermeiszer commented Feb 11, 2022

Currently, the with_state and with_mut_state simply execute the given closure in an externalities
provided environment.

It would be nice if the buider would pas a StateUtils struct to the closure. The StateUtils should provide some interface like:

impl StateUtils {
   // Executes an extrinsic or maybe just a Call enum variant  in the wasm environment. 
   pub fn exec_wasm(&self, Block::Extrinsic) -> Result;
   
   // Get the block this state is build upon
   pub fn block(&self) -> Block;
   
   // Maybe expose the API to the runtime to the closure, maybe something that allows actually working with the api
   pub fn API(&self) -> RuntimeAPi;
  
}

Implementation Idea

As the runtime API of the chains differ and need different trait bounds providing such an API statically via the builders is impossible.
Probably the best approach would be to have a trait StateUtils<API> that each builder takes. The struct StateUtils implements this trait.
But via the generic API chains can introduce additional trait bounds for the API that are checked during compilation.

@mustermeiszer mustermeiszer added I8-enhancement An additional feature. P0-someday-maybe Issue might be worth doing someday. labels Mar 2, 2022
@mustermeiszer mustermeiszer added P2-nice-to-have Issue is worth doing. and removed P0-someday-maybe Issue might be worth doing someday. labels Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I8-enhancement An additional feature. P2-nice-to-have Issue is worth doing.
Projects
None yet
Development

No branches or pull requests

1 participant