-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ariady Putra
committed
May 19, 2024
1 parent
8533763
commit db964fa
Showing
8 changed files
with
192 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: aiken-lang/[email protected] | ||
with: | ||
version: v1.0.26-alpha | ||
|
||
- run: aiken fmt --check | ||
- run: aiken check -D | ||
- run: aiken build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Aiken compilation artifacts | ||
artifacts/ | ||
# Aiken's project working directory | ||
build/ | ||
# Aiken's default documentation export | ||
docs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,55 @@ | ||
# hello_aiken | ||
# hello_aiken | ||
|
||
Write validators in the `validators` folder, and supporting functions in the `lib` folder using `.ak` as a file extension. | ||
|
||
For example, as `validators/always_true.ak` | ||
|
||
```gleam | ||
validator { | ||
fn spend(_datum: Data, _redeemer: Data, _context: Data) -> Bool { | ||
True | ||
} | ||
} | ||
``` | ||
|
||
## Building | ||
|
||
```sh | ||
aiken build | ||
``` | ||
|
||
## Testing | ||
|
||
You can write tests in any module using the `test` keyword. For example: | ||
|
||
```gleam | ||
test foo() { | ||
1 + 1 == 2 | ||
} | ||
``` | ||
|
||
To run all tests, simply do: | ||
|
||
```sh | ||
aiken check | ||
``` | ||
|
||
To run only tests matching the string `foo`, do: | ||
|
||
```sh | ||
aiken check -m foo | ||
``` | ||
|
||
## Documentation | ||
|
||
If you're writing a library, you might want to generate an HTML documentation for it. | ||
|
||
Use: | ||
|
||
```sh | ||
aiken docs | ||
``` | ||
|
||
## Resources | ||
|
||
Find more on the [Aiken's user manual](https://aiken-lang.org). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This file was generated by Aiken | ||
# You typically do not need to edit this file | ||
|
||
[[requirements]] | ||
name = "aiken-lang/stdlib" | ||
version = "1.8.0" | ||
source = "github" | ||
|
||
[[requirements]] | ||
name = "aiken-extra/string_util" | ||
version = "3.180.202403" | ||
source = "github" | ||
|
||
[[packages]] | ||
name = "aiken-lang/stdlib" | ||
version = "1.8.0" | ||
requirements = [] | ||
source = "github" | ||
|
||
[[packages]] | ||
name = "aiken-extra/string_util" | ||
version = "3.180.202403" | ||
requirements = [] | ||
source = "github" | ||
|
||
[etags] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name = "cdev-meetup/hello_aiken" | ||
version = "0.0.0" | ||
license = "Apache-2.0" | ||
description = "Aiken contracts for project 'cdev-meetup/hello_aiken'" | ||
|
||
[repository] | ||
user = "cdev-meetup" | ||
project = "hello_aiken" | ||
platform = "github" | ||
|
||
[[dependencies]] | ||
name = "aiken-lang/stdlib" | ||
version = "1.8.0" | ||
source = "github" | ||
|
||
[[dependencies]] | ||
name = "aiken-extra/string_util" | ||
version = "3.180.202403" | ||
source = "github" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use aiken/hash.{Hash, Blake2b_224} | ||
use aiken/transaction/credential.{VerificationKey} | ||
|
||
pub type PubKeyHash = Hash<Blake2b_224, VerificationKey> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"preamble": { | ||
"title": "cdev-meetup/hello_aiken", | ||
"description": "Aiken contracts for project 'cdev-meetup/hello_aiken'", | ||
"version": "0.0.0", | ||
"plutusVersion": "v2", | ||
"compiler": { | ||
"name": "Aiken", | ||
"version": "v1.0.26-alpha+unknown" | ||
}, | ||
"license": "Apache-2.0" | ||
}, | ||
"validators": [ | ||
{ | ||
"title": "hello.spend", | ||
"datum": { | ||
"title": "_datum", | ||
"schema": { | ||
"$ref": "#/definitions/Data" | ||
} | ||
}, | ||
"redeemer": { | ||
"title": "_redeemer", | ||
"schema": { | ||
"$ref": "#/definitions/Data" | ||
} | ||
}, | ||
"parameters": [ | ||
{ | ||
"title": "user_pkh", | ||
"schema": { | ||
"$ref": "#/definitions/ByteArray" | ||
} | ||
} | ||
], | ||
"compiledCode": "588901000032323232323223222253330063233001001375860166018601860186018601860186018601860126ea8c02cc024dd50011129998058008a5013253330093371e6eb8c03400801c52889980180180098068008a4c2a6600e9211856616c696461746f722072657475726e65642066616c73650013656375c002ae695ce2ab9e5573eae855d101", | ||
"hash": "dcc53c33a437ef11721e6564d69ba8011298ec41bfb5adafbc0ac9f9" | ||
} | ||
], | ||
"definitions": { | ||
"ByteArray": { | ||
"dataType": "bytes" | ||
}, | ||
"Data": { | ||
"title": "Data", | ||
"description": "Any Plutus data." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use aiken/list.{has} | ||
use aiken/transaction.{ScriptContext} | ||
use hello_aiken/alias.{PubKeyHash} | ||
use string_util/cbor.{print} | ||
|
||
validator(pkh: PubKeyHash) { | ||
fn spend(_datum: Data, _redeemer: Data, context ctx: ScriptContext) -> Bool { | ||
let txn = ctx.transaction | ||
|
||
trace print("extra_signatories", txn.extra_signatories) | ||
txn.extra_signatories |> has(pkh) | ||
} | ||
} |