Skip to content

Commit

Permalink
Use dot to separate purpose from validator name in blueprint
Browse files Browse the repository at this point in the history
  The rationale is two folds:

  1. It's more consistent with how we already separate the validator
  name from its module.

  2. Because `_` may be present in Aiken's validator's name, it is hard
     to read and I am afraid it could potentially conflict later on. So
     it's better to use a separator that cannot appear in validator
     names.
  • Loading branch information
KtorZ committed Aug 25, 2024
1 parent ed55f03 commit 8c2fdf9
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\npub type Foo {\n foo: Int\n}\n\nvalidator annotated_data {\n spend(datum: Option<Data<Foo>>, redeemer: Data, output_reference: Data, transpose: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.annotated_data_spend",
"title": "test_module.annotated_data.spend",
"datum": {
"title": "datum",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\npub type Either<left, right> {\n Left(left)\n Right(right)\n}\n\npub type Interval<a> {\n Finite(a)\n Infinite\n}\n\nvalidator generics {\n spend(datum: Option<Data>, redeemer: Either<ByteArray, Interval<Int>>, output_reference: Data, transaction: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.generics_spend",
"title": "test_module.generics.spend",
"datum": {
"title": "datum",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\npub type Dict<key, value> {\n inner: List<(ByteArray, value)>\n}\n\npub type UUID { UUID }\n\nvalidator list_2_tuples_as_list {\n mint(redeemer: Dict<UUID, Int>, policy_id: ByteArray, transaction: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.list_2_tuples_as_list_mint",
"title": "test_module.list_2_tuples_as_list.mint",
"redeemer": {
"title": "redeemer",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\npub type Dict<key, value> {\n inner: List<Pair<ByteArray, value>>\n}\n\npub type UUID { UUID }\n\nvalidator list_pairs_as_map {\n spend(datum: Option<Data>, redeemer: Dict<UUID, Int>, _output_reference: Data, transaction: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.list_pairs_as_map_spend",
"title": "test_module.list_pairs_as_map.spend",
"datum": {
"title": "datum",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\nvalidator thing {\n mint(redeemer: Data, policy_id: Data, transaction: Data) {\n True\n }\n}\n// "
description: "Code:\n\nvalidator thing {\n mint(redeemer: Data, policy_id: ByteArray, transaction: Data) {\n True\n }\n}\n// "
---
{
"title": "test_module.thing_mint",
"title": "test_module.thing.mint",
"redeemer": {
"title": "redeemer",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\nvalidator thing(utxo_ref: Int) {\n mint(redeemer: Data, policy_id: ByteArray, transaction: Data) {\n True\n }\n}\n// "
---
{
"title": "test_module.thing_mint",
"title": "test_module.thing.mint",
"redeemer": {
"title": "redeemer",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\npub type Foo {\n foo: Data\n}\n\nvalidator nested_data {\n spend(datum: Option<Foo>, redeemer: Int, output_reference: Data, transaction: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.nested_data_spend",
"title": "test_module.nested_data.spend",
"datum": {
"title": "datum",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\npub type LinkedList<a> {\n Cons(a, LinkedList<a>)\n Nil\n}\n\npub type Foo {\n Foo {\n foo: LinkedList<Bool>,\n }\n Bar {\n bar: Int,\n baz: (ByteArray, List<LinkedList<Int>>)\n }\n}\n\nvalidator recursive_generic_types {\n spend(datum: Option<Foo>, redeemer: LinkedList<Int>, output_reference: Data, transaction: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.recursive_generic_types_spend",
"title": "test_module.recursive_generic_types.spend",
"datum": {
"title": "datum",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\npub type Expr {\n Val(Int)\n Sum(Expr, Expr)\n Mul(Expr, Expr)\n}\n\nvalidator recursive_types {\n spend(datum: Option<Data>, redeemer: Expr, output_reference: Data, transaction: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.recursive_types_spend",
"title": "test_module.recursive_types.spend",
"datum": {
"title": "datum",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\n/// On-chain state\npub type State {\n /// The contestation period as a number of seconds\n contestationPeriod: ContestationPeriod,\n /// List of public key hashes of all participants\n parties: List<Party>,\n utxoHash: Hash<Blake2b_256>,\n}\n\n/// A Hash digest for a given algorithm.\npub type Hash<alg> = ByteArray\n\npub type Blake2b_256 { Blake2b_256 }\n\n/// Whatever\npub type ContestationPeriod {\n /// A positive, non-zero number of seconds.\n ContestationPeriod(Int)\n}\n\npub type Party =\n ByteArray\n\npub type Input {\n CollectCom\n Close\n /// Abort a transaction\n Abort\n}\n\nvalidator simplified_hydra {\n spend(datum: Option<State>, redeemer: Input, output_reference: Data, transaction: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.simplified_hydra_spend",
"title": "test_module.simplified_hydra.spend",
"datum": {
"title": "datum",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: crates/aiken-project/src/blueprint/validator.rs
description: "Code:\n\nvalidator tuples {\n spend(datum: Option<(Int, ByteArray)>, redeemer: (Int, Int, Int), output_reference: Data, transaction: Data) {\n True\n }\n}\n"
---
{
"title": "test_module.tuples_spend",
"title": "test_module.tuples.spend",
"datum": {
"title": "datum",
"schema": {
Expand Down
11 changes: 1 addition & 10 deletions crates/aiken-project/src/blueprint/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,7 @@ impl Validator {
};

Ok(Validator {
title: format!(
"{}.{}_{}",
&module.name,
&def.name,
if func.name == well_known::VALIDATOR_ELSE {
"__fallback"
} else {
&func.name
}
),
title: format!("{}.{}.{}", &module.name, &def.name, &func.name,),
description: func.doc.clone(),
parameters,
datum,
Expand Down
2 changes: 1 addition & 1 deletion examples/acceptance_tests/script_context/v3/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 = 1723824703, nanos_since_epoch = 979555000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724491200, nanos_since_epoch = 427525000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
]
, [ 2
, [ 1
, h'{{ certificates.purposes_publish.hash }}'
, h'{{ certificates.purposes.publish.hash }}'
]
, h'11111111111111111111111111111111111111111111111111111111'
]
Expand All @@ -109,7 +109,7 @@

{ 5: [[2, 20, 121([]), [1000000, 100000000]]]

, 7: [h'{{ certificates.purposes_publish.cbor }}']
, 7: [h'{{ certificates.purposes.publish.cbor }}']
},

true,
Expand Down
14 changes: 7 additions & 7 deletions examples/acceptance_tests/script_context/v3/ctx/mint/tx.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
, { 0: h'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
, 1:
[ 1000000
, { h'{{ mint.test_1_mint.hash }}': { h'74756e61': 100000000000000 }
, h'{{ mint.test_2_mint.hash }}': { h'61696b656e': 42 }
, { h'{{ mint.test_1.mint.hash }}': { h'74756e61': 100000000000000 }
, h'{{ mint.test_2.mint.hash }}': { h'61696b656e': 42 }
}
]
}
, { 0: h'100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
, 1:
[ 1000000
, { h'{{ mint.test_2_mint.hash }}': { h'63617264616e6f': 1 }
, { h'{{ mint.test_2.mint.hash }}': { h'63617264616e6f': 1 }
}
]
, 3: 24(h'82034463666F6F')
Expand All @@ -29,10 +29,10 @@
, 2: 42

, 9:
{ h'{{ mint.test_1_mint.hash }}':
{ h'{{ mint.test_1.mint.hash }}':
{ h'74756e61': 100000000000000
}
, h'{{ mint.test_2_mint.hash }}':
, h'{{ mint.test_2.mint.hash }}':
{ h'63617264616e6f': 1
, h'61696b656e': -14
}
Expand Down Expand Up @@ -65,8 +65,8 @@
]

, 7:
[ h'{{ mint.test_1_mint.cbor }}'
, h'{{ mint.test_2_mint.cbor }}'
[ h'{{ mint.test_1.mint.cbor }}'
, h'{{ mint.test_2.mint.cbor }}'
]

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
, h'F000000000000000000000000000000000000000000000000000000000'
, [ 2
, { h'E022222222222222222222222222222222222222222222222222222222': 1000000 }
, h'{{ proposing_all.guardrails_propose.hash }}'
, h'{{ proposing_all.guardrails.propose.hash }}'
]
, [ "https://aiken-lang.org"
, h'0000000000000000000000000000000000000000000000000000000000000000'
Expand Down Expand Up @@ -112,7 +112,7 @@

{ 5: [[5, 3, 121([]), [1000000, 100000000]]]

, 7: [h'{{ proposing_all.guardrails_propose.cbor }}']
, 7: [h'{{ proposing_all.guardrails.propose.cbor }}']
},

true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
, 32: 20
, 33: 30([15, 1])
}
, h'{{ proposing_pparams.guardrails_propose.hash }}'
, h'{{ proposing_pparams.guardrails.propose.hash }}'
]
, [ "https://aiken-lang.org"
, h'0000000000000000000000000000000000000000000000000000000000000000'
Expand All @@ -73,7 +73,7 @@

{ 5: [[5, 0, 121([]), [1000000, 100000000]]]

, 7: [h'{{ proposing_pparams.guardrails_propose.cbor }}']
, 7: [h'{{ proposing_pparams.guardrails.propose.cbor }}']
},

true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{ 0: h'70{{ simple_spend.simple_spend_spend.hash }}'
{ 0: h'70{{ simple_spend.simple_spend.spend.hash }}'
, 1: 1000000000
, 2: [1, 24(h'd87980')]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

{ 5: [[0, 0, 121([]), [1000000, 100000000]]]

, 7: [h'{{ simple_spend.simple_spend_spend.cbor }}']
, 7: [h'{{ simple_spend.simple_spend.spend.cbor }}']

},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
, [ h'7777777777777777777777777777777777777777777777777777777777777777', 2 ]: [ 2, null ]
}

, [ 3, h'{{ voting.purposes_vote.hash }}' ]:
, [ 3, h'{{ voting.purposes.vote.hash }}' ]:
{ [ h'9999999999999999999999999999999999999999999999999999999999999999', 3 ]: [ 0, null ]
}

, [ 4, h'00000000000000000000000000000000000000000000000000000000' ]:
{ [ h'9999999999999999999999999999999999999999999999999999999999999999', 4 ]: [ 1, null ]
}

, [ 1, h'{{ voting.purposes_vote.hash }}' ]:
, [ 1, h'{{ voting.purposes.vote.hash }}' ]:
{ [ h'9999999999999999999999999999999999999999999999999999999999999999', 1 ]: [ 1, null ]
}
}
Expand All @@ -43,7 +43,7 @@
, [4, 0, 121([42]), [1000000, 100000000]]
]

, 7: [h'{{ voting.purposes_vote.cbor }}']
, 7: [h'{{ voting.purposes.vote.cbor }}']
},

true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{ 0: h'30{{ withdraw.thing_spend.hash }}{{ withdraw.thing_spend.hash }}'
{ 0: h'30{{ withdraw.thing.spend.hash }}{{ withdraw.thing.spend.hash }}'
, 1: 1000000
, 2: [1, 24(h'd87980')]
, 3: 24(h'8203{{ withdraw.thing_spend.cbor }}')
, 3: 24(h'8203{{ withdraw.thing.spend.cbor }}')
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

, 5:
{ h'E000000000000000000000000000000000000000000000000000000000': 14
, h'F0{{ withdraw.thing_withdraw.hash }}': 0
, h'F0{{ withdraw.thing.withdraw.hash }}': 0
}

, 14:
Expand Down
Loading

0 comments on commit 8c2fdf9

Please sign in to comment.