Skip to content

Commit

Permalink
feat: complete examples
Browse files Browse the repository at this point in the history
  • Loading branch information
HinsonSIDAN committed Sep 4, 2024
1 parent 44ee0b3 commit 7c6526d
Show file tree
Hide file tree
Showing 100 changed files with 18,240 additions and 67 deletions.
55 changes: 55 additions & 0 deletions example-web/aiken/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# aiken-template

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).
26 changes: 26 additions & 0 deletions example-web/aiken/aiken.lock
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.9.0"
source = "github"

[[requirements]]
name = "sidan-lab/vodka"
version = "0.0.1-beta"
source = "github"

[[packages]]
name = "aiken-lang/stdlib"
version = "1.9.0"
requirements = []
source = "github"

[[packages]]
name = "sidan-lab/vodka"
version = "0.0.1-beta"
requirements = []
source = "github"

[etags]
21 changes: 21 additions & 0 deletions example-web/aiken/aiken.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name = "meshsdk/aiken-template"
version = "0.0.0"
compiler = "v1.0.31-alpha"
plutus = "v2"
license = "Apache-2.0"
description = "Aiken contracts for project 'meshsdk/aiken-template'"

[repository]
user = "meshsdk"
project = "aiken-template"
platform = "github"

[[dependencies]]
name = "aiken-lang/stdlib"
version = "1.9.0"
source = "github"

[[dependencies]]
name = "sidan-lab/vodka"
version = "0.0.1-beta"
source = "github"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.ak]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Temp hack to get some syntax highlighting on github
*.ak linguist-language=Gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Continuous Integration

on:
workflow_dispatch:
push:
branches: ["main"]
tags: ["*.*.*"]
pull_request:
branches: ["main"]

env:
CARGO_TERM_COLOR: always

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3

- name: 🧰 Setup Pages
uses: actions/configure-pages@v2

- name: 🧰 Install Aiken
uses: aiken-lang/setup-aiken@v1
with:
version: v1.0.28-alpha

- name: 📝 Run fmt
run: aiken fmt --check

- name: 🔬 Run tests
run: aiken check

- name: 📘 Generate documentation
shell: bash
working-directory: .
run: aiken docs -o docs

- name: 📦 Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: "docs/"

deploy:
if: ${{ startsWith(github.ref, 'refs/tags') }}
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: 🚀 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
3 changes: 3 additions & 0 deletions example-web/aiken/build/packages/aiken-lang-stdlib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
docs/
.DS_Store
185 changes: 185 additions & 0 deletions example-web/aiken/build/packages/aiken-lang-stdlib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# Changelog

## v1.9.0 - 2024-05-24

### Added

- A new module [`aiken/pairs`](https://aiken-lang.github.io/stdlib/aiken/pairs.html) to work with associative lists (a.k.a. `Pairs`).

### Changed

- **BREAKING-CHANGE**<br/>
Specialized all `Dict`'s key to `ByteArray`, and thus remove the need for passing an extra comparison function in many functions. `Dict` are however still specialized with a phantom type for keys.

- **BREAKING-CHANGE**<br/>
Few functions from `Dict` have been renamed for consistency:
- `from_list` -> `from_pairs`
- `from_ascending_list` -> `from_ascending_pairs`
- `to_list` -> `to_pairs`

### Removed

N/A

## v1.8.0 - 2024-03-28

### Added

- [`value.reduce`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#reduce) to efficiently fold over a value and its elements.

- [`value.from_asset_list`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#from_asset_list) to turn an asset list into a Value while enforcing invariants expected of `Value`.

- [`math.is_sqrt`](https://aiken-lang.github.io/stdlib/aiken/math.html#is_sqrt) as a more efficient alternative to `sqrt`.

### Changed

- Disclaimers in documentation to [`bytearray.to_string`](https://aiken-lang.github.io/stdlib/aiken/bytearray.html#to_string) and [`string.from_bytearray`](https://aiken-lang.github.io/stdlib/aiken/string.html#from_bytearray) regarding UTF-8 encoding.

### Removed

N/A

## v1.7.0 - 2023-11-07

### Added

- [`list.index_of`](https://aiken-lang.github.io/stdlib/aiken/list.html#index_of): For getting a values index in a list.
- [`transaction.placeholder`](https://aiken-lang.github.io/stdlib/aiken/transaction.html#placeholder): For constructing test transactions.
- [`transaction.value.is_zero`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#is_zero): For checking whether a value is null.

### Changed

- [`value.to_minted_value`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#to_minted_value) now correctly preserves the invariant of `MintedValue`: it always contain a null quantity of Ada.

### Removed

N/A

## v1.6.0 - 2023-09-08

### Added

- [`math.pow2`](https://aiken-lang.github.io/stdlib/aiken/math.html#pow2): For faster exponentions for powers of two.
- [`bytearray.test_bit`](https://aiken-lang.github.io/stdlib/aiken/bytearray.html#test_bit): For testing if a bit is set in a bytearray (MSB).

## v1.5.0 - 2023-08-16

### Removed

- retired `list.and` and `list.or` because of the new keywords for logical op chaining.

## v1.4.0 - 2023-07-21

### Changed

- Fixed missing null-check on `value.add`. Adding a null quantity of token is now correctly a no-op.

## v1.3.0 - 2023-06-30

### Added

- [`math.sqrt`](https://aiken-lang.github.io/stdlib/aiken/math.html#sqrt): For calculating integer square roots using a quadratically convergent method.
- [`math/rational.numerator`](https://aiken-lang.github.io/stdlib/aiken/math/rational.html#numerator) & [`math/rational.denominator`](https://aiken-lang.github.io/stdlib/aiken/math/rational.html#numerator): For accessing parts of a rational value.
- [`math/rational.arithmetic_mean`](https://aiken-lang.github.io/stdlib/aiken/math/rational.html#arithmetic_mean): For computing [arithmetic mean](https://en.wikipedia.org/wiki/Arithmetic_mean) of rational values.
- [`math/rational.geometric_mean`](https://aiken-lang.github.io/stdlib/aiken/math/rational.html#geometric_mean): For computing [geometric mean](https://en.wikipedia.org/wiki/Geometric_mean) of two rational values.

### Changed

- Clear empty asset lists in [`Value`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#Value) on various operations. Before that fix, it could happen that removing all assets from a given policy would lead to an empty dictionnary of assets still be present in the `Value`.

## v1.2.0 - 2023-06-17

### Added

- [`transaction/value.MintedValue`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#MintedValue)
- [`transaction/value.from_minted_value`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#from_minted_value): Convert from `MintedValue` to `Value`
- [`transaction/value.to_minted_value`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#to_minted_value): Convert from `Value` to `MintedValue`
- [`transaction/bytearray.to_hex`](https://aiken-lang.github.io/stdlib/aiken/bytearray.html#to_hex): Convert a `ByteArray` to a hex encoded `String`
- [`math/rational`](https://aiken-lang.github.io/stdlib/aiken/math/rational.html): Working with rational numbers.
- [x] `abs`
- [x] `add`
- [x] `ceil`
- [x] `compare`
- [x] `compare_with`
- [x] `div`
- [x] `floor`
- [x] `from_int`
- [x] `mul`
- [x] `negate`
- [x] `new`
- [x] `proper_fraction`
- [x] `reciprocal`
- [x] `reduce`
- [x] `round`
- [x] `round_even`
- [x] `sub`
- [x] `truncate`
- [x] `zero`

### Removed

- module `MintedValue` was merged with `Value`

## v1.1.0 - 2023-06-06

### Added

- [`list.count`](https://aiken-lang.github.io/stdlib/aiken/list.html#count): Count how many items in the list satisfy the given predicate.

- [`int.from_utf8`](https://aiken-lang.github.io/stdlib/aiken/int.html#from_utf8): Parse an integer from a utf-8 encoded `ByteArray`, when possible.

- [`dict.foldl`](https://aiken-lang.github.io/stdlib/aiken/dict.html#foldl) & [`dict.foldr`](https://aiken-lang.github.io/stdlib/aiken/dict.html#foldr): for left and right folds over dictionnary elements in ascending key order.

- [`dict.insert_with`](https://aiken-lang.github.io/stdlib/aiken/dict.html#insert_with): Insert a value in the dictionary at a given key. When the key already exist, the provided merge function is called.

- [`transaction/value.add`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#add): Add a (positive or negative) quantity of a single token to a value. This is more efficient than `merge` for a single asset.

- [`transaction/value.to_dict`](https://aiken-lang.github.io/stdlib/aiken/transaction/value.html#to_dict): Convert a `Value` into a dictionnary of dictionnaries.

- A new module [`transaction/minted_value`](https://aiken-lang.github.io/stdlib/aiken/transaction/minted_value.html): This is used exclusively for representing values present in the `mint` field of transactions. This allows to simplify some of the implementation for `Value` which no longer needs to handle the special case where null-quantity tokens would be present. It isn't possible to construct `MintedValue` by hand, they come from the script context entirely and are 'read-only'.

- More documentation for `dict` and `interval` modules.

### Changed

> **Warning**
>
> Most of those changes are breaking-changes. Though, given we're still in an
> alpha state, only the `minor` component is bumped from the version number.
> Please forgive us.
- Rework `list.{foldl, foldr, reduce, indexed_foldr}`, `dict.{fold}`, `bytearray.{foldl, foldr, reduce}` to take the iterator as last argument. For example:

```
fn foldl(self: List<a>, with: fn(a, b) -> b, zero: b) -> b
↓ becomes
fn foldl(self: List<a>, zero: b, with: fn(a, b) -> b) -> b
```

- Fixed implementation of `bytearray.slice`; `slice` would otherwise behave as if the second argument were an offset.

- Rename `transaction/value.add` into `transaction/value.merge`.

- Swap arguments of the merge function in `dict.union_with`; the first value received now corresponds to the value already present in the dictionnary.

- Fixed various examples from the documentation

### Removed

- Removed `dict.fold`; replaced with `dict.foldl` and `dict.foldr` to remove ambiguity.

## v1.0.0 - 2023-04-13

### Added

N/A

### Changed

N/A

### Removed

N/A
Loading

0 comments on commit 7c6526d

Please sign in to comment.