Skip to content

Commit

Permalink
Refresh gift_card and hello_world examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Sep 1, 2024
1 parent 7bfc014 commit 9f6daa8
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 33 deletions.
6 changes: 3 additions & 3 deletions examples/acceptance_tests/054/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use aiken/transaction/value
use cardano/assets

test test_quantity_of_1() {
let x = value.from_asset(#"000000", #"000020e05363726970744f776e6572", -1)
value.quantity_of(x, #"000000", #"000020e05363726970744f776e6572") < 0
let x = assets.from_asset(#"000000", #"000020e05363726970744f776e6572", -1)
assets.quantity_of(x, #"000000", #"000020e05363726970744f776e6572") < 0
}
6 changes: 3 additions & 3 deletions examples/acceptance_tests/067/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use aiken/bytearray.{from_string}
use aiken/hash.{Hash, Sha2_256, sha2_256}
use aiken/list
use aiken/collection/list
use aiken/crypto.{Hash, Sha2_256, sha2_256}
use aiken/option.{choice, is_none}
use aiken/primitive/bytearray.{from_string}

// Construction of the merkle tree shouldn't be done by hand, but via
// 'from_list'.
Expand Down
19 changes: 8 additions & 11 deletions examples/acceptance_tests/068/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use aiken/bytearray
use aiken/dict.{Dict}
use aiken/hash.{Blake2b_224, Hash}
use aiken/transaction/credential.{Script}
use aiken/collection/dict.{Dict}
use aiken/crypto.{Blake2b_224, Hash, Script}
use aiken/primitive/bytearray

pub type PolicyId =
Hash<Blake2b_224, Script>
Expand All @@ -13,19 +12,17 @@ pub opaque type Value {
inner: Dict<PolicyId, Dict<AssetName, Int>>,
}

pub fn zero() -> Value {
Value { inner: dict.new() }
}
pub const zero: Value = Value { inner: dict.empty }

pub fn from_asset(
policy_id: PolicyId,
asset_name: AssetName,
quantity: Int,
) -> Value {
let asset =
dict.new()
dict.empty
|> dict.insert(asset_name, quantity)
dict.new()
dict.empty
|> dict.insert(policy_id, asset)
|> Value
}
Expand Down Expand Up @@ -86,12 +83,12 @@ pub fn flatten_with(
}

test flatten_with_1() {
flatten_with(zero(), fn(p, a, q) { Some((p, a, q)) }) == []
flatten_with(zero, fn(p, a, q) { Some((p, a, q)) }) == []
}

test flatten_with_2() {
let v =
zero()
zero
|> add(from_asset("a", "1", 14))
|> add(from_asset("b", "", 42))
|> add(from_asset("a", "2", 42))
Expand Down
6 changes: 3 additions & 3 deletions examples/acceptance_tests/074/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use aiken/bytearray.{from_string}
use aiken/hash.{Hash, Sha2_256, sha2_256}
use aiken/list
use aiken/collection/list
use aiken/crypto.{Hash, Sha2_256, sha2_256}
use aiken/option.{choice, is_none}
use aiken/primitive/bytearray.{from_string}

/// Variant of MerkleTree with only hash but without actual value
pub type MerkleTree<a> {
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/084/lib/tests.ak
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use aiken/builtin.{snd_pair}
use aiken/cbor
use aiken/list
use aiken/collection/list

test tuple_when() {
let items =
Expand Down
6 changes: 3 additions & 3 deletions examples/acceptance_tests/089/validators/test2.ak
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use aiken/collection/list
use cardano/assets
use cardano/address.{Address, VerificationKey}
use cardano/assets
use cardano/transaction.{Input, NoDatum, Output, OutputReference, Transaction}

pub const own_hash = #"01020304050607080910111213140102030405060708091011121314"
Expand Down Expand Up @@ -46,7 +46,7 @@ test test_simple_oneshot() {
let output =
Output {
address: beneficiary_address(),
value: assets.zero(),
value: assets.zero,
datum: NoDatum,
reference_script: None,
}
Expand All @@ -59,7 +59,7 @@ test test_simple_oneshot() {

let tx =
Transaction {
..transaction.placeholder(),
..transaction.placeholder,
mint: mint,
extra_signatories: [other_hash],
inputs: [input],
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/099/lib/bar.ak
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use aiken/list.{count as my_count} as native_list
use aiken/collection/list.{count as my_count} as native_list

test thing_1() {
let x =
Expand Down
2 changes: 1 addition & 1 deletion examples/gift_card/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1725021962, nanos_since_epoch = 944823000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1725207295, nanos_since_epoch = 895782000 }, "d79382d2b6ecb3aee9b0755c31d8a5bbafe88a7b3706d7fb8a52fd4d05818501"]
2 changes: 1 addition & 1 deletion examples/gift_card/plutus.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"plutusVersion": "v3",
"compiler": {
"name": "Aiken",
"version": "v1.1.0+9407b67"
"version": "v1.1.0+ddfe01e"
},
"license": "Apache-2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/gift_card/validators/multi.ak
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use aiken/builtin
use aiken/collection/dict
use aiken/collection/list
use aiken/hash.{blake2b_256}
use aiken/crypto.{blake2b_256}
use aiken/primitive/bytearray
use cardano/address.{Address, PaymentCredential, Script}
use cardano/assets.{PolicyId}
use cardano/credential.{Address, PaymentCredential, Script}
use cardano/transaction.{
InlineDatum, Input, Output, OutputReference, Transaction,
} as tx
Expand Down
2 changes: 1 addition & 1 deletion examples/gift_card/validators/oneshot.ak
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use aiken/collection/dict
use aiken/collection/list
use cardano/address.{Script}
use cardano/assets.{PolicyId}
use cardano/credential.{Script}
use cardano/transaction.{OutputReference, Transaction} as tx

pub type Action {
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world/aiken.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ requirements = []
source = "github"

[etags]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1725021976, nanos_since_epoch = 403974000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1725207187, nanos_since_epoch = 801664000 }, "d79382d2b6ecb3aee9b0755c31d8a5bbafe88a7b3706d7fb8a52fd4d05818501"]
4 changes: 2 additions & 2 deletions examples/hello_world/validators/hello_world.ak
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aiken/collection/list
use cardano/credential.{VerificationKeyHash}
use aiken/crypto.{VerificationKeyHash}
use cardano/transaction.{OutputReference, Transaction}

pub type Datum {
Expand All @@ -16,7 +16,7 @@ validator hello_world {
redeemer: Redeemer,
_: OutputReference,
transaction: Transaction,
) -> Bool {
) {
let must_say_hello = redeemer.msg == "Hello, World!"

expect Some(Datum { owner }) = datum
Expand Down

0 comments on commit 9f6daa8

Please sign in to comment.