From 7848038f876437ffb76aa6c3f0fc8fe50cb95bb1 Mon Sep 17 00:00:00 2001 From: Francisco Silva Date: Mon, 4 Nov 2024 15:23:52 +0100 Subject: [PATCH] Introducing remove_accounts trusted call (#3156) * 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 * using dispatch_as_omni_account * fixing fmt --------- Signed-off-by: Francisco Silva --- parachain/pallets/omni-account/src/lib.rs | 2 -- .../identity/app-libs/stf/src/trusted_call.rs | 8 +++++++ .../core/native-task/receiver/src/lib.rs | 23 ++++++++++++------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/parachain/pallets/omni-account/src/lib.rs b/parachain/pallets/omni-account/src/lib.rs index b0ed1dcdd7..ce29a68862 100644 --- a/parachain/pallets/omni-account/src/lib.rs +++ b/parachain/pallets/omni-account/src/lib.rs @@ -263,8 +263,6 @@ pub mod pallet { let who = T::OmniAccountOrigin::ensure_origin(origin)?; ensure!(!member_account_hashes.is_empty(), Error::::EmptyAccount); - // TODO: shall we verify if MemberAccountHash's value is actually `who`? - let mut member_accounts = AccountStore::::get(&who).ok_or(Error::::UnknownAccountStore)?; diff --git a/tee-worker/identity/app-libs/stf/src/trusted_call.rs b/tee-worker/identity/app-libs/stf/src/trusted_call.rs index 809100a46c..47d31ae2fa 100644 --- a/tee-worker/identity/app-libs/stf/src/trusted_call.rs +++ b/tee-worker/identity/app-libs/stf/src/trusted_call.rs @@ -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), // original integritee trusted calls, starting from index 50 #[codec(index = 50)] @@ -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, } } @@ -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", } } @@ -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) + }, } } diff --git a/tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs b/tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs index 2af3952570..6ba8001d51 100644 --- a/tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs +++ b/tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs @@ -66,6 +66,7 @@ use std::{ Arc, }, thread, + vec::Vec, }; // TODO: move to config @@ -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::>() + )), + ), _ => { log::warn!("Received unsupported call: {:?}", call); let res: Result<(), NativeTaskError> =