Skip to content

Commit

Permalink
created new client/rest workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
nhenin committed Aug 21, 2023
1 parent a9f0ab4 commit fce01e0
Show file tree
Hide file tree
Showing 35 changed files with 83 additions and 65 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"packages/adapter",
"packages/language/core/v1",
"packages/wallet",
"packages/client/rest",
"packages/runtime"
],
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/rest/Readme.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# @marlowe.io/runtime
# @marlowe.io/client-rest
TODO
14 changes: 10 additions & 4 deletions packages/client/rest/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@marlowe.io/client-rest",
"version": "0.1.0-beta",
"description": "TODO",
"description": "Client of Runtime REST API",
"repository": "https://github.com/input-output-hk/marlowe-ts-sdk",
"publishConfig": {
"access": "public"
Expand All @@ -15,9 +15,7 @@
"scripts": {
"build": "tsc --build src",
"clean": "tsc --build --clean src",
"test": "echo 'The client rest doesnt have unit tests'",
"test:e2e": "echo 'The client rest doesnt have e2e tests'",
"build:e2e": "echo 'The client rest doesnt have unit tests'"
"test": "echo 'The client rest doesnt have unit tests'"
},
"type": "module",
"module": "./dist/index.js",
Expand All @@ -31,6 +29,14 @@
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./transaction": {
"import": "./dist/contract/transaction/index.js",
"types": "./dist/contract/transaction/index.d.ts"
},
"./withdrawal": {
"import": "./dist/contract/withdrawal/index.js",
"types": "./dist/contract/withdrawal/index.d.ts"
},
"./contract/*": "./dist/contract/*.js"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/rest/src/contract/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as t from "io-ts/lib/index.js";
import { Contract } from "@marlowe.io/language-core-v1";
import { MarloweState } from "@marlowe.io/language-core-v1/state";
import { MarloweVersion } from "@marlowe.io/language-core-v1/version";
import { ContractId } from "./id.js";
import { ContractId } from "@marlowe.io/core/marlowe";

import { TxStatus } from "./transaction/status.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/client/rest/src/contract/endpoints/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Tag, Tags, Metadata, TextEnvelope, unAddressBech32, unTxOutRef, Address
import { Header } from '../header.js';
import { RolesConfig } from '../role.js';

import { ContractId } from '../id.js';
import { ContractId } from "@marlowe.io/core/marlowe";

export interface ContractsRange extends Newtype<{ readonly ContractsRange: unique symbol }, string> {}
export const ContractsRange = fromNewtype<ContractsRange>(t.string)
Expand Down
2 changes: 1 addition & 1 deletion packages/client/rest/src/contract/endpoints/singleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DecodingError } from '@marlowe.io/adapter/codec';
import { HexTransactionWitnessSet, transactionWitnessSetTextEnvelope } from '@marlowe.io/core/cardano';

import { ContractDetails } from '../details.js';
import { ContractId, unContractId } from '../id.js';
import { ContractId, unContractId } from "@marlowe.io/core/marlowe";

export type GET = ( contractId: ContractId) => TE.TaskEither<Error | DecodingError, ContractDetails>

Expand Down
2 changes: 1 addition & 1 deletion packages/client/rest/src/contract/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MarloweVersion } from "@marlowe.io/language-core-v1/version";
import { BlockHeader, Metadata, PolicyId, Tags } from "@marlowe.io/core/cardano";

import { TxStatus } from "./transaction/status.js";
import { ContractId } from "./id.js";
import { ContractId } from "@marlowe.io/core/marlowe";


export type Header = t.TypeOf<typeof Header>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/rest/src/contract/next/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as TE from 'fp-ts/lib/TaskEither.js'
import { pipe } from 'fp-ts/lib/function.js';
import * as HTTP from '@marlowe.io/adapter/http';
import {formatValidationErrors} from 'jsonbigint-io-ts-reporters'
import { ContractId, unContractId } from '../id.js';
import { ContractId, unContractId } from "@marlowe.io/core/marlowe";
import { Environment } from '@marlowe.io/language-core-v1/environment';
import { Next } from '@marlowe.io/language-core-v1/next';
import { Party } from '@marlowe.io/language-core-v1/semantics/contract/common/payee/party.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/client/rest/src/contract/transaction/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Contract } from "@marlowe.io/language-core-v1";

import { Tags, Metadata, BlockHeader, TxOutRef, TxId, TextEnvelope } from "@marlowe.io/core/cardano";

import { ContractId } from "../id.js";
import { ContractId } from "@marlowe.io/core/marlowe";
import { TransactionId } from "./id.js";
import { TxStatus } from "./status.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { AddressesAndCollaterals, Metadata, Tags, TextEnvelope, unAddressBech32,

import { Header } from "../header.js";
import { TransactionId } from "../id.js";
import { ContractId, unContractId } from "../../id.js";
import { ContractId, unContractId } from "@marlowe.io/core/marlowe";


export interface TransactionsRange extends Newtype<{ readonly TransactionsRange: unique symbol }, string> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DecodingError } from '@marlowe.io/adapter/codec';
import { HexTransactionWitnessSet, transactionWitnessSetTextEnvelope } from '@marlowe.io/core/cardano';

import { Details } from "../details.js";
import { ContractId, unContractId } from "../../id.js";
import { ContractId, unContractId } from "@marlowe.io/core/marlowe";
import { TransactionId, unTransactionId } from "../id.js";

export type GET = ( contractId: ContractId, transactionId : TransactionId) => TE.TaskEither<Error | DecodingError, Details>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/rest/src/contract/transaction/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BuiltinByteString } from "@marlowe.io/language-core-v1";
import { Tags, Metadata, BlockHeader, TxOutRef } from "@marlowe.io/core/cardano";


import { ContractId } from "../id.js";
import { ContractId } from "@marlowe.io/core/marlowe";
import { TransactionId } from "./id.js";
import { TxStatus } from "./status.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DecodingError } from '@marlowe.io/adapter/codec';

import { AddressesAndCollaterals, TextEnvelope, unAddressBech32, unTxOutRef } from '@marlowe.io/core/cardano';

import { ContractId } from '../../id.js';
import { ContractId } from "@marlowe.io/core/marlowe";
import { RoleName } from '../../role.js';
import { WithdrawalId } from '../id.js';
import { Header } from '../header.js';
Expand Down
3 changes: 3 additions & 0 deletions packages/client/rest/src/contract/withdrawal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './id.js'
export * from './header.js'
export * from './details.js'
7 changes: 4 additions & 3 deletions packages/client/rest/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@

import axios from 'axios';
import * as TE from 'fp-ts/lib/TaskEither.js'
import { pipe } from 'fp-ts/lib/function.js';

import { MarloweJSONCodec } from '@marlowe.io/adapter/codec';
import * as HTTP from '@marlowe.io/adapter/http';

import * as WithdrawalSingleton from './contract/withdrawal/endpoints/singleton.js';
import * as WithdrawalCollection from './contract/withdrawal/endpoints/collection.js';
import * as ContractSingleton from './contract/endpoints/singleton.js';
import * as ContractCollection from './contract/endpoints/collection.js';
import * as TransactionSingleton from './contract/transaction/endpoints/singleton.js';
import * as TransactionCollection from './contract/transaction/endpoints/collection.js';
import * as ContractNext from './contract/next/endpoint.js';
import { MarloweJSONCodec } from '@marlowe.io/adapter/codec';
import { pipe } from 'fp-ts/lib/function.js';


export interface RestAPI {
healthcheck : () => TE.TaskEither<Error,Boolean>
Expand Down
7 changes: 6 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
"import": "./dist/cardano/index.js",
"types": "./dist/cardano/index.d.ts"
},
"./cardano/*": "./dist/cardano/*.js"
"./cardano/*": "./dist/cardano/*.js",
"./marlowe": {
"import": "./dist/marlowe/index.js",
"types": "./dist/marlowe/index.d.ts"
},
"./marlowe/*": "./dist/marlowe/*.js"
},
"dependencies": {
"fp-ts": "^2.16.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fromNewtype } from "io-ts-types";
import { split } from "fp-ts/lib/string.js";
import { pipe } from "fp-ts/lib/function.js";
import { head } from "fp-ts/lib/ReadonlyNonEmptyArray.js";
import { TxId } from "@marlowe.io/core/cardano";
import { TxId } from "../cardano/tx/id.js";


export type ContractId = Newtype<{ readonly ContractId: unique symbol }, string>
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/marlowe/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './contractId.js'
3 changes: 2 additions & 1 deletion packages/language/core/v1/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"outDir": "../test-dist",
"paths": {
"@marlowe.io/adapter/*": ["../../../../adapter/src/*"],
"@marlowe.io/language-core-v1/*": ["../src/*"]
"@marlowe.io/language-core-v1/*": ["../../../../language/core/v1/src*"]
},
"types": ["node", "jest"]
},
"references": [
{"path": "../../../../adapter/src"},
{"path": "../../../../language/core/v1/src"},
{"path": "../src"}
]
}
2 changes: 1 addition & 1 deletion packages/language/core/v1/typedoc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"entryPointStrategy": "expand",
"entryPoints": ["./src/semantics"],
"entryPoints": ["./src"],
"tsconfig": "./src/tsconfig.json"
}
9 changes: 1 addition & 8 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./restClient": {
"import": "./dist/instance/overRestAPI/restClient/index.js",
"types": "./dist/instance/overRestAPI/restClient/index.d.ts"
},
"./overRestAPI": {
"import": "./dist/instance/overRestAPI/runtime.js",
"types": "./dist/instance/overRestAPI/runtime.d.ts"
Expand All @@ -59,9 +55,6 @@
"fp-ts": "^2.13.1",
"io-ts": "2.2.20",
"newtype-ts": "0.3.5",
"monocle-ts":"2.3.13",
"date-fns": "2.29.3",
"json-bigint": "^1.0.0",
"jsonbigint-io-ts-reporters": "2.0.1"
"monocle-ts":"2.3.13"
}
}
16 changes: 7 additions & 9 deletions packages/runtime/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@

import * as Withdrawal from '@marlowe.io/client-rest/contract/withdrawal/details.js';

import * as TE from 'fp-ts/lib/TaskEither.js'
import { WalletAPI } from '@marlowe.io/wallet/api';
import { Next } from '@marlowe.io/language-core-v1/semantics/next/index.js';
import { DecodingError } from '@marlowe.io/adapter/codec';


import { ISO8601 } from '@marlowe.io/adapter/time';



import { Contract } from '@marlowe.io/language-core-v1/semantics/contract/index.js';
import { Input } from '@marlowe.io/language-core-v1/semantics/contract/when/input/index.js';
import { Next } from '@marlowe.io/language-core-v1/semantics/next/index.js';

import { Tags, Metadata } from '@marlowe.io/core/cardano';

import { WalletAPI } from '@marlowe.io/wallet/api';

import { RoleName, RolesConfig } from '@marlowe.io/client-rest/contract/role.js';
import { RestAPI } from '@marlowe.io/client-rest/index.js';
import { ContractId } from '@marlowe.io/client-rest/contract/id.js';

import { ContractId } from "@marlowe.io/core/marlowe";
import * as Withdrawal from '@marlowe.io/client-rest/contract/withdrawal/details.js';

export type Runtime =
{ wallet : WalletAPI & { getLovelaces : TE.TaskEither<Error,bigint>}
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/src/instance/overRestAPI/browser/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { mkRestClient } from '@marlowe.io/client-rest/index.js';
import * as T from 'fp-ts/lib/Task.js'
import { pipe } from 'fp-ts/lib/function.js';

import { getExtensionInstance } from '@marlowe.io/wallet/browser';
import { mkRuntime } from '../runtime.js';
import { Runtime } from '../../../api.js';

import { mkRestClient } from '@marlowe.io/client-rest';

export const mkRuntimeBroswer
: (runtimeURL : string)
=> (extensionName : string)
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime/src/instance/overRestAPI/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

import { ContractId } from '@marlowe.io/client-rest/contract/id.js';
import { RestAPI } from '@marlowe.io/client-rest/index.js';
import { ContractId } from "@marlowe.io/core/marlowe";;

import * as Command from './txCommand.js';
import * as A from 'fp-ts/lib/Array.js'
Expand All @@ -17,6 +16,7 @@ import { CreateRequest, ProvideInput, Runtime, WithdrawRequest } from '../../api
import { WalletAPI } from '@marlowe.io/wallet/api';
import { PolicyId } from '@marlowe.io/core/cardano';

import { RestAPI } from '@marlowe.io/client-rest';

export const mkRuntime
: (restAPI : RestAPI)
Expand Down
14 changes: 8 additions & 6 deletions packages/runtime/src/instance/overRestAPI/txCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
import * as TE from 'fp-ts/lib/TaskEither.js'

import { pipe } from 'fp-ts/lib/function.js'
import * as Contracts from '@marlowe.io/client-rest/contract/id.js';
import * as Tx from '@marlowe.io/client-rest/contract/transaction/id.js';
import * as Withdrawal from '@marlowe.io/client-rest/contract/withdrawal/details.js';
import * as Contracts from "@marlowe.io/core/marlowe";;
import { RestAPI } from '@marlowe.io/client-rest/index.js';
import { WalletAPI, getAddressesAndCollaterals } from '@marlowe.io/wallet/api';
import { DecodingError } from '@marlowe.io/adapter/codec';
import { CreateRequest, ApplyInputsRequest, WithdrawRequest } from '../../api.js';
import { ContractId } from '@marlowe.io/client-rest/contract/id.js';
import * as WithdrawalId from '@marlowe.io/client-rest/contract/withdrawal/id.js';
import { ContractId } from "@marlowe.io/core/marlowe";;


import * as Tx from '@marlowe.io/client-rest/transaction';
import * as Withdrawal from '@marlowe.io/client-rest/withdrawal';



export const create
Expand Down Expand Up @@ -78,5 +80,5 @@ export const withdraw
pipe ( wallet.signTxTheCIP30Way(withdrawalTextEnvelope.tx.cborHex)
, TE.chain ((hexTransactionWitnessSet) => client.withdrawals.withdrawal.put(withdrawalTextEnvelope.withdrawalId,hexTransactionWitnessSet))
, TE.map (() => withdrawalTextEnvelope.withdrawalId)))
, TE.chainFirstW((withdrawalId) => wallet.waitConfirmation(pipe(withdrawalId, WithdrawalId.idToTxId)))
, TE.chainFirstW((withdrawalId) => wallet.waitConfirmation(pipe(withdrawalId, Withdrawal.idToTxId)))
, TE.chainW ((withdrawalId) => client.withdrawals.withdrawal.get(withdrawalId)) )
6 changes: 3 additions & 3 deletions packages/runtime/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"@marlowe.io/adapter/*": ["../../adapter/src/*"],
"@marlowe.io/core/*": ["../../core/src/*"],
"@marlowe.io/wallet/*": ["../../wallet/src/*"],
"@marlowe.io/client-rest/*": ["../../client/rest/src/*"],
"@marlowe.io/language-core-v1/*": ["../../language/core/v1/src/*"]
"@marlowe.io/language-core-v1/*": ["../../language/core/v1/src/*"],
"@marlowe.io/client-rest/*": ["../../client/rest/src/*"]
}
},
"references": [
{ "path": "../../core/src" },
{ "path": "../../adapter/src" },
{ "path": "../../wallet/src" },
{ "path": "../../client/rest/src" },
{ "path": "../../language/core/v1/src" },
{ "path": "../../client/rest/src" }
]
}
2 changes: 1 addition & 1 deletion packages/runtime/test/endpoints/contracts.spec.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as TE from 'fp-ts/lib/TaskEither.js';
import * as O from 'fp-ts/lib/Option.js';

import { close } from '@marlowe.io/language-core-v1'
import { mkRestClient } from '@marlowe.io/runtime/restClient';
import { create } from '@marlowe.io/runtime/txCommand';
import { mkRestClient } from '@marlowe.io/client-rest/index.js';

import { initialiseBankAndverifyProvisionning } from '../provisionning.js';
import { getBankPrivateKey, getBlockfrostContext, getMarloweRuntimeUrl } from '../context.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/test/endpoints/transactions.spec.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { addMinutes, subMinutes } from 'date-fns'
import { datetoTimeout, inputNotify } from '@marlowe.io/language-core-v1';
import { oneNotifyTrue } from '@marlowe.io/language-core-v1/examples'
import { datetoIso8601Bis } from '@marlowe.io/adapter/time'
import { mkRestClient } from '@marlowe.io/runtime/restClient';
import { mkRestClient } from '@marlowe.io/client-rest/index.js';

import { getBankPrivateKey, getBlockfrostContext, getMarloweRuntimeUrl } from '../context.js';
import { initialiseBankAndverifyProvisionning } from '../provisionning.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/test/endpoints/withdrawals.spec.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { addDays } from 'date-fns/fp';
import * as Examples from '@marlowe.io/language-core-v1/examples';
import { datetoTimeout, adaValue } from '@marlowe.io/language-core-v1';
import { toInput } from '@marlowe.io/language-core-v1/next';
import { mkRestClient } from '@marlowe.io/runtime/restClient';
import { mkRestClient } from '@marlowe.io/client-rest/index.js';

import { getBankPrivateKey, getBlockfrostContext, getMarloweRuntimeUrl } from '../context.js';
import { provisionAnAdaAndTokenProvider } from '../provisionning.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/test/examples/swap.ada.token.spec.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { addDays } from 'date-fns/fp'
import { toInput } from '@marlowe.io/language-core-v1/next';
import * as Examples from '@marlowe.io/language-core-v1/examples'
import { datetoTimeout, adaValue } from '@marlowe.io/language-core-v1'
import { mkRestClient } from '@marlowe.io/runtime/restClient';
import { mkRestClient } from '@marlowe.io/client-rest/index.js';

import { getBankPrivateKey, getBlockfrostContext, getMarloweRuntimeUrl } from '../context.js';
import { provisionAnAdaAndTokenProvider } from '../provisionning.js'
Expand Down
Loading

0 comments on commit fce01e0

Please sign in to comment.