diff --git a/crates/aiken/src/cmd/new.rs b/crates/aiken/src/cmd/new.rs index f6596f8e..0a52c98f 100644 --- a/crates/aiken/src/cmd/new.rs +++ b/crates/aiken/src/cmd/new.rs @@ -107,7 +107,59 @@ fn create_lib(root: &Path) -> miette::Result<()> { fn create_validators(root: &Path) -> miette::Result<()> { let validators = root.join("validators"); - fs::create_dir_all(validators).into_diagnostic() + fs::create_dir_all(&validators).into_diagnostic()?; + create_validator_placeholder(&validators) +} + +fn create_validator_placeholder(validators: &Path) -> miette::Result<()> { + fs::write( + validators.join("placeholder.ak"), + indoc! { + r#" + use cardano/address.{Credential} + use cardano/assets.{PolicyId} + use cardano/certificate.{Certificate} + use cardano/governance.{ProposalProcedure, Voter} + use cardano/transaction.{Transaction, OutputReference} + + validator placeholder { + mint(_redeemer: Data, _policy_id: PolicyId, _self: Transaction) { + todo @"mint logic goes here" + } + + spend(_datum: Option, _redeemer: Data, _utxo: OutputReference, _self: Transaction) { + todo @"spend logic goes here" + } + + withdraw(_redeemer: Data, _account: Credential, _self: Transaction) { + todo @"withdraw logic goes here" + } + + publish(_redeemer: Data, _certificate: Certificate, _self: Transaction) { + todo @"publish logic goes here" + } + + vote(_redeemer: Data, _voter: Voter, _self: Transaction) { + todo @"vote logic goes here" + } + + propose(_redeemer: Data, _proposal: ProposalProcedure, _self: Transaction) { + todo @"propose logic goes here" + } + + // // If needs be, remove any of unneeded handlers above, and use: + // + // else(_ctx: ScriptContext) { + // todo @"fallback logic if none of the other purposes match" + // } + // + // // You will also need an additional import: + // // + // // use cardano/script_context.{ScriptContext} + } + "#, + }, + ).into_diagnostic() } fn readme(root: &Path, project_name: &str) -> miette::Result<()> {