From f177b8230d2cd1290f14588baba74c30399a608c Mon Sep 17 00:00:00 2001 From: Hernan Rajchert Date: Fri, 8 Mar 2024 11:24:49 -0300 Subject: [PATCH] Renamed deprecatedContractsAPI back to its original name --- examples/nodejs/src/escrow-flow.ts | 15 ++++++--------- packages/runtime/lifecycle/src/api.ts | 4 ++-- .../lifecycle/src/generic/applicable-actions.ts | 6 +----- .../{deprecated-contracts.ts => contracts.ts} | 0 .../lifecycle/src/generic/new-contract-api.ts | 2 +- packages/runtime/lifecycle/src/generic/runtime.ts | 10 +++------- 6 files changed, 13 insertions(+), 24 deletions(-) rename packages/runtime/lifecycle/src/generic/{deprecated-contracts.ts => contracts.ts} (100%) diff --git a/examples/nodejs/src/escrow-flow.ts b/examples/nodejs/src/escrow-flow.ts index a8da5c6c..09bbc2c7 100644 --- a/examples/nodejs/src/escrow-flow.ts +++ b/examples/nodejs/src/escrow-flow.ts @@ -88,17 +88,14 @@ async function main(action: "buy" | "sell", otherAddress: string, amount: number console.log("Mediator: " + Mediator); console.log("Amount: " + amount); - const [contractId, txId] = await runtime.deprecatedContractAPI.createContract( - { - contract: escrow, - roles: { Buyer, Seller, Mediator }, - } - ); + const contractInstance = await runtime.newContractAPI.createContract({ + contract: escrow, + roles: { Buyer, Seller, Mediator }, + }); - console.log("Contract ID: " + contractId); - console.log("Transaction ID: " + txId); + console.log("Contract ID: " + contractInstance.contractId); console.log("Waiting for confirmation..."); - await wallet.waitConfirmation(txId); + await contractInstance.waitForConfirmation(); console.log("Contract created successfully!"); } diff --git a/packages/runtime/lifecycle/src/api.ts b/packages/runtime/lifecycle/src/api.ts index f2a717f5..93ad387a 100644 --- a/packages/runtime/lifecycle/src/api.ts +++ b/packages/runtime/lifecycle/src/api.ts @@ -33,7 +33,7 @@ import { import { ContractsAPI, CreateContractRequestBase, -} from "./generic/deprecated-contracts.js"; +} from "./generic/contracts.js"; export { ApplicableActionsAPI, ApplicableAction, @@ -74,7 +74,7 @@ export interface RuntimeLifecycle { /** * The contracts API is a high level API that lets you create and interact with Marlowe contracts. */ - deprecatedContractAPI: ContractsAPI; + contracts: ContractsAPI; payouts: PayoutsAPI; applicableActions: ApplicableActionsAPI; } diff --git a/packages/runtime/lifecycle/src/generic/applicable-actions.ts b/packages/runtime/lifecycle/src/generic/applicable-actions.ts index 2e94a6ff..f7c490d3 100644 --- a/packages/runtime/lifecycle/src/generic/applicable-actions.ts +++ b/packages/runtime/lifecycle/src/generic/applicable-actions.ts @@ -1,8 +1,4 @@ -import { - ApplyInputsRequest, - ContractsAPI, - applyInputs, -} from "./deprecated-contracts.js"; +import { ApplyInputsRequest, ContractsAPI, applyInputs } from "./contracts.js"; import { Monoid } from "fp-ts/lib/Monoid.js"; import * as R from "fp-ts/lib/Record.js"; diff --git a/packages/runtime/lifecycle/src/generic/deprecated-contracts.ts b/packages/runtime/lifecycle/src/generic/contracts.ts similarity index 100% rename from packages/runtime/lifecycle/src/generic/deprecated-contracts.ts rename to packages/runtime/lifecycle/src/generic/contracts.ts diff --git a/packages/runtime/lifecycle/src/generic/new-contract-api.ts b/packages/runtime/lifecycle/src/generic/new-contract-api.ts index 70986e1b..9a9f68c6 100644 --- a/packages/runtime/lifecycle/src/generic/new-contract-api.ts +++ b/packages/runtime/lifecycle/src/generic/new-contract-api.ts @@ -10,7 +10,7 @@ import { createContract, applyInputs, getInputHistory, -} from "./deprecated-contracts.js"; +} from "./contracts.js"; import { SingleInputTx, TransactionSuccess, diff --git a/packages/runtime/lifecycle/src/generic/runtime.ts b/packages/runtime/lifecycle/src/generic/runtime.ts index 938f729f..75c0c645 100644 --- a/packages/runtime/lifecycle/src/generic/runtime.ts +++ b/packages/runtime/lifecycle/src/generic/runtime.ts @@ -4,7 +4,7 @@ import { WalletAPI } from "@marlowe.io/wallet/api"; import { FPTSRestAPI, RestClient } from "@marlowe.io/runtime-rest-client"; import { mkPayoutLifecycle } from "./payouts.js"; -import { mkContractLifecycle } from "./deprecated-contracts.js"; +import { mkContractLifecycle } from "./contracts.js"; import { mkApplicableActionsAPI } from "./applicable-actions.js"; import * as NewContract from "./new-contract-api.js"; @@ -13,15 +13,11 @@ export function mkRuntimeLifecycle( restClient: RestClient, wallet: WalletAPI ): RuntimeLifecycle { - const deprecatedContractAPI = mkContractLifecycle( - wallet, - deprecatedRestAPI, - restClient - ); + const contracts = mkContractLifecycle(wallet, deprecatedRestAPI, restClient); return { wallet: wallet, restClient, - deprecatedContractAPI, + contracts, newContractAPI: NewContract.mkContractsAPI({ wallet, restClient }), payouts: mkPayoutLifecycle(wallet, deprecatedRestAPI, restClient), applicableActions: mkApplicableActionsAPI({ restClient, wallet }),