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

Separate trusted calls/getters from rest. #36

Open
clangenb opened this issue Jan 24, 2023 · 0 comments
Open

Separate trusted calls/getters from rest. #36

clangenb opened this issue Jan 24, 2023 · 0 comments

Comments

@clangenb
Copy link
Member

clangenb commented Jan 24, 2023

I would like that the app-lib/stf part is touched as little as possible when we add our encointer stuff. This refactoring is the step related to the bigger refactoring in #35. Example for the trusted call below:

// in app-libs
enum TrustedCall {
      ...
      Encointer(EncointerTrustedCall)
}


impl TrustedCall {
     pub fn account(&self) -> AccountId {
          match self {
            ...
            Encointer(call) => call.acount()
        }
     }  
}

impl ExecuteCall for TrustedCall {
     pub fn execute(&self) -> AccountId {
          match self {
            ...
            Encointer(call) => call.execute()
        }
     } 

    pub fn get_storage_hashes_to_update(&self) -> AccountId {
          match self {
            ...
            Encointer(call) => call.get_storage_hashes_to_update()
        }
     }  
}
// in encointer/stf
enum EncointerTrustedCall{
      ...
      ceremonies_register_participant(...)
}


impl EncointerTrustedCall{
     pub fn account(&self) -> AccountId {
          match self {
            ...
            ceremonies_register_participant(...) => account,
        }
     }  
}

impl ExecuteCall for EncointerTrustedCall{
     pub fn execute(&self) -> AccountId {
          match self {
            ...
            ceremonies_register_participant(...) => // do stuff...
        }
     }  

    pub fn get_storage_hashes_to_update(&self) -> AccountId {
          match self {
            ...
             ceremonies_register_participant(...)  => // do stuff...
        }
     }  
}

The cool thing about this, is that for every encointer specific behaviour in stf, we only add exactly one line into the app-libs/stf crate, which makes upstream merges much easier.

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

1 participant