Skip to content

Commit

Permalink
Merge pull request #9 from Anastasia-Labs/develop
Browse files Browse the repository at this point in the history
fix: bump stdlib version
  • Loading branch information
HarunJr authored Oct 22, 2024
2 parents 1426440 + 1af45f9 commit 8e5c1f7
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: aiken-lang/setup-aiken@v0.1.0
- uses: aiken-lang/setup-aiken@v1.0.2
with:
version: v1.0.26-alpha
version: v1.0.29-alpha

- run: aiken fmt --check
- run: aiken check -D
Expand Down
2 changes: 1 addition & 1 deletion aiken.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ platform = "github"

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

[[dependencies]]
Expand Down
6 changes: 3 additions & 3 deletions lib/aiken-design-patterns/merkelized-validator.ak
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aiken/dict.{Dict}
use aiken/hash.{Blake2b_224, Hash}
use aiken/pairs
use aiken/transaction.{Redeemer, ScriptContext, ScriptPurpose, WithdrawFrom}
use aiken/transaction/credential.{Inline, Script, ScriptCredential}

Expand All @@ -11,11 +11,11 @@ pub type WithdrawRedeemer<a, b> {
pub fn spend(
staking_validator: Hash<Blake2b_224, Script>,
function_args: List<Data>,
redeemers: Dict<ScriptPurpose, Redeemer>,
redeemers: Pairs<ScriptPurpose, Redeemer>,
) -> List<Data> {
expect Some(rdmr) =
redeemers
|> dict.get(WithdrawFrom(Inline(ScriptCredential(staking_validator))))
|> pairs.get_first(WithdrawFrom(Inline(ScriptCredential(staking_validator))))
expect WithdrawRedeemer { input_args, results }: WithdrawRedeemer<Data, Data> =
rdmr

Expand Down
4 changes: 2 additions & 2 deletions lib/aiken-design-patterns/stake-validator.ak
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aiken/dict
use aiken/hash.{Blake2b_224, Hash}
use aiken/pairs
use aiken/transaction.{
Output, Redeemer, ScriptContext, Spend, Transaction, WithdrawFrom,
}
Expand All @@ -17,7 +17,7 @@ pub fn spend(ctx: ScriptContext) -> Bool {
let own_withdrawal = Inline(own_addr.payment_credential)

// Arbitrary withdrawal from this script is required.
dict.has_key(withdrawals, own_withdrawal)
pairs.has_key(withdrawals, own_withdrawal)
}

pub fn withdraw(
Expand Down
27 changes: 7 additions & 20 deletions validators/merkelized-validator-example.ak
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use aiken/dict
use aiken/fuzz
use aiken/hash.{Blake2b_224, Hash}
use aiken/interval
use aiken/transaction.{
Redeemer, ScriptContext, ScriptPurpose, Transaction, TransactionId,
WithdrawFrom,
}
use aiken/transaction.{ScriptContext, Transaction, TransactionId, WithdrawFrom}
use aiken/transaction/credential.{Inline, Script, ScriptCredential}
use aiken/transaction/value
use aiken_design_patterns/merkelized_validator.{WithdrawRedeemer} as merkelized_validator
Expand Down Expand Up @@ -36,13 +33,8 @@ test spend_validator() {
let stake_validator: Hash<Blake2b_224, Script> =
#"99999999999999999999999999999999999999999999999999999999"
let redeemer: Data = WithdrawRedeemer { input_args: [2, 4], results: [20] }
let redeemers: dict.Dict<ScriptPurpose, Redeemer> =
dict.new()
|> dict.insert(
WithdrawFrom(Inline(ScriptCredential(stake_validator))),
redeemer,
fn(_, _) -> Ordering { Less },
)
let redeemers =
[Pair(WithdrawFrom(Inline(ScriptCredential(stake_validator))), redeemer)]
let tx =
Transaction {
inputs: [],
Expand All @@ -51,7 +43,7 @@ test spend_validator() {
fee: value.zero(),
mint: value.zero() |> value.to_minted_value(),
certificates: [],
withdrawals: dict.new(),
withdrawals: [],
validity_range: interval.everything(),
extra_signatories: [],
redeemers,
Expand Down Expand Up @@ -145,13 +137,8 @@ test prop_spend_validator(r via random_spend_input()) {
let stake_validator: Hash<Blake2b_224, Script> = r.bs
let redeemer: Data =
WithdrawRedeemer { input_args: xs, results: expected_sum_of_squares }
let redeemers: dict.Dict<ScriptPurpose, Redeemer> =
dict.new()
|> dict.insert(
WithdrawFrom(Inline(ScriptCredential(stake_validator))),
redeemer,
fn(_, _) -> Ordering { Less },
)
let redeemers =
[Pair(WithdrawFrom(Inline(ScriptCredential(stake_validator))), redeemer)]
let tx =
Transaction {
inputs: [],
Expand All @@ -160,7 +147,7 @@ test prop_spend_validator(r via random_spend_input()) {
fee: value.zero(),
mint: value.zero() |> value.to_minted_value(),
certificates: [],
withdrawals: dict.new(),
withdrawals: [],
validity_range: interval.everything(),
extra_signatories: [],
redeemers,
Expand Down
24 changes: 8 additions & 16 deletions validators/multi-utxo-indexer-example.ak
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ test spend_validator() {
},
}
let withdrawals =
dict.new()
|> dict.insert(Inline(ScriptCredential(own_val_hash)), 1, fn(_, _) { Less })
[Pair(Inline(ScriptCredential(own_val_hash)), 1)]
let tx =
Transaction {
inputs: [input_utxo],
Expand All @@ -76,7 +75,7 @@ test spend_validator() {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -132,12 +131,7 @@ test prop_spend_validator(r via random_spend_input()) {
},
}
let withdrawals =
dict.new()
|> dict.insert(
Inline(ScriptCredential(own_val_hash)),
r.withdraw_amount,
fn(_, _) { Less },
)
[Pair(Inline(ScriptCredential(own_val_hash)), r.withdraw_amount)]
let tx =
Transaction {
inputs: [input_utxo],
Expand All @@ -149,7 +143,7 @@ test prop_spend_validator(r via random_spend_input()) {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -211,8 +205,7 @@ test withdraw_validator() {
let redeemer =
[(0, 0)]
let withdrawals =
dict.new()
|> dict.insert(Inline(ScriptCredential(own_val_hash)), 1, fn(_, _) { Less })
[Pair(Inline(ScriptCredential(own_val_hash)), 1)]
let tx =
Transaction {
inputs: [input_utxo],
Expand All @@ -224,7 +217,7 @@ test withdraw_validator() {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -310,8 +303,7 @@ fn random_withdraw_input() -> Fuzzer<WithdrawInput> {
test prop_withdraw_validator(r via random_withdraw_input()) {
let script_purpose = WithdrawFrom(Inline(ScriptCredential(r.val_hash)))
let withdrawals =
dict.new()
|> dict.insert(Inline(ScriptCredential(r.val_hash)), 1, fn(_, _) { Less })
[Pair(Inline(ScriptCredential(r.val_hash)), 1)]
let tx =
Transaction {
inputs: r.inputs,
Expand All @@ -323,7 +315,7 @@ test prop_withdraw_validator(r via random_withdraw_input()) {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
24 changes: 8 additions & 16 deletions validators/multi-utxo-indexer-one-to-many-example.ak
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ test spend_validator() {
},
}
let withdrawals =
dict.new()
|> dict.insert(Inline(ScriptCredential(own_val_hash)), 1, fn(_, _) { Less })
[Pair(Inline(ScriptCredential(own_val_hash)), 1)]
let tx =
Transaction {
inputs: [input_utxo],
Expand All @@ -70,7 +69,7 @@ test spend_validator() {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -126,12 +125,7 @@ test prop_spend_validator(r via random_spend_input()) {
},
}
let withdrawals =
dict.new()
|> dict.insert(
Inline(ScriptCredential(own_val_hash)),
r.withdraw_amount,
fn(_, _) { Less },
)
[Pair(Inline(ScriptCredential(own_val_hash)), r.withdraw_amount)]
let tx =
Transaction {
inputs: [input_utxo],
Expand All @@ -143,7 +137,7 @@ test prop_spend_validator(r via random_spend_input()) {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -205,8 +199,7 @@ test withdraw_validator() {
let redeemer =
[(0, [0])]
let withdrawals =
dict.new()
|> dict.insert(Inline(ScriptCredential(own_val_hash)), 1, fn(_, _) { Less })
[Pair(Inline(ScriptCredential(own_val_hash)), 1)]
let tx =
Transaction {
inputs: [input_utxo],
Expand All @@ -218,7 +211,7 @@ test withdraw_validator() {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -304,8 +297,7 @@ fn random_withdraw_input() -> Fuzzer<WithdrawInput> {
test prop_withdraw_validator(r via random_withdraw_input()) {
let script_purpose = WithdrawFrom(Inline(ScriptCredential(r.val_hash)))
let withdrawals =
dict.new()
|> dict.insert(Inline(ScriptCredential(r.val_hash)), 1, fn(_, _) { Less })
[Pair(Inline(ScriptCredential(r.val_hash)), 1)]
let tx =
Transaction {
inputs: r.inputs,
Expand All @@ -317,7 +309,7 @@ test prop_withdraw_validator(r via random_withdraw_input()) {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
8 changes: 4 additions & 4 deletions validators/singular-utxo-indexer-example.ak
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ test spend_validator() {
fee: value.zero(),
mint: value.zero() |> value.to_minted_value(),
certificates: [],
withdrawals: dict.new(),
withdrawals: [],
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -169,10 +169,10 @@ test prop_spend_validator(r via random_spend_input()) {
fee: value.zero(),
mint: value.zero() |> value.to_minted_value(),
certificates: [],
withdrawals: dict.new(),
withdrawals: [],
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
8 changes: 4 additions & 4 deletions validators/singular-utxo-indexer-one-to-many-example.ak
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ test spend_validator() {
fee: value.zero(),
mint: value.zero() |> value.to_minted_value(),
certificates: [],
withdrawals: dict.new(),
withdrawals: [],
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -145,10 +145,10 @@ test prop_spend_validator(r via random_spend_input()) {
fee: value.zero(),
mint: value.zero() |> value.to_minted_value(),
certificates: [],
withdrawals: dict.new(),
withdrawals: [],
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
14 changes: 4 additions & 10 deletions validators/stake-validator-example.ak
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ test spend_validator() {
},
}
let withdrawals =
dict.new()
|> dict.insert(Inline(ScriptCredential(own_val_hash)), 1, fn(_, _) { Less })
[Pair(Inline(ScriptCredential(own_val_hash)), 1)]
let tx =
Transaction {
inputs: [input_utxo],
Expand All @@ -63,7 +62,7 @@ test spend_validator() {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -115,12 +114,7 @@ test prop_spend_validator(r via random_spend_input()) {
},
}
let withdrawals =
dict.new()
|> dict.insert(
Inline(ScriptCredential(own_val_hash)),
r.withdraw_amount,
fn(_, _) { Less },
)
[Pair(Inline(ScriptCredential(own_val_hash)), r.withdraw_amount)]
let tx =
Transaction {
inputs: [input_utxo],
Expand All @@ -132,7 +126,7 @@ test prop_spend_validator(r via random_spend_input()) {
withdrawals,
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down
8 changes: 4 additions & 4 deletions validators/tx-level-minter-example.ak
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ test spend_validator() {
fee: value.zero(),
mint: minted_value,
certificates: [],
withdrawals: dict.new(),
withdrawals: [],
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -125,10 +125,10 @@ test prop_spend_validator(r via random_spend_input()) {
fee: value.zero(),
mint: minted_value,
certificates: [],
withdrawals: dict.new(),
withdrawals: [],
validity_range: interval.everything(),
extra_signatories: [],
redeemers: dict.new(),
redeemers: [],
datums: dict.new(),
id: TransactionId {
hash: #"0000000000000000000000000000000000000000000000000000000000000000",
Expand Down

0 comments on commit 8e5c1f7

Please sign in to comment.