Skip to content

Commit

Permalink
Introducing remove_accounts trusted call (#3156)
Browse files Browse the repository at this point in the history
* removing invalid comment

* adding remove_accounts trusted_call

* adding remove_accounts trusted_call handler

* small refactoring

* fixing build

* adding missing import

* Update trusted_call.rs

Signed-off-by: Francisco Silva <franjs.francisco@gmail.com>

* using dispatch_as_omni_account

* fixing fmt

---------

Signed-off-by: Francisco Silva <franjs.francisco@gmail.com>
  • Loading branch information
silva-fj authored Nov 4, 2024
1 parent 9d797a5 commit 7848038
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
2 changes: 0 additions & 2 deletions parachain/pallets/omni-account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ pub mod pallet {
let who = T::OmniAccountOrigin::ensure_origin(origin)?;
ensure!(!member_account_hashes.is_empty(), Error::<T>::EmptyAccount);

// TODO: shall we verify if MemberAccountHash's value is actually `who`?

let mut member_accounts =
AccountStore::<T>::get(&who).ok_or(Error::<T>::UnknownAccountStore)?;

Expand Down
8 changes: 8 additions & 0 deletions tee-worker/identity/app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ pub enum TrustedCall {
request_intent(Identity, Intent),
#[codec(index = 27)]
create_account_store(Identity),
#[codec(index = 29)]
remove_accounts(Identity, Vec<Identity>),

// original integritee trusted calls, starting from index 50
#[codec(index = 50)]
Expand Down Expand Up @@ -235,6 +237,7 @@ impl TrustedCall {
Self::clean_id_graphs(sender_identity) => sender_identity,
Self::request_intent(sender_identity, ..) => sender_identity,
Self::create_account_store(sender_identity) => sender_identity,
Self::remove_accounts(sender_identity, ..) => sender_identity,
}
}

Expand All @@ -250,6 +253,7 @@ impl TrustedCall {
Self::maybe_create_id_graph(..) => "maybe_create_id_graph",
Self::request_intent(..) => "request_intent",
Self::create_account_store(..) => "create_account_store",
Self::remove_accounts(..) => "remove_account",
_ => "unsupported_trusted_call",
}
}
Expand Down Expand Up @@ -912,6 +916,10 @@ where
error!("please use author_submitNativeRequest instead");
Ok(TrustedCallResult::Empty)
},
TrustedCall::remove_accounts(..) => {
error!("please use author_submitNativeRequest instead");
Ok(TrustedCallResult::Empty)
},
}
}

Expand Down
23 changes: 15 additions & 8 deletions tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use std::{
Arc,
},
thread,
vec::Vec,
};

// TODO: move to config
Expand Down Expand Up @@ -224,16 +225,22 @@ fn handle_trusted_call<
)),
),
},
TrustedCall::create_account_store(who) => {
let create_account_store_call = OpaqueCall::from_tuple(&compose_call!(
TrustedCall::create_account_store(who) => OpaqueCall::from_tuple(&compose_call!(
&metadata,
"OmniAccount",
"create_account_store",
who
)),
TrustedCall::remove_accounts(who, identities) => create_dispatch_as_omni_account_call(
who.hash(),
OpaqueCall::from_tuple(&compose_call!(
&metadata,
"OmniAccount",
"create_account_store",
who
));

create_account_store_call
},
"remove_accounts",
who,
identities.iter().map(|i| i.hash()).collect::<Vec<H256>>()
)),
),
_ => {
log::warn!("Received unsupported call: {:?}", call);
let res: Result<(), NativeTaskError> =
Expand Down

0 comments on commit 7848038

Please sign in to comment.