Fix remaining acceptance tests to be V3-compatible

This commit is contained in:
KtorZ 2024-08-27 18:58:50 +02:00
parent d615b4f889
commit 48535636ed
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
59 changed files with 357 additions and 277 deletions

View File

@ -14,6 +14,7 @@ pub fn filter(xs: List<a>, f: fn(a) -> Bool) -> List<a> {
} }
test filter_1() { test filter_1() {
filter([1, filter([1, 2, 3, 4, 5, 6], fn(x) { builtin.mod_integer(x, 2) == 0 }) == [
2, 3, 4, 5, 6], fn(x) { builtin.mod_integer(x, 2) == 0 }) == [2, 4, 6] 2, 4, 6,
]
} }

View File

@ -3,14 +3,14 @@
[[requirements]] [[requirements]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
source = "github" source = "github"
[[packages]] [[packages]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
requirements = [] requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723158432, nanos_since_epoch = 10066000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724777134, nanos_since_epoch = 232157000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@ -3,5 +3,5 @@ version = "0.0.0"
[[dependencies]] [[dependencies]]
name = 'aiken-lang/stdlib' name = 'aiken-lang/stdlib'
version = 'main' version = 'v2'
source = 'github' source = 'github'

View File

@ -5,12 +5,12 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
} }
}, },
"validators": [ "validators": [
{ {
"title": "spend.mint", "title": "spend.bar.mint",
"redeemer": { "redeemer": {
"title": "_redeemer", "title": "_redeemer",
"schema": { "schema": {
@ -21,15 +21,28 @@
{ {
"title": "output_reference", "title": "output_reference",
"schema": { "schema": {
"$ref": "#/definitions/aiken~1transaction~1OutputReference" "$ref": "#/definitions/cardano~1transaction~1OutputReference"
} }
} }
], ],
"compiledCode": "589e0100003232323232323222322533300553330053370e900018031baa3232330010013758600460126ea8c008c024dd50019129998058008a6103d87a800013232533300a3375e600a60186ea80080244cdd2a40006601c00497ae0133004004001300f002300d0012300b00114a229405261365653330033370e900018021baa00115333006300537540022930b0b2b9a5573aaae7955cfaba05742ae881", "compiledCode": "58c90100003232323232323222533300332323232325332330093001300a375400426464a666016600660186ea8c8c8cc004004dd6180118079baa00922533301100114c0103d87a80001323253330103375e600a60246ea800803c4cdd2a40006602800497ae0133004004001301500230130012301100114a229414ccc028c008c02cdd50020a99980698061baa00414985858dd7180718059baa002370e90000b1806180680118058009805801180480098029baa00114984d9595cd2ab9d5573caae7d5d02ba157441",
"hash": "0241f73ef186e53566d1b5a81eca50049b0d86833e6b88fe26b1e4bc" "hash": "2edaecec5a072cd65b12395410ce6da7cafaffdf70506cbcb40b4df8"
}, },
{ {
"title": "spend.spend", "title": "spend.bar.else",
"parameters": [
{
"title": "output_reference",
"schema": {
"$ref": "#/definitions/cardano~1transaction~1OutputReference"
}
}
],
"compiledCode": "58c90100003232323232323222533300332323232325332330093001300a375400426464a666016600660186ea8c8c8cc004004dd6180118079baa00922533301100114c0103d87a80001323253330103375e600a60246ea800803c4cdd2a40006602800497ae0133004004001301500230130012301100114a229414ccc028c008c02cdd50020a99980698061baa00414985858dd7180718059baa002370e90000b1806180680118058009805801180480098029baa00114984d9595cd2ab9d5573caae7d5d02ba157441",
"hash": "2edaecec5a072cd65b12395410ce6da7cafaffdf70506cbcb40b4df8"
},
{
"title": "spend.foo.spend",
"datum": { "datum": {
"title": "_datum", "title": "_datum",
"schema": { "schema": {
@ -42,8 +55,13 @@
"$ref": "#/definitions/Data" "$ref": "#/definitions/Data"
} }
}, },
"compiledCode": "58ef01000032323232323232222533300432330010013758601460166016600e6ea8c028c01cdd50011129998048008a501325333007333007533300a3253330083370e900118049baa00114bd6f7b63009bab300d300a375400264660020026eacc034c038c028dd518068019129998060008a60103d87a8000132323232533300d33722911050000000000000021533300d3371e91010500000000000000213374a9000198089ba60014bd700a6103d87a80001330060060033756601c0066eb8c030008c040008c0380045288a504a094452889980180180098060008a4c26cacae6955ceaab9e5573eae815d0aba21", "compiledCode": "5901230100003232323232323225333002323232323253330073370e900118041baa001132323232330010013758602060226022601a6ea8020894ccc03c0045280992999806999806a99980819299980719b8748008c03cdd50008a5eb7bdb1804dd5980998081baa001323300100137566026602860206ea8c04c00c894ccc048004530103d87a800013232323253330133372291105000000000000002153330133371e91010500000000000000213374a90001980b9ba60014bd700a6103d87a8000133006006003375660280066eb8c048008c058008c0500045288a504a0944528899801801800980900098071807801180680098049baa00116300b300c002300a001300a00230080013004375400229309b2b2b9a5573aaae7955cfaba05742ae881",
"hash": "f56561e01063b11146809755d9907147e79d3166aa5c65fba4040fd1" "hash": "cf024265a1ff4ab129cef178c64b8c4cab25d62129242e01e29bb3d1"
},
{
"title": "spend.foo.else",
"compiledCode": "5901230100003232323232323225333002323232323253330073370e900118041baa001132323232330010013758602060226022601a6ea8020894ccc03c0045280992999806999806a99980819299980719b8748008c03cdd50008a5eb7bdb1804dd5980998081baa001323300100137566026602860206ea8c04c00c894ccc048004530103d87a800013232323253330133372291105000000000000002153330133371e91010500000000000000213374a90001980b9ba60014bd700a6103d87a8000133006006003375660280066eb8c048008c058008c0500045288a504a0944528899801801800980900098071807801180680098049baa00116300b300c002300a001300a00230080013004375400229309b2b2b9a5573aaae7955cfaba05742ae881",
"hash": "cf024265a1ff4ab129cef178c64b8c4cab25d62129242e01e29bb3d1"
} }
], ],
"definitions": { "definitions": {
@ -68,7 +86,7 @@
} }
] ]
}, },
"aiken/transaction/OutputReference": { "cardano/transaction/OutputReference": {
"title": "OutputReference", "title": "OutputReference",
"description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output", "description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",
"anyOf": [ "anyOf": [
@ -79,7 +97,7 @@
"fields": [ "fields": [
{ {
"title": "transaction_id", "title": "transaction_id",
"$ref": "#/definitions/aiken~1transaction~1TransactionId" "$ref": "#/definitions/ByteArray"
}, },
{ {
"title": "output_index", "title": "output_index",
@ -88,23 +106,6 @@
] ]
} }
] ]
},
"aiken/transaction/TransactionId": {
"title": "TransactionId",
"description": "A unique transaction identifier, as the hash of a transaction body. Note that the transaction id\n isn't a direct hash of the `Transaction` as visible on-chain. Rather, they correspond to hash\n digests of transaction body as they are serialized on the network.",
"anyOf": [
{
"title": "TransactionId",
"dataType": "constructor",
"index": 0,
"fields": [
{
"title": "hash",
"$ref": "#/definitions/ByteArray"
}
]
}
]
} }
} }
} }

View File

@ -1,29 +1,33 @@
use aiken/dict use aiken/collection/dict
use aiken/list use aiken/collection/list
use aiken/transaction.{Output, OutputReference, ScriptContext} use cardano/assets.{PolicyId}
use aiken/transaction/value.{PolicyId} use cardano/transaction.{Output, OutputReference, Transaction}
const my_policy_id: PolicyId = #"0000000000" const my_policy_id: PolicyId = #"0000000000"
pub fn has_policy_id(self: Output, policy_id: PolicyId) -> Bool { pub fn has_policy_id(self: Output, policy_id: PolicyId) -> Bool {
self.value self.value
|> value.tokens(policy_id) |> assets.tokens(policy_id)
|> dict.is_empty |> dict.is_empty
|> not |> not
} }
validator foo { validator foo {
spend(_datum: Data, _redeemer: Data, o_ref: Data, tx: Transaction) -> Bool { spend(_datum: Option<Data>, _redeemer: Data, _o_ref: Data, self: Transaction) {
ctx.transaction.outputs self.outputs
|> list.any(has_policy_id(_, my_policy_id)) |> list.any(has_policy_id(_, my_policy_id))
} }
else(_) {
fail
}
} }
validator bar(output_reference: OutputReference) { validator bar(output_reference: OutputReference) {
mint(_redeemer: Void, _policy_id: Data, tx: Transaction) -> Bool { mint(_redeemer: Void, _policy_id, self: Transaction) {
when when
list.find( list.find(
ctx.transaction.inputs, self.inputs,
fn(input) { input.output_reference == output_reference }, fn(input) { input.output_reference == output_reference },
) )
is { is {
@ -31,4 +35,8 @@ validator bar(output_reference: OutputReference) {
None -> False None -> False
} }
} }
else(_) {
fail
}
} }

View File

@ -29,7 +29,7 @@ test expect_ford1() {
], ],
) )
expect Ford { owner, wheels, truck_bed_limit, .. }: Car = initial_car expect Ford { owner, wheels, truck_bed_limit, .. }: Car = initial_car
owner == #"" && ( wheels == 4 && truck_bed_limit == 10000 ) owner == #"" && wheels == 4 && truck_bed_limit == 10000
} }
test expect_ford2() { test expect_ford2() {
@ -42,14 +42,14 @@ test expect_ford2() {
car_doors: [], car_doors: [],
} }
expect Ford { owner, wheels, remote_connect, .. } = initial_car expect Ford { owner, wheels, remote_connect, .. } = initial_car
owner == #"2222222222" && ( wheels == 6 && remote_connect == #"" ) owner == #"2222222222" && wheels == 6 && remote_connect == #""
} }
test expect_list1() { test expect_list1() {
let initial_car = let initial_car =
[5, 6, 7] [5, 6, 7]
expect [a, b, c] = initial_car expect [a, b, c] = initial_car
a == 5 && ( b == 6 && c == 7 ) a == 5 && b == 6 && c == 7
} }
test expect_list2() { test expect_list2() {

View File

@ -5,12 +5,12 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
} }
}, },
"validators": [ "validators": [
{ {
"title": "foo.spend", "title": "foo.foo.spend",
"datum": { "datum": {
"title": "_datum", "title": "_datum",
"schema": { "schema": {
@ -23,8 +23,13 @@
"$ref": "#/definitions/Void" "$ref": "#/definitions/Void"
} }
}, },
"compiledCode": "585201000032323232232232253330064a229309b2b299980219b8748000c014dd50008a99980398031baa001149858594ccc008cdc3a400060066ea800454ccc014c010dd50008a4c2c2cae6955ceaab9e5573f", "compiledCode": "587601000032323232323225333002323232323253330073370e900118041baa0011323232324a2a66601466e1d2000300b375400a2a66601a60186ea80145261616300d300e002300c001300937540022c6014601600460120026012004600e00260086ea8004526136565734aae7555cf2ab9f5742ae89",
"hash": "84a516ff1f146f698164b5e64ff813e4e22ba2fa35491f2dc3d70935" "hash": "c613c8326fea00dff179b7108f248b60c155881bbce544d84fe573e1"
},
{
"title": "foo.foo.else",
"compiledCode": "587601000032323232323225333002323232323253330073370e900118041baa0011323232324a2a66601466e1d2000300b375400a2a66601a60186ea80145261616300d300e002300c001300937540022c6014601600460120026012004600e00260086ea8004526136565734aae7555cf2ab9f5742ae89",
"hash": "c613c8326fea00dff179b7108f248b60c155881bbce544d84fe573e1"
} }
], ],
"definitions": { "definitions": {

View File

@ -1,7 +1,11 @@
validator foo { validator foo {
spend(_datum: Void, _redeemer: Void, oref: Data, _tx: Void) -> Bool { spend(_datum: Option<Void>, _redeemer: Void, oref: Data, _tx: Void) {
True True
} }
else(_) {
fail
}
} }
test foo() { test foo() {

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596650, nanos_since_epoch = 294733000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776969, nanos_since_epoch = 835808000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596651, nanos_since_epoch = 984539000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776974, nanos_since_epoch = 866167000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596658, nanos_since_epoch = 893017000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776995, nanos_since_epoch = 750600000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596651, nanos_since_epoch = 968695000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776974, nanos_since_epoch = 455232000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596660, nanos_since_epoch = 748574000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724777001, nanos_since_epoch = 587403000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -322,7 +322,7 @@ test get_proof_4() {
let h1: ByteArray = get_proof_item_value(p1) let h1: ByteArray = get_proof_item_value(p1)
let h2: ByteArray = get_proof_item_value(p2) let h2: ByteArray = get_proof_item_value(p2)
size_match && ( h1 == hash_fn(cat) && h2 == right_node_hash ) size_match && h1 == hash_fn(cat) && h2 == right_node_hash
} }
fn do_from_list( fn do_from_list(

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596659, nanos_since_epoch = 760789000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776997, nanos_since_epoch = 900786000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596660, nanos_since_epoch = 681097000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724777000, nanos_since_epoch = 47370000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596647, nanos_since_epoch = 155791000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776959, nanos_since_epoch = 949879000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -3,14 +3,14 @@
[[requirements]] [[requirements]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
source = "github" source = "github"
[[packages]] [[packages]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
requirements = [] requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723158434, nanos_since_epoch = 487166000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724776963, nanos_since_epoch = 265617000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@ -5,12 +5,12 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
} }
}, },
"validators": [ "validators": [
{ {
"title": "spend.pool_contract", "title": "spend.foo.spend",
"datum": { "datum": {
"title": "datum", "title": "datum",
"schema": { "schema": {
@ -23,8 +23,13 @@
"$ref": "#/definitions/spend~1PoolRedeemer" "$ref": "#/definitions/spend~1PoolRedeemer"
} }
}, },
"compiledCode": "5904170100003232323232323232232325333004300230053754006264a6660100022c264a66666601a002264a6660140022c264a66666601e0022c2c2c26464a66601a0022c264a6666660240022c2c2c264a66601e6024006266601200e24a66601a6016601c6ea80044c94ccc044004584c94cccccc05800454ccc048c0540084c8c8c94ccc048c0400044c94ccc058004584c94cccccc06c0045858584c94ccc060c06c00c5401458dd68008b180c000980a1baa004153330123003001132533301600116132533333301b00115333017301a00215333014301230153754002264a6660300022c264a66666603a002264a6660340022c264a66666603e0022c2c2c264a666038603e006266602c0082a0122c2c6eb400458c070004c07000858585858c068004c058dd50008b0b0b0b0b0b180c000980a1baa004153330123370e9002000899299980b0008b099299999980d8008a99980b980d0010a99980a1809180a9baa001132533301800116132533333301d001132533301a00116132533333301f001161616132533301c301f0031333016004150091616375a0022c603800260380042c2c2c2c6034002602c6ea8004585858585858c060004c050dd50020b18091baa0031253330113232325333014301200114a226464646464a666032601400c26464a666036601860386ea80044c8c8c94ccc078c070c07cdd5000899192999810180f18109baa0011324a2604a60446ea800458cc01c03c00cc08cc080dd50008b198038068009804244101ff003020301d37540022940c00cc070dd5005180f180d9baa00713232533301b300c301c37540022646464a66603c6038603e6ea80044c8c94ccc080c078c084dd50008992513025302237540022c6600e01e006604660406ea800458cc01c034004c021220101ff003020301d37540022940c00cc070dd5005180f180d9baa00722330053758601260386ea8c024c070dd5001119baf300a301d37546008603a6ea80040088c074c07800488cc00cdd6180e980f180f180d1baa3007301a3754004466ebcc020c06cdd500080111191980080080191299980e0008a6103d87a800013232533301b300500213374a90001980f80125eb804cc010010004c080008c0780048cdd2a40006603266e95200233019375200297ae0330194c103d87a80004bd70180a1baa00130013014375400c4602e00229309b2b1b87480085858585858c04c004c03cdd50008b0b0b1bad00116300f001300f003375a0022c601800260180042c2c2c2c6014002600c6ea800c588894ccc018c010c01cdd5001899299980500080109929999998078008018018018018991929998068008028992999999809000803003003003099299980798090018a8040039bae001300f001300f003375c002601800260106ea800c004dc3a4000ae6955ceaab9e5573eae815d0aba25749", "compiledCode": "5903a2010000323232323232323225333002323232323253323300830013009375400426464646464a66601a6004601c6ea80204c94ccc044004584c94cccccc05800454ccc048c0540084c8c94ccc044c0180044c94ccc054004584c94cccccc0680045858584c94ccc05cc06800c5401458dd68008b180b80098099baa00315333011300a001132533301500116132533333301a00115333016301900215333013300830143754002264a66602e0022c264a666666038002264a6660320022c264a66666603c0022c2c2c264a666036603c00626660180082a0122c2c6eb400458c06c004c06c00858585858c064004c054dd50008b0b0b0b0b0b180b80098099baa003153330113370e9002000899299980a8008b099299999980d0008a99980b180c8010a9998099804180a1baa001132533301700116132533333301c001132533301900116132533333301e001161616132533301b301e003133300c004150091616375a0022c603600260360042c2c2c2c6032002602a6ea8004585858585858c05c004c04cdd50018b18089baa0021533300f30043010375400a264646464a666026601000229444c8c8c8c94ccc05cc0400144c8c8c94ccc068c03cc06cdd500089919299980e1808980e9baa0011324a26042603c6ea800458cc01406000cc07cc070dd50008b1980200b0009802a44101ff00301c3019375400c2646464a666034601e60366ea80044c8c94ccc070c044c074dd50008992513021301e37540022c6600a030006603e60386ea800458cc010058004c015220101ff00301c3019375400c44660086eb0c020c068dd5001119baf3009301b3754603c603e60366ea800400888cc00cdd6180e180e980e980c9baa00223375e601060346ea800400888c8cc00400400c894ccc06c004530103d87a800013232533301a300500213374a90001980f00125eb804cc010010004c07c008c0740048cdd2a40006603066e95200233018375200297ae0330184c103d87a80004bd7018099baa0013001301337540184602c002602860226ea8014585858585858c04c004c03cdd50040b1112999807980218081baa00313253330130010021325333333018001003003003003132325333016001005132533333301b0010060060060061325333018301b00315008007375c002603000260300066eb8004c054004c044dd50018009b8748000c03cc040008c038004c028dd50011b874800858c02cc030008c028004c028008c020004c010dd50008a4c26cacae6955ceaab9e5573eae815d0aba257481",
"hash": "640debfa5063d2e3fd7f23e9777aaf3a0f575a99972ccda8748a49c0" "hash": "10e8faa163e7c7699b978c2df5f2b1fadc9796e866d67b88799def6e"
},
{
"title": "spend.foo.else",
"compiledCode": "5903a2010000323232323232323225333002323232323253323300830013009375400426464646464a66601a6004601c6ea80204c94ccc044004584c94cccccc05800454ccc048c0540084c8c94ccc044c0180044c94ccc054004584c94cccccc0680045858584c94ccc05cc06800c5401458dd68008b180b80098099baa00315333011300a001132533301500116132533333301a00115333016301900215333013300830143754002264a66602e0022c264a666666038002264a6660320022c264a66666603c0022c2c2c264a666036603c00626660180082a0122c2c6eb400458c06c004c06c00858585858c064004c054dd50008b0b0b0b0b0b180b80098099baa003153330113370e9002000899299980a8008b099299999980d0008a99980b180c8010a9998099804180a1baa001132533301700116132533333301c001132533301900116132533333301e001161616132533301b301e003133300c004150091616375a0022c603600260360042c2c2c2c6032002602a6ea8004585858585858c05c004c04cdd50018b18089baa0021533300f30043010375400a264646464a666026601000229444c8c8c8c94ccc05cc0400144c8c8c94ccc068c03cc06cdd500089919299980e1808980e9baa0011324a26042603c6ea800458cc01406000cc07cc070dd50008b1980200b0009802a44101ff00301c3019375400c2646464a666034601e60366ea80044c8c94ccc070c044c074dd50008992513021301e37540022c6600a030006603e60386ea800458cc010058004c015220101ff00301c3019375400c44660086eb0c020c068dd5001119baf3009301b3754603c603e60366ea800400888cc00cdd6180e180e980e980c9baa00223375e601060346ea800400888c8cc00400400c894ccc06c004530103d87a800013232533301a300500213374a90001980f00125eb804cc010010004c07c008c0740048cdd2a40006603066e95200233018375200297ae0330184c103d87a80004bd7018099baa0013001301337540184602c002602860226ea8014585858585858c04c004c03cdd50040b1112999807980218081baa00313253330130010021325333333018001003003003003132325333016001005132533333301b0010060060060061325333018301b00315008007375c002603000260300066eb8004c054004c044dd50018009b8748000c03cc040008c038004c028dd50011b874800858c02cc030008c028004c028008c020004c010dd50008a4c26cacae6955ceaab9e5573eae815d0aba257481",
"hash": "10e8faa163e7c7699b978c2df5f2b1fadc9796e866d67b88799def6e"
} }
], ],
"definitions": { "definitions": {

View File

@ -1,16 +1,14 @@
use aiken/collection/list
use aiken/hash.{Blake2b_224, Hash}
use aiken/interval.{Finite} use aiken/interval.{Finite}
use aiken/list
use aiken/option use aiken/option
use cardano/assets.{ use cardano/assets.{
AssetName, PolicyId, Value, add, flatten, from_asset, negate, quantity_of, AssetName, PolicyId, Value, add, flatten, from_asset, negate, quantity_of,
} }
use cardano/credential.{ use cardano/credential.{Address, Script, VerificationKey}
Address, Script, ScriptCredential, VerificationKey, VerificationKeyCredential,
}
use cardano/hash.{Blake2b_224, Hash}
use cardano/transaction.{ use cardano/transaction.{
Datum, InlineDatum, Input, Output, OutputReference, Transaction, Datum, InlineDatum, Input, Output, OutputReference, Transaction, TransactionId,
TransactionId, ValidityRange, ValidityRange,
} }
// Datum/Redeemer pool // Datum/Redeemer pool
@ -20,7 +18,7 @@ pub type PoolDatum {
lent_out: Int, lent_out: Int,
} }
type PoolRedeemer { pub type PoolRedeemer {
action: PoolRedeemerType, action: PoolRedeemerType,
} }
@ -50,17 +48,11 @@ pub fn get_output(transaction: Transaction, address: Address) -> Option<Output>
} }
pub fn get_input(transaction: Transaction, address: Address) -> Option<Input> { pub fn get_input(transaction: Transaction, address: Address) -> Option<Input> {
list.find( list.find(transaction.inputs, fn(input) { input.output.address == address })
transaction.inputs,
fn(input) { input.output.address == address },
)
} }
pub fn scripthash_address(scripthash: ByteArray) { pub fn scripthash_address(scripthash: ByteArray) {
Address { Address { payment_credential: Script(scripthash), stake_credential: None }
payment_credential: ScriptCredential(scripthash),
stake_credential: None,
}
} }
pub fn validate_pool_deposit( pub fn validate_pool_deposit(
@ -91,13 +83,33 @@ pub fn validate_pool_borrow(
} }
validator foo { validator foo {
spend(datum: PoolDatum, redeemer: PoolRedeemer, output_ref: OutputReference, transaction: Transaction) { spend(
datum: Option<PoolDatum>,
redeemer: PoolRedeemer,
output_ref: OutputReference,
transaction: Transaction,
) {
expect Some(datum) = datum
when redeemer.action is { when redeemer.action is {
PoolWithdraw(_) -> True PoolWithdraw(_) -> True
PoolDeposit(pool_deposit_redeemer) -> PoolDeposit(pool_deposit_redeemer) ->
validate_pool_deposit(transaction, output_ref, datum, pool_deposit_redeemer) validate_pool_deposit(
transaction,
output_ref,
datum,
pool_deposit_redeemer,
)
PoolBorrow(pool_borrow_redeemer) -> PoolBorrow(pool_borrow_redeemer) ->
validate_pool_borrow(transaction, output_ref, datum, pool_borrow_redeemer) validate_pool_borrow(
transaction,
output_ref,
datum,
pool_borrow_redeemer,
)
} }
} }
else(_) {
fail
}
} }

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596656, nanos_since_epoch = 683898000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776989, nanos_since_epoch = 656788000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596654, nanos_since_epoch = 513356000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776984, nanos_since_epoch = 618944000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596654, nanos_since_epoch = 519690000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776985, nanos_since_epoch = 375340000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -3,14 +3,14 @@
[[requirements]] [[requirements]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
source = "github" source = "github"
[[packages]] [[packages]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
requirements = [] requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723158435, nanos_since_epoch = 59914000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724776958, nanos_since_epoch = 450634000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@ -5,12 +5,12 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
} }
}, },
"validators": [ "validators": [
{ {
"title": "spend.gift_card", "title": "spend.foo.mint",
"redeemer": { "redeemer": {
"title": "rdmr", "title": "rdmr",
"schema": { "schema": {
@ -27,15 +27,34 @@
{ {
"title": "utxo_ref", "title": "utxo_ref",
"schema": { "schema": {
"$ref": "#/definitions/aiken~1transaction~1OutputReference" "$ref": "#/definitions/cardano~1transaction~1OutputReference"
} }
} }
], ],
"compiledCode": "5901ce010000323232323232322322232323232533300930040011533300c300b375400a2a0042c2a66601260060022a66601860166ea8014540085858c024dd50020929998041919192999805980318061baa00113232323253330123015002132325333011300c3012375401a2a666022646600200200c44a66602c00229404c94ccc050cdd7980c980b1baa301900201114a226600600600260320022a6660226016002266e3c00803c5280b0b1bad3012002375c60200022c602600264a66601c6010601e6ea800452f5bded8c026eacc04cc040dd500099191980080099198008009bab3015301630163016301600522533301400114bd6f7b630099191919299980a99b9148900002153330153371e91010000210031005133019337606ea4008dd3000998030030019bab3016003375c60280046030004602c00244a666026002298103d87a800013232323253330143372200e0042a66602866e3c01c0084cdd2a4000660306e980052f5c02980103d87a80001330060060033756602a0066eb8c04c008c05c008c054004dd7180918079baa00337586022002601a6ea800858c03cc040008c038004c028dd50008a4c26cac6e1d2002370e90001bae0015734aae7555cf2ab9f5740ae855d11", "compiledCode": "59018501000032323232323232232225333005323232323253323300b3001300c3754004264646464a66601e600a0022a66602460226ea801c540085854ccc03cc00c00454ccc048c044dd50038a8010b0b18079baa006132323232533301430170021323253330133009301437540162a666026646600200200c44a66603000229404c94ccc058cdd7980d980c1baa301b00201314a226600600600260360022a666026600e002266e3c0080445280b0b1bad3014002375c60240022c602a00264a666020600860226ea800452f5bded8c026eacc054c048dd500099198008009bab3015301630163016301600322533301400114c103d87a80001323232325333015337220140042a66602a66e3c0280084cdd2a4000660326e980052f5c02980103d87a80001330060060033756602c0066eb8c050008c060008c058004dd6180980098079baa007370e90011bae3010300d37540046e1d200016300e300f002300d001300d002300b0013007375400229309b2b1bae0015734aae7555cf2ab9f5740ae855d11",
"hash": "4ef9bf69c108d6abd0a5af057a519df56d7fb333de428563810495a0" "hash": "784b2caa5e99b3d37361e3c3d51e7fd39f616025037eee525b73c5da"
}, },
{ {
"title": "spend2.backtrace", "title": "spend.foo.else",
"parameters": [
{
"title": "token_name",
"schema": {
"$ref": "#/definitions/ByteArray"
}
},
{
"title": "utxo_ref",
"schema": {
"$ref": "#/definitions/cardano~1transaction~1OutputReference"
}
}
],
"compiledCode": "59018501000032323232323232232225333005323232323253323300b3001300c3754004264646464a66601e600a0022a66602460226ea801c540085854ccc03cc00c00454ccc048c044dd50038a8010b0b18079baa006132323232533301430170021323253330133009301437540162a666026646600200200c44a66603000229404c94ccc058cdd7980d980c1baa301b00201314a226600600600260360022a666026600e002266e3c0080445280b0b1bad3014002375c60240022c602a00264a666020600860226ea800452f5bded8c026eacc054c048dd500099198008009bab3015301630163016301600322533301400114c103d87a80001323232325333015337220140042a66602a66e3c0280084cdd2a4000660326e980052f5c02980103d87a80001330060060033756602c0066eb8c050008c060008c058004dd6180980098079baa007370e90011bae3010300d37540046e1d200016300e300f002300d001300d002300b0013007375400229309b2b1bae0015734aae7555cf2ab9f5740ae855d11",
"hash": "784b2caa5e99b3d37361e3c3d51e7fd39f616025037eee525b73c5da"
},
{
"title": "spend2.foo.spend",
"datum": { "datum": {
"title": "_datum", "title": "_datum",
"schema": { "schema": {
@ -48,8 +67,13 @@
"$ref": "#/definitions/Void" "$ref": "#/definitions/Void"
} }
}, },
"compiledCode": "58ac010000323232323232322323223225333007533300730053008375464660020026eb0c034c038c038c028dd5180698051baa00222533300c00114c0103d87a800013232533300b4a2266e9520003300f0024bd70099802002000980800118070008a511614984d9594ccc014c00cc018dd50008a99980418039baa001149858594ccc00cc004c010dd50010a99980318029baa00214985858dc3a4000ae6955ceaab9e5573eae815d0aba201", "compiledCode": "58c70100003232323232323225333002323232323253330073370e900118041baa001132323232533300b3370e900018061baa32330010013758602260246024601c6ea8024894ccc0400045300103d87a800013232533300f4a2266e952000330130024bd70099802002000980a00118090008a5116533300a3370e900018059baa0051533300d300c375400a2930b0b18071807801180680098049baa00116300b300c002300a001300a00230080013004375400229309b2b2b9a5573aaae7955cfaba05742ae881",
"hash": "c58d31e63ad2d807c2188dfb1deafc433fe0f6a867e5cf8df68f068f" "hash": "c4700bfdb383c890d2a4c4505d3fc6d4b51e1998c3f33dd83e12ba44"
},
{
"title": "spend2.foo.else",
"compiledCode": "58c70100003232323232323225333002323232323253330073370e900118041baa001132323232533300b3370e900018061baa32330010013758602260246024601c6ea8024894ccc0400045300103d87a800013232533300f4a2266e952000330130024bd70099802002000980a00118090008a5116533300a3370e900018059baa0051533300d300c375400a2930b0b18071807801180680098049baa00116300b300c002300a001300a00230080013004375400229309b2b2b9a5573aaae7955cfaba05742ae881",
"hash": "c4700bfdb383c890d2a4c4505d3fc6d4b51e1998c3f33dd83e12ba44"
} }
], ],
"definitions": { "definitions": {
@ -70,7 +94,7 @@
} }
] ]
}, },
"aiken/transaction/OutputReference": { "cardano/transaction/OutputReference": {
"title": "OutputReference", "title": "OutputReference",
"description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output", "description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",
"anyOf": [ "anyOf": [
@ -81,7 +105,7 @@
"fields": [ "fields": [
{ {
"title": "transaction_id", "title": "transaction_id",
"$ref": "#/definitions/aiken~1transaction~1TransactionId" "$ref": "#/definitions/ByteArray"
}, },
{ {
"title": "output_index", "title": "output_index",
@ -91,23 +115,6 @@
} }
] ]
}, },
"aiken/transaction/TransactionId": {
"title": "TransactionId",
"description": "A unique transaction identifier, as the hash of a transaction body. Note that the transaction id\n isn't a direct hash of the `Transaction` as visible on-chain. Rather, they correspond to hash\n digests of transaction body as they are serialized on the network.",
"anyOf": [
{
"title": "TransactionId",
"dataType": "constructor",
"index": 0,
"fields": [
{
"title": "hash",
"$ref": "#/definitions/ByteArray"
}
]
}
]
},
"spend/Action": { "spend/Action": {
"title": "Action", "title": "Action",
"anyOf": [ "anyOf": [

View File

@ -1,15 +1,15 @@
use aiken/collection/dict use aiken/collection/dict
use aiken/collection/list.{find, foldr} use aiken/collection/list.{find, foldr}
use cardano/assets.{PolicyId, add, zero}
use cardano/transaction.{Input, OutputReference, Transaction} as tx use cardano/transaction.{Input, OutputReference, Transaction} as tx
use cardano/transaction/assets.{add, zero}
type Action { pub type Action {
Mint Mint
Burn Burn
} }
validator foo(token_name: ByteArray, utxo_ref: OutputReference) { validator foo(token_name: ByteArray, utxo_ref: OutputReference) {
mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) -> Bool { mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) {
let Transaction { inputs, mint, .. } = transaction let Transaction { inputs, mint, .. } = transaction
expect [Pair(asset_name, amount)] = expect [Pair(asset_name, amount)] =
mint mint
@ -24,4 +24,8 @@ validator foo(token_name: ByteArray, utxo_ref: OutputReference) {
Burn -> todo @"burn" Burn -> todo @"burn"
} }
} }
else(_) {
fail
}
} }

View File

@ -3,15 +3,19 @@ use cardano/transaction.{Output, Transaction}
validator foo { validator foo {
spend( spend(
_datum: Void, _datum: Option<Void>,
_redeemer: Void, _redeemer: Void,
_ref: Data, _ref: Data,
transaction: Transaction, transaction: Transaction,
) -> Bool { ) {
expect Some(_) = list.find(transaction.outputs, fn(_) { True }) expect Some(_) = list.find(transaction.outputs, fn(_) { True })
let _ = find_stuff(transaction) let _ = find_stuff(transaction)
True True
} }
else(_) {
fail
}
} }
fn find_stuff(transaction: Transaction) -> Output { fn find_stuff(transaction: Transaction) -> Output {

View File

@ -5,12 +5,12 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
} }
}, },
"validators": [ "validators": [
{ {
"title": "foo.spend", "title": "foo.foo.spend",
"datum": { "datum": {
"title": "datum", "title": "datum",
"schema": { "schema": {
@ -20,42 +20,32 @@
"redeemer": { "redeemer": {
"title": "redeemer", "title": "redeemer",
"schema": { "schema": {
"$ref": "#/definitions/RedeemerWrapper$Int" "$ref": "#/definitions/Int"
} }
}, },
"compiledCode": "5850010000323232322253330033370e900018021baa001153330033370e6eb4009205414984d9584c8c894ccc018cdc399b800030024815052613656375a600e600c6ea8008dd68012b9a5573aaae795d09", "compiledCode": "589a01000032323232322533300232323232323253330083370e9001000899191919299980619b8748000c034dd5001099b87337006eb4c03cc038dd5001000a40a82c6eb4018c034c038008c030004c028dd50010a99980419b87480000044c8cdc39bad00448150dd7180598051baa00216300837540026012601400460100026010004600c00260086ea8004526136565734aae7555cf2ba15745",
"hash": "dcac7ebcaf29721b4b48cc73775fa91939ad9015ea267b697e92b051" "hash": "86f0253dd8dd836d6588f5794eb8f08edd4476df28b607553126846e"
}, },
{ {
"title": "foo.mint", "title": "foo.foo.mint",
"redeemer": { "redeemer": {
"title": "redeemer", "title": "redeemer",
"schema": { "schema": {
"$ref": "#/definitions/Int" "$ref": "#/definitions/Int"
} }
}, },
"compiledCode": "5850010000323232322253330033370e900018021baa001153330033370e6eb4009205414984d9584c8c894ccc018cdc399b800030024815052613656375a600e600c6ea8008dd68012b9a5573aaae795d09", "compiledCode": "589a01000032323232322533300232323232323253330083370e9001000899191919299980619b8748000c034dd5001099b87337006eb4c03cc038dd5001000a40a82c6eb4018c034c038008c030004c028dd50010a99980419b87480000044c8cdc39bad00448150dd7180598051baa00216300837540026012601400460100026010004600c00260086ea8004526136565734aae7555cf2ba15745",
"hash": "dcac7ebcaf29721b4b48cc73775fa91939ad9015ea267b697e92b051" "hash": "86f0253dd8dd836d6588f5794eb8f08edd4476df28b607553126846e"
},
{
"title": "foo.foo.else",
"compiledCode": "589a01000032323232322533300232323232323253330083370e9001000899191919299980619b8748000c034dd5001099b87337006eb4c03cc038dd5001000a40a82c6eb4018c034c038008c030004c028dd50010a99980419b87480000044c8cdc39bad00448150dd7180598051baa00216300837540026012601400460100026010004600c00260086ea8004526136565734aae7555cf2ba15745",
"hash": "86f0253dd8dd836d6588f5794eb8f08edd4476df28b607553126846e"
} }
], ],
"definitions": { "definitions": {
"Int": { "Int": {
"dataType": "integer" "dataType": "integer"
},
"RedeemerWrapper$Int": {
"title": "Wrapped Redeemer",
"description": "A redeemer wrapped in an extra constructor to make multi-validator detection possible on-chain.",
"anyOf": [
{
"dataType": "constructor",
"index": 1,
"fields": [
{
"$ref": "#/definitions/Int"
}
]
}
]
} }
} }
} }

View File

@ -1,9 +1,14 @@
validator foo { validator foo {
spend(datum: Int, redeemer: Int, _ref: Data, _transaction: Data) { spend(datum: Option<Int>, redeemer: Int, _ref: Data, _transaction: Data) {
expect Some(datum) = datum
datum + redeemer == 42 datum + redeemer == 42
} }
mint(redeemer: Int, _policy: ByteArray, _transaction: Data) { mint(redeemer: Int, _policy: ByteArray, _transaction: Data) {
redeemer == 42 redeemer == 42
} }
else(_) {
fail
}
} }

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596649, nanos_since_epoch = 139799000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776965, nanos_since_epoch = 937696000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596646, nanos_since_epoch = 924702000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776958, nanos_since_epoch = 302886000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596647, nanos_since_epoch = 226716000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776958, nanos_since_epoch = 249560000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -3,14 +3,14 @@
[[requirements]] [[requirements]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
source = "github" source = "github"
[[packages]] [[packages]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
requirements = [] requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723158437, nanos_since_epoch = 77334000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724776991, nanos_since_epoch = 269398000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@ -4,5 +4,5 @@ description = ""
[[dependencies]] [[dependencies]]
name = 'aiken-lang/stdlib' name = 'aiken-lang/stdlib'
version = 'main' version = 'v2'
source = 'github' source = 'github'

View File

@ -5,12 +5,12 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
} }
}, },
"validators": [ "validators": [
{ {
"title": "other.validate", "title": "other.validate.spend",
"datum": { "datum": {
"title": "raw_datum", "title": "raw_datum",
"schema": { "schema": {
@ -23,8 +23,13 @@
"$ref": "#/definitions/Data" "$ref": "#/definitions/Data"
} }
}, },
"compiledCode": "5902b1010000323232323232322225333004323232533300730033008375400c264a6660160022c264a66666601e0022a666018601c00426464a666016600e002264a66601e0022c264a6666660260022a66602060240042a66601a6012601c6ea80044c94ccc044004584c94cccccc05400454ccc048c05000854ccc03cc02cc040dd500089929998098008b099299999980b800899299980a8008b099299999980c8008a99980b180c001099980680189919299980a9808800899299980c8008b099299999980e8008a99980d180e00109919299980c980a800899299980e8008b09929999998108008a99980f1810001099980a8008a8020b0b0b0b0b0b180f000980d9baa003153330193014001132533301d001161325333333021001161616132325333020001161325333333024001161616132325333023001161325333333027001161616132533302530270031500b16375a0022c604800260480066eb400458c084004c08400cdd68008b180f000980d9baa00316301937540042a0082c2c2c2c2c6034002602e6ea800c54ccc054c04000454ccc060c05cdd50018a8010b0b180a9baa0021500a16161616161630160013016002161616163014001301137540022c2c2c2c2c2c6024002601e6ea8004585858585858c040004c034dd50018a99980598030008a99980718069baa003150021616300b37540042a666012600a60146ea8c034c02cdd50040a5114a02c2c2c2c2c601800260126ea801858888c94ccc028c0180044c94ccc03800400c4c94cccccc0480040100100100104c94ccc040c04800c54018014dd7000980780098061baa0041533300a3005001132533300e00100313253333330120010040040040041325333010301200315006005375c002601e00260186ea8010008c028dd50019b8748008dc3a400029309b2b2b9a5573aaae7955cfaba15744ae91", "compiledCode": "5902fd010000323232323232322533300232323232325332330083001300937540042646464a664660186002601a6ea80084c8c94ccc038c00cc03cdd500109929998090008b099299999980b0008a999809980a8010991929998091803800899299980b0008b099299999980d0008a99980b980c8010a99980a1804980a9baa001132533301800116132533333301c00115333019301b00215333016300b30173754002264a6660340022c264a66666603c002264a6660380022c264a6666660400022a66603a603e004266601a00626464a6660386022002264a6660400022c264a6666660480022a666042604600426464a666040602a002264a6660480022c264a6666660500022a66604a604e004266602a0022a0082c2c2c2c2c2c604a00260446ea800c54ccc080c0640044c94ccc090004584c94cccccc0a00045858584c8c94ccc09c004584c94cccccc0ac0045858584c8c94ccc0a8004584c94cccccc0b80045858584c94ccc0b0c0b800c5402c58dd68008b181580098158019bad0011630280013028003375a0022c604a00260446ea800c58c080dd50010a8020b0b0b0b0b1810800980f1baa0031533301c30150011533301f301e37540062a0042c2c60386ea800854028585858585858c074004c07400858585858c06c004c060dd50008b0b0b0b0b0b180c800980b1baa0011616161616163017001301437540062a66602460160022a66602a60286ea800c540085858c048dd50010a999808180298089baa30143012375400829445280b0b0b0b0b180980098081baa002162223253330113006001132533301500100313253333330190010040040040041325333017301900315006005375c002602c00260266ea801054ccc044c0280044c94ccc05400400c4c94cccccc0640040100100100104c94ccc05cc06400c54018014dd7000980b00098099baa004002301137540066020601c6ea8008dc3a40002c601c601e004601a00260146ea8008dc3a40042c6014601600460120026012004600e00260086ea8004526136565734aae7555cf2ab9f5742ae895d21",
"hash": "22fcdd5defc5c63e55afed5ee2e88c9c695809f8b1e99342e045438d" "hash": "a63866b5537d618101fccdf892f6bb58f0f1092bc483bfedca3a813e"
},
{
"title": "other.validate.else",
"compiledCode": "5902fd010000323232323232322533300232323232325332330083001300937540042646464a664660186002601a6ea80084c8c94ccc038c00cc03cdd500109929998090008b099299999980b0008a999809980a8010991929998091803800899299980b0008b099299999980d0008a99980b980c8010a99980a1804980a9baa001132533301800116132533333301c00115333019301b00215333016300b30173754002264a6660340022c264a66666603c002264a6660380022c264a6666660400022a66603a603e004266601a00626464a6660386022002264a6660400022c264a6666660480022a666042604600426464a666040602a002264a6660480022c264a6666660500022a66604a604e004266602a0022a0082c2c2c2c2c2c604a00260446ea800c54ccc080c0640044c94ccc090004584c94cccccc0a00045858584c8c94ccc09c004584c94cccccc0ac0045858584c8c94ccc0a8004584c94cccccc0b80045858584c94ccc0b0c0b800c5402c58dd68008b181580098158019bad0011630280013028003375a0022c604a00260446ea800c58c080dd50010a8020b0b0b0b0b1810800980f1baa0031533301c30150011533301f301e37540062a0042c2c60386ea800854028585858585858c074004c07400858585858c06c004c060dd50008b0b0b0b0b0b180c800980b1baa0011616161616163017001301437540062a66602460160022a66602a60286ea800c540085858c048dd50010a999808180298089baa30143012375400829445280b0b0b0b0b180980098081baa002162223253330113006001132533301500100313253333330190010040040040041325333017301900315006005375c002602c00260266ea801054ccc044c0280044c94ccc05400400c4c94cccccc0640040100100100104c94ccc05cc06400c54018014dd7000980b00098099baa004002301137540066020601c6ea8008dc3a40002c601c601e004601a00260146ea8008dc3a40042c6014601600460120026012004600e00260086ea8004526136565734aae7555cf2ab9f5742ae895d21",
"hash": "a63866b5537d618101fccdf892f6bb58f0f1092bc483bfedca3a813e"
} }
], ],
"definitions": { "definitions": {

View File

@ -1,5 +1,5 @@
use aiken/transaction.{Transaction} use cardano/credential.{Address}
use aiken/transaction/credential.{Address} use cardano/transaction.{Transaction}
type TestData { type TestData {
addr: Address, addr: Address,
@ -10,12 +10,17 @@ type TestDatum {
} }
validator validate { validator validate {
spend(raw_datum: Option<Data>, _redeemer: Data, oref: Data, _tx: Transaction) -> Bool { spend(raw_datum: Option<Data>, _redeemer: Data, oref: Data, _tx: Transaction) {
expect datum: TestDatum = raw_datum expect Some(datum): Option<Data> = raw_datum
expect datum: TestDatum = datum
let TestDatum { data } = datum let TestDatum { data } = datum
when data is { when data is {
Some(_) -> True Some(_) -> True
None -> False None -> False
} }
} }
else(_) {
fail
}
} }

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596654, nanos_since_epoch = 519706000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776982, nanos_since_epoch = 107153000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596656, nanos_since_epoch = 683917000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776991, nanos_since_epoch = 282756000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -3,14 +3,14 @@
[[requirements]] [[requirements]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
source = "github" source = "github"
[[packages]] [[packages]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
requirements = [] requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723158435, nanos_since_epoch = 937845000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724776982, nanos_since_epoch = 146951000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@ -4,5 +4,5 @@ description = ""
[[dependencies]] [[dependencies]]
name = 'aiken-lang/stdlib' name = 'aiken-lang/stdlib'
version = 'main' version = 'v2'
source = 'github' source = 'github'

View File

@ -1,7 +1,6 @@
use aiken/cbor use cardano/assets.{from_lovelace}
use aiken/transaction.{Datum, InlineDatum, NoDatum, Output} use cardano/credential.{Address, VerificationKey}
use aiken/transaction/credential.{Address, VerificationKeyCredential} use cardano/transaction.{Datum, InlineDatum, NoDatum, Output}
use aiken/transaction/value.{from_lovelace}
type SmallOracleState { type SmallOracleState {
Thing(Int) Thing(Int)
@ -18,7 +17,7 @@ fn create_output(
let x = let x =
Output { Output {
address: Address { address: Address {
payment_credential: VerificationKeyCredential(payment_key), payment_credential: VerificationKey(payment_key),
stake_credential: None, stake_credential: None,
}, },
value: from_lovelace(value), value: from_lovelace(value),

View File

@ -5,12 +5,12 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
} }
}, },
"validators": [ "validators": [
{ {
"title": "test2.simple_oneshot", "title": "test2.simple_oneshot.mint",
"redeemer": { "redeemer": {
"title": "_r", "title": "_r",
"schema": { "schema": {
@ -21,12 +21,25 @@
{ {
"title": "utxo_ref", "title": "utxo_ref",
"schema": { "schema": {
"$ref": "#/definitions/aiken~1transaction~1OutputReference" "$ref": "#/definitions/cardano~1transaction~1OutputReference"
} }
} }
], ],
"compiledCode": "58d8010000323232323232322232322533300632325333008300530093754601a601c00426464a666014600e60166ea8cc00400c8cdd7980198069baa00100a1533300a3007300b375466002006466ebcc00cc034dd50008050a5114a02c44646600200200644a6660200022980103d87a800013232533300f300500213374a90001980980125eb804cc010010004c050008c0480048c03800458dd6180618049baa300c0013008375400229309b2b2999802180098029baa00215333007300637540042930b0b1b87480015cd2ab9d5573caae7d5d02ba15745", "compiledCode": "58f00100003232323232323222533300332323232325332330093001300a375400426464646464a66601c600c601e6ea8cc00400c8cdd7980198089baa00100e1533300e3006300f375466002006466ebcc00cc044dd50008070a5114a02c44646600200200644a666028002298103d87a8000132325333013300500213374a90001980b80125eb804cc010010004c060008c0580048c048004dd6180818069baa007533300a3002300b37540082a66601a60186ea80105261616375c601c60166ea8008dc3a40002c6018601a004601600260160046012002600a6ea8004526136565734aae7555cf2ab9f5740ae855d101",
"hash": "0934dd37409ea743705a7340769acd8c84843fec54013e9f0ced9251" "hash": "6f67a4f89e77e01da00ed12f89b15baa823791e83757d5ac97843e91"
},
{
"title": "test2.simple_oneshot.else",
"parameters": [
{
"title": "utxo_ref",
"schema": {
"$ref": "#/definitions/cardano~1transaction~1OutputReference"
}
}
],
"compiledCode": "58f00100003232323232323222533300332323232325332330093001300a375400426464646464a66601c600c601e6ea8cc00400c8cdd7980198089baa00100e1533300e3006300f375466002006466ebcc00cc044dd50008070a5114a02c44646600200200644a666028002298103d87a8000132325333013300500213374a90001980b80125eb804cc010010004c060008c0580048c048004dd6180818069baa007533300a3002300b37540082a66601a60186ea80105261616375c601c60166ea8008dc3a40002c6018601a004601600260160046012002600a6ea8004526136565734aae7555cf2ab9f5740ae855d101",
"hash": "6f67a4f89e77e01da00ed12f89b15baa823791e83757d5ac97843e91"
} }
], ],
"definitions": { "definitions": {
@ -47,7 +60,7 @@
} }
] ]
}, },
"aiken/transaction/OutputReference": { "cardano/transaction/OutputReference": {
"title": "OutputReference", "title": "OutputReference",
"description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output", "description": "An `OutputReference` is a unique reference to an output on-chain. The `output_index`\n corresponds to the position in the output list of the transaction (identified by its id)\n that produced that output",
"anyOf": [ "anyOf": [
@ -58,7 +71,7 @@
"fields": [ "fields": [
{ {
"title": "transaction_id", "title": "transaction_id",
"$ref": "#/definitions/aiken~1transaction~1TransactionId" "$ref": "#/definitions/ByteArray"
}, },
{ {
"title": "output_index", "title": "output_index",
@ -67,23 +80,6 @@
] ]
} }
] ]
},
"aiken/transaction/TransactionId": {
"title": "TransactionId",
"description": "A unique transaction identifier, as the hash of a transaction body. Note that the transaction id\n isn't a direct hash of the `Transaction` as visible on-chain. Rather, they correspond to hash\n digests of transaction body as they are serialized on the network.",
"anyOf": [
{
"title": "TransactionId",
"dataType": "constructor",
"index": 0,
"fields": [
{
"title": "hash",
"$ref": "#/definitions/ByteArray"
}
]
}
]
} }
} }
} }

View File

@ -1,10 +1,7 @@
use aiken/list use aiken/collection/list
use aiken/transaction.{ use cardano/assets
Input, Mint, NoDatum, Output, OutputReference, ScriptContext, Transaction, use cardano/credential.{Address, VerificationKey}
TransactionId, use cardano/transaction.{Input, NoDatum, Output, OutputReference, Transaction}
}
use aiken/transaction/credential.{Address, VerificationKeyCredential}
use aiken/transaction/value
pub const own_hash = #"01020304050607080910111213140102030405060708091011121314" pub const own_hash = #"01020304050607080910111213140102030405060708091011121314"
@ -20,17 +17,14 @@ pub fn beneficiary_address() {
pub fn keyhash_address(keyhash: ByteArray) { pub fn keyhash_address(keyhash: ByteArray) {
Address { Address {
payment_credential: VerificationKeyCredential(keyhash), payment_credential: VerificationKey(keyhash),
stake_credential: None, stake_credential: None,
} }
} }
validator simple_oneshot(utxo_ref: OutputReference) { validator simple_oneshot(utxo_ref: OutputReference) {
mint(_r: Void, oref: Data, ctx: ScriptContext) -> Bool { mint(_r: Void, _policy_id: ByteArray, self: Transaction) {
let ScriptContext { transaction, purpose } = ctx let Transaction { inputs, .. } = self
let Transaction { inputs, .. } = transaction
expect Mint(_policy_id) = purpose
expect Some(_input) = expect Some(_input) =
list.find(inputs, fn(input) { input.output_reference == utxo_ref }) list.find(inputs, fn(input) { input.output_reference == utxo_ref })
@ -42,31 +36,34 @@ validator simple_oneshot(utxo_ref: OutputReference) {
None -> False None -> False
} }
} }
else(_) {
fail
}
} }
test test_simple_oneshot() { test test_simple_oneshot() {
let output = let output =
Output { Output {
address: beneficiary_address(), address: beneficiary_address(),
value: value.zero(), value: assets.zero(),
datum: NoDatum, datum: NoDatum,
reference_script: None, reference_script: None,
} }
let val = let mint =
value.from_asset(policy_id: own_hash, asset_name: "testtoken", quantity: 1) assets.from_asset(policy_id: own_hash, asset_name: "testtoken", quantity: 1)
let utxo = let utxo = OutputReference { transaction_id: "", output_index: 0 }
OutputReference { transaction_id: TransactionId(""), output_index: 0 }
let input = Input { output_reference: utxo, output } let input = Input { output_reference: utxo, output }
let tx = let tx =
Transaction { Transaction {
..transaction.placeholder(), ..transaction.placeholder(),
mint: value.to_minted_value(val), mint: mint,
extra_signatories: [other_hash], extra_signatories: [other_hash],
inputs: [input], inputs: [input],
} }
let context = ScriptContext { purpose: Mint(own_hash), transaction: tx }
simple_oneshot(utxo, Void, context) == True simple_oneshot.mint(utxo, Void, own_hash, tx) == True
} }

View File

@ -5,12 +5,12 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
} }
}, },
"validators": [ "validators": [
{ {
"title": "foo.spend", "title": "foo.foo.spend",
"datum": { "datum": {
"title": "datum", "title": "datum",
"schema": { "schema": {
@ -23,8 +23,13 @@
"$ref": "#/definitions/Data" "$ref": "#/definitions/Data"
} }
}, },
"compiledCode": "583f010000322322253330053370e00690487777c9cfdde5c8f27bf4c1637fc55b5eeef7d8c4d9e0d4454967ff7d6e7ee6e242eb60c6318a4c26cac6eb40055cd1", "compiledCode": "5884010000323232323225333002323232323253330073370e900118041baa001132323375e6018601a004980129d8799fc25822018c641ac1624dfb73d7e9e4852882cc4b1df75eb615fe302d3df21196ecf93dfb88ff00300b001300937540022c6012601400460100026010004600c00260086ea8004526136565734aae7555cf2ba15745",
"hash": "6c5f960b7a078766778eef14cef347f3b5cd3c5fc4a7797f031aad70" "hash": "dfa7cee7ce4b00790987cebda791bad5ffd34e12c58adc567094edad"
},
{
"title": "foo.foo.else",
"compiledCode": "5884010000323232323225333002323232323253330073370e900118041baa001132323375e6018601a004980129d8799fc25822018c641ac1624dfb73d7e9e4852882cc4b1df75eb615fe302d3df21196ecf93dfb88ff00300b001300937540022c6012601400460100026010004600c00260086ea8004526136565734aae7555cf2ba15745",
"hash": "dfa7cee7ce4b00790987cebda791bad5ffd34e12c58adc567094edad"
} }
], ],
"definitions": { "definitions": {

View File

@ -2,7 +2,11 @@ const foo =
45898945895546556456546223123184821312385384845153123213185685815615232323484552 45898945895546556456546223123184821312385384845153123213185685815615232323484552
validator foo { validator foo {
spend(datum: Int, _redeemer: Data, o_ref: Data, _tx: Data) { spend(datum: Option<Int>, _redeemer: Data, o_ref: Data, _tx: Data) {
datum == foo datum == Some(foo)
}
else(_) {
fail
} }
} }

View File

@ -3,14 +3,14 @@
[[requirements]] [[requirements]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
source = "github" source = "github"
[[packages]] [[packages]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
requirements = [] requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1723158436, nanos_since_epoch = 833716000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724776968, nanos_since_epoch = 78547000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@ -10,5 +10,5 @@ platform = "github"
[[dependencies]] [[dependencies]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
source = "github" source = "github"

View File

@ -6,13 +6,13 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+6e4a16d" "version": "v1.0.31-alpha+4003343"
}, },
"license": "Apache-2.0" "license": "Apache-2.0"
}, },
"validators": [ "validators": [
{ {
"title": "foo.is_fourty_two", "title": "foo.is_fourty_two.spend",
"datum": { "datum": {
"title": "dat", "title": "dat",
"schema": { "schema": {
@ -25,8 +25,13 @@
"$ref": "#/definitions/Data" "$ref": "#/definitions/Data"
} }
}, },
"compiledCode": "581c01000032222533300453330043375e00400629445280a4c26cacae69", "compiledCode": "586d01000032323232323225333002323232323253330073370e900118041baa0011323253330093375e66e9520003300c0044bd70180698070010a5114a0601800260126ea800458c028c02c008c024004c024008c01c004c010dd50008a4c26cacae6955ceaab9e5740ae855d101",
"hash": "8be8ae44ae022691acf356eae743ba402b8b7918f1e54092367ae0b7" "hash": "aa09f972cd22cf3bcbadb40dbe865d16dd4a50ff84022ef76a885d63"
},
{
"title": "foo.is_fourty_two.else",
"compiledCode": "586d01000032323232323225333002323232323253330073370e900118041baa0011323253330093375e66e9520003300c0044bd70180698070010a5114a0601800260126ea800458c028c02c008c024004c024008c01c004c010dd50008a4c26cacae6955ceaab9e5740ae855d101",
"hash": "aa09f972cd22cf3bcbadb40dbe865d16dd4a50ff84022ef76a885d63"
} }
], ],
"definitions": { "definitions": {

View File

@ -1,7 +1,11 @@
use aiken/transaction.{ScriptContext} use cardano/transaction.{Transaction}
validator is_fourty_two { validator is_fourty_two {
spend(dat, rdm, oref, _ctx: Transaction) -> Bool { spend(dat, rdm, _oref, _ctx: Transaction) {
rdm == dat && #"68656c6c6f20776f726c64" == #"68656c6c6f20776f726c64" Some(rdm) == dat && #"68656c6c6f20776f726c64" == #"68656c6c6f20776f726c64"
}
else(_) {
fail
} }
} }

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596652, nanos_since_epoch = 132897000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776974, nanos_since_epoch = 482154000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -24,5 +24,5 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1724596654, nanos_since_epoch = 381692000 }, "24d601fa19a2002318495bbb8562b9677563ca1b5c03126d6b093a65df076bef"] "aiken-lang/fuzz@main" = [{ secs_since_epoch = 1724776982, nanos_since_epoch = 317854000 }, "24d601fa19a2002318495bbb8562b9677563ca1b5c03126d6b093a65df076bef"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596653, nanos_since_epoch = 898649000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776982, nanos_since_epoch = 83201000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -13,4 +13,4 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724596646, nanos_since_epoch = 86095000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776954, nanos_since_epoch = 774618000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -24,5 +24,5 @@ requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/fuzz@main" = [{ secs_since_epoch = 1724597285, nanos_since_epoch = 266243000 }, "24d601fa19a2002318495bbb8562b9677563ca1b5c03126d6b093a65df076bef"] "aiken-lang/fuzz@main" = [{ secs_since_epoch = 1724776955, nanos_since_epoch = 575782000 }, "24d601fa19a2002318495bbb8562b9677563ca1b5c03126d6b093a65df076bef"]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724597284, nanos_since_epoch = 808906000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"] "aiken-lang/stdlib@main" = [{ secs_since_epoch = 1724776954, nanos_since_epoch = 782601000 }, "5e58899446492a704d0927a43299139856bef746e697b55895ba34206fa28452"]

View File

@ -6,7 +6,7 @@
"plutusVersion": "v2", "plutusVersion": "v2",
"compiler": { "compiler": {
"name": "Aiken", "name": "Aiken",
"version": "v1.0.31-alpha+0c9ea19" "version": "v1.0.31-alpha+4003343"
}, },
"license": "Apache-2.0" "license": "Apache-2.0"
}, },

View File

@ -21,6 +21,10 @@ validator foo_3(Foo { a0, .. }: Foo) {
mint(_redeemer, _policy_, _tx) { mint(_redeemer, _policy_, _tx) {
a0 == 1 a0 == 1
} }
else(_) {
fail
}
} }
test example_1() { test example_1() {
@ -32,14 +36,15 @@ test example_2() {
} }
test example_3() { test example_3() {
foo_3_mint(Foo { a0: 1, a1: False }, "", "", "") foo_3.mint(Foo { a0: 1, a1: False }, "", "", "")
} }
test example_4() { test example_4() {
let foo_4 = fn(Foo { a1, .. }) { a1 } let foo_4 =
fn(Foo { a1, .. }) { a1 }
foo_4(Foo { a0: 1, a1: True }) foo_4(Foo { a0: 1, a1: True })
} }
test example_5((a, b) via fuzz.both(fuzz.int(), fuzz.int())) { test example_5((a, b) via fuzz.both(fuzz.int(), fuzz.int())) {
a + b == b + a a + b == b + a
} }

View File

@ -3,14 +3,14 @@
[[requirements]] [[requirements]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
source = "github" source = "github"
[[packages]] [[packages]]
name = "aiken-lang/stdlib" name = "aiken-lang/stdlib"
version = "main" version = "v2"
requirements = [] requirements = []
source = "github" source = "github"
[etags] [etags]
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1714852860, nanos_since_epoch = 160588000 }, "5ee55dc5ccf269bb493f4cacb32096f0191a6adb2ef39d62a1f79b8c5a8fcc7f"] "aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724778883, nanos_since_epoch = 61117000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]

View File

@ -10,5 +10,5 @@ platform = 'github'
[[dependencies]] [[dependencies]]
name = 'aiken-lang/stdlib' name = 'aiken-lang/stdlib'
version = 'main' version = 'v2'
source = 'github' source = 'github'

View File

@ -1,26 +1,26 @@
use aiken/builtin use aiken/builtin
use aiken/bytearray use aiken/collection/dict
use aiken/dict use aiken/collection/list
use aiken/hash.{blake2b_256} use aiken/hash.{blake2b_256}
use aiken/list use aiken/primitive/bytearray
use aiken/transaction.{ use cardano/assets.{PolicyId}
InlineDatum, Input, Output, ScriptContext, Spend, Transaction, use cardano/credential.{Address, PaymentCredential, Script}
use cardano/transaction.{
InlineDatum, Input, Output, OutputReference, Transaction,
} as tx } as tx
use aiken/transaction/credential.{Address, PaymentCredential, ScriptCredential}
use aiken/transaction/value
type Action { pub type Action {
Mint(Int) Mint(Int)
Burn Burn
} }
type SpendTokenName = pub type SpendTokenName =
ByteArray ByteArray
validator redeem(creator: ByteArray) { validator redeem(creator: ByteArray) {
spend( spend(
// Each spend input checks for a token name matching the datum being burned // Each spend input checks for a token name matching the datum being burned
datum: SpendTokenName, datum: Option<SpendTokenName>,
_r: Data, _r: Data,
own_ref: OutputReference, own_ref: OutputReference,
transaction: Transaction, transaction: Transaction,
@ -35,23 +35,22 @@ validator redeem(creator: ByteArray) {
.. ..
} = own_input } = own_input
expect ScriptCredential(own_validator_hash) = payment_credential expect Script(own_validator_hash) = payment_credential
expect Some(datum) = datum
( (
mint mint
|> value.from_minted_value |> assets.quantity_of(own_validator_hash, datum)
|> value.quantity_of(own_validator_hash, datum)
) == -1 ) == -1
} }
mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) -> Bool { mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) {
let Transaction { inputs, mint, extra_signatories, outputs, .. } = let Transaction { inputs, mint, extra_signatories, outputs, .. } =
transaction transaction
let minted_assets = let minted_assets =
mint mint
|> value.from_minted_value |> assets.tokens(policy_id)
|> value.tokens(policy_id)
|> dict.to_pairs() |> dict.to_pairs()
when rdmr is { when rdmr is {
@ -75,7 +74,7 @@ validator redeem(creator: ByteArray) {
minted_assets, minted_assets,
outputs, outputs,
expected_minted_token_names, expected_minted_token_names,
ScriptCredential(policy_id), Script(policy_id),
) )
} }
Burn -> Burn ->
@ -88,6 +87,10 @@ validator redeem(creator: ByteArray) {
) )
} }
} }
else(_) {
fail
}
} }
fn insert(self: List<a>, e: a, compare: fn(a, a) -> Ordering) -> List<a> { fn insert(self: List<a>, e: a, compare: fn(a, a) -> Ordering) -> List<a> {

View File

@ -1,21 +1,20 @@
use aiken/dict use aiken/collection/dict
use aiken/list use aiken/collection/list
use aiken/transaction.{OutputReference, ScriptContext, Transaction} as tx use cardano/assets.{PolicyId}
use aiken/transaction/value use cardano/transaction.{OutputReference, Transaction} as tx
type Action { pub type Action {
Mint Mint
Burn Burn
} }
validator gift_card(token_name: ByteArray, utxo_ref: OutputReference) { validator gift_card(token_name: ByteArray, utxo_ref: OutputReference) {
mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) -> Bool { mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) {
let Transaction { inputs, mint, .. } = transaction let Transaction { inputs, mint, .. } = transaction
expect [Pair(asset_name, amount)] = expect [Pair(asset_name, amount)] =
mint mint
|> value.from_minted_value |> assets.tokens(policy_id)
|> value.tokens(policy_id)
|> dict.to_pairs() |> dict.to_pairs()
when rdmr is { when rdmr is {
@ -28,18 +27,25 @@ validator gift_card(token_name: ByteArray, utxo_ref: OutputReference) {
Burn -> amount == -1 && asset_name == token_name Burn -> amount == -1 && asset_name == token_name
} }
} }
else(_) {
fail
}
} }
validator redeem(token_name: ByteArray, policy_id: ByteArray) { validator redeem(token_name: ByteArray, policy_id: ByteArray) {
spend(_d: Data, _r: Data, _o_ref: Data, transaction: Transaction) -> Bool { spend(_d, _r, _o_ref: Data, transaction: Transaction) {
let Transaction { mint, .. } = transaction let Transaction { mint, .. } = transaction
expect [Pair(asset_name, amount)] = expect [Pair(asset_name, amount)] =
mint mint
|> value.from_minted_value |> assets.tokens(policy_id)
|> value.tokens(policy_id)
|> dict.to_pairs() |> dict.to_pairs()
amount == -1 && asset_name == token_name amount == -1 && asset_name == token_name
} }
else(_) {
fail
}
} }