Skip to content

Commit

Permalink
feat(ucli): initial setup of ucli
Browse files Browse the repository at this point in the history
Signed-off-by: aeryz <abdullaheryz@protonmail.com>
  • Loading branch information
aeryz committed Oct 31, 2023
1 parent 5c94a01 commit 8c50e3e
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"light-clients/*",
"generated/rust",
"generated/contracts",
"ucli",
"unionvisor",
"voyager",
"cosmwasm/*",
Expand Down
2 changes: 1 addition & 1 deletion lib/chain-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ unionlabs = { workspace = true, default-features = true }
beacon-api = { workspace = true, default-features = false }
contracts.workspace = true
serde-utils.workspace = true
protos = { workspace = true, default-features = true }
protos = { workspace = true, default-features = true, features = [ "client" ] }

futures = "0.3.28"
ethers = { workspace = true, features = ["rustls", "ws"] }
Expand Down
18 changes: 18 additions & 0 deletions ucli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "ucli"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ethers = { workspace = true, features = ["rustls", "ws"] }
clap = { version = "4.3.0", features = ["derive", "env", "error-context"] }
serde_json = "1.0.96"
serde = { version = "1.0.173", features = ["derive"] }
hex = { version = "0.4.3", features = [ "serde" ] }

unionlabs = { workspace = true, features = ["ethabi"] }
contracts.workspace = true
chain-utils.workspace = true
tendermint-rpc = { workspace = true, features = ["http-client", "websocket-client"] }
103 changes: 103 additions & 0 deletions ucli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
use std::{collections::BTreeMap, ffi::OsString, str::FromStr};

use chain_utils::private_key::PrivateKey;
use clap::{
error::{ContextKind, ContextValue},
Args, Parser, Subcommand,
};
use ethers::{
prelude::k256::ecdsa,
signers::LocalWallet,
types::{Address, H256},
};
use serde::{Deserialize, Serialize};
use tendermint_rpc::WebSocketClientUrl;

#[derive(Debug, Parser)]
#[command(arg_required_else_help = true)]
pub struct AppArgs {
#[arg(
long,
short = 'c',
env,
global = true,
default_value = "~/.config/ucli/config.json"
)]
pub config_file_path: OsString,
#[command(subcommand)]
pub command: Command,
}

#[derive(Debug, Subcommand)]
pub enum Command {
#[command(subcommand)]
Tx(TxCmd),
}

#[derive(Debug, Subcommand)]
pub enum TxCmd {
#[command(subcommand)]
Evm(EvmTx),
}

#[derive(Debug, Subcommand)]
pub enum EvmTx {
Transfer {
#[arg(long)]
on: String,
#[arg(long)]
relay_address: Address,
// #[arg(long)]
// from: Address,
// #[arg(long)]
// to: String,
#[arg(long)]
port_id: String,
#[arg(long)]
channel_id: String,
#[arg(long)]
receiver: String,
#[arg(long)]
amount: u64,
#[arg(long)]
denom: String,
},
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(bound(serialize = "", deserialize = ""))]
pub struct Config {
/// Map of chain name to it's respective config.
pub chain: BTreeMap<String, ChainConfig>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", tag = "chain_type")]
pub enum ChainConfig {
Evm(EvmChainConfig),
Union(UnionChainConfig),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EvmChainConfig {
/// The address of the `IBCHandler` smart contract.
pub ibc_handler_address: Address,

/// The signer that will be used to submit transactions by voyager.
pub signers: Vec<PrivateKey<ecdsa::SigningKey>>,

// TODO(benluelo): Use `Url` or something similar
/// The RPC endpoint for the execution chain.
pub eth_rpc_api: String,
/// The RPC endpoint for the beacon chain.
pub eth_beacon_rpc_api: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UnionChainConfig {
pub signers: Vec<PrivateKey<ecdsa::SigningKey>>,
pub fee_denom: String,
pub ws_url: WebSocketClientUrl,
pub prover_endpoint: String,
pub grpc_url: String,
}
5 changes: 5 additions & 0 deletions ucli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod cli;

fn main() {
println!("Hello, world!");
}

0 comments on commit 8c50e3e

Please sign in to comment.