Skip to content

Commit

Permalink
snake to camel case in definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Jan 17, 2025
1 parent 4c3b0cb commit 9610083
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ function resolveSchema(schema: any): any {
}
}

function resolveDefinitions(
definitions: Blueprint["definitions"],
): Blueprint["definitions"] {
return Object.fromEntries(
Object.entries(definitions).map(([name, schema]) => {
return [name, resolveSchema(schema)];
}),
);
}

function schemaToType(schema: any): string {
if (!schema) throw new Error("Could not generate type.");
const shapeType = (schema.anyOf ? "enum" : schema["$ref"] ? "$ref" : "") ||
Expand Down Expand Up @@ -276,7 +286,7 @@ const plutus = imports +
"\n\n" +
`${definitionsToTypes(definitions)}` +
"\n\n" +
`const definitions = ${JSON.stringify(definitions)};` +
`const definitions = ${JSON.stringify(resolveDefinitions(definitions))};` +
"\n\n" +
validators.join("\n\n");

Expand Down
6 changes: 3 additions & 3 deletions tests/emulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
assertEquals,
} from "https://deno.land/[email protected]/testing/asserts.ts";

async function generateAccount(assets: Assets) {
function generateAccount(assets: Assets) {
const seedPhrase = Crypto.generateSeed();
const { credential } = Crypto.seedToDetails(seedPhrase, 0, "Payment");
const address = Addresses.credentialToAddress({ Emulator: 0 }, credential);
Expand All @@ -23,8 +23,8 @@ async function generateAccount(assets: Assets) {
};
}

const ACCOUNT_0 = await generateAccount({ lovelace: 75000000000n });
const ACCOUNT_1 = await generateAccount({ lovelace: 100000000n });
const ACCOUNT_0 = generateAccount({ lovelace: 75000000000n });
const ACCOUNT_1 = generateAccount({ lovelace: 100000000n });

const emulator = new Emulator([ACCOUNT_0, ACCOUNT_1]);

Expand Down

0 comments on commit 9610083

Please sign in to comment.