|
@@ -45,7 +45,7 @@ use darkfi::{
|
|
|
};
|
|
};
|
|
|
use darkfi_money_contract::model::{Coin, TokenId};
|
|
use darkfi_money_contract::model::{Coin, TokenId};
|
|
|
use darkfi_sdk::{
|
|
use darkfi_sdk::{
|
|
|
- crypto::{FuncId, PublicKey, SecretKey},
|
|
|
|
|
|
|
+ crypto::{ContractId, FuncId, PublicKey, SecretKey},
|
|
|
pasta::{group::ff::PrimeField, pallas},
|
|
pasta::{group::ff::PrimeField, pallas},
|
|
|
tx::TransactionHash,
|
|
tx::TransactionHash,
|
|
|
};
|
|
};
|
|
@@ -262,6 +262,13 @@ enum Subcmd {
|
|
|
/// Sub command to execute
|
|
/// Sub command to execute
|
|
|
command: TokenSubcmd,
|
|
command: TokenSubcmd,
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ /// Contract functionalities
|
|
|
|
|
+ Contract {
|
|
|
|
|
+ #[structopt(subcommand)]
|
|
|
|
|
+ /// Sub command to execute
|
|
|
|
|
+ command: ContractSubcmd,
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize, StructOpt)]
|
|
#[derive(Clone, Debug, Deserialize, StructOpt)]
|
|
@@ -473,6 +480,22 @@ enum TokenSubcmd {
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#[derive(Clone, Debug, Deserialize, StructOpt)]
|
|
|
|
|
+enum ContractSubcmd {
|
|
|
|
|
+ /// Generate a new deploy authority
|
|
|
|
|
+ GenerateDeploy,
|
|
|
|
|
+ /*
|
|
|
|
|
+ /// Deploy a smart contract
|
|
|
|
|
+ Deploy {
|
|
|
|
|
+ /// Path to deploy authority
|
|
|
|
|
+ deploy_auth: String,
|
|
|
|
|
+
|
|
|
|
|
+ /// Path to contract wasm bincode
|
|
|
|
|
+ wasm_path: String,
|
|
|
|
|
+ },
|
|
|
|
|
+ */
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/// CLI-util structure
|
|
/// CLI-util structure
|
|
|
pub struct Drk {
|
|
pub struct Drk {
|
|
|
/// Wallet database operations handler
|
|
/// Wallet database operations handler
|
|
@@ -1618,5 +1641,21 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
|
|
//Ok(())
|
|
//Ok(())
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ Subcmd::Contract { command } => match command {
|
|
|
|
|
+ ContractSubcmd::GenerateDeploy => {
|
|
|
|
|
+ let deploy_authority = SecretKey::random(&mut OsRng);
|
|
|
|
|
+ let contract_id = ContractId::derive(deploy_authority);
|
|
|
|
|
+ println!(
|
|
|
|
|
+ "Deploy authority: {}",
|
|
|
|
|
+ bs58::encode(deploy_authority.inner().to_repr()).into_string()
|
|
|
|
|
+ );
|
|
|
|
|
+ println!(
|
|
|
|
|
+ "Contract ID: {}",
|
|
|
|
|
+ bs58::encode(&contract_id.inner().to_repr()).into_string()
|
|
|
|
|
+ );
|
|
|
|
|
+ Ok(())
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|