feat: implement generate contract with options

This commit is contained in:
Magamedrasul Ibragimov
2023-02-06 14:38:21 +04:00
parent 5e4c1c6bd1
commit 0f6ebf7cc2
3 changed files with 11 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ pub struct CLI {
#[derive(Subcommand)]
pub enum Commands {
#[command(about = "Generates smart-contract")]
Contract,
Contract { depth: u8, deposit: u128 },
#[command(about = "Generates circuit")]
Circuit,
#[command(about = "Generates webapp template")]

View File

@@ -1,7 +1,14 @@
use fs_extra::dir::{copy, CopyOptions};
pub fn contract() {
use minijinja::render;
pub fn contract(depth: u8, deposit: u128) {
let options = CopyOptions::new();
copy("./resources/vendor/rln-contract", "./", &options).unwrap();
let rln_file = fs_extra::file::read_to_string("./rln-contract/contracts/Rln.sol").unwrap();
let rln_file = render!(&rln_file, membership_deposit => deposit, depth => depth);
fs_extra::file::write_all("./rln-contract/contracts/Rln.sol", &rln_file).unwrap();
}

View File

@@ -17,9 +17,8 @@ fn main() {
let cli = CLI::parse();
match cli.command {
Commands::Contract => {
println!("Generated smart-contract");
contract();
Commands::Contract { depth, deposit } => {
contract(depth, deposit);
}
Commands::Circuit => println!("circuit"),
Commands::Webapp => println!("webapp"),