-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add new cli for IDGraph clean (#3115)
Co-authored-by: higherordertech <higherordertech>
- Loading branch information
1 parent
1fd1efc
commit 8daa6bf
Showing
7 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
tee-worker/identity/cli/src/trusted_base_cli/commands/litentry/clean_id_graphs.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2020-2024 Trust Computing GmbH. | ||
// This file is part of Litentry. | ||
// | ||
// Litentry is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Litentry is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Litentry. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use crate::{ | ||
get_layer_two_nonce, | ||
trusted_cli::TrustedCli, | ||
trusted_command_utils::{get_identifiers, get_pair_from_str}, | ||
trusted_operation::perform_trusted_operation, | ||
Cli, CliResult, CliResultOk, | ||
}; | ||
use clap::Parser; | ||
use ita_stf::{Index, TrustedCall}; | ||
use itp_stf_primitives::{traits::TrustedCallSigning, types::KeyPair}; | ||
use sp_core::Pair; | ||
|
||
// usage exmaple: | ||
// | ||
// ./bin/litentry-cli trusted --mrenclave <mrenclave> --direct clean-id-graphs | ||
|
||
#[derive(Parser)] | ||
pub struct CleanIDGraphsCommand {} | ||
|
||
impl CleanIDGraphsCommand { | ||
pub(crate) fn run(&self, cli: &Cli, trusted_cli: &TrustedCli) -> CliResult { | ||
let alice = get_pair_from_str(trusted_cli, "//Alice", cli); | ||
|
||
let (mrenclave, shard) = get_identifiers(trusted_cli, cli); | ||
let nonce = get_layer_two_nonce!(alice, cli, trusted_cli); | ||
|
||
let top = TrustedCall::clean_id_graphs(alice.public().into()) | ||
.sign(&KeyPair::Sr25519(Box::new(alice)), nonce, &mrenclave, &shard) | ||
.into_trusted_operation(trusted_cli.direct); | ||
Ok(perform_trusted_operation::<()>(cli, trusted_cli, &top).map(|_| CliResultOk::None)?) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters