Skip to content

Commit

Permalink
fix bug due to default validator lacking datum/redeemer
Browse files Browse the repository at this point in the history
from plutus.ts:

```
"validators": [
    ...,
    {
      "title": "[..].else",
      "parameters": [
        {
          "title": "...",
          "schema": {
            "$ref": "..."
          }
        }
      ],
      "compiledCode": "...",
      "hash": "..."
    },
    ...
]
```

Hope this slaps, haven't been able to try it due to #152
  • Loading branch information
lemmon-714 authored Sep 7, 2024
1 parent 297954f commit 1c77b9b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/blaze-blueprint/src/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ export async function generateBlueprint({
if (useSdk) {
generator.useSDK();
}
const validators = plutusJson.validators.map((validator) => {
const validators = plutusJson.validators.flatMap((validator) => {
const title = validator.title;
if (title.endsWith(`.else`)) return [];
const name = (() => {
// Validators can reside under sub-directories and without replacing `/`
// in the path the resulting `plutus.ts` will have validators with `/`
Expand Down Expand Up @@ -303,7 +304,7 @@ export async function generateBlueprint({

const script = validator.compiledCode;

return `export interface ${name} {
return [`export interface ${name} {
new (${paramsArgs.map((param) => param.join(":")).join(",")}): Script;${
datum ? `\n${datumTitle}: ${generator.schemaToType(datumSchema)};` : ""
}
Expand All @@ -322,7 +323,7 @@ export async function generateBlueprint({
}},
${datum ? `{${datumTitle}: ${JSON.stringify(datumSchema)}},` : ""}
{${redeemerTitle}: ${JSON.stringify(redeemerSchema)}},
) as unknown as ${name};`;
) as unknown as ${name};`];
});

const plutus = generator.imports + "\n\n" + validators.join("\n\n");
Expand Down

0 comments on commit 1c77b9b

Please sign in to comment.