Commit Graph

113 Commits

Author SHA1 Message Date
KtorZ
bc690c5410 Generated wrapped schemas for multi-validators' redeemers 2023-03-17 18:40:49 -04:00
Kasey White
bb6fc76971 start on registering redeemer wrapper type in definitions 2023-03-17 18:40:49 -04:00
KtorZ
7e1403a3b2 Complete generation of blueprint multi-validators. 2023-03-17 18:40:49 -04:00
Kasey White
fe92b27d50 start on refactoring validator to support multi-validators in blueprint 2023-03-17 18:40:49 -04:00
KtorZ
61113cd7b9 distinguish between multi vs single validator case in blueprint schema generation. 2023-03-17 18:40:48 -04:00
rvcas
c3870e340e feat(codegen): support multi-validators
* rename force_wrap to force
* add a bunch of builder methods to Term<Name>
* refactor one tiny location to show off builder methods
* split generate into `generate` and `generate_test`
* create wrap_as_multi_validator function

Co-authored-by: Kasey White <kwhitemsg@gmail.com>
2023-03-17 18:40:44 -04:00
rvcas
ed92869fb9 feat(validator): parsing and typechecking for double validators 2023-03-17 18:38:24 -04:00
KtorZ
ae981403c6 Re-introduce field title & description in referenced schemas. 2023-03-12 12:44:49 -04:00
KtorZ
451737237e Fix blueprint generation for recursive types.
This was a bit tricky and I ended up breaking things down a lot and
  trying different path. This commit is the result of the most
  satisfying one.

  It introduces a new 'concept' and types: Definitions and Reference.
  These elements are meant to reflect JSON pointers and JSON-schema
  definitions which we now use for pretty much all user-defined
  data-types.

  In fact, Schemas are no longer inlined, but are always referencing
  some schema under "definitions".

  This indirection is necessary in order to cope with recursive types.
  And while it's only truly necessary for recursive types, using it
  consistently makes it both easier to produce and easier to consume.

  ---

  The blueprint generation for recursive types here also works thanks to
  the 'Definitions' data-structure wrapper around a BTreeMap. This uses
  a strategy where:

  (1) schemas are only generated if they haven't been seen before
  (2) schemas are marked as seen BEFORE actually being generated (to
  effectively stop a recursive generation).

  This relies on one important aspect: the key must be uniquely
  identifying a given schema. Which means that we have to monomorphize
  data-types with generic parameters also here, and use keys that are
  specialized in one data-type.

  ---

  In this large overhaul we've also lost one thing which I didn't bother
  re-introducing yet to keep the work manageable: title for record
  fields. Before, we use to pull those from record constructor when
  available, yet now, every record constructor has been replaced by a
  `$ref`. We could theoritically attach a title to the reference. I'll
  try to quickly add that in a later commit.
2023-03-12 12:44:49 -04:00
KtorZ
f67e049dc2 Introduce indirection for fields. 2023-03-12 12:44:49 -04:00
KtorZ
3a7aac0a33 Make blueprint code slightly more resilient to changes.
Leverage traits instead of hard-coded type parameters.
2023-03-12 12:44:49 -04:00
KtorZ
e44f18bae5 Add failing test scenario for recursive types. 2023-03-12 12:44:49 -04:00
KtorZ
a66c9bd2c3 Remove redundant match on tuple blueprint generation. 2023-03-08 16:40:03 +01:00
rvcas
e2dc4ec6c8 feat: implement convert command 2023-03-03 20:57:20 -05:00
KtorZ
6d098a4571 Fix blueprint generation for nested fields with Data
Having the data's schema be optional at the level of the 'Schema' did not allow to represent cases where there would be an opaque data at an arbitrary nesting. So I introduced a new variant 'Opaque' on 'Data' to fill that gap.
2023-03-02 15:25:17 -05:00
rvcas
a40f88b918 fix: test never used Foo 2023-03-02 15:25:17 -05:00
KtorZ
65c336cb82 Update blueprint outputs to reflect latest specification.
Schemas of datums, redeemers and parameters are now nested under a field 'schema'. This allows to define a field 'purpose' at the same level.
2023-03-02 17:17:27 +01:00
KtorZ
70cdf3cb26 Add 'exported_data' test and revert 413a056 2023-03-02 16:09:08 +01:00
Kasey White
413a056c08 fix: Data was not allowed in an interface
Co-authored-by: rvcas <x@rvcas.dev>
2023-03-01 21:34:36 -05:00
KtorZ
a46a9fca41 Only use colors & text decorations on ANSI-capable terminals.
Fixes #404.
2023-02-26 13:19:03 +01:00
KtorZ
0838d48f7c Move module name validation outside of type-checking
And disable it for documentation generation. This way, we can generate documentation for aiken/builtins and aiken (prelude)
2023-02-22 11:51:32 +01:00
KtorZ
c0230a811f Add 'plutusVersion' to blueprints. 2023-02-21 15:37:35 +01:00
KtorZ
82a32a082b Remove 'purpose' from blueprint's schema.
This has been removed from the CIP-0057 specification since validators
  are often re-used for multiple purposes (especially validators with
  arity 2). It's misleading to assign a validator a purpose since the
  purpose distinction actually happens _within_ the validator itself.
2023-02-21 15:30:41 +01:00
KtorZ
db0dfbbec1 Fix blueprint schema for tuples. 2023-02-21 15:29:33 +01:00
rvcas
815d7d80c6 feat(lsp): hover and goto definition 2023-02-20 15:30:25 -05:00
KtorZ
e9e3f4f50a Implement TraceIfFalse type-checking and AST transformation.
This caused me some trouble. In my first approach, I ended up having
  multiple traces because nested values would be evaluated twice; once
  as condition, and once as part of the continuation.

  To prevent this, we can simply evaluate the condition once, and return
  plain True / False boolean as outcome. So this effectively transforms any
  expression:

  ```
  expr
  ```

  as

  ```
  if expr { True } else { trace("...", False) }
  ```
2023-02-16 20:29:41 -05:00
KtorZ
3204322da6 Fix validator lookup by title.
We want the lookup to yield a result when there's only a single
  validator; and no title is provided. So that users can simply do
  'aiken address' in their project if it's unambiguous. The validator's
  name is only required to disambiguate between multiple validators.

  I also noticed that the order of arguments in with_validator was
  wrong. Somehow.
2023-02-16 10:28:27 +01:00
rvcas
a311531508 fix(cli): aiken address 2023-02-16 00:05:55 -05:00
rvcas
2e78b7100c fix: blueprint tests 2023-02-16 00:05:55 -05:00
rvcas
673b57b81c feat: get bluprint stuff compiling again 2023-02-16 00:05:55 -05:00
rvcas
d03288cece feat(validator): move return type and arity check to infer 2023-02-16 00:05:55 -05:00
Kasey White
ddef61a855 fix: blueprint tests 2023-02-10 19:45:44 -05:00
KtorZ
62fe321ddf Add 'Ordering' data-type to the Prelude.
Useful to have around to build comparison functions.
2023-02-09 11:07:30 +01:00
rvcas
fd14da0720 chore: fix blueprint tests 2023-02-09 00:09:23 -05:00
KtorZ
95a62f7172 Fix oversights in blueprint / schema generation. 2023-02-08 19:04:50 +01:00
KtorZ
6e554129e9 Fix blueprint validator tests. 2023-02-07 12:28:34 +01:00
Matthias Benkort
8feaefe073 Merge pull request #335 from aiken-lang/blueprint-parameters
Blueprint parameters
2023-02-07 11:43:01 +01:00
rvcas
3ff927d30a feat: reset the generator when generate finishes 2023-02-05 20:35:39 -05:00
rvcas
501d667532 chore: fix tests 2023-02-05 20:35:39 -05:00
Kasey White
c32a9d7b6f commit working changes so far 2023-02-05 20:35:39 -05:00
KtorZ
b04fb5962a Do not compute addresses of parameterized validators
And leave a proper notice.
2023-02-04 11:49:56 +01:00
KtorZ
9b8ff590b8 Implement 'blueprint apply' command.
This is still a bit clunky as the interface is expecting parameters in UPLC form and we don't do any kind of verification. So it is easy to shoot oneself in the foot at the moment (for example, to apply an integer into something that should have received a data). To be improved later.
2023-02-04 11:39:55 +01:00
KtorZ
ea269b14a2 Fix deserialization issue when 'parameters' is missing.
Deserialize to an empty vector.
2023-02-04 11:38:09 +01:00
KtorZ
592d3d7a1c Define 'apply_parameter' method on 'Project' 2023-02-04 10:44:33 +01:00
KtorZ
12f4768008 Write method to apply a UPLC term to an existing 'Validator' 2023-02-04 10:22:23 +01:00
KtorZ
9c71aab3db Factor out reusable parts regarding blueprints from lib/project
So we can re-apply the same logic for applying arguments.
2023-02-04 10:21:45 +01:00
KtorZ
55ecc199d1 Add 'parameters' to blueprints for parameterized validators.
Without that, we have no way to distinguish between fully applied
   validators and those that still require some hard-coded parameters.

   Next steps is to make it easier to apply parameters to those, as well
   as forbid the creation of addresses of validators that aren't fully
   qualified.
2023-02-04 09:31:43 +01:00
rvcas
50b5273967 fix(tests): validator hashs and cbor changed for blueprints 2023-02-01 23:49:33 -05:00
rvcas
a365649360 chore: clippy autofix 2023-02-01 18:53:11 -05:00
KtorZ
daee8e39d6 Implement new command: address
This calculates a validator's address from validators found in a blueprint. It also provides a convenient way to attach a delegation part to the validator if needs be. The command is meant to provide a nice user experience and works 'out of the box' for projects that have only a single validator. Just call 'aiken address' to get the validator's address.

  Note that the command-line doesn't provide any option to configure the target network. This automatically assumes testnet, and will until we deem the project ready for mainnet. Those brave enough to run an Aiken's program on mainnet will find a way anyway.
2023-01-31 15:39:40 +01:00