mirror of
https://github.com/Rate-Limiting-Nullifier/rln-cli.git
synced 2026-01-09 04:37:58 -05:00
feat: implement generate contract with options
This commit is contained in:
@@ -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")]
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user