Skip to content

Commit

Permalink
format & updated change log
Browse files Browse the repository at this point in the history
  • Loading branch information
nhenin committed May 11, 2024
1 parent a90f886 commit ba14e9c
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 54 deletions.
5 changes: 0 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,3 @@ Prototypes have been also built on top of this sdk:
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.

To help in the development of this SDK, please refer to [this document](./doc/howToDevelop.md).





Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
### General

- Feat: **Initial Account Deposits Feature Integration (Runtime v1.0.0):**

- **Purpose:** This update introduces the capability for users to make initial deposits into their accounts upon creation. This feature aims to streamline the account setup process and enhance user experience.
- **Benefits:** This feature squashes the Contract Creation and Initial Input Deposits into 1 transaction instead of multiple ones.

- Feat: **Introduction of a New Contract API in the Runtime Lifecycle API:**
- **Purpose:** The addition of a new Contract API is designed to provide developers with more flexibility and control (contract instance concept) over smart contract management within the runtime environment.
- **Benefits:** Developers can now leverage enhanced functionalities for deploying, updating, and interacting with smart contracts. This API simplifies complex contract operations and supports more robust smart contract development.

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

- 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))

### @marlowe.io/runtime-core

- Feat: `initial account deposits` (runtime v1.0.0) for Contract Creation ([PR-188](https://github.com/input-output-hk/marlowe-ts-sdk/pull/188)):
- Added `export type accountDeposits = { [key in AddressOrRole]: AssetsMap };` and associated utility functions.

### @marlowe.io/runtime-lifecycle

- Feat: New Contract API `packages/runtime/lifecycle/src/generic/new-contract-api.ts` ([PR-188](https://github.com/input-output-hk/marlowe-ts-sdk/pull/188)):
- Generic `waitConfirmation()` : same for contract creation and apply inputs
- Seamless Integration of Applicable Actions API
- simplfied interface (`create` and `load` with a concept of `ContractInstance` object)
- see end to end tests for examples (e.g : `swap.ada.token.e2e.spec.ts`)
- 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)):
- new parameter field `accountDeposits` in
- e.g

```ts
const sellerContractInstance = await sellerLifecycle.newContractAPI.create({
contract: swapContract,
roles: { [scheme.ask.buyer.role_token]: mintRole("OpenRole") },
accountDeposits: mkaccountDeposits([[scheme.offer.seller, seller.assetsProvisioned]]),
});
```

### @marlowe.io/language-examples

- Feat: `Atomic swap v2` : Simplified version using the new runtime `v1.0.0` feature (`initial account deposits`)
- see end to end tests for examples (e.g : `swap.ada.token.e2e.spec.ts`)
8 changes: 1 addition & 7 deletions examples/rest-client-flow/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ <h2>Request</h2>
This should be filled with a JSON object that starts with an array, where each element is a numbered
parameter.
</p>
<textarea
id="parameter-json"
type="text"
style="width: 100%; height: 20em"
>
{}</textarea
>
<textarea id="parameter-json" type="text" style="width: 100%; height: 20em">{}</textarea>
</div>
<br />
<input id="healthcheck" type="button" value="Healthcheck" class="endpoint" />
Expand Down
6 changes: 2 additions & 4 deletions jsdelivr-npm-importmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ const importMap = {
"https://cdn.jsdelivr.net/npm/@marlowe.io/language-specification-client@0.4.0-beta-rc1/dist/bundled/esm/language-specification-client.js",
"@marlowe.io/token-metadata-client":
"https://cdn.jsdelivr.net/npm/@marlowe.io/token-metadata-client@0.4.0-beta-rc1/dist/bundled/esm/token-metadata-client.js",
"@marlowe.io/wallet":
"https://cdn.jsdelivr.net/npm/@marlowe.io/wallet@0.4.0-beta-rc1/dist/bundled/esm/wallet.js",
"@marlowe.io/wallet/api":
"https://cdn.jsdelivr.net/npm/@marlowe.io/wallet@0.4.0-beta-rc1/dist/bundled/esm/api.js",
"@marlowe.io/wallet": "https://cdn.jsdelivr.net/npm/@marlowe.io/wallet@0.4.0-beta-rc1/dist/bundled/esm/wallet.js",
"@marlowe.io/wallet/api": "https://cdn.jsdelivr.net/npm/@marlowe.io/wallet@0.4.0-beta-rc1/dist/bundled/esm/api.js",
"@marlowe.io/wallet/browser":
"https://cdn.jsdelivr.net/npm/@marlowe.io/wallet@0.4.0-beta-rc1/dist/bundled/esm/browser.js",
"@marlowe.io/wallet/lucid":
Expand Down
10 changes: 2 additions & 8 deletions packages/adapter/src/io-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ export function formatValidationErrors(errors: Errors): string {
}).join("\n");
}

export function dynamicAssertType<G extends t.Any>(
guard: G,
value: unknown,
message?: string
): t.TypeOf<G> {
export function dynamicAssertType<G extends t.Any>(guard: G, value: unknown, message?: string): t.TypeOf<G> {
const result = guard.decode(value);
if (Either.isLeft(result)) {
throw new InvalidTypeError(guard, value, result.left, message);
Expand All @@ -123,9 +119,7 @@ export class InvalidTypeError extends Error {
public readonly errors: Errors,
message?: string
) {
const msg =
message ??
`Unexpected type for value:\n${formatValidationErrors(errors)}`;
const msg = message ?? `Unexpected type for value:\n${formatValidationErrors(errors)}`;
super(msg);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/runtime/core/src/contract/accountDeposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type AddressOrRole = string;
export const AddressOrRoleGuard = t.string;
/**
* A map of tags to their content. The key is a string, the value can be anything.
* New feature from runtime v1.0.0 (initial account deposits))
*/
export type accountDeposits = { [key in AddressOrRole]: AssetsMap };
/**
Expand Down
6 changes: 1 addition & 5 deletions packages/runtime/lifecycle/src/browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ export async function mkRuntimeLifecycle(
strict = true
): Promise<RuntimeLifecycle> {
dynamicAssertType(BrowserRuntimeLifecycleOptionsGuard, options);
dynamicAssertType(
t.boolean,
strict,
"Invalid type for argument 'strict', expected boolean"
);
dynamicAssertType(t.boolean, strict, "Invalid type for argument 'strict', expected boolean");

const { runtimeURL, walletName } = options;
const wallet = await mkBrowserWallet(walletName);
Expand Down
22 changes: 7 additions & 15 deletions packages/runtime/lifecycle/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,21 @@ export interface RuntimeLifecycleOptions {
/**
* @hidden
*/
export const RuntimeLifecycleOptionsGuard: t.Type<RuntimeLifecycleOptions> =
t.type({
runtimeURL: t.string,
// TODO: Create a shallow guard for the wallet that checks that all methods are present as t.function.
wallet: t.any,
});
export const RuntimeLifecycleOptionsGuard: t.Type<RuntimeLifecycleOptions> = t.type({
runtimeURL: t.string,
// TODO: Create a shallow guard for the wallet that checks that all methods are present as t.function.
wallet: t.any,
});

/**
* Creates an instance of RuntimeLifecycle.
* @param options
* @param strict Whether to perform runtime checking to provide helpful error messages. May have a slight negative performance impact. Default value is `true`.
* @category RuntimeLifecycle
*/
export function mkRuntimeLifecycle(
options: RuntimeLifecycleOptions,
strict = true
): RuntimeLifecycle {
export function mkRuntimeLifecycle(options: RuntimeLifecycleOptions, strict = true): RuntimeLifecycle {
dynamicAssertType(RuntimeLifecycleOptionsGuard, options);
dynamicAssertType(
t.boolean,
strict,
"Invalid type for argument 'strict', expected boolean"
);
dynamicAssertType(t.boolean, strict, "Invalid type for argument 'strict', expected boolean");
const { runtimeURL, wallet } = options;
const deprecatedRestAPI = mkFPTSRestClient(runtimeURL);
const restClient = mkRestClient(runtimeURL, strict);
Expand Down
12 changes: 2 additions & 10 deletions packages/runtime/lifecycle/src/nodejs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ import { Lucid } from "lucid-cardano";
import * as t from "io-ts/lib/index.js";
import { dynamicAssertType } from "@marlowe.io/adapter/io-ts";

export async function mkRuntimeLifecycle(
runtimeURL: string,
lucid: Lucid,
strict = true
): Promise<RuntimeLifecycle> {
dynamicAssertType(
t.boolean,
strict,
"Invalid type for argument 'strict', expected boolean"
);
export async function mkRuntimeLifecycle(runtimeURL: string, lucid: Lucid, strict = true): Promise<RuntimeLifecycle> {
dynamicAssertType(t.boolean, strict, "Invalid type for argument 'strict', expected boolean");
const wallet = await Wallet.mkLucidWallet(lucid);
const deprecatedRestAPI = mkFPTSRestClient(runtimeURL);
const restClient = mkRestClient(runtimeURL, strict);
Expand Down

0 comments on commit ba14e9c

Please sign in to comment.