From 821866fa6db4b4b6894d5f12c94b3bebac669f05 Mon Sep 17 00:00:00 2001 From: Mike the Tike Date: Thu, 5 Oct 2023 09:35:06 +0200 Subject: [PATCH] add template parameter --- .../tari_scaffolder/src/template/src/cli.rs.liquid | 8 +++++--- .../tari_scaffolder/src/template/src/main.rs.liquid | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/applications/tari_scaffolder/src/template/src/cli.rs.liquid b/applications/tari_scaffolder/src/template/src/cli.rs.liquid index 2abe24fb5..118f1562e 100644 --- a/applications/tari_scaffolder/src/template/src/cli.rs.liquid +++ b/applications/tari_scaffolder/src/template/src/cli.rs.liquid @@ -12,6 +12,8 @@ pub(crate) struct Cli { pub daemon_jrpc_endpoint: Option, #[clap(long, short='t', alias= "token")] pub auth_token: String, + #[clap(long, alias="template_address", default_value ="5d824fb9902af3afa3eefe6b15764ebf336c6b1c6d8438e6efd478b4639d1e36")] + pub template: String, #[clap(subcommand)] pub command: Command, } @@ -38,7 +40,7 @@ pub(crate) mod {{ c.name }} { use tari_engine_types::instruction::Instruction; use tari_utilities::hex::Hex; use tari_utilities::hex::from_hex; - +use tari_engine_types::TemplateAddress; #[derive(Debug, Args, Clone)] pub struct Command { {% for arg in c.args %} @@ -52,9 +54,9 @@ pub(crate) mod {{ c.name }} { impl Command { - pub async fn run(self, mut client: DaemonClient) { + pub async fn run(self, mut client: DaemonClient, template_address: TemplateAddress) { - let template_address= from_hex("0c54557e7e3ccfd8b1a632d40d58b4e8f65d319a49495966025350c097847cd8").unwrap().try_into().unwrap(); + // let template_address= ; let function = "{{c.name}}".to_string(); diff --git a/applications/tari_scaffolder/src/template/src/main.rs.liquid b/applications/tari_scaffolder/src/template/src/main.rs.liquid index f7aca63a8..2300da414 100644 --- a/applications/tari_scaffolder/src/template/src/main.rs.liquid +++ b/applications/tari_scaffolder/src/template/src/main.rs.liquid @@ -12,6 +12,7 @@ use multiaddr::Multiaddr; use std::str::FromStr; use reqwest; use serde_json::json; +use tari_utilities::hex::from_hex; @@ -21,10 +22,11 @@ async fn main() { let jrpc = cli.daemon_jrpc_endpoint.clone().unwrap_or_else(|| "http://127.0.0.1:18016".to_string()); let token = cli.auth_token.clone(); let client= DaemonClient::new(jrpc, token); + let template_address = from_hex(&cli.template).unwrap().try_into().unwrap(); match cli.command { {% for c in commands %} Command::{{c.title}}(com) => { - com.run(client).await; + com.run(client, template_address).await; } {% endfor %} }