Skip to content

Commit

Permalink
Adding create_account_store trusted call (#3152)
Browse files Browse the repository at this point in the history
  • Loading branch information
silva-fj authored Oct 30, 2024
1 parent b0197c4 commit 68fc670
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
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 @@ -141,6 +141,8 @@ pub enum TrustedCall {
clean_id_graphs(Identity),
#[codec(index = 26)]
request_intent(Identity, Intent),
#[codec(index = 27)]
create_account_store(Identity),

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

Expand All @@ -246,6 +249,7 @@ impl TrustedCall {
Self::activate_identity(..) => "activate_identity",
Self::maybe_create_id_graph(..) => "maybe_create_id_graph",
Self::request_intent(..) => "request_intent",
Self::create_account_store(..) => "create_account_store",
_ => "unsupported_trusted_call",
}
}
Expand Down Expand Up @@ -904,6 +908,10 @@ where
error!("please use author_submitNativeRequest instead");
Ok(TrustedCallResult::Empty)
},
TrustedCall::create_account_store(..) => {
error!("please use author_submitNativeRequest instead");
Ok(TrustedCallResult::Empty)
},
}
}

Expand Down
61 changes: 38 additions & 23 deletions tee-worker/identity/litentry/core/native-task/receiver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,24 @@ fn handle_trusted_call<
},
};

let (who, intent_call) = match call {
let create_dispatch_as_omni_account_call = |member_identity_hash: H256, call: OpaqueCall| {
OpaqueCall::from_tuple(&compose_call!(
&metadata,
"OmniAccount",
"dispatch_as_omni_account",
member_identity_hash,
call
))
};

let opaque_call = match call {
TrustedCall::request_intent(who, intent) => match intent {
Intent::SystemRemark(remark) =>
(who, OpaqueCall::from_tuple(&compose_call!(&metadata, "System", "remark", remark))),
Intent::TransferNative(transfer) => (
who,
Intent::SystemRemark(remark) => create_dispatch_as_omni_account_call(
who.hash(),
OpaqueCall::from_tuple(&compose_call!(&metadata, "System", "remark", remark)),
),
Intent::TransferNative(transfer) => create_dispatch_as_omni_account_call(
who.hash(),
OpaqueCall::from_tuple(&compose_call!(
&metadata,
"Balances",
Expand All @@ -201,15 +213,26 @@ fn handle_trusted_call<
transfer.value
)),
),
Intent::CallEthereum(_) | Intent::TransferEthereum(_) => (
who,
OpaqueCall::from_tuple(&compose_call!(
&metadata,
"OmniAccount",
"request_intent",
intent
)),
),
Intent::CallEthereum(_) | Intent::TransferEthereum(_) =>
create_dispatch_as_omni_account_call(
who.hash(),
OpaqueCall::from_tuple(&compose_call!(
&metadata,
"OmniAccount",
"request_intent",
intent
)),
),
},
TrustedCall::create_account_store(who) => {
let create_account_store_call = OpaqueCall::from_tuple(&compose_call!(
&metadata,
"OmniAccount",
"create_account_store",
who
));

create_account_store_call
},
_ => {
log::warn!("Received unsupported call: {:?}", call);
Expand All @@ -220,15 +243,7 @@ fn handle_trusted_call<
},
};

let omni_account_call = OpaqueCall::from_tuple(&compose_call!(
&metadata,
"OmniAccount",
"dispatch_as_omni_account",
who.hash(),
intent_call
));

let extrinsic = match context.extrinsic_factory.create_extrinsics(&[omni_account_call], None) {
let extrinsic = match context.extrinsic_factory.create_extrinsics(&[opaque_call], None) {
Ok(extrinsic) => extrinsic,
Err(e) => {
log::error!("Failed to create extrinsic: {:?}", e);
Expand Down

0 comments on commit 68fc670

Please sign in to comment.