Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroProofs committed Dec 23, 2023
0 parents commit c482a13
Show file tree
Hide file tree
Showing 8 changed files with 401 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/tests.yml
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/setup-aiken@v0.1.0
with:
version: v1

- run: aiken fmt --check
- run: aiken check -D
- run: aiken build
6 changes: 6 additions & 0 deletions .gitignore
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/
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Bullet

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).
15 changes: 15 additions & 0 deletions aiken.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by Aiken
# You typically do not need to edit this file

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

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

[etags]
14 changes: 14 additions & 0 deletions aiken.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name = "aiken-lang/composable-account"
version = "0.0.0"
license = "Apache-2.0"
description = "Aiken contracts for project 'aiken-lang/composable-account'"

[repository]
user = "aiken-lang"
project = "composable-account"
platform = "github"

[[dependencies]]
name = "aiken-lang/stdlib"
version = "1.7.0"
source = "github"
Empty file.
38 changes: 38 additions & 0 deletions lib/composable-account/utils.ak
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use aiken/builtin
use aiken/dict.{Dict}
use aiken/hash.{Blake2b_224, Hash}
use aiken/list
use aiken/transaction/credential.{VerificationKey}

pub fn list_at(list: List<a>, index: Int) -> a {
if index == 0 {
builtin.head_list(list)
} else {
builtin.tail_list(list) |> list_at(index - 1)
}
}

pub fn dict_get(dict: Dict<a, b>, key: a) -> b {
dict |> dict.to_list |> do_dict_get(key)
}

fn do_dict_get(list: List<(a, b)>, key: a) -> b {
expect [head, ..tail] = list

if builtin.fst_pair(head) == key {
builtin.snd_pair(head)
} else {
do_dict_get(tail, key)
}
}

pub fn validate_keys_present(
owners: List<Hash<Blake2b_224, VerificationKey>>,
signers: List<Hash<Blake2b_224, VerificationKey>>,
) -> Bool {
when owners is {
[] -> True
[owner, ..rest_owners] ->
list.has(signers, owner) && validate_keys_present(rest_owners, signers)
}
}
Loading

0 comments on commit c482a13

Please sign in to comment.