Skip to content

Commit 0178987

Browse files
committed
refactor: update code blocks to use Aiken syntax highlighting in smart contract section
1 parent 3893419 commit 0178987

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

docs/smart-contracts/lessons/03-aiken-contracts.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Minting script validation logic is triggered when assets are minted or burned un
109109

110110
Example: `/aiken-workspace/validators/mint.ak`:
111111

112-
```rust
112+
```aiken
113113
use cardano/assets.{PolicyId}
114114
use cardano/transaction.{Transaction, placeholder}
115115
@@ -135,7 +135,7 @@ This script compiles into a script with hash `def68337867cb4f1f95b6b811fedbfcdd7
135135

136136
Upgrade the script to allow minting/burning only when signed by a specific key:
137137

138-
```rust
138+
```aiken
139139
validator minting_policy(owner_vkey: VerificationKeyHash) {
140140
mint(_redeemer: Data, _policy_id: PolicyId, tx: Transaction) {
141141
key_signed(tx.extra_signatories, owner_vkey)
@@ -154,7 +154,7 @@ validator minting_policy(owner_vkey: VerificationKeyHash) {
154154

155155
Extend the policy to include a redeemer specifying the transaction action (minting or burning):
156156

157-
```rust
157+
```aiken
158158
pub type MyRedeemer {
159159
MintToken
160160
BurnToken
@@ -187,7 +187,7 @@ Spending script validation is triggered when a UTXO is spent in the transaction.
187187

188188
Example: `/aiken-workspace/validators/spend.ak`:
189189

190-
```rust
190+
```aiken
191191
pub type Datum {
192192
oracle_nft: PolicyId,
193193
}
@@ -226,7 +226,7 @@ Withdrawal script validation is triggered when withdrawing from a reward account
226226

227227
Example: `/aiken-workspace/validators/withdraw.ak`:
228228

229-
```rust
229+
```aiken
230230
use aiken/crypto.{VerificationKeyHash}
231231
use cardano/address.{Credential, Script}
232232
use cardano/certificate.{Certificate}

docs/smart-contracts/lessons/04-contract-testing.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ We will enhance the withdrawal contract from the previous lesson to include two
2626

2727
### Contract Code
2828

29-
```rust
29+
```aiken
3030
use aiken/crypto.{VerificationKeyHash}
3131
use cardano/address.{Address, Credential}
3232
use cardano/assets.{PolicyId}
@@ -100,7 +100,7 @@ In the last line of `ContinueCounting` branch, you may notice the use of `?` ope
100100

101101
We complete the contract by validating inputs and outputs:
102102

103-
```rust
103+
```aiken
104104
use aiken/crypto.{VerificationKeyHash}
105105
use cardano/address.{Address, Credential}
106106
use cardano/assets.{PolicyId, without_lovelace}
@@ -206,7 +206,7 @@ In Aiken, we can build testing functions with `test` keyword, followed by runnin
206206

207207
The vanilla example:
208208

209-
```rust
209+
```aiken
210210
test always_true() {
211211
True
212212
}
@@ -220,7 +220,7 @@ With `aiken check`, we will see:
220220

221221
In our complex withdrawal contract, we have a `publish` function that always returns `True`. We can write a test for it:
222222

223-
```rust
223+
```aiken
224224
use mocktail.{complete, mock_utxo_ref, mocktail_tx}
225225
226226
test test_publish() {
@@ -238,7 +238,7 @@ In this test, we call the `publish` function of our contract with mock parameter
238238

239239
For the rest of script purposes, it will fallback to the `else` branch which always fails. We can write a test for it:
240240

241-
```rust
241+
```aiken
242242
test test_else() fail {
243243
complex_withdrawal_contract.else(
244244
"",
@@ -263,7 +263,7 @@ You will notice the `withdraw` function is validated the `Transaction` mostly, t
263263

264264
In `vodka`, the `mocktail` module provides a set of functions to create mock data for testing Aiken contracts. We can use `mocktail_tx()` to create a mock `Transaction` and then use various functions to modify the transaction to fit our test case.
265265

266-
```rust
266+
```aiken
267267
const mock_oracle_nft = mock_policy_id(0)
268268
269269
const mock_oracle_address = mock_script_address(0, None)
@@ -323,7 +323,7 @@ We can import all the `mock_...` functions from `mocktail` module to build up th
323323

324324
Now we can write a test for `ContinueCounting` action:
325325

326-
```rust
326+
```aiken
327327
test success_continue_counting() {
328328
complex_withdrawal_contract.withdraw(
329329
mock_oracle_nft,
@@ -338,7 +338,7 @@ test success_continue_counting() {
338338

339339
In the mocktail transaction building methods, we can pass a boolean parameter to indicate whether we want the field to be present or not. This allows us to dynamically create failure cases by omitting certain fields.
340340

341-
```rust
341+
```aiken
342342
type ContinueCountingTest {
343343
is_ref_input_presented: Bool,
344344
is_thread_input_presented: Bool,
@@ -395,7 +395,7 @@ fn mock_continue_counting_tx(test_case: ContinueCountingTest) -> Transaction {
395395

396396
And we update the successful test accordingly:
397397

398-
```rust
398+
```aiken
399399
test success_continue_counting() {
400400
let test_case =
401401
ContinueCountingTest {
@@ -418,7 +418,7 @@ test success_continue_counting() {
418418

419419
And we can populate the failure cases at ease:
420420

421-
```rust
421+
```aiken
422422
test fail_continue_counting_no_ref_input() fail {
423423
let test_case =
424424
ContinueCountingTest {

docs/smart-contracts/lessons/05-avoid-redundant-validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Let's assume we have all the common logics checked in the lesson 4's withdrawal
122122

123123
### Spending
124124

125-
```rust
125+
```aiken
126126
use aiken/crypto.{ScriptHash}
127127
use cardano/transaction.{OutputReference, Transaction}
128128
use cocktail.{withdrawal_script_validated}
@@ -150,7 +150,7 @@ validator spending_logics_delegated(
150150

151151
### Minting
152152

153-
```rust
153+
```aiken
154154
use aiken/crypto.{ScriptHash}
155155
use cardano/assets.{PolicyId}
156156
use cardano/transaction.{Transaction}

docs/smart-contracts/lessons/07-vesting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The datum serves as the configuration for the vesting contract. It includes:
3030

3131
First, we define the datum's shape, as this datum serves as configuration and contains the different parameters of our vesting operation.
3232

33-
```rust
33+
```aiken
3434
pub type VestingDatum {
3535
/// POSIX time in milliseconds, e.g. 1672843961000
3636
lock_until: Int,
@@ -45,7 +45,7 @@ This datum can be found in `aiken-vesting/aiken-workspace/lib/vesting/types.ak`.
4545

4646
Next, we define the spend validator.
4747

48-
```rust
48+
```aiken
4949
validator vesting {
5050
spend(
5151
datum_opt: Option<VestingDatum>,

docs/smart-contracts/lessons/08-plutus-nft.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The oracle NFT acts as the single source of truth for the system. It uses a stat
2323

2424
The following code defines the minting policy for the oracle NFT:
2525

26-
```rust
26+
```aiken
2727
pub type MintPolarity {
2828
RMint
2929
RBurn
@@ -66,7 +66,7 @@ The oracle validator holds the current state of the NFT index. It defines the da
6666

6767
### Datum Definition
6868

69-
```rust
69+
```aiken
7070
pub type OracleDatum {
7171
count: Int,
7272
lovelace_price: Int,
@@ -76,7 +76,7 @@ pub type OracleDatum {
7676

7777
### Redeemer Types
7878

79-
```rust
79+
```aiken
8080
pub type OracleRedeemer {
8181
MintPlutusNFT
8282
StopOracle
@@ -87,7 +87,7 @@ pub type OracleRedeemer {
8787

8888
The validator ensures the state changes are valid:
8989

90-
```rust
90+
```aiken
9191
validator oracle {
9292
spend(
9393
datum_opt: Option<OracleDatum>,
@@ -114,7 +114,7 @@ In this setup, we identified the own input with `find_input` function, which is
114114

115115
We know that for state change, we will have exactly one input from current address, and one output to the same address. We can then perform below pattern matching:
116116

117-
```rust
117+
```aiken
118118
let own_address = own_input.output.address
119119
when
120120
(
@@ -133,7 +133,7 @@ We know that for state change, we will have exactly one input from current addre
133133

134134
Add in core checks for `MintPlutusNFT`:
135135

136-
```rust
136+
```aiken
137137
let is_output_value_clean = list.length(flatten(only_output.value)) == 2
138138
let is_count_updated =
139139
only_output.datum == InlineDatum(
@@ -149,7 +149,7 @@ Notice there is a `is_output_value_clean` check here, which ensures the changed
149149

150150
Complete with `StopOracle` logics:
151151

152-
```rust
152+
```aiken
153153
(StopOracle, [_], _) -> {
154154
let is_oracle_nft_burnt =
155155
only_minted_token(mint, oracle_nft_policy, "", -1)
@@ -161,7 +161,7 @@ Complete with `StopOracle` logics:
161161

162162
A complete oracle validator looks like this:
163163

164-
```rust
164+
```aiken
165165
validator oracle {
166166
spend(
167167
datum_opt: Option<OracleDatum>,
@@ -221,7 +221,7 @@ The Plutus NFT minting validator ensures the NFT is unique and non-fungible.
221221

222222
### Code Explanation
223223

224-
```rust
224+
```aiken
225225
pub type MintPolarity {
226226
RMint
227227
RBurn

docs/smart-contracts/smart-contract-languages/aiken/advanced-data-structures/linked-list.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Each entry in the list comprises:
3030

3131
#### EntryDatum Definition
3232

33-
```rust
33+
```aiken
3434
data EntryDatum = EntryDatum {
3535
key :: BuiltinByteString,
3636
value :: Maybe SomeValue,
@@ -101,7 +101,7 @@ The Aiken Linked List implementation provides several functions to create and ma
101101

102102
For a complete example, including tests and further explanations, reger to the provided sample validator:
103103

104-
```rust
104+
```aiken
105105
use aiken/bytearray
106106
use aiken/dict
107107
use aiken/interval.{Finite, Interval, IntervalBound, is_entirely_before}
@@ -570,15 +570,15 @@ test mint_validator_remove() {
570570

571571
#### Constants
572572

573-
```rust
573+
```aiken
574574
pub const origin_node_token_name = "FSN"
575575
576576
pub const set_node_prefix = "FSN"
577577
```
578578

579579
#### Linked List
580580

581-
```rust
581+
```aiken
582582
use aiken/bytearray
583583
use aiken/interval.{Interval}
584584
use aiken/list
@@ -692,7 +692,7 @@ pub fn remove(
692692

693693
#### Types
694694

695-
```rust
695+
```aiken
696696
use aiken/hash.{Blake2b_224, Hash}
697697
use aiken/transaction.{OutputReference}
698698
use aiken/transaction/credential.{Address, VerificationKey}
@@ -748,7 +748,7 @@ pub type NodeAction {
748748

749749
### Utilities
750750

751-
```rust
751+
```aiken
752752
use aiken/bytearray
753753
use aiken/dict.{has_key}
754754
use aiken/interval.{Interval}

docs/smart-contracts/smart-contract-languages/aiken/advanced-data-structures/merkle-tree.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ The Aiken Merkle Tree implementation provides several functions to create and ma
8989

9090
## Validator Logic
9191

92-
```rust
92+
```aiken
9393
// /**
9494
// * This file contains the implementation of a spend_validator function that validates a spend transaction
9595
// * using a Merkle tree. It also includes a test case for the spend_validator function.
@@ -146,7 +146,7 @@ test spend_validator_1() {
146146

147147
### Library
148148

149-
```rust
149+
```aiken
150150
// This code is sourced from https://github.com/aiken-lang/trees/blob/main/lib/aiken/trees/mt.ak
151151
//
152152
// A purely functional implementation of MerkleTrees that is suitable for

docs/smart-contracts/smart-contract-languages/aiken/advanced-data-structures/trie.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ This visual representation helps understand how Tries optimize space and search
6666

6767
## Validator Logic
6868

69-
```rust
69+
```aiken
7070
use aiken/dict
7171
use aiken/list
7272
use aiken/transaction.{

0 commit comments

Comments
 (0)