From 2da11935acc60a9fd1e7f06a4002312b01f918dd Mon Sep 17 00:00:00 2001 From: "Chris M. Hiatt" <69039074+lemmon-714@users.noreply.github.com> Date: Sat, 7 Sep 2024 14:19:57 +0200 Subject: [PATCH] fix bug due to default validator lacking datum/redeemer from plutus.ts: ``` "validators": [ ..., { "title": "[..].else", "parameters": [ { "title": "...", "schema": { "$ref": "..." } } ], "compiledCode": "...", "hash": "..." }, ... ] ``` Hope this slaps, haven't been able to try it due to https://github.com/butaneprotocol/blaze-cardano/issues/152 --- packages/blaze-blueprint/src/blueprint.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/blaze-blueprint/src/blueprint.ts b/packages/blaze-blueprint/src/blueprint.ts index bf55fc0f..d91c3b73 100644 --- a/packages/blaze-blueprint/src/blueprint.ts +++ b/packages/blaze-blueprint/src/blueprint.ts @@ -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 `/` @@ -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)};` : "" } @@ -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");