Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate generate-account-key in favour of generate-moonbeam-key #3090

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[workspace]
exclude = ["bin/utils/moonkey"]
members = [
"bin/utils/moonkey",
"client/rpc/dev",
"client/rpc/finality",
"client/vrf",
Expand Down Expand Up @@ -411,6 +409,7 @@ tracing-core = "0.1.32"
trie-root = "0.18.0"
url = { version = "2.4.0" }
thiserror = "1.0.63"
colored = { version = "2.1.0" }

# The list of dependencies below (which can be both direct and indirect dependencies) are crates
# that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of
Expand Down
17 changes: 0 additions & 17 deletions bin/utils/moonkey/Cargo.toml

This file was deleted.

39 changes: 0 additions & 39 deletions bin/utils/moonkey/src/main.rs

This file was deleted.

8 changes: 6 additions & 2 deletions node/cli-opt/src/account_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct GenerateAccountKey {
}

impl GenerateAccountKey {
pub fn run(&self) {
pub fn run(&self, deprecated: bool) {
// Retrieve the mnemonic from the args or generate random ones
let mnemonic = if let Some(phrase) = &self.mnemonic {
Mnemonic::from_phrase(phrase, Language::English).expect("invalid mnemonic")
Expand All @@ -53,7 +53,11 @@ impl GenerateAccountKey {

// Retrieves the seed from the mnemonic
let seed = Seed::new(&mnemonic, "");
let derivation_path = format!("m/44'/60'/0'/0/{}", self.account_index.unwrap_or(0));
let derivation_path = if deprecated {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should allow to pass a --network moonbeam|moonriver|moonbase|ethereum

format!("m/44'/60'/0'/0/{}", self.account_index.unwrap_or(0))
} else {
format!("m/44'/1284'/0'/0/{}", self.account_index.unwrap_or(0))
};
let private_key = if let Some(private_key) =
derivation_path.parse().ok().and_then(|derivation_path| {
let extended = ExtendedPrivateKey::<Secp256k1SecretKey>::derive_from_path(
Expand Down
1 change: 1 addition & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ clap-num = { workspace = true }
log = { workspace = true }
parity-scale-codec = { workspace = true }
url = { workspace = true }
colored = { workspace = true }

# Moonbeam
moonbeam-cli-opt = { workspace = true }
Expand Down
17 changes: 16 additions & 1 deletion node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//! It is built using clap and inherits behavior from Substrate's sc_cli crate.

use clap::Parser;
use colored::Colorize;
use moonbeam_cli_opt::{account_key::GenerateAccountKey, EthApi, FrontierBackendType, Sealing};
use moonbeam_service::chain_spec;
use sc_cli::{Error as CliError, SubstrateCli};
Expand Down Expand Up @@ -372,7 +373,10 @@ pub enum KeyCmd {
#[clap(flatten)]
BaseCli(sc_cli::KeySubcommand),
/// Generate an Ethereum account.
#[clap(about = "This command is deprecated, please use `generate-moonbeam-key` instead.")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it so it points to this PR with explanation about why it is deprecated and the difference between the 2.

GenerateAccountKey(GenerateAccountKey),
/// Generate a Moonbeam account.
GenerateMoonbeamKey(GenerateAccountKey),
}

impl KeyCmd {
Expand All @@ -381,7 +385,18 @@ impl KeyCmd {
match self {
KeyCmd::BaseCli(cmd) => cmd.run(cli),
KeyCmd::GenerateAccountKey(cmd) => {
cmd.run();
eprintln!(
"\n{}\n",
"Warning: This command is deprecated, please use `generate-moonbeam-key`instead."
.on_yellow()
.black()
.bold()
);
cmd.run(true);
Ok(())
}
KeyCmd::GenerateMoonbeamKey(cmd) => {
cmd.run(false);
Ok(())
}
}
Expand Down
Loading