Skip to content

Commit

Permalink
re-enabled legacy way for defining Closed Role tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
nhenin committed Dec 13, 2023
1 parent cf0b487 commit 0a6b6d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
7 changes: 1 addition & 6 deletions examples/nodejs/src/escrow-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Lucid, Blockfrost } from "lucid-cardano";
import { readConfig } from "./config.js";
import { datetoTimeout } from "@marlowe.io/language-core-v1";
import { addressBech32 } from "@marlowe.io/runtime-core";
import { mintRole } from "@marlowe.io/runtime-rest-client/contract";

const args = arg({
"--help": Boolean,
Expand Down Expand Up @@ -113,11 +112,7 @@ async function main(

const [contractId, txId] = await runtime.contracts.createContract({
contract: escrow,
roles: {
Buyer: mintRole(Buyer),
Seller: mintRole(Seller),
Mediator: mintRole(Mediator),
},
roles: { Buyer, Seller, Mediator },
});

console.log("Contract ID: " + contractId);
Expand Down
19 changes: 15 additions & 4 deletions packages/runtime/client/rest/src/contract/rolesConfigurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PolicyId, RoleName } from "@marlowe.io/language-core-v1";

import * as G from "@marlowe.io/language-core-v1/guards";
import { AddressBech32, AddressBech32Guard } from "@marlowe.io/runtime-core";
import { assertGuardEqual, proxy } from "@marlowe.io/adapter/io-ts";

/**
* Definition a of Closed Role Tlken
Expand Down Expand Up @@ -148,11 +149,21 @@ export const RoleTokenConfigurationGuard: t.Type<RoleTokenConfiguration> =
/**
* @category Roles Configuration
*/
export type MintRolesTokens = { [x: RoleName]: RoleTokenConfiguration };
export type RoleTokenConfigurations = RoleTokenConfiguration | ClosedRole;

export const MintRolesTokensGuard: t.Type<MintRolesTokens> = t.record(
G.RoleName,
RoleTokenConfigurationGuard
export const RoleConfigurationsGuard = t.union([
RoleTokenConfigurationGuard,
ClosedRoleGuard,
]);

/**
* @category Roles Configuration
*/
export type MintRolesTokens = { [x: RoleName]: RoleTokenConfigurations };

export const MintRolesTokensGuard = assertGuardEqual(
proxy<MintRolesTokens>(),
t.record(G.RoleName, RoleConfigurationsGuard)
);

/**
Expand Down

0 comments on commit 0a6b6d7

Please sign in to comment.