-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devnet): move keygen and cosmwasm address computation into devne…
…t-utils (#1986) Removes `ucli` as a dependency of cosmos devnets, as it takes quite a long time to build. `devnet-utils` only depends on `unionlabs` from the workspace; if `unionlabs` is changed then all the contracts need to be rebuilt anyways so it's fine.
- Loading branch information
Showing
10 changed files
with
152 additions
and
104 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
edition = { workspace = true } | ||
license-file = { workspace = true } | ||
name = "devnet-utils" | ||
repository = { workspace = true } | ||
version = "0.1.0" | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
base64 = { workspace = true } | ||
bip39 = "2.0.0" | ||
clap = { workspace = true, features = ["derive", "error-context", "help"] } | ||
cosmwasm-std = "2.0.3" | ||
ed25519-compact = { version = "2.1.1", default-features = false, features = ["ed25519"] } | ||
hex = { workspace = true, features = ["std"] } | ||
strum = { version = "0.26.1", features = ["derive"] } | ||
unionlabs.workspace = true |
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,92 @@ | ||
use base64::{display::Base64Display, engine::general_purpose::STANDARD}; | ||
use bip39::Mnemonic; | ||
use clap::{Parser, Subcommand}; | ||
use ed25519_compact::{KeyPair, Seed}; | ||
use unionlabs::hash::{H160, H256}; | ||
|
||
#[derive(Parser)] | ||
#[clap(arg_required_else_help = true)] | ||
struct App { | ||
#[clap(subcommand)] | ||
command: Cmd, | ||
} | ||
|
||
#[derive(Subcommand)] | ||
enum Cmd { | ||
#[clap(subcommand)] | ||
Keygen(KeygenCmd), | ||
#[command(subcommand)] | ||
Compute(ComputeCmd), | ||
} | ||
|
||
#[derive(Subcommand)] | ||
enum KeygenCmd { | ||
Key { | ||
mnemonic: Mnemonic, | ||
#[arg(long)] | ||
key_type: KeyType, | ||
}, | ||
Mnemonic { | ||
seed: String, | ||
}, | ||
} | ||
|
||
#[derive(Subcommand)] | ||
pub enum ComputeCmd { | ||
Instantiate2Address { | ||
#[arg(long)] | ||
creator: H160, | ||
#[arg(long)] | ||
checksum: H256, | ||
#[arg(long)] | ||
salt: String, | ||
}, | ||
} | ||
|
||
#[derive(strum::EnumString, Clone)] | ||
#[strum(serialize_all = "kebab-case")] | ||
enum KeyType { | ||
Ed25519, | ||
} | ||
|
||
fn main() { | ||
let app = App::parse(); | ||
|
||
match app.command { | ||
Cmd::Keygen(cmd) => match cmd { | ||
KeygenCmd::Key { mnemonic, key_type } => match key_type { | ||
KeyType::Ed25519 => { | ||
let key_pair = | ||
KeyPair::from_seed(Seed::new(mnemonic.to_entropy().try_into().unwrap())); | ||
|
||
println!("{}", Base64Display::new(&*key_pair.sk, &STANDARD)); | ||
} | ||
}, | ||
KeygenCmd::Mnemonic { seed } => { | ||
println!( | ||
"{}", | ||
Mnemonic::from_entropy(&hex::decode(seed).unwrap()).unwrap() | ||
); | ||
} | ||
}, | ||
Cmd::Compute(cmd) => match cmd { | ||
ComputeCmd::Instantiate2Address { | ||
creator, | ||
checksum, | ||
salt, | ||
} => { | ||
println!( | ||
"{}", | ||
hex::encode( | ||
&*cosmwasm_std::instantiate2_address( | ||
&checksum.0, | ||
&creator.0.into(), | ||
&hex::decode(salt).unwrap(), | ||
) | ||
.unwrap() | ||
) | ||
); | ||
} | ||
}, | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.