Skip to content

Commit b4d7f52

Browse files
committed
Replace cardano-serialization-lib with cardano-data-lite
1 parent 3ba73f2 commit b4d7f52

File tree

181 files changed

+5652
-21123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+5652
-21123
lines changed

.github/workflows/pages.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
npm install -g spago
1919
npm install -g purescript@0.15.8
2020
rm -rf package.json # remove package.json so that we are no more in an ESM module. A hack to make 'spago docs' work
21+
wget -O package-set.dhall "$(grep -oP 'https://raw[^ ]+' packages.dhall)"
22+
sed -i 's|https://raw[^ ]*|./package-set.dhall|' packages.dhall
2123
spago docs
2224
- name: Deploy
2325
uses: JamesIves/github-pages-deploy-action@v4.3.3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ plutip-server/dist-newstyle/
3030
plutip-server/dist/
3131
plutip-server/.stack-work/
3232
nixos.qcow2
33+
/package-set.dhall

CHANGELOG.md

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
99

1010
- [[Unreleased]](#unreleased)
1111
- [Changed](#changed)
12+
- [Removed](#removed)
1213
- [Fixed](#fixed)
1314
- [[v9.3.1]](#v931)
1415
- [Fixed](#fixed-1)
@@ -18,38 +19,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1819
- [[v9.2.0]](#v920)
1920
- [Added](#added)
2021
- [Changed](#changed-2)
21-
- [Removed](#removed)
22+
- [Removed](#removed-1)
2223
- [Fixed](#fixed-3)
2324
- [[v9.1.0]](#v910)
2425
- [Added](#added-1)
2526
- [Changed](#changed-3)
26-
- [Removed](#removed-1)
27+
- [Removed](#removed-2)
2728
- [Fixed](#fixed-4)
2829
- [[v9.0.0]](#v900)
2930
- [Deprecated](#deprecated)
3031
- [Added](#added-2)
31-
- [Removed](#removed-2)
32+
- [Removed](#removed-3)
3233
- [Changed](#changed-4)
3334
- [Fixed](#fixed-5)
3435
- [[v8.0.0]](#v800)
3536
- [Added](#added-3)
3637
- [Changed](#changed-5)
3738
- [Fixed](#fixed-6)
38-
- [Removed](#removed-3)
39+
- [Removed](#removed-4)
3940
- [[v7.0.0]](#v700)
4041
- [Added](#added-4)
4142
- [Changed](#changed-6)
4243
- [Fixed](#fixed-7)
43-
- [Removed](#removed-4)
44+
- [Removed](#removed-5)
4445
- [[v6.0.0]](#v600)
4546
- [Added](#added-5)
4647
- [Changed](#changed-7)
4748
- [Fixed](#fixed-8)
48-
- [Removed](#removed-5)
49+
- [Removed](#removed-6)
4950
- [[v5.0.0]](#v500)
5051
- [Added](#added-6)
5152
- [Changed](#changed-8)
52-
- [Removed](#removed-6)
53+
- [Removed](#removed-7)
5354
- [Fixed](#fixed-9)
5455
- [Runtime Dependencies](#runtime-dependencies)
5556
- [[v4.0.2] - 2023-01-17](#v402---2023-01-17)
@@ -59,23 +60,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
5960
- [[v4.0.0] - 2022-12-15](#v400---2022-12-15)
6061
- [Added](#added-8)
6162
- [Changed](#changed-9)
62-
- [Removed](#removed-7)
63+
- [Removed](#removed-8)
6364
- [Fixed](#fixed-11)
6465
- [Runtime Dependencies](#runtime-dependencies-1)
6566
- [[3.0.0] - 2022-11-21](#300---2022-11-21)
6667
- [Added](#added-9)
6768
- [Changed](#changed-10)
68-
- [Removed](#removed-8)
69+
- [Removed](#removed-9)
6970
- [Fixed](#fixed-12)
7071
- [Runtime Dependencies](#runtime-dependencies-2)
7172
- [[2.0.0] - 2022-09-12](#200---2022-09-12)
7273
- [Added](#added-10)
7374
- [Changed](#changed-11)
74-
- [Removed](#removed-9)
75+
- [Removed](#removed-10)
7576
- [Fixed](#fixed-13)
7677
- [[2.0.0-alpha] - 2022-07-05](#200-alpha---2022-07-05)
7778
- [Added](#added-11)
78-
- [Removed](#removed-10)
79+
- [Removed](#removed-11)
7980
- [Changed](#changed-12)
8081
- [Fixed](#fixed-14)
8182
- [[1.1.0] - 2022-06-30](#110---2022-06-30)
@@ -90,11 +91,34 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
9091

9192
### Changed
9293

93-
- `cardano-serialization-lib` was replaced by `cardano-data-lite` v1.0
94+
- `cardano-serialization-lib` was replaced by `cardano-data-lite` v1.0.0
95+
- Bumped [cardano-node to v10.1.4](https://github.com/IntersectMBO/cardano-node/releases/tag/10.1.4) capable of crossing the second Chang hardfork ([#1657](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1657))
96+
- Bumped [Ogmios to v6.8.0](https://github.com/CardanoSolutions/ogmios/releases/tag/v6.8.0) ([#1657](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1657))
97+
- `QueryHandle` has been renamed to `Provider` ([#1665](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1665))
98+
- `QueryBackend` renamed to `ProviderBackend`
99+
- `QueryBackendParams` renamed to `ProviderBackendParams`
100+
- `queryHandleFor*Backend` renamed to `providerFor*Backend`
101+
- `getQueryHandle` renamed to `getProvider`
102+
- `mkQueryHandle` renamed to `mkProvider`
103+
- Also multiple corresponding file names have changed replacing the `QueryHandle` names to `Provider` ones
104+
- Switched to the [purescript-cardano-package-set](https://github.com/mlabs-haskell/purescript-cardano-package-set) in `packages.dhall` (see the [section on updating PureScript dependencies in the docs](./doc/ctl-as-dependency.md)) ([#1667](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1667))
105+
- Switched to the aggregate `@mlabs-haskell/ctl-npm-meta` package for NPM dependencies (see the [section on updating JS dependencies in the docs](./doc/ctl-as-dependency.md)) ([#1666](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1666))
106+
- Ignore **any** tx evaluation errors if tx marked invalid. Previously, certain internal evaluation errors were not properly handled, leading to unexpected behavior for a subset of explicitly marked "invalid" transactions. ([#1668](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1668))
107+
- `Provider` (previously called `QueryHandle`) is extracted to its own package [purescript-cardano-provider](https://github.com/mlabs-haskell/purescript-cardano-provider) using module names in the format `Cardano.Provider.*` ([#1671](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1671))
108+
- Switched from WebSocket to HTTP when interfacing with Ogmios. Note: Mempool functionality still uses WebSocket, as it requires a persistent connection to track state. ([#1575](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1575))
109+
- Blockfrost Provider has been extracted to a separate package [purescript-cardano-blockfrost-provider](https://github.com/mlabs-haskell/purescript-cardano-blockfrost-provider) using module names in the format `Cardano.Blockfrost.*` ([#1661](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1661))
110+
- Kupo + Ogmios Provider has been extracted to a separate package [purescript-cardano-kupmios-provider](https://github.com/mlabs-haskell/purescript-cardano-kupmios-provider) using module names in the format `Cardano.Kupmios.*` ([#1662](https://github.com/Plutonomicon/cardano-transaction-lib/issues/1662))
111+
- Ogmios' mempool functionality has been extracted to a separate package [purescript-cardano-ogmios-mempool](https://github.com/mlabs-haskell/purescript-cardano-ogmios-mempool) using the module `Cardano.Ogmios.Mempool`. To use it, the user must create and manage the websocket connection (see [Test.Ctl.Testnet.Contract.OgmiosMempool](https://github.com/Plutonomicon/cardano-transaction-lib/blob/cd80e31d59b233e48ccb2a0b6635d5d8beb5b160/test/Testnet/Contract/OgmiosMempool.purs))
112+
- Made adjustments to the [E2E testing documentation page](./doc/e2e-testing.md). Updated the [template](./templates/ctl-scaffold) to use the newly introduced `e2eConfigs` helper function that allows to define E2E configurations without unnecessary boilerplate. ([#1674](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1674))
113+
114+
### Removed
115+
116+
- References to the discontinued Nami and Flint wallets ([#1674](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1674))
94117

95118
### Fixed
96119

97120
- Fixed transaction witness set 'attach' functions. Previously, the updated witness set was incorrectly appended to the existing set, causing performance degradation when processing constraints for complex transactions. ([#1653](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1653))
121+
- Fixed a critical bug where Blockfrost `getUtxo` would also return **spent** outputs ([#1664](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1664))
98122

99123
## [v9.3.1]
100124

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ You can also access [PureScript documentation for CTL and its dependencies](http
6464
- [`cardano-serialization-lib`](https://github.com/Emurgo/cardano-serialization-lib/)
6565
- [Ogmios](https://ogmios.dev) for chain queries
6666
- [Kupo](https://cardanosolutions.github.io/kupo/) for chain queries
67-
- [CIP-30](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030) (wallet interface - Nami partially implements this)
68-
- [Nami docs](https://github.com/Berry-Pool/nami-wallet)
67+
- [CIP-30](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030) (wallet interface)
6968
- [Alonzo CDDL spec](https://github.com/input-output-hk/cardano-ledger/blob/0738804155245062f05e2f355fadd1d16f04cd56/alonzo/impl/cddl-files/alonzo.cddl)
7069

7170
## Available support channels info
@@ -88,7 +87,7 @@ CTL is being developed by MLabs. The following companies/funds have contributed
8887
- [Indigo Protocol](https://indigoprotocol.io/)
8988
- [Equine](https://www.equine.gg/)
9089
- [Liqwid Labs](https://liqwid.finance/)
91-
- [PlayerMint](https://www.playermint.com/)
90+
- PlayerMint
9291
- [Fourier Labs](https://fourierlabs.io/)
9392
- Ardana
9493

@@ -97,5 +96,5 @@ CTL is being developed by MLabs. The following companies/funds have contributed
9796
- [Indigo Protocol](https://indigoprotocol.io/)
9897
- [Liqwid](https://liqwid.finance/)
9998
- [Clarity](https://clarity.community/)
100-
- [PlayerMint](https://www.playermint.com/)
99+
- PlayerMint
101100
- [SingularityNet](https://singularitynet.io/)

doc/blockfrost.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ See [this example](../test/Blockfrost/Contract.purs), which can be executed with
132132

133133
On production, the environment should be configured on PureScript side (environment variables are not respected).
134134

135-
`mkBlockfrostBackendParams` can be called on a populated `BlockfrostBackendParams` record to create a `QueryBackendParams` value. `backendParams` field of `ContractParams` uses a value of this type. And `ContractParams` can in turn be used with `runContract`.
135+
`mkBlockfrostBackendParams` can be called on a populated `BlockfrostBackendParams` record to create a `ProviderBackendParams` value. `backendParams` field of `ContractParams` uses a value of this type. And `ContractParams` can in turn be used with `runContract`.
136136

137137
```purescript
138138
type BlockfrostBackendParams =

doc/comparisons.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For a more in-depth explanation of the differences between PAB and CTL (with cod
4545

4646
### Query layer differences
4747

48-
Lucid uses a [`Provider` class](https://deno.land/x/lucid@0.10.5/mod.ts?s=Provider) that defines all available queries. CTL query methods are defined in [`QueryHandle`](https://github.com/Plutonomicon/cardano-transaction-lib/blob/develop/src/Internal/Contract/QueryHandle/Type.purs#L36).
48+
Lucid uses a [`Provider` class](https://deno.land/x/lucid@0.10.5/mod.ts?s=Provider) that defines all available queries. CTL query methods are defined in [`Provider`](https://github.com/mlabs-haskell/purescript-cardano-provider/blob/e789464eac6dc18708b25f7a9008a7e6633b3f9a/src/Provider/Type.purs#L20).
4949

5050
CTL supports the following queries that Lucid does not:
5151

@@ -63,7 +63,7 @@ Lucid, on the other hand, provides a way to get a UTxO that contains a specified
6363

6464
- Both CTL and Lucid support [Blockfrost](./blockfrost.md) and [Kupo+Ogmios](./runtime.md)
6565
- Lucid also supports [Maestro](https://www.gomaestro.org/)
66-
- Both CTL and Lucid allow for custom backends - Lucid via `Provider` interface implementation, and CTL via a custom `QueryHandle`.
66+
- Both CTL and Lucid support multiple query backends through a `Provider` interface. Although CTL does not support specifying custom backends without forking, individual queries in the existing backend can still be replaced. Refer to [doc/custom-query-layers.md](./custom-query-layers.md) for more information.
6767

6868
### Staking support
6969

@@ -79,6 +79,6 @@ Additionally, CTL supports [testing with real wallets](./e2e-testing.md) via hea
7979

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

82-
- 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.
82+
- CTL uses [`cardano-serialization-lib`](https://github.com/Emurgo/cardano-serialization-lib/), while Lucid uses [`Pallas`](https://github.com/txpipe/pallas).
8383
- 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.
84-
- 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`.
84+
- Plutus Data conversion is handled via a [schema-enabled API](https://github.com/spacebudz/lucid/blob/e13206b225edb0e55a7eeb98b1200223e201fbfe/examples/typed_data.ts#L15) in Lucid. CTL allows for automatic `ToData` / `FromData` deriving for some types, via `HasPlutusSchema`.

doc/ctl-as-dependency.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ Do note that `runLocalTestnetTest` in `overlays.purescript` requires the presenc
2626
To see an example project that uses both `overlays`, please refer to our [scaffolding template](../templates/ctl-scaffold/flake.nix). You can also use this template to conveniently initialize a new CTL-based project (`nix flake init -t github:Plutonomicon/cardano-transaction-lib` in a new directory). It will take a significant amount of time for spago to download the dependencies.
2727

2828
## Upgrading CTL
29-
30-
Unfortunately, the process of upgrading CTL is fairly involved. This is in part due to the complexity of the project and in part due to features inherent to Spago's approach to dependency management. The following assumes that you are using a project based on Nix flakes and using our overlays as outlined above.
29+
Unfortunately, upgrading CTL remains a relatively involved process. However, it has been partially simplified with the introduction of our [Cardano domain PureScript package set](https://github.com/mlabs-haskell/purescript-cardano-package-set) and the aggregate [NPM package](https://www.npmjs.com/package/@mlabs-haskell/ctl-npm-meta). This complexity arises partly from the scale of the project itself and in part due to features inherent to Spago's approach to dependency management. The following assumes that you are using a project based on Nix flakes and using our overlays as outlined above.
3130

3231
Make sure to perform **all** of the following steps, otherwise you **will** encounter difficult-to-debug issues:
3332

@@ -36,38 +35,30 @@ Make sure to perform **all** of the following steps, otherwise you **will** enco
3635
- Update the `rev` you're using for CTL in your flake `inputs`
3736
- **Note**: Nix might throw an error about CTL following a "non-existent input" after doing this. The best way to solve this is to upgrade the version of Nix that you're using. Otherwise, `nix flake lock --update-input <NAME>`, where `NAME` corresponds to CTL in your flake's `inputs`, should solve this
3837

39-
2. **Update your Purescript dependencies**
40-
41-
- Update the CTL `version` in your `packages.dhall`. Make sure that this is the exact same revision as in your flake inputs
42-
- Possibly update the `dependencies` section for CTL in your `packages.dhall`
38+
2. **Update your PureScript dependencies**
4339

44-
- You can find a list of CTL's dependencies in our own `spago.dhall` (but make sure to check at the correct revision)
45-
- You might also need to add new transitive git dependencies if CTL has added any to its own direct dependencies (i.e. you need to copy the matching stanzas from CTL's `packages.dhall` to your own; these are contained in the `additions` record in CTL's `packages.dhall`)
40+
- Make sure to set `upstream` to our PureScript package set in `packages.dhall`
4641

47-
- For example, if the following package `foo` is added to CTL's `additions` (in `packages.dhall`) between your old revision and the one you're upgrading to:
42+
- Simply copy it from the CTL's `packages.dhall` at the correct revision
43+
- This package set should include all the necessary Cardano domain packages, so you no longer need to keep track of the individual PureScript dependencies with each CTL update, as was required previously
44+
- Your `upstream` should look like this:
4845

49-
```dhall
46+
```dhall
47+
let upstream =
48+
https://raw.githubusercontent.com/mlabs-haskell/purescript-cardano-package-set/<version>/packages.dhall
49+
sha256:<hash>
50+
```
5051

51-
let additions =
52-
{ foo =
53-
{ dependencies =
54-
[ "bar"
55-
, "baz"
56-
]
57-
}
58-
, repo = "https://github.com/quux/foo.git"
59-
, version = "0000000000000000000000000000000000000000"
60-
-- ...
61-
}
62-
```
52+
- Update the CTL `version` in your `packages.dhall`. Make sure that this is the exact same revision as in your flake inputs
53+
- Possibly update the `dependencies` section for CTL in your `packages.dhall`
6354

64-
You also need to add the same package, identically, to your own `packages.dhall`, otherwise the compiler will not be able to find it
55+
- You can find a list of CTL's dependencies in our own `spago.dhall` (but make sure to check at the correct revision)
6556

6657
- Run `spago2nix generate` and make sure to stage and commit the resulting `spago-packages.nix` if it has changed
6758

6859
3. **Update your JS dependencies**
6960

70-
- The NPM dependencies your project has must have the exact same versions CTL's own `package.json` specifies.
61+
- CTL currently has a single aggregate or meta NPM dependency that encompasses all other dependencies: `@mlabs-haskell/ctl-npm-meta`. Your project must use **the exact same version** of this dependency as specified in CTL's `package.json`.
7162
- You have to update `package-lock.json` by running `npm install`. If you are in a nix shell and use our setup that symlinks `./node_modules`, npm will complain about inability to write to the filesystem, use `npm i --package-lock-only` to skip writing to `node_modules`. If your `node_modules` are managed by Nix, you will have to re-enter the shell for the changes to apply.
7263

7364
4. **Update your webpack/esbuild config**

doc/custom-query-layers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
CTL can be extended with custom (user) query layers if needed. At this moment it can be done by forking.
1818

19-
Every query CTL uses, except of backend-specific ones, goes through a [query handle](https://github.com/Plutonomicon/cardano-transaction-lib/blob/10a88faa2e6237aafc90568e3488f3421517af63/src/Internal/Contract/QueryHandle/Type.purs#L36).
19+
Every query CTL uses, except of backend-specific ones, goes through a [provider](https://github.com/mlabs-haskell/purescript-cardano-provider/blob/e789464eac6dc18708b25f7a9008a7e6633b3f9a/src/Provider/Type.purs#L20).
2020

21-
A new [backend option](https://github.com/Plutonomicon/cardano-transaction-lib/blob/10a88faa2e6237aafc90568e3488f3421517af63/src/Internal/Contract/QueryBackend.purs#L57) should be added, with corresponding [initialization code](https://github.com/Plutonomicon/cardano-transaction-lib/blob/develop/src/Internal/Contract/QueryHandle.purs)
21+
A new [backend option](https://github.com/Plutonomicon/cardano-transaction-lib/blob/20207fcda113cdafc80ef136d4c59e1ca3fe698e/src/Internal/Contract/ProviderBackend.purs#L57) should be added, with corresponding [initialization code](https://github.com/Plutonomicon/cardano-transaction-lib/blob/develop/src/Internal/Contract/Provider.purs)
2222

2323
## Replacing some queries in existing backend
2424

2525
Substituting the query layer for a few functions only (assuming the original backend remains available for initial connection) can be done without forking CTL.
2626

27-
`ContractEnv` contains a QueryHandle (inside a `Reader`), so a [`local`](https://pursuit.purescript.org/packages/purescript-transformers/6.0.0/docs/Control.Monad.Reader.Class#v:local) call with a function that replaces some `QueryHandle` record entries will just work.
27+
`ContractEnv` contains a Provider (inside a `Reader`), so a [`local`](https://pursuit.purescript.org/packages/purescript-transformers/6.0.0/docs/Control.Monad.Reader.Class#v:local) call with a function that replaces some `Provider` record entries will just work.
2828

2929
# Configuring CTL's default query layer (Kupo/Ogmios)
3030

0 commit comments

Comments
 (0)