diff --git a/Cargo.toml b/Cargo.toml index 9b2a13c7ef..a8cd37821d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,6 +73,7 @@ members = [ "common/topology", "common/types", "common/wasm-utils", + "demos/rust-cosmos-broadcaster-client", "explorer-api", "gateway", "gateway/gateway-requests", diff --git a/demos/rust-cosmos-broadcaster-client/Cargo.toml b/demos/rust-cosmos-broadcaster-client/Cargo.toml new file mode 100644 index 0000000000..04f47ab582 --- /dev/null +++ b/demos/rust-cosmos-broadcaster-client/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "rust-cosmos-broadcaster-client" +version = "0.1.0" +authors.workspace = true +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = { version = "4.0", features = ["derive"] } +nym-validator-client = { path = "../../common/client-libs/validator-client", features = ["nyxd-client"] } +nym-network-defaults = { path = "../../common/network-defaults" } +async-trait = { workspace = true, optional = true } +bip39 = { workspace = true, features = ["rand"], optional = true } +cosmrs = { git = "https://github.com/neacsu/cosmos-rust", branch = "neacsu/feegrant_support", features = ["rpc", "bip32", "cosmwasm"], optional = true } + +[dev-dependencies] +bip39 = { workspace = true } +cosmrs = { git = "https://github.com/neacsu/cosmos-rust", branch = "neacsu/feegrant_support", features = ["rpc", "bip32"] } +tokio = { version = "1.24.1", features = ["rt-multi-thread", "macros"] } +ts-rs = "6.1.2" diff --git a/demos/rust-cosmos-broadcaster-client/plan.txt b/demos/rust-cosmos-broadcaster-client/plan.txt new file mode 100644 index 0000000000..3ff129e190 --- /dev/null +++ b/demos/rust-cosmos-broadcaster-client/plan.txt @@ -0,0 +1,13 @@ +Plan: +* rewrite ts cosmos broadcaster SP in rust +* create simple rust binary for client cli use with 2 functions: + * use standard CLI method - cf. NymCLI + * getSequence() for offline signing + * submitTx() for sending tx thru mixnet to SP for broadcasting + +* rust server code - communicates with chain + * sdk + * nym validator client - broadcast client, gets sequence + submits tx +* rust client code - communicates with server via mixnet + * sdk + * nym validator client - offline signer diff --git a/demos/rust-cosmos-broadcaster-client/src/main.rs b/demos/rust-cosmos-broadcaster-client/src/main.rs new file mode 100644 index 0000000000..1fb28154a5 --- /dev/null +++ b/demos/rust-cosmos-broadcaster-client/src/main.rs @@ -0,0 +1,45 @@ +use clap::{CommandFactory, Parser, Subcommand, Args}; +use nym_validator_client::nyxd::CosmWasmClient; +use nym_validator_client::signing::direct_wallet::DirectSecp256k1HdWallet; +use nym_validator_client::signing::tx_signer::TxSigner; +use nym_validator_client::signing::SignerData; +/* use cosmrs::bank::MsgSend; +use cosmrs::rpc::{self, HttpClient}; +use cosmrs::tx::Msg; +use cosmrs::{tx, AccountId, Coin, Denom}; +*/ + +#[derive(Debug, Parser)] +#[clap(name = "cosmos tx broadcaster ")] +#[clap(about = "binary which accepts pre-signed txs from the mixnet and broadcasts them to a cosmos sdk chain ")] +struct Cli { + #[clap(subcommand)] + command: Option, +} + +#[derive(Debug, Subcommand)] +enum Commands { + /// Reverses a string + Reverse(Reverse), + /// Inspects a string + Inspect(Inspect), +} + +#[derive(Debug, Args)] +struct Reverse { + /// The string to reverse + string: Option, +} + +#[derive(Debug, Args)] +struct Inspect { + /// The string to inspect + string: Option, + #[arg(short = 'd', long = "digits")] + only_digits: bool, +} + + +fn main() { + println!("Hello, world!"); +}