Skip to content

Commit a058f7f

Browse files
format & updated change log
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 6378fb2 commit a058f7f

File tree

9 files changed

+20
-58
lines changed

9 files changed

+20
-58
lines changed

Readme.md

-5
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,3 @@ Prototypes have been also built on top of this sdk:
7979
To report a bug or request a new feature, please look through existing [Github Issues](https://github.com/input-output-hk/marlowe-ts-sdk/issues) before opening a new one.
8080

8181
To help in the development of this SDK, please refer to [this document](./doc/howToDevelop.md).
82-
83-
84-
85-
86-

changelog.d/20240511_113958_nicolas.henin_runtime_lifecycle_refactor.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
### @marlowe.io/runtime-rest-client
1313

14-
- Feat: `initial account deposits` (runtime v1.0.0) for Contract Creation (`BuildCreateContractTxRequest` via `buildCreateContractTx`)([PR-188](https://github.com/input-output-hk/marlowe-ts-sdk/pull/188))
14+
- Feat: `initial account deposits` (runtime v1.0.0) for Contract Creation (`BuildCreateContractTxRequest` via `buildCreateContractTx`):([PR-188](https://github.com/input-output-hk/marlowe-ts-sdk/pull/188))
1515

1616
### @marlowe.io/runtime-core
1717

@@ -24,10 +24,10 @@
2424
- Generic `waitConfirmation()` : same for contract creation and apply inputs
2525
- Seamless Integration of Applicable Actions API
2626
- simplfied interface (`create` and `load` with a concept of `ContractInstance` object)
27-
- see end to end tests for examples (e.g : `swap.ada.token.e2e.spec.ts`)
27+
- see end-to-end tests for examples (e.g : `swap.ada.token.e2e.spec.ts`)
2828
- Feat: `initial account deposits` feature (runtime v1.0.0) for Contract Creation ([PR-188](https://github.com/input-output-hk/marlowe-ts-sdk/pull/188)):
2929
- new parameter field `accountDeposits` in
30-
- e.g
30+
- e.g.
3131

3232
```ts
3333
const sellerContractInstance = await sellerLifecycle.newContractAPI.create({
@@ -40,4 +40,4 @@ const sellerContractInstance = await sellerLifecycle.newContractAPI.create({
4040
### @marlowe.io/language-examples
4141

4242
- Feat: `Atomic swap v2` : Simplified version using the new runtime `v1.0.0` feature (`initial account deposits`)
43-
- see end to end tests for examples (e.g : `swap.ada.token.e2e.spec.ts`)
43+
- see end-to-end tests for examples (e.g : `swap.ada.token.e2e.spec.ts`)

examples/rest-client-flow/index.html

+1-7
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ <h2>Request</h2>
2525
This should be filled with a JSON object that starts with an array, where each element is a numbered
2626
parameter.
2727
</p>
28-
<textarea
29-
id="parameter-json"
30-
type="text"
31-
style="width: 100%; height: 20em"
32-
>
33-
{}</textarea
34-
>
28+
<textarea id="parameter-json" type="text" style="width: 100%; height: 20em">{}</textarea>
3529
</div>
3630
<br />
3731
<input id="healthcheck" type="button" value="Healthcheck" class="endpoint" />

jsdelivr-npm-importmap.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ const importMap = {
4242
"https://cdn.jsdelivr.net/npm/@marlowe.io/[email protected]/dist/bundled/esm/language-specification-client.js",
4343
"@marlowe.io/token-metadata-client":
4444
"https://cdn.jsdelivr.net/npm/@marlowe.io/[email protected]/dist/bundled/esm/token-metadata-client.js",
45-
"@marlowe.io/wallet":
46-
"https://cdn.jsdelivr.net/npm/@marlowe.io/[email protected]/dist/bundled/esm/wallet.js",
47-
"@marlowe.io/wallet/api":
48-
"https://cdn.jsdelivr.net/npm/@marlowe.io/[email protected]/dist/bundled/esm/api.js",
45+
"@marlowe.io/wallet": "https://cdn.jsdelivr.net/npm/@marlowe.io/[email protected]/dist/bundled/esm/wallet.js",
46+
"@marlowe.io/wallet/api": "https://cdn.jsdelivr.net/npm/@marlowe.io/[email protected]/dist/bundled/esm/api.js",
4947
"@marlowe.io/wallet/browser":
5048
"https://cdn.jsdelivr.net/npm/@marlowe.io/[email protected]/dist/bundled/esm/browser.js",
5149
"@marlowe.io/wallet/lucid":

packages/adapter/src/io-ts.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,7 @@ export function formatValidationErrors(errors: Errors): string {
100100
}).join("\n");
101101
}
102102

103-
export function dynamicAssertType<G extends t.Any>(
104-
guard: G,
105-
value: unknown,
106-
message?: string
107-
): t.TypeOf<G> {
103+
export function dynamicAssertType<G extends t.Any>(guard: G, value: unknown, message?: string): t.TypeOf<G> {
108104
const result = guard.decode(value);
109105
if (Either.isLeft(result)) {
110106
throw new InvalidTypeError(guard, value, result.left, message);
@@ -123,9 +119,7 @@ export class InvalidTypeError extends Error {
123119
public readonly errors: Errors,
124120
message?: string
125121
) {
126-
const msg =
127-
message ??
128-
`Unexpected type for value:\n${formatValidationErrors(errors)}`;
122+
const msg = message ?? `Unexpected type for value:\n${formatValidationErrors(errors)}`;
129123
super(msg);
130124
}
131125
}

packages/runtime/core/src/contract/accountDeposits.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type AddressOrRole = string;
66
export const AddressOrRoleGuard = t.string;
77
/**
88
* A map of tags to their content. The key is a string, the value can be anything.
9+
* New feature from runtime v1.0.0 (initial account deposits))
910
*/
1011
export type AccountDeposits = { [key in AddressOrRole]: AssetsMap };
1112
/**

packages/runtime/lifecycle/src/browser/index.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ export async function mkRuntimeLifecycle(
8080
strict = true
8181
): Promise<RuntimeLifecycle> {
8282
dynamicAssertType(BrowserRuntimeLifecycleOptionsGuard, options);
83-
dynamicAssertType(
84-
t.boolean,
85-
strict,
86-
"Invalid type for argument 'strict', expected boolean"
87-
);
83+
dynamicAssertType(t.boolean, strict, "Invalid type for argument 'strict', expected boolean");
8884

8985
const { runtimeURL, walletName } = options;
9086
const wallet = await mkBrowserWallet(walletName);

packages/runtime/lifecycle/src/index.ts

+7-15
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,21 @@ export interface RuntimeLifecycleOptions {
4242
/**
4343
* @hidden
4444
*/
45-
export const RuntimeLifecycleOptionsGuard: t.Type<RuntimeLifecycleOptions> =
46-
t.type({
47-
runtimeURL: t.string,
48-
// TODO: Create a shallow guard for the wallet that checks that all methods are present as t.function.
49-
wallet: t.any,
50-
});
45+
export const RuntimeLifecycleOptionsGuard: t.Type<RuntimeLifecycleOptions> = t.type({
46+
runtimeURL: t.string,
47+
// TODO: Create a shallow guard for the wallet that checks that all methods are present as t.function.
48+
wallet: t.any,
49+
});
5150

5251
/**
5352
* Creates an instance of RuntimeLifecycle.
5453
* @param options
5554
* @param strict Whether to perform runtime checking to provide helpful error messages. May have a slight negative performance impact. Default value is `true`.
5655
* @category RuntimeLifecycle
5756
*/
58-
export function mkRuntimeLifecycle(
59-
options: RuntimeLifecycleOptions,
60-
strict = true
61-
): RuntimeLifecycle {
57+
export function mkRuntimeLifecycle(options: RuntimeLifecycleOptions, strict = true): RuntimeLifecycle {
6258
dynamicAssertType(RuntimeLifecycleOptionsGuard, options);
63-
dynamicAssertType(
64-
t.boolean,
65-
strict,
66-
"Invalid type for argument 'strict', expected boolean"
67-
);
59+
dynamicAssertType(t.boolean, strict, "Invalid type for argument 'strict', expected boolean");
6860
const { runtimeURL, wallet } = options;
6961
const deprecatedRestAPI = mkFPTSRestClient(runtimeURL);
7062
const restClient = mkRestClient(runtimeURL, strict);

packages/runtime/lifecycle/src/nodejs/index.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,8 @@ import { Lucid } from "lucid-cardano";
66
import * as t from "io-ts/lib/index.js";
77
import { dynamicAssertType } from "@marlowe.io/adapter/io-ts";
88

9-
export async function mkRuntimeLifecycle(
10-
runtimeURL: string,
11-
lucid: Lucid,
12-
strict = true
13-
): Promise<RuntimeLifecycle> {
14-
dynamicAssertType(
15-
t.boolean,
16-
strict,
17-
"Invalid type for argument 'strict', expected boolean"
18-
);
9+
export async function mkRuntimeLifecycle(runtimeURL: string, lucid: Lucid, strict = true): Promise<RuntimeLifecycle> {
10+
dynamicAssertType(t.boolean, strict, "Invalid type for argument 'strict', expected boolean");
1911
const wallet = await Wallet.mkLucidWallet(lucid);
2012
const deprecatedRestAPI = mkFPTSRestClient(runtimeURL);
2113
const restClient = mkRestClient(runtimeURL, strict);

0 commit comments

Comments
 (0)