Skip to content

Commit

Permalink
Merge pull request #1639 from Plutonomicon/develop
Browse files Browse the repository at this point in the history
Release v9.0.0
  • Loading branch information
klntsky authored Jul 24, 2024
2 parents a5f9947 + c027375 commit 7bc136f
Show file tree
Hide file tree
Showing 117 changed files with 2,763 additions and 3,928 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
run: |
npm install -g spago
npm install -g purescript@0.15.8
rm -rf package.json # remove package.json so that we are no more in an ESM module. A hack to make 'spago docs' work
spago docs
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4.3.3
Expand Down
32 changes: 28 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [[Unreleased]](#unreleased)
- [[v9.0.0]](#v900)
- [Deprecated](#deprecated)
- [Added](#added)
- [Removed](#removed)
- [Changed](#changed)
Expand Down Expand Up @@ -67,14 +68,37 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## [Unreleased]
## [v9.0.0]

### Deprecated

> [!WARNING]
> **IMPORTANT** Constraints interface (`Contract.TxConstraints` & `Contract.ScriptLookups`) has been deprecated and will be removed in a future version. Please use [`purescript-cardano-transaction-builder`](https://github.com/mlabs-haskell/purescript-cardano-transaction-builder) (via `Contract.Transaction.buildTx`) for new contracts. The motivation for deprecation is that it was unnecessarily complex, not flexible enough, and existed only because of the desire to provide code-level compatibility with PAB. See [this Catalyst proposal](https://cardano.ideascale.com/c/idea/101478) for more info.
### Added

- `Contract.Transaction.buildTx :: Array TransactionBuilderStep -> Contract Transaction` that provides a `Contract`-based interface for the [new transaction builder](https://github.com/mlabs-haskell/purescript-cardano-transaction-builder).
- `Contract.Transaction.submitTxFromBuildPlan :: UtxoMap -> BalanceTxConstraintsBuilder -> Array TransactionBuilderStep -> Contract Transaction` - a convenience function that executes the whole transaction creation pipeline starting from a build plan for [the new transaction builder](https://github.com/mlabs-haskell/purescript-cardano-transaction-builder).
- `Contract.ClientError.pprintClientError` to provide readable error reports.
- `Contract.Staking.getStakeCredentialDelegationsAndRewards` utility function

### Removed

- **IMPORTANT** `UnbalancedTx` type has been removed. This change was motivated by the fact that `UnbalancedTx` existed simply to tie together transaction building and balancing by keeping extra context. Now that transaction builder is placed in [its own package](https://github.com/mlabs-haskell/purescript-cardano-transaction-builder), there is no more need in `UnbalancedTx`, that is not used with the new builder.
- **IMPORTANT** `balanceTxWithConstraints`, `balanceTxWithConstraintsE` - use `balanceTx`
- **IMPORTANT** `balanceTxsWithConstraints` - use `balanceTxs`
- **IMPORTANT** `withBalancedTxWithConstraints`, `withBalancedTxWithConstraints` - use `withBalancedTxs`
- **IMPORTANT** `Contract.Scripts.applyArgs` - use `Cardano.Plutus.ApplyArgs.applyArgs` from [purescript-uplc-apply-args](https://github.com/mlabs-haskell/purescript-uplc-apply-args).
- `Contract.Transaction.submitTxFromConstraintsReturningFee` - too niche use case to be allowed in the public API.
- `Contract.Transaction` lens values. Use lenses from `Cardano.Types.Transaction`

### Changed

- `Contract.Transaction.mkUnbalancedTx` now returns a tuple: a transaction and the UTxOs it used.
- `Contract.Transaction.balanceTx` accepts two extra argument: a list of used UTxOs (set to `Data.Map.empty` if none of them are coming from the outside of the wallet) and balancer constraints (set to `mempty` if not needed)
- Default synchronization parameters: all [wallet <-> query layer synchronization primitives](./doc/query-layers.md) are now off by default. The reason is that the runtime overhead made the users unhappy and it was not worth it for most of the users. If your dApp sends transactions in quick succession, consider enabling the synchronization again by using `softSynchronizationParams` (old behavior) or `strictSynchronizationParams`.
- `BalanceTxConstraintsBuilder` has been renamed to `BalancerConstraints`. It is still available under the old name as a type synonym.

### Fixed

## [v8.0.0]
Expand Down Expand Up @@ -481,7 +505,7 @@ Then consult with [the template's build scripts](./templates/ctl-scaffold/esbuil

### Added

- Support passing the inital UTxO distribution as an Array and also get the KeyWallets as an Array when writing Plutip tests. ([#1018](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1018)). An usage example can be found [here](doc/plutip-testing.md).
- Support passing the initial UTxO distribution as an Array and also get the KeyWallets as an Array when writing Plutip tests. ([#1018](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1018)). An usage example can be found [here](doc/plutip-testing.md).
- New `Contract.Test.Utils` assertions and checks: `assertOutputHasRefScript`, `checkOutputHasRefScript`, `checkTxHasMetadata` ([#1044](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1044))
- `Parallel` instance to `Contract` monad. Parallel capabilities are in the associated `ParContract` datatype ([#1037](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1037))
- Balancer constraints interface (check [Building and submitting transactions](https://github.com/Plutonomicon/cardano-transaction-lib/blob/95bdd213eff16a5e00df82fb27bbe2479e8b4196/doc/getting-started.md#building-and-submitting-transactions) and `examples/BalanceTxConstraints.purs` for reference) ([#1053](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1053))
Expand Down Expand Up @@ -533,7 +557,7 @@ Then consult with [the template's build scripts](./templates/ctl-scaffold/esbuil
- Adapted Gero wallet extension to `preview` network in E2E test suite ([#1086](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1086))
- `Contact.TextEnvelope` how provides more type safe interface with simplified error handling ([#988](https://github.com/Plutonomicon/cardano-transaction-lib/issues/988))
- Forbid minting zero tokens. ([#1156](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1156))
- Modified functions `getWalletAddress`, `ownPubKeyHash`, `ownStakePubKeyHash`, `getWalletAddressWithNetworkTag` and `ownPaymentPubKeyHash` to return `Contract r (Array Adress)`. ([#1045](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1045))
- Modified functions `getWalletAddress`, `ownPubKeyHash`, `ownStakePubKeyHash`, `getWalletAddressWithNetworkTag` and `ownPaymentPubKeyHash` to return `Contract r (Array Address)`. ([#1045](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1045))
- `pubKeyHashAddress` and `scriptHashAddress` now both accept an optional `Credential` that corresponds to the staking component of the address ([#1060](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1060))
- `utxosAt` and `getUtxo` now use Kupo internally, `utxosAt` returns `UtxoMap` without `Maybe` context. The users will need to set `kupoConfig` in `ConfigParams`. ([#1185](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1185))
- `Interval` type is redesigned to restrain some finite intervals to be expressed in the system ([#1041](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1041))
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL := bash
.ONESHELL:
.PHONY: esbuild-bundle esbuild-serve webpack-bundle webpack-serve check-format format query-testnet-tip clean check-explicit-exports spago-build create-bundle-entrypoint create-html-entrypoint delete-bundle-entrypoint
.PHONY: esbuild-bundle esbuild-serve webpack-bundle webpack-serve check-format format query-testnet-tip clean check-explicit-exports spago-build create-bundle-entrypoint create-html-entrypoint delete-bundle-entrypoint run-template-checks
.SHELLFLAGS := -eu -o pipefail -c

ps-sources := $(shell fd --no-ignore-parent -epurs)
Expand Down Expand Up @@ -108,6 +108,11 @@ run-ci-actions:
nix build -L .#checks.x86_64-linux.ctl-staking-test
nix build -L .#checks.x86_64-linux.examples-imports-check

run-template-checks:
nix build -L .#checks.x86_64-linux.template-deps-json
nix build -L .#checks.x86_64-linux.template-dhall-diff
nix build -L .#checks.x86_64-linux.template-version

clean:
@ rm -r .psc-ide-port || true
@ rm -rf .psci_modules || true
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,19 @@ You can find help, more information and ongoing discusion about the project here

## Funding acknowledgements

CTL is being developed by MLabs. The following companies/funds have contributed significant resources to development:
CTL is being developed by MLabs. The following companies/funds have contributed significant resources (development time or funding):

- [IOHK](https://iohk.io/en/about/)
- [Catalyst Fund8](https://cardano.ideascale.com/c/idea/396607)
- [Catalyst Fund9](https://cardano.ideascale.com/c/idea/420791)
- [Catalyst Fund10](https://cardano.ideascale.com/c/idea/101478)
- [Intersect MBO](https://docs.intersectmbo.org/intersect-community-grants/grant-projects)
- [MLabs](https://mlabs.city/)
- [Indigo Protocol](https://indigoprotocol.io/)
- [Equine](https://www.equine.gg/)
- [Liqwid Labs](https://liqwid.finance/)
- [PlayerMint](https://www.playermint.com/)
- [Fourier Labs](https://fourierlabs.io/)
- Ardana

## Use in production
Expand Down
31 changes: 6 additions & 25 deletions doc/babbage-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,29 @@ This document is a reference/explainer for the new CTL APIs introduced for Babba
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Reference Inputs](#reference-inputs)
- [Reference Scripts](#reference-scripts)
- [Reference Inputs & Reference Scripts](#reference-inputs--reference-scripts)
- [Inline Data](#inline-data)
- [Collateral Output](#collateral-output)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Reference Inputs
## Reference Inputs & Reference Scripts

[Reference inputs](https://cips.cardano.org/cip/CIP-0031#reference-inputs) allow looking at an output without spending it in Plutus scripts.

There are two ways to use an input as a reference in the constraints API:

1. via `mustReferenceOutput`, which allows Plutus scripts to access the information (e.g. datum, locked value) contained in the output.

[Usage example](../examples/PlutusV2/ReferenceInputs.purs)

2. by providing constraints which accept a value of the type `InputWithScriptRef` with the `RefInput` constructor. These allow scripts (validating or minting) to be reused by reference between multiple transactions without including them in those transactions, explained further in [Reference Scripts](#reference-scripts).

[Usage example](../examples/PlutusV2/ReferenceInputsAndScripts.purs)

## Reference Scripts

[Reference Scripts](https://cips.cardano.org/cip/CIP-0033) allows the use of scripts without attaching them to the transaction (and using a reference instead).

Reference scripts can be utilized in CTL by first creating a reference point for the script to be used later via `mustPayToScriptWithScriptRef` (or its variants).
Reference scripts can be utilized in CTL by first creating a UTxO containing the script to be used later.

This constraint utilises a new `ScriptRef` type that includes either a native script or a Plutus script.

Then, `mustSpendScriptOutputUsingScriptRef` (or its variants) can be used to use a reference script. It accepts a value of type `InputWithScriptRef` that specifies whether the UTxO with the reference script should be spent or referenced.

[Usage example](../examples/PlutusV2/ReferenceScripts.purs)
[Usage example](../examples/PlutusV2/ReferenceInputsAndScripts.purs)

## Inline Data

[CIP-32](https://cips.cardano.org/cip/CIP-0032) introduces the inline data feature that allows storing datum values directly in transaction outputs, instead of just the hashes.

In CTL, alternating between datum storage options can be achieved by specifying a `DatumPresence` value with constraints that accept it, like `mustPayToPubKeyWithDatum`.

[Usage example](../examples/PlutusV2/InlineDatum.purs)

## Collateral Output

[CIP-40](https://cips.cardano.org/cip/CIP-0040) introduces explicit collateral output. On validation failure, previously the entire collateral was consumed. Now, if excess collateral is supplied, even with native assets, the surplus can be returned on validation failure.

Collateral output is automatically added to transactions in CTL. To trigger a collateral return, the `mustNotBeValid` constraint should be explicitly specified, otherwise a script error would be detected earlier and the transaction will not be sent.

[Usage example](../examples/Lose7Ada.purs)
6 changes: 3 additions & 3 deletions doc/balancing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Configuring balancing process](#configuring-balancing-process)
- [Configuring the balancing process](#configuring-the-balancing-process)
- [Balancer constraints](#balancer-constraints)
- [Concurrent spending](#concurrent-spending)
- [Balancing a Tx for other wallet](#balancing-a-tx-for-other-wallet)
Expand All @@ -10,7 +10,7 @@

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# Configuring balancing process
# Configuring the balancing process

Transaction balancing in Cardano is the process of finding a set of inputs and outputs that that sum up to zero, covering all the required fees for the transaction to be valid.

Expand All @@ -37,7 +37,7 @@ Setting `mustUseUtxosAtAddress`, `mustSendChangeToAddress` and `mustUseCollatera

## Synchronization

Before balancing, CTL tries to synchronize the wallet state with the query layer, i.e. waits until all UTxOs that the wallet returns are visible in the query layer. Thus the situation when the query layer refuses to validate a Tx (either during ex-units evaluation or on Tx submission) is only possible due to a rollback or a synchronization timeout. Please see [our docs for query layer synchronization](./query-layers.md).
It's possible to make CTL try to synchronize the wallet state with the query layer, i.e. wait until all UTxOs that the wallet returns are visible in the query layer. Thus the situation when the query layer refuses to validate a Tx (either during ex-units evaluation or on Tx submission) is only possible due to a rollback or a synchronization timeout. Please see [our docs for query layer synchronization](./query-layers.md).

## Balancing process limitations

Expand Down
2 changes: 1 addition & 1 deletion doc/blockfrost.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Go to https://blockfrost.io to generate a new API key and specify it as `BLOCKFR

### Generating private keys

Follow https://developers.cardano.org/docs/stake-pool-course/handbook/keys-addresses/ to generate a private payment key (and, optionally, a stake key). You can use [this script](https://github.com/Plutonomicon/cardano-transaction-lib/blob/develop/scripts/generate-keys.sh) for convenience instead of following instructions in this section manually.
Follow [this guide](https://developers.cardano.org/docs/operate-a-stake-pool/generating-wallet-keys) to generate a private payment key (and, optionally, a stake key). You can use [this script](https://github.com/Plutonomicon/cardano-transaction-lib/blob/develop/scripts/generate-keys.sh) for convenience instead of following instructions in this section manually.

The generated keys should look like this:

Expand Down
3 changes: 2 additions & 1 deletion doc/comparisons.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ Additionally, CTL supports [testing with real wallets](./e2e-testing.md) via hea

Lucid aims for simplicity, while CTL allows more fine-grained control over transaction building process without losing the benefits of declarativeness.

- CTL uses [`cardano-serialization-lib`](https://github.com/Emurgo/cardano-serialization-lib/), while Lucid uses a fork of [`cardano-multiplatform-lib`](https://github.com/berry-pool/cardano-multiplatform-lib). Lucid allows to use CML's `TxBuilder` or [call CML directly](https://lucid.spacebudz.io/docs/advanced/cml/), while CTL allows to alter the transaction arbitrarily as PureScript data type either before or after balancing. In CTL, CSL types and method wrappers are a part of the internal interface, but technically they can be used as well.
- CTL uses [`cardano-serialization-lib`](https://github.com/Emurgo/cardano-serialization-lib/), while Lucid uses a fork of [`cardano-multiplatform-lib`](https://github.com/berry-pool/cardano-multiplatform-lib). Lucid allows to use CML's `TxBuilder` or [call CML directly](https://lucid.spacebudz.io/docs/advanced/cml/), while CTL allows to alter the transaction arbitrarily as PureScript data type either before or after balancing.
- In CTL, CSL types and method wrappers are used via [`purescript-cardano-serialization-lib`](https://github.com/mlabs-haskell/purescript-cardano-serialization-lib) and [`purescript-cardano-types`](https://github.com/mlabs-haskell/purescript-cardano-types). However, `TxBuilder` APIs from CSL are not provided by these packages.
- Plutus Data conversion is handled via a [schema-enabled API](https://lucid.spacebudz.io/docs/advanced/type-casting/) in Lucid. CTL allows for automatic `ToData` / `FromData` deriving for some types, via `HasPlutusSchema`.
10 changes: 10 additions & 0 deletions doc/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This document outlines development workflows for CTL itself. You may also wish t
- [JS](#js)
- [Switching development networks](#switching-development-networks)
- [Maintaining the template](#maintaining-the-template)
- [Updating the template](#updating-the-template)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -148,4 +149,13 @@ Set new `network.name` and `network.magic` in `runtime.nix`. Also see [Changing

[The template](../templates/ctl-scaffold/) must be kept up-to-date with the repo. Although there are some checks for common problems in CI, it's still possible to forget to update the `package-lock.json` file.

## Updating the template

1. Update the revision of CTL in the template's `flake.nix`
2. Update the npm packages in the `package.json` (if needed)
3. Run `npm i` to update the lockfile (if there are NPM dependency version changes)
4. Update the revisions in the template's `packages.dhall` (CTL version must match the one in `flake.nix`)
5. Run `spago2nix generate`
6. Run `nix develop`

[This helper script](../scripts/template-check.sh) can be used to make sure the template can be initialized properly from a given revision.
Loading

0 comments on commit 7bc136f

Please sign in to comment.