-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(da): add NamespaceCommand for deriving DA namespace from genesis…
… file (#3003) This commit introduces the `NamespaceCommand` which allows users to derive the DA namespace from a genesis file. The command is now part of the DA command module, enhancing the functionality provided by the CLI.
- Loading branch information
Showing
3 changed files
with
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pub mod namespace; | ||
pub mod unpack; |
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,23 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use clap::Parser; | ||
use rooch_config::da_config::derive_genesis_namespace; | ||
use rooch_types::error::RoochResult; | ||
use std::path::PathBuf; | ||
|
||
/// Derive DA namespace from genesis file. | ||
#[derive(Debug, Parser)] | ||
pub struct NamespaceCommand { | ||
#[clap(long = "genesis-file-path")] | ||
pub genesis_file_path: PathBuf, | ||
} | ||
|
||
impl NamespaceCommand { | ||
pub fn execute(self) -> RoochResult<()> { | ||
let genesis_bytes = std::fs::read(&self.genesis_file_path)?; | ||
let namespace = derive_genesis_namespace(&genesis_bytes); | ||
println!("DA genesis namespace: {}", namespace); | ||
Ok(()) | ||
} | ||
} |
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