https://github.com/sidan-lab/vodka
Provide utility function for aiken onchain validation and testing utility
https://github.com/sidan-lab/vodka
Last synced: 6 months ago
JSON representation
Provide utility function for aiken onchain validation and testing utility
- Host: GitHub
- URL: https://github.com/sidan-lab/vodka
- Owner: sidan-lab
- License: apache-2.0
- Created: 2024-03-19T08:31:46.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-09T08:02:58.000Z (10 months ago)
- Last Synced: 2024-08-09T19:34:25.629Z (10 months ago)
- Language: Gleam
- Homepage: https://sidan-lab.github.io/vodka/
- Size: 178 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-aiken - sidan-lab/vodka - Offer validation utils and similar to offchain code building experience framework for unit testing. (Libraries)
README
Vodka - Library for Aiken Development
[](https://github.com/sidan-lab/vodka/blob/main/LICENSE)
[](https://github.com/sidan-lab/vodka/actions/workflows/build_docs.yml)
[](https://x.com/sidan_lab)
Vodka is a library build for [Aiken](https://aiken-lang.org/) development. It offers
1. [Cocktail](https://sidan-lab.github.io/vodka/cocktail.html) - Validating utils in writing on-chain code in aiken
2. [Mocktail](https://sidan-lab.github.io/vodka/mocktail.html) - Unit test utils for easy building mock value for unit test## Version
Vodka is now upgraded to support latest PlutusV3 with latest version, if you want to use the old version compatible for legacy aiken version, please refer to below's table
| Vodka | Aiken Compiler | `aiken-lang/stdlib` |
| ---------- | -------------- | ------------------- |
| 0.1.6 | ^v1.1.5 | v2.1.0 |
| 0.0.1-beta | v1.0.29-alpha | v1.9.0 |## Vodka is pure and simple
For your transaction.
```rs
let Transaction { inputs, outputs, extra_signatories, .. } = context.transaction
```Locating inputs & outputs:
```rs
when (inputs_at(inputs, target_address), outputs_at(outputs, target_address)) is {
([only_input], [only_output]) -> ...
_ -> False
}
```Checking signature with:
```rs
key_signed(extra_signatories, key_hash_required)
```## Imports and function groups
All onchain utility functions can be imported from `cocktail` and are grouped with a naming convention of `vodka_`.
```ak
use cocktail.{}
```| Type | Naming Convention |
| ------------------------------------ | ----------------------------------------- |
| Address | `vodka_address.{}` |
| Value | `vodka_value.{}` |
| transaction.extra_signatories | `vodka_extra_signatories.{}` |
| transaction.inputs | `vodka_inputs.{}` |
| transaction.mints | `vodka_mints.{}` |
| transaction.outputs | `vodka_outputs.{}` |
| transaction.redeemers | `vodka_redeemers.{}` |
| transaction.validity_range | `vodka_validity_range.{}` |
| ByteArray and Int conversion & utils | `vodka_converter.{}` |## Taste it before vodka cocktail, mocktail can be mixed, blended and Mesh
Building unit testing in vodka, easily indicating how you should build in [whisky](https://whisky.sidan.io/) and [Mesh](https://meshjs.dev/).
You can taste if your transaction can pass your aiken contract validation:
```rs
# Mock transaction
let mock_tx: Transaction = mocktail_tx()
...
|> required_signer_hash(is_key_provided, mock_pub_key_hex(1))
|> complete()
```Then move it to blend a whisky:
```rs
let mut tx = MeshTxBuilder::new_core()
tx.spending_plutus_script_v2()
...
.required_signer_hash(key_hash)
.complete(None)```
Or Mesh:
```ts
const txBuilder = new MeshTxBuilder();
await txBuilder
...
.requiredSignerHash(keyHash)
.complete();
```## Start mixing
Simply run
```sh
aiken add sidan-lab/vodka --version 0.1.6
```or putting the below in you `aiken.toml`
```toml
[[dependencies]]
name = "sidan-lab/vodka"
version = "0.1.6"
source = "github"
```## Documentation
Please refer to the [hosted documentation](https://sidan-lab.github.io/vodka/).
