Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

account Deposit Integration (runtime V1.0.0)

# This is the commit message #2:

w
  • Loading branch information
nhenin committed May 11, 2024
1 parent 0961c3d commit c17f6d8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 11 deletions.
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`)
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import {
AddressBech32Guard,
ContractId,
ContractIdGuard,
accountDeposits,
accountDepositsGuard,
AccountDeposits,
AccountDepositsGuard,
} from "@marlowe.io/runtime-core";
import { ContractHeader, ContractHeaderGuard } from "../header.js";
import { RolesConfiguration, RolesConfigurationGuard } from "../rolesConfigurations.js";
Expand Down Expand Up @@ -193,7 +193,7 @@ export type BuildCreateContractTxRequestWithContract = {
export const BuildCreateContractTxRequestOptionsGuard = assertGuardEqual(
proxy<BuildCreateContractTxRequestOptions>(),
t.intersection([
t.type({ changeAddress: AddressBech32Guard, version: MarloweVersion, accounts: accountDepositsGuard }),
t.type({ changeAddress: AddressBech32Guard, version: MarloweVersion, accounts: AccountDepositsGuard }),
t.partial({
roles: RolesConfigurationGuard,
threadRoleName: G.RoleName,
Expand Down Expand Up @@ -498,7 +498,7 @@ export interface BuildCreateContractTxRequestOptions {
* describe an initial deposit of assets for the accounts in the contract. The key is the address or role name and the value is the assets.
* These assets will be deposited in the accounts at the creation of the contract, and will come from the contract creator's wallet.
*/
accounts: accountDeposits;
accounts: AccountDeposits;

/**
* The Marlowe validator version to use.
Expand All @@ -525,7 +525,7 @@ export const PostContractsRequest = t.intersection([
contract: ContractOrSourceIdGuard,
tags: TagsGuard,
metadata: MetadataGuard,
accounts: accountDepositsGuard,
accounts: AccountDepositsGuard,
}),
t.partial({ roles: RolesConfigurationGuard }),
t.partial({ threadTokenName: G.RoleName }),
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime/core/src/contract/accountDeposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ export const AddressOrRoleGuard = t.string;
/**
* A map of tags to their content. The key is a string, the value can be anything.
*/
export type accountDeposits = { [key in AddressOrRole]: AssetsMap };
export type AccountDeposits = { [key in AddressOrRole]: AssetsMap };
/**
* @hidden
*/
export const accountDepositsGuard = t.record(AddressOrRoleGuard, AssetsMapGuard);
export const AccountDepositsGuard = t.record(AddressOrRoleGuard, AssetsMapGuard);
/**
* a function that takes a list of party with associated assets and returns an accountDeposits
* the party object is converted to a string using partyToString.
* @param accounts
* @returns
*/
export function mkaccountDeposits(accounts: [Party, Assets][]): accountDeposits {
export function mkaccountDeposits(accounts: [Party, Assets][]): AccountDeposits {
return Object.fromEntries(accounts.map(([party, assets]) => [partyToString(party), mapAsset(assets)]));
}
6 changes: 3 additions & 3 deletions packages/runtime/lifecycle/src/generic/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
StakeAddressBech32,
Metadata,
Tags,
accountDeposits,
AccountDeposits,
} from "@marlowe.io/runtime-core";

import { FPTSRestAPI, RestClient, RestDI, ItemRange, DeprecatedRestDI } from "@marlowe.io/runtime-rest-client";
Expand Down Expand Up @@ -93,10 +93,10 @@ export interface CreateContractRequestBase {
* Assets will be withdrawn from the creator's wallet and deposited into the participant's accounts when the contract is created.
* </p>
* @see
* - {@link @marlowe.io/runtime-core!accountDeposits}
* - {@link @marlowe.io/runtime-core!index.AccountDeposits}
*/

accountDeposits?: accountDeposits;
accountDeposits?: AccountDeposits;
/**
* Role Token Configuration for the new contract passed in the `contract` field.
*
Expand Down

0 comments on commit c17f6d8

Please sign in to comment.