Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- [[Unreleased]](#unreleased)
- [Changed](#changed)
- [Removed](#removed)
- [Fixed](#fixed)
- [[v9.3.1]](#v931)
- [Fixed](#fixed-1)
Expand All @@ -18,38 +19,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [[v9.2.0]](#v920)
- [Added](#added)
- [Changed](#changed-2)
- [Removed](#removed)
- [Removed](#removed-1)
- [Fixed](#fixed-3)
- [[v9.1.0]](#v910)
- [Added](#added-1)
- [Changed](#changed-3)
- [Removed](#removed-1)
- [Removed](#removed-2)
- [Fixed](#fixed-4)
- [[v9.0.0]](#v900)
- [Deprecated](#deprecated)
- [Added](#added-2)
- [Removed](#removed-2)
- [Removed](#removed-3)
- [Changed](#changed-4)
- [Fixed](#fixed-5)
- [[v8.0.0]](#v800)
- [Added](#added-3)
- [Changed](#changed-5)
- [Fixed](#fixed-6)
- [Removed](#removed-3)
- [Removed](#removed-4)
- [[v7.0.0]](#v700)
- [Added](#added-4)
- [Changed](#changed-6)
- [Fixed](#fixed-7)
- [Removed](#removed-4)
- [Removed](#removed-5)
- [[v6.0.0]](#v600)
- [Added](#added-5)
- [Changed](#changed-7)
- [Fixed](#fixed-8)
- [Removed](#removed-5)
- [Removed](#removed-6)
- [[v5.0.0]](#v500)
- [Added](#added-6)
- [Changed](#changed-8)
- [Removed](#removed-6)
- [Removed](#removed-7)
- [Fixed](#fixed-9)
- [Runtime Dependencies](#runtime-dependencies)
- [[v4.0.2] - 2023-01-17](#v402---2023-01-17)
Expand All @@ -59,23 +60,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [[v4.0.0] - 2022-12-15](#v400---2022-12-15)
- [Added](#added-8)
- [Changed](#changed-9)
- [Removed](#removed-7)
- [Removed](#removed-8)
- [Fixed](#fixed-11)
- [Runtime Dependencies](#runtime-dependencies-1)
- [[3.0.0] - 2022-11-21](#300---2022-11-21)
- [Added](#added-9)
- [Changed](#changed-10)
- [Removed](#removed-8)
- [Removed](#removed-9)
- [Fixed](#fixed-12)
- [Runtime Dependencies](#runtime-dependencies-2)
- [[2.0.0] - 2022-09-12](#200---2022-09-12)
- [Added](#added-10)
- [Changed](#changed-11)
- [Removed](#removed-9)
- [Removed](#removed-10)
- [Fixed](#fixed-13)
- [[2.0.0-alpha] - 2022-07-05](#200-alpha---2022-07-05)
- [Added](#added-11)
- [Removed](#removed-10)
- [Removed](#removed-11)
- [Changed](#changed-12)
- [Fixed](#fixed-14)
- [[1.1.0] - 2022-06-30](#110---2022-06-30)
Expand Down Expand Up @@ -106,6 +107,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- `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))
- 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))
- 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))
- 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))

### Removed

- References to the discontinued Nami and Flint wallets ([#1674](https://github.com/Plutonomicon/cardano-transaction-lib/pull/1674))

### Fixed

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ You can also access [PureScript documentation for CTL and its dependencies](http
- [`cardano-serialization-lib`](https://github.com/Emurgo/cardano-serialization-lib/)
- [Ogmios](https://ogmios.dev) for chain queries
- [Kupo](https://cardanosolutions.github.io/kupo/) for chain queries
- [CIP-30](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030) (wallet interface - Nami partially implements this)
- [Nami docs](https://github.com/Berry-Pool/nami-wallet)
- [CIP-30](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030) (wallet interface)
- [Alonzo CDDL spec](https://github.com/input-output-hk/cardano-ledger/blob/0738804155245062f05e2f355fadd1d16f04cd56/alonzo/impl/cddl-files/alonzo.cddl)

## Available support channels info
Expand Down
130 changes: 95 additions & 35 deletions doc/e2e-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ For purposes of testing, there are two parts to using a wallet: providing the ri
### Where to Find the Installed Extensions

1. Locate your browser profile directory. Commonly used locations include: `~/.config/{google-chrome,chromium}/Default` (where `Default` is the profile name), `~/snap/chromium/common/chromium/Default`.
2. Make sure that inside the profile, your desired extension is unpacked. Nami should be in `Extensions/lpfcbjknijpeeillifnkikgncikgfhdo`, Gero (testnet version) in `Extensions/iifeegfcfhlhhnilhfoeihllenamcfgc`.
2. Make sure that inside the profile, your desired extension is unpacked. Gero (testnet version) should be in `Extensions/iifeegfcfhlhhnilhfoeihllenamcfgc`.
3. Add the version as a subdirectory, too. The final path may look like `/home/user/.config/google-chrome/Default/Extensions/iifeegfcfhlhhnilhfoeihllenamcfgc/1.10.9_0`

### How to Use a Different User Wallet
Expand Down Expand Up @@ -125,14 +125,6 @@ The tests can set up using CLI arguments, environment variables, or both. CLI ar
| Lode CRX URL | `--lode-crx-url` | `LODE_CRX_URL` |
| Lode password | `--lode-password` | `LODE_PASSWORD` |
| Lode Extension ID | `--lode-extid` | `LODE_EXTID` |
| Nami CRX URL | `--nami-crx-url` | `NAMI_CRX_URL` |
| Nami CRX file | `--nami-crx` | `NAMI_CRX` |
| Nami password | `--nami-password` | `NAMI_PASSWORD` |
| Nami Extension ID | `--nami-extid` | `NAMI_EXTID` |
| Flint CRX URL | `--flint-crx-url` | `FLINT_CRX_URL` |
| Flint CRX file | `--flint-crx` | `FLINT_CRX` |
| Flint password | `--flint-password` | `FLINT_PASSWORD` |
| Flint Extension ID | `--flint-extid` | `FLINT_EXTID` |
| Gero CRX URL | `--gero-crx-url` | `GERO_CRX_URL` |
| Gero CRX file | `--gero-crx` | `GERO_CRX` |
| Gero password | `--gero-password` | `GERO_PASSWORD` |
Expand Down Expand Up @@ -224,22 +216,74 @@ See [this file](../templates/ctl-scaffold/test/E2E.purs) for a quick example:
```purescript
main :: Effect Unit
main = do
configs <- liftEither $ lmap error mkConfigs
-- Adds links to all available tests to the DOM for convenience
addLinks configs tests
-- Serves the appropriate `Contract` with e2eTestHooks
route configs tests

configs :: Map E2EConfigName (ContractParams /\ Maybe WalletMock)
configs = Map.fromFoldable
[ "nami" /\ testnetNamiConfig /\ Nothing
, "gero" /\ testnetGeroConfig /\ Nothing
, "flint" /\ testnetFlintConfig /\ Nothing
, "eternl" /\ testnetEternlConfig /\ Nothing
, "lode" /\ testnetLodeConfig /\ Nothing
, "nami-mock" /\ testnetNamiConfig /\ Just MockNami
, "gero-mock" /\ testnetGeroConfig /\ Just MockGero
, "flint-mock" /\ testnetFlintConfig /\ Just MockFlint
, "lode-mock" /\ testnetLodeConfig /\ Just MockLode
mkConfigs :: Either String (Map E2EConfigName (ContractParams /\ Maybe String))
mkConfigs =
e2eConfigs
[ "eternl"
, "gero"
, "lode"
, "eternl-mock"
, "gero-mock"
, "lode-mock"
, "localnet-eternl-mock"
, "localnet-gero-mock"
, "localnet-lode-mock"
]

tests :: Map E2ETestName (Contract Unit)
tests = Map.fromFoldable
[ "Contract" /\ Scaffold.contract
-- Add more `Contract`s here
]

tests :: Map E2ETestName (Contract Unit)
tests = Map.fromFoldable
[ "Contract" /\ Scaffold.contract
-- Add more `Contract`s here
]
```

It is also possible to specify E2E configurations directly without using
the `e2eConfigs` helper function:

```purescript
main :: Effect Unit
main = do
-- Adds links to all available tests to the DOM for convenience
addLinks configs tests
-- Serves the appropriate `Contract` with e2eTestHooks
route configs tests

configs :: Map E2EConfigName (ContractParams /\ Maybe String)
configs = map (map walletName) <$> Map.fromFoldable
[ "eternl" /\ testnetConfig' Eternl /\ Nothing
, "gero" /\ testnetConfig' Gero /\ Nothing
, "lode" /\ testnetConfig' Lode /\ Nothing
, "eternl-mock" /\ testnetConfig' Eternl /\ Just Eternl
, "gero-mock" /\ testnetConfig' Gero /\ Just Gero
, "lode-mock" /\ testnetConfig' Lode /\ Just Lode
, "localnet-eternl-mock" /\ testnetConfig' Eternl /\ Just Eternl
, "localnet-gero-mock" /\ testnetConfig' Gero /\ Just Gero
, "localnet-lode-mock" /\ testnetConfig' Lode /\ Just Lode
]
where
testnetConfig' :: KnownWallet -> ContractParams
testnetConfig' wallet =
testnetConfig
{ walletSpec =
Just $ ConnectToGenericCip30 (walletName wallet) { cip95: false }
}

tests :: Map E2ETestName (Contract Unit)
tests = Map.fromFoldable
[ "Contract" /\ Scaffold.contract
-- Add more `Contract`s here
]

tests :: Map E2ETestName (Contract Unit)
Expand All @@ -253,11 +297,11 @@ Now, the `Scaffold.contract` can be used as a test:

```bash
E2E_TESTS="
nami:http://localhost:4008/?nami:Contract
eternl:http://localhost:4008/?eternl:Contract
"
```

The `nami:` prefix specifies which browser extension to load for the test, and the query parameter is for the router to be able to find the appropriate config.
The `eternl:` prefix specifies which browser extension to load for the test, and the query parameter is for the router to be able to find the appropriate config.

Refer to the docs for `Contract.Test.E2E.route` function for an overview of the URL structure.

Expand Down Expand Up @@ -286,39 +330,55 @@ As a result, you will get json files that look like this:
Simply copy the `cborHex` from payment and stake signing keys (the order is important), and add them to the URL, separating by `:`:

```
http://localhost:4008/?nami-mock:Contract:58200b07c066ba037344acee5431e6df41f6034bf1c5ffd6f803751e356807c6a209:5820f0db841df6c7fbc4506c58fad6676db0354a02dfd26efca445715a8adeabc338
http://localhost:4008/?eternl-mock:Contract:58200b07c066ba037344acee5431e6df41f6034bf1c5ffd6f803751e356807c6a209:5820f0db841df6c7fbc4506c58fad6676db0354a02dfd26efca445715a8adeabc338
```

The `nami:` prefix should not be specified, otherwise CTL will refuse to overwrite the existing wallet with a mock.
The `eternl:` prefix should not be specified, otherwise CTL will refuse to overwrite the existing wallet with a mock.

In order to use the keys, their corresponding address must be pre-funded using the [faucet](https://docs.cardano.org/cardano-testnet/tools/faucet) (beware of IP-based rate-limiting) or from another wallet. Most contracts require at least two UTxOs to run (one will be used as collateral), so it's best to make two transactions.

### Using CIP-30 mock with Cardano Testnet

It's possible to run headless browser tests on top of a Cardano Testnet cluster.

To do that, it's enough to define a config name that:

- uses a `ContractParams` value with `networkId` set to `MainnetId`.
- Specifies a wallet mock (e.g. `MockNami`)
To do that, it's enough to define a config that specifies a wallet mock.
For `e2eConfigs`, the name config must include the `-mock` suffix.

E.g.:

```purescript
wallets :: Map E2EConfigName (ContractParams /\ Maybe WalletMock)
wallets = Map.fromFoldable
[ "testnet-nami-mock" /\ mainnetNamiConfig /\ Just MockNami
, "testnet-gero-mock" /\ mainnetGeroConfig /\ Just MockGero
, "testnet-flint-mock" /\ mainnetFlintConfig /\ Just MockFlint
, "testnet-lode-mock" /\ mainnetLodeConfig /\ Just MockLode
mkConfigs :: Either String (Map E2EConfigName (ContractParams /\ Maybe String))
mkConfigs =
e2eConfigs
[ "localnet-eternl-mock"
, "localnet-gero-mock"
, "localnet-lode-mock"
]
```

or, if finer control over the configurations is needed:

```purescript
configs :: Map E2EConfigName (ContractParams /\ Maybe String)
configs = map (map walletName) <$> Map.fromFoldable
[ "localnet-eternl-mock" /\ testnetConfig' Eternl /\ Just Eternl
, "localnet-gero-mock" /\ testnetConfig' Gero /\ Just Gero
, "localnet-lode-mock" /\ testnetConfig' Lode /\ Just Lode
]
where
testnetConfig' :: KnownWallet -> ContractParams
testnetConfig' wallet =
testnetConfig
{ walletSpec =
Just $ ConnectToGenericCip30 (walletName wallet) { cip95: false }
}
```

Then a test entry *without* specifying any private key can be used:

```bash
export E2E_TESTS="
plutip:http://localhost:4008/?plutip-nami-mock:SomeContract
localnet:http://localhost:4008/?localnet-gero-mock:SomeContract
"
```

Expand Down
12 changes: 10 additions & 2 deletions doc/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,17 @@ main = Contract.Monad.launchAff_ do -- we re-export this for you
Then use the eliminator `Contract.Monad.runContract` with a config specifying network and wallet:

```purescript

testnetEternlConfig :: Contract.Monad.ContractParams
testnetEternlConfig =
Contract.Config.testnetConfig
{ walletSpec =
Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false }
}

main :: Effect Unit
main = Contract.Monad.launchAff_ do
runContract Contract.Config.testnetNamiConfig do
runContract testnetEternlConfig do
...
```

Expand All @@ -135,7 +143,7 @@ main = Contract.Monad.launchAff_ do -- we re-export this for you
, kupoConfig: defaultKupoServerConfig
}
, networkId: TestnetId
, walletSpec: Just ConnectToNami
, walletSpec: Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false }
, logLevel: Trace
, customLogger: Nothing
, suppressLogs: false
Expand Down
4 changes: 2 additions & 2 deletions examples/AdditionalUtxos.purs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Contract.BalanceTxConstraints
)
import Contract.Config
( ContractParams
, KnownWallet(Nami)
, KnownWallet(Eternl)
, WalletSpec(ConnectToGenericCip30)
, testnetConfig
, walletName
Expand Down Expand Up @@ -61,7 +61,7 @@ import Test.QuickCheck.Gen (randomSampleOne)
main :: Effect Unit
main = example $ testnetConfig
{ walletSpec =
Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false }
Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false }
}

example :: ContractParams -> Effect Unit
Expand Down
4 changes: 2 additions & 2 deletions examples/AlwaysMints.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Cardano.Types.RedeemerDatum as RedeemerDatum
import Cardano.Types.Transaction as Transaction
import Contract.Config
( ContractParams
, KnownWallet(Nami)
, KnownWallet(Eternl)
, WalletSpec(ConnectToGenericCip30)
, testnetConfig
, walletName
Expand All @@ -38,7 +38,7 @@ import Data.Map as Map
main :: Effect Unit
main = example $ testnetConfig
{ walletSpec =
Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false }
Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false }
}

contract :: Contract Unit
Expand Down
4 changes: 2 additions & 2 deletions examples/AlwaysSucceeds.purs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import Cardano.Types.TransactionUnspentOutput (toUtxoMap)
import Contract.Address (mkAddress)
import Contract.Config
( ContractParams
, KnownWallet(Nami)
, KnownWallet(Eternl)
, WalletSpec(ConnectToGenericCip30)
, testnetConfig
, walletName
Expand All @@ -62,7 +62,7 @@ import Effect.Exception (error)
main :: Effect Unit
main = example $ testnetConfig
{ walletSpec =
Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false }
Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false }
}

contract :: Contract Unit
Expand Down
4 changes: 2 additions & 2 deletions examples/AwaitTxConfirmedWithTimeout.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Contract.Prelude
import Cardano.AsCbor (decodeCbor)
import Contract.Config
( ContractParams
, KnownWallet(Nami)
, KnownWallet(Eternl)
, WalletSpec(ConnectToGenericCip30)
, testnetConfig
, walletName
Expand All @@ -28,7 +28,7 @@ import Partial.Unsafe (unsafePartial)
main :: Effect Unit
main = example $ testnetConfig
{ walletSpec =
Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false }
Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false }
}

example :: ContractParams -> Effect Unit
Expand Down
Loading