Fix validator placeholder template
- Remove escape sequences for curly braces, not actually needed - Make indentation 2-space - Make it compile without errors - Also add some example for 'else'
This commit is contained in:
parent
44c894518b
commit
75c88be091
|
@ -107,7 +107,7 @@ 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)
|
||||
}
|
||||
|
||||
|
@ -116,37 +116,47 @@ fn create_validator_placeholder(validators: &Path) -> miette::Result<()> {
|
|||
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 my_script {{
|
||||
mint(redeemer: MyMintRedeemer, policy_id: PolicyId, self: Transaction) {{
|
||||
todo @"mint logic goes here"
|
||||
}}
|
||||
|
||||
spend(datum: Option<MyDatum>, redeemer: MySpendRedeemer, utxo: OutputReference, self: Transaction) {{
|
||||
todo @"spend logic goes here"
|
||||
}}
|
||||
|
||||
withdraw(redeemer: MyWithdrawRedeemer, account: Credential, self: Transaction) {{
|
||||
todo @"withdraw logic goes here"
|
||||
}}
|
||||
|
||||
publish(redeemer: MyPublishRedeemer, certificate: Certificate, self: Transaction) {{
|
||||
todo @"publish logic goes here"
|
||||
}}
|
||||
|
||||
vote(redeemer: MyVoteRedeemer, voter: Voter, self: Transaction) {{
|
||||
todo @"vote logic goes here"
|
||||
}}
|
||||
|
||||
propose(redeemer: MyProposeRedeemer, proposal: ProposalProcedure, self: Transaction) {{
|
||||
todo @"propose logic goes here"
|
||||
}}
|
||||
}}
|
||||
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<Data>, _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()
|
||||
|
|
Loading…
Reference in New Issue