From 641c5db449fee74d79479333f6d3e193353e3d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 13 Dec 2023 11:28:21 +0100 Subject: [PATCH 01/12] scaffolding --- .../rest/src/contract/endpoints/sources.ts | 9 ++++ .../client/rest/src/contract/next/endpoint.ts | 3 ++ packages/runtime/client/rest/src/index.ts | 51 +++++++++++++++---- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/packages/runtime/client/rest/src/contract/endpoints/sources.ts b/packages/runtime/client/rest/src/contract/endpoints/sources.ts index e8b098c6..5e021d7c 100644 --- a/packages/runtime/client/rest/src/contract/endpoints/sources.ts +++ b/packages/runtime/client/rest/src/contract/endpoints/sources.ts @@ -40,3 +40,12 @@ export const createContractSources = (axiosInstance: AxiosInstance) => { ); }; }; + +export interface GetContractBySourceIdRequest {} +export interface GetContractBySourceIdResponse {} + +export interface GetContractSourceAdjacencyRequest {} +export interface GetContractSourceAdjacencyResponse {} + +export interface GetContractSourceClosureRequest {} +export interface GetContractSourceClosureResponse {} diff --git a/packages/runtime/client/rest/src/contract/next/endpoint.ts b/packages/runtime/client/rest/src/contract/next/endpoint.ts index da479456..2278ec3b 100644 --- a/packages/runtime/client/rest/src/contract/next/endpoint.ts +++ b/packages/runtime/client/rest/src/contract/next/endpoint.ts @@ -40,3 +40,6 @@ export const getViaAxios: (axiosInstance: AxiosInstance) => GET = const contractNextEndpoint = (contractId: ContractId): string => `/contracts/${encodeURIComponent(unContractId(contractId))}/next`; + +export interface GetNextStepsForContractRequest {} +export interface GetNextStepsForContractResponse {} diff --git a/packages/runtime/client/rest/src/index.ts b/packages/runtime/client/rest/src/index.ts index 35a2d11e..bc685488 100644 --- a/packages/runtime/client/rest/src/index.ts +++ b/packages/runtime/client/rest/src/index.ts @@ -40,8 +40,7 @@ import { import { submitContractViaAxios } from "./contract/endpoints/singleton.js"; import { ContractDetails } from "./contract/details.js"; import { TransactionDetails } from "./contract/transaction/details.js"; -import { CreateContractSourcesResponse } from "./contract/endpoints/sources.js"; -import { BuildCreateContractTxRequestWithContract } from "./contract/index.js"; +import * as ContractSources from "./contract/endpoints/sources.js"; // import curlirize from 'axios-curlirize'; /** @@ -89,7 +88,30 @@ export interface RestClient { createContractSources( mainId: Label, bundle: Bundle - ): Promise; + ): Promise; + + getContractSourceById( + request: ContractSources.GetContractBySourceIdRequest + ): Promise; + + getContractSourceAdjacency( + request: ContractSources.GetContractSourceAdjacencyRequest + ): Promise; + + getContractSourceClosure( + request: ContractSources.GetContractSourceClosureRequest + ): Promise; + + getNextStepsForContract( + request: ContractNext.GetNextStepsForContractRequest + ): Promise; + + // getContractSource: ContractSource.GET; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-contract-import-by-id + // getContractAdjacency: ContractSource.GET_ADJACENCY; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-adjacency-by-id if so lets unify + // getContractClosure: ContractSource.GET_CLOSURE; // Jamie is it this one? - https://docs.marlowe.iohk.io/api/get-closure-by-id + + // getNextStepsForContract: Next.GET; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-transaction-output-by-id? if so lets unify + /** * Gets a single contract by id * @param contractId The id of the contract to get @@ -97,6 +119,7 @@ export interface RestClient { * @see {@link https://docs.marlowe.iohk.io/api/get-contract-by-id | The backend documentation} */ getContractById(contractId: ContractId): Promise; + /** * Submits a signed contract creation transaction * @see {@link https://docs.marlowe.iohk.io/api/submit-contract-to-chain | The backend documentation} @@ -105,6 +128,7 @@ export interface RestClient { contractId: ContractId, txEnvelope: TextEnvelope ): Promise; + /** * Gets a paginated list of {@link contract.TxHeader } for a given contract. * @see {@link https://docs.marlowe.iohk.io/api/get-transactions-for-contract | The backend documentation } @@ -116,6 +140,7 @@ export interface RestClient { contractId: ContractId, range?: TransactionsRange ): Promise; + /** * Create an unsigned transaction which applies inputs to a contract. * @see {@link https://docs.marlowe.iohk.io/api/apply-inputs-to-contract | The backend documentation} @@ -126,6 +151,7 @@ export interface RestClient { applyInputsToContract( request: Transactions.ApplyInputsToContractRequest ): Promise; + // getTransactionById: Transaction.GET; // - https://docs.marlowe.iohk.io/api/get-transaction-by-id /** * Submit a signed transaction (generated with {@link @marlowe.io/runtime-rest-client!index.RestClient#applyInputsToContract} and signed with the {@link @marlowe.io/wallet!api.WalletAPI#signTx} procedure) that applies inputs to a contract. @@ -195,13 +221,6 @@ export interface RestClient { */ healthcheck(): Promise; - // getNextStepsForContract: Next.GET; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-transaction-output-by-id? if so lets unify - - // postContractSource: ContractSources.POST; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/access-contract-import if so lets unify - // getContractSource: ContractSource.GET; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-contract-import-by-id - // getContractAdjacency: ContractSource.GET_ADJACENCY; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-adjacency-by-id if so lets unify - // getContractClosure: ContractSource.GET_CLOSURE; // Jamie is it this one? - https://docs.marlowe.iohk.io/api/get-closure-by-id - /** * Get payouts to parties from role-based contracts. * @see {@link https://docs.marlowe.iohk.io/api/get-role-payouts | The backend documentation} @@ -280,6 +299,18 @@ export function mkRestClient(baseURL: string): RestClient { createContractSources(mainId, bundle) { return Sources.createContractSources(axiosInstance)(mainId, bundle); }, + getContractSourceById(request) { + throw "Not implemented!"; + }, + getContractSourceAdjacency(request) { + throw "Not implemented!"; + }, + getContractSourceClosure(request) { + throw "Not implemented!"; + }, + getNextStepsForContract(request) { + throw "Not implemented!"; + }, submitContract(contractId, txEnvelope) { return submitContractViaAxios(axiosInstance)(contractId, txEnvelope); }, From 93aaaaf0fffdd0803e26acb2b8494bd10b427180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 13 Dec 2023 12:39:22 +0100 Subject: [PATCH 02/12] getContractSourceById implementation --- .../rest/src/contract/endpoints/sources.ts | 38 +++++++++++++++++-- packages/runtime/client/rest/src/index.ts | 24 ++++++------ 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/packages/runtime/client/rest/src/contract/endpoints/sources.ts b/packages/runtime/client/rest/src/contract/endpoints/sources.ts index 5e021d7c..e44cf6c7 100644 --- a/packages/runtime/client/rest/src/contract/endpoints/sources.ts +++ b/packages/runtime/client/rest/src/contract/endpoints/sources.ts @@ -4,7 +4,7 @@ import * as E from "fp-ts/lib/Either.js"; import { pipe } from "fp-ts/lib/function.js"; import { formatValidationErrors } from "jsonbigint-io-ts-reporters"; -import { BuiltinByteString } from "@marlowe.io/language-core-v1"; +import { BuiltinByteString, Contract } from "@marlowe.io/language-core-v1"; import { Bundle, Label } from "@marlowe.io/marlowe-object"; import { AxiosInstance } from "axios"; @@ -41,11 +41,43 @@ export const createContractSources = (axiosInstance: AxiosInstance) => { }; }; -export interface GetContractBySourceIdRequest {} -export interface GetContractBySourceIdResponse {} +export interface GetContractBySourceIdRequest { + contractSourceId: BuiltinByteString; + expand?: boolean; +} + +export interface GetContractBySourceIdResponse { + contract: Contract; +} + +const GetContractBySourceIdResponseGuard: t.Type = + t.type({ contract: G.Contract }); + +export const getContractSourceById = + (axiosInstance: AxiosInstance) => + async ({ + contractSourceId, + expand, + }: GetContractBySourceIdRequest): Promise => { + const response = await axiosInstance.get( + `/contracts/sources/${encodeURIComponent(contractSourceId)}`, + { params: { expand } } + ); + return pipe( + GetContractBySourceIdResponseGuard.decode(response.data), + E.match( + (e) => { + throw formatValidationErrors(e); + }, + (e) => e + ) + ); + }; export interface GetContractSourceAdjacencyRequest {} + export interface GetContractSourceAdjacencyResponse {} export interface GetContractSourceClosureRequest {} + export interface GetContractSourceClosureResponse {} diff --git a/packages/runtime/client/rest/src/index.ts b/packages/runtime/client/rest/src/index.ts index bc685488..59bb1fa5 100644 --- a/packages/runtime/client/rest/src/index.ts +++ b/packages/runtime/client/rest/src/index.ts @@ -40,7 +40,6 @@ import { import { submitContractViaAxios } from "./contract/endpoints/singleton.js"; import { ContractDetails } from "./contract/details.js"; import { TransactionDetails } from "./contract/transaction/details.js"; -import * as ContractSources from "./contract/endpoints/sources.js"; // import curlirize from 'axios-curlirize'; /** @@ -88,19 +87,24 @@ export interface RestClient { createContractSources( mainId: Label, bundle: Bundle - ): Promise; + ): Promise; + /** + * Gets the contract associated with given source id + * @throws DecodingError - If the response from the server can't be decoded + * @see {@link https://docs.marlowe.iohk.io/api/get-contract-source-by-id | The backend documentation} + */ getContractSourceById( - request: ContractSources.GetContractBySourceIdRequest - ): Promise; + request: Sources.GetContractBySourceIdRequest + ): Promise; getContractSourceAdjacency( - request: ContractSources.GetContractSourceAdjacencyRequest - ): Promise; + request: Sources.GetContractSourceAdjacencyRequest + ): Promise; getContractSourceClosure( - request: ContractSources.GetContractSourceClosureRequest - ): Promise; + request: Sources.GetContractSourceClosureRequest + ): Promise; getNextStepsForContract( request: ContractNext.GetNextStepsForContractRequest @@ -299,9 +303,7 @@ export function mkRestClient(baseURL: string): RestClient { createContractSources(mainId, bundle) { return Sources.createContractSources(axiosInstance)(mainId, bundle); }, - getContractSourceById(request) { - throw "Not implemented!"; - }, + getContractSourceById: Sources.getContractSourceById(axiosInstance), getContractSourceAdjacency(request) { throw "Not implemented!"; }, From 652a201a55ed64b7a6319f77f183f8e5365f5a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 13 Dec 2023 13:06:41 +0100 Subject: [PATCH 03/12] getContractSourceAdjacency implementation --- .../rest/src/contract/endpoints/sources.ts | 36 +++++++++++++++---- packages/runtime/client/rest/src/index.ts | 10 ++++-- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/packages/runtime/client/rest/src/contract/endpoints/sources.ts b/packages/runtime/client/rest/src/contract/endpoints/sources.ts index e44cf6c7..edaf271a 100644 --- a/packages/runtime/client/rest/src/contract/endpoints/sources.ts +++ b/packages/runtime/client/rest/src/contract/endpoints/sources.ts @@ -46,12 +46,10 @@ export interface GetContractBySourceIdRequest { expand?: boolean; } -export interface GetContractBySourceIdResponse { - contract: Contract; -} +export type GetContractBySourceIdResponse = Contract; const GetContractBySourceIdResponseGuard: t.Type = - t.type({ contract: G.Contract }); + G.Contract; export const getContractSourceById = (axiosInstance: AxiosInstance) => @@ -74,9 +72,35 @@ export const getContractSourceById = ); }; -export interface GetContractSourceAdjacencyRequest {} +export interface GetContractSourceAdjacencyRequest { + contractSourceId: BuiltinByteString; +} + +export interface GetContractSourceAdjacencyResponse { + results: BuiltinByteString[]; +} + +const GetContractSourceAdjacencyResponseGuard: t.Type = + t.type({ results: t.array(G.BuiltinByteString) }); -export interface GetContractSourceAdjacencyResponse {} +export const getContractSourceAdjacency = + (axiosInstance: AxiosInstance) => + async ({ + contractSourceId, + }: GetContractSourceAdjacencyRequest): Promise => { + const response = await axiosInstance.get( + `/contracts/sources/${encodeURIComponent(contractSourceId)}/adjacency` + ); + return pipe( + GetContractSourceAdjacencyResponseGuard.decode(response.data), + E.match( + (e) => { + throw formatValidationErrors(e); + }, + (e) => e + ) + ); + }; export interface GetContractSourceClosureRequest {} diff --git a/packages/runtime/client/rest/src/index.ts b/packages/runtime/client/rest/src/index.ts index 59bb1fa5..ca79a7a2 100644 --- a/packages/runtime/client/rest/src/index.ts +++ b/packages/runtime/client/rest/src/index.ts @@ -98,6 +98,11 @@ export interface RestClient { request: Sources.GetContractBySourceIdRequest ): Promise; + /** + * Get the contract source IDs which are adjacent to a contract source (they appear directly in the contract source). + * @throws DecodingError - If the response from the server can't be decoded + * @see {@link https://docs.marlowe.iohk.io/api/get-adjacent-contract-source-i-ds-by-id | The backend documentation} + */ getContractSourceAdjacency( request: Sources.GetContractSourceAdjacencyRequest ): Promise; @@ -304,9 +309,8 @@ export function mkRestClient(baseURL: string): RestClient { return Sources.createContractSources(axiosInstance)(mainId, bundle); }, getContractSourceById: Sources.getContractSourceById(axiosInstance), - getContractSourceAdjacency(request) { - throw "Not implemented!"; - }, + getContractSourceAdjacency: + Sources.getContractSourceAdjacency(axiosInstance), getContractSourceClosure(request) { throw "Not implemented!"; }, From be3e2ad0874a05e7282746efddc66bee6eda48f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 13 Dec 2023 13:20:27 +0100 Subject: [PATCH 04/12] getContractSourceClosure implementation --- .../rest/src/contract/endpoints/sources.ts | 30 +++++++++++++++++-- packages/runtime/client/rest/src/index.ts | 9 ++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/packages/runtime/client/rest/src/contract/endpoints/sources.ts b/packages/runtime/client/rest/src/contract/endpoints/sources.ts index edaf271a..3d3f5890 100644 --- a/packages/runtime/client/rest/src/contract/endpoints/sources.ts +++ b/packages/runtime/client/rest/src/contract/endpoints/sources.ts @@ -102,6 +102,32 @@ export const getContractSourceAdjacency = ); }; -export interface GetContractSourceClosureRequest {} +export interface GetContractSourceClosureRequest { + contractSourceId: BuiltinByteString; +} + +export interface GetContractSourceClosureResponse { + results: BuiltinByteString[]; +} -export interface GetContractSourceClosureResponse {} +const GetContractSourceClosureResponseGuard: t.Type = + t.type({ results: t.array(G.BuiltinByteString) }); + +export const getContractSourceClosure = + (axiosInstance: AxiosInstance) => + async ({ + contractSourceId, + }: GetContractSourceClosureRequest): Promise => { + const response = await axiosInstance.get( + `/contracts/sources/${encodeURIComponent(contractSourceId)}/closure` + ); + return pipe( + GetContractSourceClosureResponseGuard.decode(response.data), + E.match( + (e) => { + throw formatValidationErrors(e); + }, + (e) => e + ) + ); + }; diff --git a/packages/runtime/client/rest/src/index.ts b/packages/runtime/client/rest/src/index.ts index ca79a7a2..ceea560e 100644 --- a/packages/runtime/client/rest/src/index.ts +++ b/packages/runtime/client/rest/src/index.ts @@ -107,6 +107,11 @@ export interface RestClient { request: Sources.GetContractSourceAdjacencyRequest ): Promise; + /** + * Get the contract source IDs which appear in the full hierarchy of a contract source (including the ID of the contract source itself). + * @throws DecodingError - If the response from the server can't be decoded + * @see {@link https://docs.marlowe.iohk.io/api/get-contract-source-closure-by-id | The backend documentation} + */ getContractSourceClosure( request: Sources.GetContractSourceClosureRequest ): Promise; @@ -311,9 +316,7 @@ export function mkRestClient(baseURL: string): RestClient { getContractSourceById: Sources.getContractSourceById(axiosInstance), getContractSourceAdjacency: Sources.getContractSourceAdjacency(axiosInstance), - getContractSourceClosure(request) { - throw "Not implemented!"; - }, + getContractSourceClosure: Sources.getContractSourceClosure(axiosInstance), getNextStepsForContract(request) { throw "Not implemented!"; }, From 2ecf468d01c1212aaaccbf674b6c038f1175a6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 13 Dec 2023 14:27:55 +0100 Subject: [PATCH 05/12] getNextStepsForContract implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Björn Kihlberg --- .../client/rest/src/contract/next/endpoint.ts | 49 ++++++++++++++++++- packages/runtime/client/rest/src/index.ts | 25 +++++----- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/packages/runtime/client/rest/src/contract/next/endpoint.ts b/packages/runtime/client/rest/src/contract/next/endpoint.ts index 2278ec3b..a00ab4b5 100644 --- a/packages/runtime/client/rest/src/contract/next/endpoint.ts +++ b/packages/runtime/client/rest/src/contract/next/endpoint.ts @@ -1,4 +1,6 @@ import { AxiosInstance } from "axios"; +import * as t from "io-ts/lib/index.js"; +import * as G from "@marlowe.io/language-core-v1/guards"; import * as E from "fp-ts/lib/Either.js"; import * as TE from "fp-ts/lib/TaskEither.js"; import { pipe } from "fp-ts/lib/function.js"; @@ -10,6 +12,7 @@ import { Next } from "@marlowe.io/language-core-v1/next"; import { stringify } from "qs"; import { DecodingError } from "@marlowe.io/adapter/codec"; import { posixTimeToIso8601 } from "@marlowe.io/adapter/time"; +import { partiesToStrings } from "@marlowe.io/language-core-v1/participants.js"; export type GET = ( contractId: ContractId @@ -41,5 +44,47 @@ export const getViaAxios: (axiosInstance: AxiosInstance) => GET = const contractNextEndpoint = (contractId: ContractId): string => `/contracts/${encodeURIComponent(unContractId(contractId))}/next`; -export interface GetNextStepsForContractRequest {} -export interface GetNextStepsForContractResponse {} +export interface GetNextStepsForContractRequest { + contractId: ContractId; + validityStart: bigint; + validityEnd: bigint; + parties?: Party[]; +} + +export type GetNextStepsForContractResponse = Next; + +const GetNextStepsForContractResponseGuard = Next; + +export const getNextStepsForContract = + (axiosInstance: AxiosInstance) => + async ({ + contractId, + validityStart, + validityEnd, + parties, + }: GetNextStepsForContractRequest): Promise => { + const response = await axiosInstance.get( + `/contracts/${encodeURIComponent( + unContractId(contractId) + )}/next?${stringify({ + validityStart: posixTimeToIso8601(validityStart), + validityEnd: posixTimeToIso8601(validityEnd), + party: parties, + })}`, + { + headers: { + Accept: "application/json", + "Content-Type": "application/json", + }, + } + ); + return pipe( + GetNextStepsForContractResponseGuard.decode(response.data), + E.match( + (e) => { + throw formatValidationErrors(e); + }, + (e) => e + ) + ); + }; diff --git a/packages/runtime/client/rest/src/index.ts b/packages/runtime/client/rest/src/index.ts index ceea560e..7e2b3952 100644 --- a/packages/runtime/client/rest/src/index.ts +++ b/packages/runtime/client/rest/src/index.ts @@ -27,8 +27,8 @@ import * as Contracts from "./contract/endpoints/collection.js"; import * as Transaction from "./contract/transaction/endpoints/singleton.js"; import * as Transactions from "./contract/transaction/endpoints/collection.js"; import * as Sources from "./contract/endpoints/sources.js"; +import * as Next from "./contract/next/endpoint.js"; import { TransactionsRange } from "./contract/transaction/endpoints/collection.js"; -import * as ContractNext from "./contract/next/endpoint.js"; import { unsafeTaskEither } from "@marlowe.io/adapter/fp-ts"; import { ContractId, @@ -116,15 +116,14 @@ export interface RestClient { request: Sources.GetContractSourceClosureRequest ): Promise; + /** + * Get inputs which could be performed on a contract within a time range by the requested parties. + * @throws DecodingError - If the response from the server can't be decoded + * @see {@link https://docs.marlowe.iohk.io/api/get-next-contract-steps | The backend documentation} + */ getNextStepsForContract( - request: ContractNext.GetNextStepsForContractRequest - ): Promise; - - // getContractSource: ContractSource.GET; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-contract-import-by-id - // getContractAdjacency: ContractSource.GET_ADJACENCY; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-adjacency-by-id if so lets unify - // getContractClosure: ContractSource.GET_CLOSURE; // Jamie is it this one? - https://docs.marlowe.iohk.io/api/get-closure-by-id - - // getNextStepsForContract: Next.GET; // - Jamie, is it this one? https://docs.marlowe.iohk.io/api/get-transaction-output-by-id? if so lets unify + request: Next.GetNextStepsForContractRequest + ): Promise; /** * Gets a single contract by id @@ -317,9 +316,7 @@ export function mkRestClient(baseURL: string): RestClient { getContractSourceAdjacency: Sources.getContractSourceAdjacency(axiosInstance), getContractSourceClosure: Sources.getContractSourceClosure(axiosInstance), - getNextStepsForContract(request) { - throw "Not implemented!"; - }, + getNextStepsForContract: Next.getNextStepsForContract(axiosInstance), submitContract(contractId, txEnvelope) { return submitContractViaAxios(axiosInstance)(contractId, txEnvelope); }, @@ -510,7 +507,7 @@ export interface ContractsAPI { /** * @see {@link } */ - next: ContractNext.GET; + next: Next.GET; transactions: { /** * @see {@link } @@ -590,7 +587,7 @@ export function mkFPTSRestClient(baseURL: string): FPTSRestAPI { contract: { get: Contract.getViaAxios(axiosInstance), put: Contract.putViaAxios(axiosInstance), - next: ContractNext.getViaAxios(axiosInstance), + next: Next.getViaAxios(axiosInstance), transactions: { getHeadersByRange: Transactions.getHeadersByRangeViaAxios(axiosInstance), From fc0a315430ca9231a32f36eb05789d5bb137e23a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 13 Dec 2023 14:54:24 +0100 Subject: [PATCH 06/12] changelog fragment --- .../20231213_145052_bjorn.wilhelm.kihlberg_PLT_7701.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog.d/20231213_145052_bjorn.wilhelm.kihlberg_PLT_7701.md diff --git a/changelog.d/20231213_145052_bjorn.wilhelm.kihlberg_PLT_7701.md b/changelog.d/20231213_145052_bjorn.wilhelm.kihlberg_PLT_7701.md new file mode 100644 index 00000000..9f08c0c4 --- /dev/null +++ b/changelog.d/20231213_145052_bjorn.wilhelm.kihlberg_PLT_7701.md @@ -0,0 +1,6 @@ +### @marlowe.io/runtime-rest-client + +- PLT-7701: Extend the rest client with procedure `getContractSourceById`. (Implemented in [PR-128](https://github.com/input-output-hk/marlowe-ts-sdk/pull/128)) +- PLT-7702: Extend the rest client with procedure `getContractSourceAdjacency`. (Implemented in [PR-128](https://github.com/input-output-hk/marlowe-ts-sdk/pull/128)) +- PLT-7703: Extend the rest client with procedure `getContractSourceClosure`. (Implemented in [PR-128](https://github.com/input-output-hk/marlowe-ts-sdk/pull/128)) +- PLT-8427: Extend the rest client with procedure `getNextStepsForContract`. (Implemented in [PR-128](https://github.com/input-output-hk/marlowe-ts-sdk/pull/128)) From 9dd619ac362074993e0dcc72c1c7c4a4adc380dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 13 Dec 2023 14:59:31 +0100 Subject: [PATCH 07/12] reverse eta reduction --- packages/runtime/client/rest/src/index.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/runtime/client/rest/src/index.ts b/packages/runtime/client/rest/src/index.ts index 7e2b3952..9d378452 100644 --- a/packages/runtime/client/rest/src/index.ts +++ b/packages/runtime/client/rest/src/index.ts @@ -312,11 +312,18 @@ export function mkRestClient(baseURL: string): RestClient { createContractSources(mainId, bundle) { return Sources.createContractSources(axiosInstance)(mainId, bundle); }, - getContractSourceById: Sources.getContractSourceById(axiosInstance), - getContractSourceAdjacency: - Sources.getContractSourceAdjacency(axiosInstance), - getContractSourceClosure: Sources.getContractSourceClosure(axiosInstance), - getNextStepsForContract: Next.getNextStepsForContract(axiosInstance), + getContractSourceById(request) { + return Sources.getContractSourceById(axiosInstance)(request); + }, + getContractSourceAdjacency(request) { + return Sources.getContractSourceAdjacency(axiosInstance)(request); + }, + getContractSourceClosure(request) { + return Sources.getContractSourceClosure(axiosInstance)(request); + }, + getNextStepsForContract(request) { + return Next.getNextStepsForContract(axiosInstance)(request); + }, submitContract(contractId, txEnvelope) { return submitContractViaAxios(axiosInstance)(contractId, txEnvelope); }, From 6efc9d598ac6ec421b2f3bf467db623aa2d09ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Wed, 13 Dec 2023 15:02:04 +0100 Subject: [PATCH 08/12] remove unused endpoints --- packages/runtime/client/rest/src/contract/next/endpoint.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/runtime/client/rest/src/contract/next/endpoint.ts b/packages/runtime/client/rest/src/contract/next/endpoint.ts index a00ab4b5..62bdaec7 100644 --- a/packages/runtime/client/rest/src/contract/next/endpoint.ts +++ b/packages/runtime/client/rest/src/contract/next/endpoint.ts @@ -1,6 +1,4 @@ import { AxiosInstance } from "axios"; -import * as t from "io-ts/lib/index.js"; -import * as G from "@marlowe.io/language-core-v1/guards"; import * as E from "fp-ts/lib/Either.js"; import * as TE from "fp-ts/lib/TaskEither.js"; import { pipe } from "fp-ts/lib/function.js"; @@ -12,7 +10,6 @@ import { Next } from "@marlowe.io/language-core-v1/next"; import { stringify } from "qs"; import { DecodingError } from "@marlowe.io/adapter/codec"; import { posixTimeToIso8601 } from "@marlowe.io/adapter/time"; -import { partiesToStrings } from "@marlowe.io/language-core-v1/participants.js"; export type GET = ( contractId: ContractId From d29184fd59ac2e81fbf8fd9cb8edde6d4393cad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Thu, 14 Dec 2023 16:42:09 +0100 Subject: [PATCH 09/12] merkleization flow example --- examples/merkleization-flow/index.html | 79 ++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 examples/merkleization-flow/index.html diff --git a/examples/merkleization-flow/index.html b/examples/merkleization-flow/index.html new file mode 100644 index 00000000..0cfea906 --- /dev/null +++ b/examples/merkleization-flow/index.html @@ -0,0 +1,79 @@ + + + + + + Merkleization Flow + + + + + + + + From 3c831c0a6a00f2f9f3fc77b368573334d546e753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Thu, 14 Dec 2023 16:42:46 +0100 Subject: [PATCH 10/12] fix small issue --- examples/js/poc-helpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/js/poc-helpers.js b/examples/js/poc-helpers.js index 6c879970..19c28a30 100644 --- a/examples/js/poc-helpers.js +++ b/examples/js/poc-helpers.js @@ -39,7 +39,7 @@ export function logJSON(message, json) { export function getRuntimeUrl() { const runtimeUrlInput = document.getElementById("runtimeUrl"); return ( - runtimeUrlInput.value || + (runtimeUrlInput && runtimeUrlInput.value) || "https://marlowe-runtime-preprod-web.demo.scdev.aws.iohkdev.io/" ); } From 56ea3ee1e038796d7938e69eb7cd3785c88cb632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Thu, 14 Dec 2023 17:34:29 +0100 Subject: [PATCH 11/12] extend rest-client-flow --- examples/merkleization-flow/index.html | 79 -------------------------- examples/rest-client-flow/index.html | 37 ++++++++++++ 2 files changed, 37 insertions(+), 79 deletions(-) delete mode 100644 examples/merkleization-flow/index.html diff --git a/examples/merkleization-flow/index.html b/examples/merkleization-flow/index.html deleted file mode 100644 index 0cfea906..00000000 --- a/examples/merkleization-flow/index.html +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - Merkleization Flow - - - - - - - - diff --git a/examples/rest-client-flow/index.html b/examples/rest-client-flow/index.html index 0ee0f410..c15c20a5 100644 --- a/examples/rest-client-flow/index.html +++ b/examples/rest-client-flow/index.html @@ -135,6 +135,43 @@

Request

>/contracts/:contractId/transactions/:transactionId
+ + GETs contract source by contract Source ID + /contracts/sources/:contractSourceId +
+ + GETs the contract Source IDs which are adjacent to a contract + /contracts/sources/:contractSourceId/adjacency +
+ + GETs the contract Source IDs which appear in the full hierarchy of a + contract source + /contracts/sources/:contractSourceId/closure +

Console

From efe215d930102e2194f1238300ac13055f304a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kihlberg?= Date: Thu, 14 Dec 2023 17:55:19 +0100 Subject: [PATCH 12/12] use type alias for contract source id --- packages/marlowe-object/src/index.ts | 7 ++++- packages/marlowe-object/src/reference.ts | 12 ++++++- .../rest/src/contract/endpoints/sources.ts | 31 +++++++++++-------- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/packages/marlowe-object/src/index.ts b/packages/marlowe-object/src/index.ts index 30045999..a2cc29f8 100644 --- a/packages/marlowe-object/src/index.ts +++ b/packages/marlowe-object/src/index.ts @@ -1,6 +1,11 @@ export { Action, Deposit, Notify, Choice } from "./actions.js"; export { ChoiceName, ChoiceId, Bound, ChosenNum } from "./choices.js"; -export { Reference, Label } from "./reference.js"; +export { + Reference, + Label, + ContractSourceId, + ContractSourceIdGuard, +} from "./reference.js"; export { Address, Role, Party } from "./participants.js"; export { Payee, PayeeAccount, PayeeParty, AccountId } from "./payee.js"; diff --git a/packages/marlowe-object/src/reference.ts b/packages/marlowe-object/src/reference.ts index 67204e52..ae9e7606 100644 --- a/packages/marlowe-object/src/reference.ts +++ b/packages/marlowe-object/src/reference.ts @@ -8,6 +8,14 @@ export type Label = string; export const LabelGuard: t.Type