2018-03-03 13:41:36 -08:00
|
|
|
//! A command-line executable for generating the chain's genesis block.
|
|
|
|
|
2018-04-21 06:12:57 -07:00
|
|
|
extern crate isatty;
|
2018-03-03 13:41:36 -08:00
|
|
|
extern crate serde_json;
|
2018-03-27 15:24:05 -07:00
|
|
|
extern crate solana;
|
2018-03-03 13:41:36 -08:00
|
|
|
|
2018-04-21 06:12:57 -07:00
|
|
|
use isatty::stdin_isatty;
|
2018-03-27 15:24:05 -07:00
|
|
|
use solana::mint::Mint;
|
2018-04-21 06:12:57 -07:00
|
|
|
use std::io::{stdin, Read};
|
2018-04-19 07:55:47 -07:00
|
|
|
use std::process::exit;
|
2018-03-03 13:41:36 -08:00
|
|
|
|
|
|
|
fn main() {
|
2018-04-21 06:12:57 -07:00
|
|
|
if stdin_isatty() {
|
|
|
|
eprintln!("nothing found on stdin, expected a json file");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut buffer = String::new();
|
|
|
|
let num_bytes = stdin().read_to_string(&mut buffer).unwrap();
|
|
|
|
if num_bytes == 0 {
|
|
|
|
eprintln!("empty file on stdin, expected a json file");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
let mint: Mint = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
2018-04-19 07:55:47 -07:00
|
|
|
eprintln!("failed to parse json: {}", e);
|
|
|
|
exit(1);
|
|
|
|
});
|
2018-03-07 16:08:12 -08:00
|
|
|
for x in mint.create_entries() {
|
2018-04-19 07:55:47 -07:00
|
|
|
let serialized = serde_json::to_string(&x).unwrap_or_else(|e| {
|
|
|
|
eprintln!("failed to serialize: {}", e);
|
|
|
|
exit(1);
|
|
|
|
});
|
|
|
|
println!("{}", serialized);
|
2018-03-03 13:41:36 -08:00
|
|
|
}
|
|
|
|
}
|