diff --git a/CHANGELOG.md b/CHANGELOG.md index 20903a3..79eb477 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) ## [Unreleased] +## [0.6.0] — 2026-04-25 + +### Added +- `nu genesis init --chain-id --dev-wallet --burn-wallet `: genesis.json template üretir +- `nu genesis info`: çalışan node'dan genesis root node'u gösterir + +### Changed +- `genesis init` çıktısı TOML'dan JSON'a geçti; nu-node `genesis.json` formatıyla uyumlu + ## [0.5.0] — 2026-04-24 ### Added diff --git a/Cargo.lock b/Cargo.lock index e396edb..d8505b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,6 +37,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anstream" version = "1.0.0" @@ -111,6 +120,12 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + [[package]] name = "base16ct" version = "0.2.0" @@ -181,6 +196,19 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + [[package]] name = "cipher" version = "0.4.4" @@ -746,6 +774,30 @@ dependencies = [ "windows-registry", ] +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "icu_collections" version = "2.2.0" @@ -1025,6 +1077,7 @@ dependencies = [ "aes-gcm", "anyhow", "argon2", + "chrono", "clap", "dirs", "hex", @@ -1039,6 +1092,15 @@ dependencies = [ "uuid", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "once_cell" version = "1.21.4" @@ -2065,6 +2127,41 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "windows-link" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index 1571dac..aac8a32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,3 +23,4 @@ aes-gcm = "0.10" rpassword = "7" sha2 = "0.10" uuid = { version = "1", features = ["v4"] } +chrono = "0.4" diff --git a/src/commands/genesis.rs b/src/commands/genesis.rs index 5cb1cde..f10fcd2 100644 --- a/src/commands/genesis.rs +++ b/src/commands/genesis.rs @@ -4,21 +4,66 @@ use crate::rpc::Client; #[derive(Subcommand)] pub enum GenesisCmd { - /// Initialize genesis block configuration + /// Create a genesis.json template for a new chain Init { #[arg(long)] chain_id: String, - #[arg(long, default_value = "genesis.toml")] output: String, + #[arg(long)] dev_wallet: String, + #[arg(long)] burn_wallet: String, + #[arg(long, default_value = "genesis.json")] output: String, }, + /// Show the applied genesis info from a running node + Info, } -pub async fn run(cmd: GenesisCmd, _rpc: &Client) -> Result<()> { +pub async fn run(cmd: GenesisCmd, rpc: &Client) -> Result<()> { match cmd { - GenesisCmd::Init { chain_id, output } => { - let template = format!( - "[genesis]\nchain_id = \"{chain_id}\"\n\n[bootstrap_peers]\n# Add validator multiaddrs here\n" - ); - std::fs::write(&output, template)?; - println!("Genesis config written to {output}"); + GenesisCmd::Init { chain_id, dev_wallet, burn_wallet, output } => { + let template = serde_json::json!({ + "chain_id": chain_id, + "genesis_time": chrono::Utc::now().timestamp_millis(), + "dev_wallet": dev_wallet, + "burn_wallet": burn_wallet, + "accounts": [ + { + "address": dev_wallet, + "balance": 52_000_000u64, + "staked": 5_000_000u64, + "pon_score": 1.4 + } + ], + "validators": [ + { + "address": dev_wallet, + "stake": 5_000_000u64, + "pon_score": 1.4, + "is_active": true + } + ], + "genesis_story": { + "story_id": "genesis", + "root_node": { + "node_id": "0", + "author": dev_wallet, + "content_hash": "bafkreigenesisrootnode000000000000000000000000000000000000000", + "submitted_at": chrono::Utc::now().timestamp_millis() + } + } + }); + let json = serde_json::to_string_pretty(&template)?; + std::fs::write(&output, &json)?; + println!("Genesis template written to {output}"); + println!("Edit content_hash to your actual IPFS CID before starting the node."); + } + GenesisCmd::Info => { + match rpc.call("nu_getNode", vec![serde_json::json!("0")]).await { + Ok(node) if !node.is_null() => { + println!("Genesis node #0:"); + println!("{}", serde_json::to_string_pretty(&node)?); + } + _ => { + println!("Genesis not yet applied or node unreachable."); + } + } } } Ok(())