diff --git a/CHANGELOG.md b/CHANGELOG.md index a8b9459f1d..1cc39ac8a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/README.md b/README.md index c98986f812..7c30bd609c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/doc/e2e-testing.md b/doc/e2e-testing.md index 2aa978b280..4f5cb11c46 100644 --- a/doc/e2e-testing.md +++ b/doc/e2e-testing.md @@ -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 @@ -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` | @@ -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) @@ -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. @@ -286,10 +330,10 @@ 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. @@ -297,28 +341,44 @@ In order to use the keys, their corresponding address must be pre-funded using t 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 " ``` diff --git a/doc/getting-started.md b/doc/getting-started.md index 31dbbfca3a..0674127418 100644 --- a/doc/getting-started.md +++ b/doc/getting-started.md @@ -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 ... ``` @@ -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 diff --git a/examples/AdditionalUtxos.purs b/examples/AdditionalUtxos.purs index 7a8780ca3b..7b716186ca 100644 --- a/examples/AdditionalUtxos.purs +++ b/examples/AdditionalUtxos.purs @@ -30,7 +30,7 @@ import Contract.BalanceTxConstraints ) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -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 diff --git a/examples/AlwaysMints.purs b/examples/AlwaysMints.purs index fcbe987528..10f718219c 100644 --- a/examples/AlwaysMints.purs +++ b/examples/AlwaysMints.purs @@ -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 @@ -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 diff --git a/examples/AlwaysSucceeds.purs b/examples/AlwaysSucceeds.purs index 5e2041ad76..a445266081 100644 --- a/examples/AlwaysSucceeds.purs +++ b/examples/AlwaysSucceeds.purs @@ -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 @@ -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 diff --git a/examples/AwaitTxConfirmedWithTimeout.purs b/examples/AwaitTxConfirmedWithTimeout.purs index d465229f8a..6db0050094 100644 --- a/examples/AwaitTxConfirmedWithTimeout.purs +++ b/examples/AwaitTxConfirmedWithTimeout.purs @@ -13,7 +13,7 @@ import Contract.Prelude import Cardano.AsCbor (decodeCbor) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -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 diff --git a/examples/ByUrl.purs b/examples/ByUrl.purs index 57ef2b7a20..21aed947de 100644 --- a/examples/ByUrl.purs +++ b/examples/ByUrl.purs @@ -4,11 +4,10 @@ import Prelude import Contract.Config ( ContractParams - , KnownWallet(Nami, Gero, Flint, Eternl, Lode, Lace, NuFi) + , KnownWallet(Gero, Eternl, Lode, Lace, NuFi) , WalletSpec(ConnectToGenericCip30) , blockfrostPublicPreprodServerConfig , blockfrostPublicPreviewServerConfig - , mainnetConfig , mkBlockfrostBackendParams , testnetConfig , walletName @@ -65,11 +64,7 @@ main = do if isNothing mbApiKey then Map.empty else Map.fromFoldable - [ "blockfrost-nami-preview" - /\ (mkBlockfrostPreviewConfig mbApiKey) - { walletSpec = connectTo Nami } - /\ Nothing - , "blockfrost-gero-preview" + [ "blockfrost-gero-preview" /\ (mkBlockfrostPreviewConfig mbApiKey) { walletSpec = connectTo Gero } /\ Nothing @@ -81,10 +76,6 @@ main = do /\ (mkBlockfrostPreviewConfig mbApiKey) { walletSpec = connectTo Lode } /\ Nothing - , "blockfrost-flint-preview" - /\ (mkBlockfrostPreviewConfig mbApiKey) - { walletSpec = connectTo Flint } - /\ Nothing , "blockfrost-nufi-preview" /\ (mkBlockfrostPreviewConfig mbApiKey) { walletSpec = connectTo NuFi } @@ -93,10 +84,6 @@ main = do /\ (mkBlockfrostPreviewConfig mbApiKey) { walletSpec = connectTo Lace } /\ Nothing - , "blockfrost-nami-preprod" - /\ (mkBlockfrostPreprodConfig mbApiKey) - { walletSpec = connectTo Nami } - /\ Nothing , "blockfrost-gero-preprod" /\ (mkBlockfrostPreprodConfig mbApiKey) { walletSpec = connectTo Gero } @@ -109,10 +96,6 @@ main = do /\ (mkBlockfrostPreprodConfig mbApiKey) { walletSpec = connectTo Lode } /\ Nothing - , "blockfrost-flint-preprod" - /\ (mkBlockfrostPreprodConfig mbApiKey) - { walletSpec = connectTo Flint } - /\ Nothing , "blockfrost-nufi-preprod" /\ (mkBlockfrostPreprodConfig mbApiKey) { walletSpec = connectTo NuFi } @@ -138,23 +121,17 @@ getBlockfrostApiKey = do wallets :: Map E2EConfigName (ContractParams /\ Maybe String) wallets = map (map walletName) <$> Map.fromFoldable - [ "nami" /\ testnetConfig' Nami /\ Nothing - , "gero" /\ testnetConfig' Gero /\ Nothing - , "flint" /\ testnetConfig' Flint /\ Nothing + [ "gero" /\ testnetConfig' Gero /\ Nothing , "eternl" /\ testnetConfig' Eternl /\ Nothing , "lode" /\ testnetConfig' Lode /\ Nothing , "nufi" /\ testnetConfig' NuFi /\ Nothing , "lace" /\ testnetConfig' Lace /\ Nothing - , "nami-mainnet" /\ mainnetNamiConfig /\ Nothing - , "nami-mock" /\ testnetConfig' Nami /\ Just Nami , "gero-mock" /\ testnetConfig' Gero /\ Just Gero - , "flint-mock" /\ testnetConfig' Flint /\ Just Flint , "lode-mock" /\ testnetConfig' Lode /\ Just Lode - , "plutip-nami-mock" /\ testnetConfig' Nami /\ Just Nami - , "plutip-gero-mock" /\ testnetConfig' Gero /\ Just Gero - , "plutip-flint-mock" /\ testnetConfig' Flint /\ Just Flint - , "plutip-lode-mock" /\ testnetConfig' Lode /\ Just Lode - , "plutip-nufi-mock" /\ testnetConfig' NuFi /\ Just NuFi + , "localnet-eternl-mock" /\ testnetConfig' Eternl /\ Just Eternl + , "localnet-gero-mock" /\ testnetConfig' Gero /\ Just Gero + , "localnet-lode-mock" /\ testnetConfig' Lode /\ Just Lode + , "localnet-nufi-mock" /\ testnetConfig' NuFi /\ Just NuFi ] where testnetConfig' :: KnownWallet -> ContractParams @@ -164,13 +141,6 @@ wallets = map (map walletName) <$> Map.fromFoldable Just $ ConnectToGenericCip30 (walletName wallet) { cip95: false } } - mainnetNamiConfig :: ContractParams - mainnetNamiConfig = - mainnetConfig - { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } - } - mkBlockfrostPreviewConfig :: Maybe String -> ContractParams mkBlockfrostPreviewConfig apiKey = testnetConfig diff --git a/examples/Cip30.purs b/examples/Cip30.purs index eb45938f21..11112a8748 100644 --- a/examples/Cip30.purs +++ b/examples/Cip30.purs @@ -17,7 +17,7 @@ import Cardano.Wallet.Cip30 import Cardano.Wallet.Cip30.TypeSafe as Cip30 import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -38,7 +38,7 @@ import Effect.Exception (error) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/DropTokens.purs b/examples/DropTokens.purs index 5381ddf79c..6291d96549 100644 --- a/examples/DropTokens.purs +++ b/examples/DropTokens.purs @@ -8,7 +8,7 @@ import Cardano.Types.MultiAsset as MultiAsset import Cardano.Types.Value as Value import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -28,7 +28,7 @@ import Test.Ctl.Fixtures (nullPaymentPubKeyHash) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/ExUnits.purs b/examples/ExUnits.purs index 1fdb5dfa06..319b41818f 100644 --- a/examples/ExUnits.purs +++ b/examples/ExUnits.purs @@ -20,7 +20,7 @@ import Cardano.Types.TransactionUnspentOutput (toUtxoMap) import Contract.Address (mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -50,7 +50,7 @@ import JS.BigInt as BigInt main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } contract :: Contract Unit diff --git a/examples/IncludeDatum.purs b/examples/IncludeDatum.purs index 7074c37d1e..9cb22cad42 100644 --- a/examples/IncludeDatum.purs +++ b/examples/IncludeDatum.purs @@ -32,7 +32,7 @@ import Cardano.Types.TransactionUnspentOutput (toUtxoMap) import Contract.Address (mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -59,7 +59,7 @@ import JS.BigInt as BigInt main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/Lose7Ada.purs b/examples/Lose7Ada.purs index 9d61939316..f5e92ae266 100644 --- a/examples/Lose7Ada.purs +++ b/examples/Lose7Ada.purs @@ -33,7 +33,7 @@ import Cardano.Types.TransactionUnspentOutput (toUtxoMap) import Contract.Address (mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -68,7 +68,7 @@ import Test.Spec.Assertions (shouldEqual) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/ManyAssets.purs b/examples/ManyAssets.purs index b640702ae4..9a3afbde00 100644 --- a/examples/ManyAssets.purs +++ b/examples/ManyAssets.purs @@ -19,7 +19,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 @@ -35,7 +35,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 } } example :: ContractParams -> Effect Unit diff --git a/examples/MintsMultipleTokens.purs b/examples/MintsMultipleTokens.purs index c87f5b6252..e9f644eca9 100644 --- a/examples/MintsMultipleTokens.purs +++ b/examples/MintsMultipleTokens.purs @@ -23,7 +23,7 @@ import Cardano.Types.PlutusScript as PlutusScript import Cardano.Types.Transaction as Transaction import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -42,7 +42,7 @@ import JS.BigInt (fromInt) as BigInt main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } contract :: Contract Unit diff --git a/examples/NativeScriptMints.purs b/examples/NativeScriptMints.purs index 62fe5fa1b8..f6bd8ff6ef 100644 --- a/examples/NativeScriptMints.purs +++ b/examples/NativeScriptMints.purs @@ -23,7 +23,7 @@ import Cardano.Types.Transaction as Transaction import Contract.Address (PaymentPubKeyHash, mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -43,7 +43,7 @@ import JS.BigInt as BigInt main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } contract :: Contract Unit diff --git a/examples/OneShotMinting.purs b/examples/OneShotMinting.purs index 694fc63e02..41dcfe8063 100644 --- a/examples/OneShotMinting.purs +++ b/examples/OneShotMinting.purs @@ -28,7 +28,7 @@ import Cardano.Types.Transaction as Transaction import Cardano.Types.TransactionUnspentOutput (fromUtxoMap) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -70,7 +70,7 @@ import JS.BigInt (BigInt) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/PaysWithDatum.purs b/examples/PaysWithDatum.purs index bea549b6a3..8415c3773a 100644 --- a/examples/PaysWithDatum.purs +++ b/examples/PaysWithDatum.purs @@ -13,7 +13,7 @@ import Cardano.Types.BigNum as BigNum import Contract.Address (Address) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -65,7 +65,7 @@ type ContractResult = main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/Pkh2Pkh.purs b/examples/Pkh2Pkh.purs index fe1ff36502..fdc040d31b 100644 --- a/examples/Pkh2Pkh.purs +++ b/examples/Pkh2Pkh.purs @@ -16,7 +16,7 @@ import Cardano.Types.PlutusData as PlutusData import Cardano.Types.Transaction as Transaction import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -32,7 +32,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 diff --git a/examples/PlutusV2/AlwaysSucceeds.purs b/examples/PlutusV2/AlwaysSucceeds.purs index ba43f5b11e..9ceb09f5b2 100644 --- a/examples/PlutusV2/AlwaysSucceeds.purs +++ b/examples/PlutusV2/AlwaysSucceeds.purs @@ -11,7 +11,7 @@ import Contract.Prelude import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -29,7 +29,7 @@ import Ctl.Examples.PlutusV2.Scripts.AlwaysSucceeds (alwaysSucceedsScriptV2) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } contract :: Contract Unit diff --git a/examples/PlutusV2/InlineDatum.purs b/examples/PlutusV2/InlineDatum.purs index a0d1e7e7cb..40ddfd00e8 100644 --- a/examples/PlutusV2/InlineDatum.purs +++ b/examples/PlutusV2/InlineDatum.purs @@ -18,7 +18,7 @@ import Cardano.Types.BigNum as BigNum import Contract.Address (mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -49,7 +49,7 @@ import Test.Spec.Assertions (shouldEqual) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/PlutusV2/OneShotMinting.purs b/examples/PlutusV2/OneShotMinting.purs index e8ec3979e9..98f65ce163 100644 --- a/examples/PlutusV2/OneShotMinting.purs +++ b/examples/PlutusV2/OneShotMinting.purs @@ -13,7 +13,7 @@ import Contract.Prelude import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -32,7 +32,7 @@ import Effect.Exception (error) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/PlutusV2/ReferenceInputsAndScripts.purs b/examples/PlutusV2/ReferenceInputsAndScripts.purs index c19a2fd965..5f63721bf5 100644 --- a/examples/PlutusV2/ReferenceInputsAndScripts.purs +++ b/examples/PlutusV2/ReferenceInputsAndScripts.purs @@ -29,7 +29,7 @@ import Cardano.Types.Transaction as Transaction import Contract.Address (mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -58,7 +58,7 @@ import Effect.Exception (error) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/SendsToken.purs b/examples/SendsToken.purs index 6b4efcff92..69cd219762 100644 --- a/examples/SendsToken.purs +++ b/examples/SendsToken.purs @@ -28,7 +28,7 @@ import Cardano.Types.Transaction as Transaction import Contract.Address (mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -51,7 +51,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 } } example :: ContractParams -> Effect Unit diff --git a/examples/SignData.purs b/examples/SignData.purs index b32747731f..aac92e55b1 100644 --- a/examples/SignData.purs +++ b/examples/SignData.purs @@ -9,7 +9,7 @@ import Cardano.Types.PublicKey as PublicKey import Contract.Address (Address) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -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 diff --git a/examples/SignMultiple.purs b/examples/SignMultiple.purs index 047fd12dfa..f6d4632ff2 100644 --- a/examples/SignMultiple.purs +++ b/examples/SignMultiple.purs @@ -20,7 +20,7 @@ import Cardano.Types.Transaction as Transaction import Contract.Address (mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -62,7 +62,7 @@ import Effect.Ref as Ref main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } getLockedInputs diff --git a/examples/TxChaining.purs b/examples/TxChaining.purs index bcafe5c2f2..01b17d5645 100644 --- a/examples/TxChaining.purs +++ b/examples/TxChaining.purs @@ -27,7 +27,7 @@ import Contract.BalanceTxConstraints ) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -52,7 +52,7 @@ import Effect.Exception (throw) main :: Effect Unit main = example $ testnetConfig { walletSpec = - Just $ ConnectToGenericCip30 (walletName Nami) { cip95: false } + Just $ ConnectToGenericCip30 (walletName Eternl) { cip95: false } } example :: ContractParams -> Effect Unit diff --git a/examples/Utxos.purs b/examples/Utxos.purs index 780f5be22d..cccc4594bb 100644 --- a/examples/Utxos.purs +++ b/examples/Utxos.purs @@ -23,7 +23,7 @@ import Cardano.Types.Transaction as Transaction import Contract.Address (mkAddress) import Contract.Config ( ContractParams - , KnownWallet(Nami) + , KnownWallet(Eternl) , WalletSpec(ConnectToGenericCip30) , testnetConfig , walletName @@ -62,7 +62,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 diff --git a/flake.nix b/flake.nix index 33b77fd1a0..bf5e27b153 100644 --- a/flake.nix +++ b/flake.nix @@ -132,6 +132,10 @@ ); }; ogmiosFixtures = buildOgmiosFixtures pkgs; + exportOgmiosFixtures = + '' + export OGMIOS_FIXTURES="${ogmiosFixtures}" + ''; project = pkgs.purescriptProject { inherit src pkgs projectName; packageJson = ./package.json; @@ -152,15 +156,24 @@ ]; }; }; - exportOgmiosFixtures = - '' - export OGMIOS_FIXTURES="${ogmiosFixtures}" - ''; + ctlScaffoldProject = pkgs.purescriptProject rec { + inherit pkgs; + projectName = "ctl-scaffold"; + packageJson = ./templates/ctl-scaffold/package.json; + packageLock = ./templates/ctl-scaffold/package-lock.json; + src = builtins.path { + path = ./templates/ctl-scaffold; + name = "${projectName}-src"; + filter = path: ftype: !(pkgs.lib.hasSuffix ".md" path); + }; + }; in rec { packages = { ctl-purs-project = project.buildPursProject { }; + ctl-scaffold-purs-project = ctlScaffoldProject.buildPursProject { }; + ctl-example-bundle-web-esbuild = project.bundlePursProjectEsbuild { main = "Ctl.Examples.ByUrl"; }; diff --git a/src/Contract/Config.purs b/src/Contract/Config.purs index dd2c012c85..74545aecd4 100644 --- a/src/Contract/Config.purs +++ b/src/Contract/Config.purs @@ -60,7 +60,7 @@ import Ctl.Internal.ServerConfig ) import Ctl.Internal.Wallet.Spec ( Cip1852DerivationPath - , KnownWallet(Nami, Gero, Flint, Eternl, Lode, Lace, NuFi) + , KnownWallet(Gero, Eternl, Lode, Lace, NuFi) , MnemonicSource(MnemonicString, MnemonicFile) , PrivatePaymentKeySource(PrivatePaymentKeyFile, PrivatePaymentKeyValue) , PrivateStakeKeySource(PrivateStakeKeyFile, PrivateStakeKeyValue) diff --git a/src/Contract/Test/E2E.purs b/src/Contract/Test/E2E.purs index 7f8582ba8e..d1cb7083e9 100644 --- a/src/Contract/Test/E2E.purs +++ b/src/Contract/Test/E2E.purs @@ -4,5 +4,11 @@ module Contract.Test.E2E import Ctl.Internal.Test.E2E.Feedback.Hooks (e2eFeedbackHooks) as X import Ctl.Internal.Test.E2E.Options (parseCliArgs) as X -import Ctl.Internal.Test.E2E.Route (E2EConfigName, E2ETestName, addLinks, route) as X +import Ctl.Internal.Test.E2E.Route + ( E2EConfigName + , E2ETestName + , addLinks + , e2eConfigs + , route + ) as X import Ctl.Internal.Test.E2E.Runner (runE2ECommand, runE2ETests) as X diff --git a/src/Contract/Wallet.purs b/src/Contract/Wallet.purs index 118c0fda54..a3a0d9babf 100644 --- a/src/Contract/Wallet.purs +++ b/src/Contract/Wallet.purs @@ -68,7 +68,7 @@ import Ctl.Internal.Wallet.Spec , mkKeyWalletFromMnemonic ) import Ctl.Internal.Wallet.Spec - ( KnownWallet(Nami, Gero, Flint, Eternl, Lode, Lace, NuFi) + ( KnownWallet(Gero, Eternl, Lode, Lace, NuFi) , MnemonicSource(MnemonicString, MnemonicFile) , PrivatePaymentKeySource(PrivatePaymentKeyFile, PrivatePaymentKeyValue) , PrivateStakeKeySource(PrivateStakeKeyFile, PrivateStakeKeyValue) @@ -188,7 +188,6 @@ getWalletBalance = do -- | Get the collateral of the browser wallet. This collateral will vary -- | depending on the wallet. --- | E.g. Nami creates a hard-coded 5 Ada collateral. -- | Throws on `Promise` rejection by wallet, returns `Nothing` if no collateral -- | is available. getWalletCollateral diff --git a/src/Internal/Test/E2E/Options.purs b/src/Internal/Test/E2E/Options.purs index f2866c0853..c309e3c10e 100644 --- a/src/Internal/Test/E2E/Options.purs +++ b/src/Internal/Test/E2E/Options.purs @@ -36,7 +36,7 @@ import Ctl.Internal.Test.E2E.Types , SettingsArchive , SettingsArchiveUrl , TmpDir - , WalletExt(LodeExt, FlintExt, GeroExt, NamiExt, EternlExt) + , WalletExt(LodeExt, GeroExt, EternlExt) , WalletPassword , mkE2ETest , mkExtensionId @@ -94,8 +94,7 @@ type TestOptions = Record ) type ClusterPortsOptions_ (r :: Row Type) = - ( plutipPort :: Maybe UInt - , ogmiosPort :: Maybe UInt + ( ogmiosPort :: Maybe UInt , kupoPort :: Maybe UInt | r ) @@ -219,18 +218,13 @@ browserOptionsParser = ado , metavar "CHROMIUM CLI ARGUMENT" ] - nami <- parseWallet "Nami" eternl <- parseWallet "Eternl" gero <- parseWallet "Gero" - flint <- parseWallet "Flint" lode <- parseWallet "Lode" let wallets = Map.fromFoldable $ catMaybes - [ mkConfig NamiExt nami.extensionId nami.password nami.crxFile nami.crxUrl - , mkConfig GeroExt gero.extensionId gero.password gero.crxFile gero.crxUrl - , mkConfig FlintExt flint.extensionId flint.password flint.crxFile - flint.crxUrl + [ mkConfig GeroExt gero.extensionId gero.password gero.crxFile gero.crxUrl , mkConfig LodeExt lode.extensionId lode.password lode.crxFile lode.crxUrl , mkConfig EternlExt eternl.extensionId eternl.password eternl.crxFile eternl.crxUrl @@ -330,24 +324,14 @@ uintParser = eitherReader \str -> defaultPorts :: { kupo :: Int , ogmios :: Int - , plutip :: Int } defaultPorts = - { plutip: 8087 - , ogmios: 1345 + { ogmios: 1345 , kupo: 1443 } clusterPortsOptionsParser :: Parser ClusterPortsOptions clusterPortsOptionsParser = ado - plutipPort <- option (Just <$> uintParser) $ fold - [ long "plutip-port" - , help "Plutip port for use with local cluster" - , value Nothing - , showDefaultWith $ const $ - showPort "PLUTIP" defaultPorts.plutip - , metavar "PORT" - ] ogmiosPort <- option (Just <$> uintParser) $ fold [ long "ogmios-port" , help "Ogmios port for use with local Plutip cluster" @@ -365,8 +349,7 @@ clusterPortsOptionsParser = ado , metavar "PORT" ] in - { plutipPort - , ogmiosPort + { ogmiosPort , kupoPort } where diff --git a/src/Internal/Test/E2E/Route.purs b/src/Internal/Test/E2E/Route.purs index 7988505105..bc13946d4c 100644 --- a/src/Internal/Test/E2E/Route.purs +++ b/src/Internal/Test/E2E/Route.purs @@ -1,10 +1,11 @@ module Ctl.Internal.Test.E2E.Route ( E2ETestName , E2EConfigName - , route - , parseRoute , Route , addLinks + , e2eConfigs + , parseRoute + , route ) where import Prelude @@ -13,12 +14,14 @@ import Cardano.Types (NetworkId(TestnetId)) import Cardano.Types.PrivateKey (PrivateKey) import Cardano.Types.PrivateKey as PrivateKey import Cardano.Types.RawBytes (RawBytes(RawBytes)) -import Contract.Config (ContractParams) +import Contract.Config (ContractParams, testnetConfig) import Contract.Monad (Contract, runContract) import Contract.Test.Cip30Mock (withCip30Mock) import Contract.Wallet - ( PrivatePaymentKey(PrivatePaymentKey) + ( KnownWallet(Gero, Eternl, Lode) + , PrivatePaymentKey(PrivatePaymentKey) , PrivateStakeKey(PrivateStakeKey) + , walletName ) import Contract.Wallet.Key (privateKeysToKeyWallet) import Control.Alt ((<|>)) @@ -33,15 +36,17 @@ import Data.Array (last) import Data.Array as Array import Data.Bifunctor (lmap) import Data.ByteArray (hexToByteArray) -import Data.Either (Either(Left), note) +import Data.Either (Either(Left, Right), note) import Data.Foldable (fold) import Data.Map (Map) import Data.Map as Map -import Data.Maybe (Maybe(Just, Nothing), maybe) +import Data.Maybe (Maybe(Just, Nothing), fromMaybe, maybe) import Data.Newtype (wrap) -import Data.String (stripPrefix) +import Data.String (stripPrefix, stripSuffix) import Data.String.Common (split) import Data.String.Pattern (Pattern(Pattern)) +import Data.Traversable (traverse) +import Data.Tuple (Tuple(Tuple)) import Data.Tuple.Nested (type (/\), (/\)) import Effect (Effect) import Effect.Aff (Aff, delay, launchAff_) @@ -55,6 +60,48 @@ type E2ETestName = String -- | CIP-30 mock). Used in the URL for routing type E2EConfigName = String +-- | A helper function that derives wallets and Contract parameters +-- | from the provided E2E configuration names. +e2eConfigs + :: Array E2EConfigName + -> Either String (Map E2EConfigName (ContractParams /\ Maybe String)) +e2eConfigs = + map Map.fromFoldable + <<< traverse (\env -> Tuple env <$> resolveConfigName env) + where + resolveConfigName + :: E2EConfigName + -> Either String (ContractParams /\ Maybe String) + resolveConfigName configName = do + let + walletSpec = + fromMaybe configName $ stripPrefix (Pattern "localnet-") + configName + wallet' /\ isMock = + maybe (walletSpec /\ false) (flip Tuple true) $ stripSuffix + (Pattern "-mock") + walletSpec + wallet <- resolveWallet wallet' + pure $ + Tuple + (mkContractParams wallet) + (if isMock then Just wallet else Nothing) + + resolveWallet :: String -> Either String String + resolveWallet = + case _ of + "gero" -> Right $ walletName Gero + "eternl" -> Right $ walletName Eternl + "lode" -> Right $ walletName Lode + wallet -> Left $ "e2eConfigs: unsupported wallet: " <> wallet + + mkContractParams :: String -> ContractParams + mkContractParams wallet = + testnetConfig + { walletSpec = + Just $ ConnectToGenericCip30 wallet { cip95: false } + } + -- | Router state - parsed from URL by `parseRoute` type Route = { configName :: E2EConfigName @@ -127,7 +174,6 @@ addLinks configMaps testMaps = do -- | ``` -- | gero:MintsMultiple -- | eternl:AlwaysSucceeds:58200b07c066ba037344acee5431e6df41f6034bf1c5ffd6f803751e356807c6a209 --- | nami-mock:MintsMultiple:58200b07c066ba037344acee5431e6df41f6034bf1c5ffd6f803751e356807c6a209:5820f0db841df6c7fbc4506c58fad6676db0354a02dfd26efca445715a8adeabc338 -- | ``` -- | -- | In case that for the specified `E2EConfigName` a `WalletMock` is provided @@ -191,7 +237,7 @@ route configs tests = do noConfigParametersError :: E2EConfigName -> String noConfigParametersError configName = "Unable to look up the config parameters: " <> configName - <> "Common reasons are:\n" + <> "\nCommon reasons are:\n" <> "- The page that is used to serve the test contracts is not up to " <> "date\n" <> "- The name of the test suite configuration is wrong (" diff --git a/src/Internal/Test/E2E/Runner.purs b/src/Internal/Test/E2E/Runner.purs index 44f1a03717..16e21cc633 100644 --- a/src/Internal/Test/E2E/Runner.purs +++ b/src/Internal/Test/E2E/Runner.purs @@ -55,7 +55,7 @@ import Ctl.Internal.Test.E2E.Types , SettingsArchive , SettingsRuntime , TmpDir - , WalletExt(FlintExt, NamiExt, GeroExt, LodeExt, EternlExt, LaceExt) + , WalletExt(GeroExt, LodeExt, EternlExt, LaceExt) , getE2EWalletExtension , mkE2ETest , mkExtensionId @@ -64,16 +64,12 @@ import Ctl.Internal.Test.E2E.Types import Ctl.Internal.Test.E2E.Wallets ( eternlConfirmAccess , eternlSign - , flintConfirmAccess - , flintSign , geroConfirmAccess , geroSign , laceConfirmAccess , laceSign , lodeConfirmAccess , lodeSign - , namiConfirmAccess - , namiSign ) import Ctl.Internal.Test.UtxoDistribution (withStakeKey) import Ctl.Internal.Testnet.Contract (withTestnetContractEnv) @@ -288,18 +284,14 @@ testPlan opts@{ tests } rt@{ wallets } = confirmAccess = case wallet of EternlExt -> eternlConfirmAccess - FlintExt -> flintConfirmAccess GeroExt -> geroConfirmAccess LodeExt -> lodeConfirmAccess - NamiExt -> namiConfirmAccess LaceExt -> laceConfirmAccess sign = case wallet of EternlExt -> eternlSign - FlintExt -> flintSign GeroExt -> geroSign LodeExt -> lodeSign - NamiExt -> namiSign LaceExt -> laceSign someWallet = { wallet @@ -362,7 +354,6 @@ readTestRuntime testOptions = do ( delete (Proxy :: Proxy "noHeadless") <<< delete (Proxy :: Proxy "tests") <<< delete (Proxy :: Proxy "testTimeout") - <<< delete (Proxy :: Proxy "plutipPort") <<< delete (Proxy :: Proxy "ogmiosPort") <<< delete (Proxy :: Proxy "kupoPort") <<< delete (Proxy :: Proxy "passBrowserLogs") @@ -371,15 +362,12 @@ readTestRuntime testOptions = do readPorts :: TestOptions -> Effect ClusterPortsOptions readPorts testOptions = do - plutipPort <- - readPortNumber "PLUTIP" testOptions.plutipPort ogmiosPort <- readPortNumber "OGMIOS" testOptions.ogmiosPort kupoPort <- readPortNumber "KUPO" testOptions.kupoPort pure - { plutipPort - , ogmiosPort + { ogmiosPort , kupoPort } where @@ -400,17 +388,13 @@ readExtensions :: Map.Map WalletExt ExtensionOptions -> Aff (Map.Map WalletExt ExtensionParams) readExtensions wallets = do - nami <- readExtensionParams "NAMI" wallets - flint <- readExtensionParams "FLINT" wallets gero <- readExtensionParams "GERO" wallets lode <- readExtensionParams "LODE" wallets eternl <- readExtensionParams "ETERNL" wallets lace <- readExtensionParams "LACE" wallets pure $ Map.fromFoldable $ catMaybes - [ Tuple NamiExt <$> nami - , Tuple FlintExt <$> flint - , Tuple GeroExt <$> gero + [ Tuple GeroExt <$> gero , Tuple LodeExt <$> lode , Tuple EternlExt <$> eternl , Tuple LaceExt <$> lace @@ -535,19 +519,19 @@ readTests optUrls = do mkError testSpec = error $ "Failed to parse test data from: " <> testSpec <> "\nTest spec must be of form \"wallet:url\", where allowed wallets are: \ - \eternl, flint, gero, lode, nami." + \eternl, gero, lode." -- | Run an example in a new browser page. -- | -- | Example usage: -- | -- | ```purescript --- | withBrowser options NamiExt \browser -> do +-- | withBrowser options EternlExt \browser -> do -- | withE2ETest -- | false -- do not skip jQuery -- | (wrap "http://myserver:1234/docontract") -- | browser do --- | namiSign $ wrap "mypassword" +-- | eternlSign $ wrap "mypassword" -- | ``` withE2ETest :: forall (a :: Type) @@ -718,7 +702,7 @@ readExtensionParams extName wallets = do liftMaybe (error $ mkExtIdError str) $ mkExtensionId str let mbCliOptions :: Maybe ExtensionOptions - mbCliOptions = Map.lookup NamiExt wallets + mbCliOptions = Map.lookup EternlExt wallets envOptions :: ExtensionOptions envOptions = { crxFile, password, extensionId, crxUrl } @@ -948,8 +932,6 @@ defaultErrorReader = walletName :: WalletExt -> String walletName = case _ of EternlExt -> "eternl" - FlintExt -> "flint" GeroExt -> "gero" LodeExt -> "lode" - NamiExt -> "nami" LaceExt -> "lace" diff --git a/src/Internal/Test/E2E/Types.purs b/src/Internal/Test/E2E/Types.purs index f4b0c82825..d1717919d4 100644 --- a/src/Internal/Test/E2E/Types.purs +++ b/src/Internal/Test/E2E/Types.purs @@ -12,7 +12,7 @@ module Ctl.Internal.Test.E2E.Types , unExtensionId , WalletPassword , ExtensionParams - , WalletExt(FlintExt, NamiExt, GeroExt, LodeExt, EternlExt, LaceExt) + , WalletExt(GeroExt, LodeExt, EternlExt, LaceExt) , Extensions , E2ETestRuntime , SettingsRuntime @@ -92,8 +92,8 @@ type ExtensionParams = , extensionId :: ExtensionId } --- | Enumeration of all known extensions. -data WalletExt = FlintExt | NamiExt | GeroExt | LodeExt | EternlExt | LaceExt +-- | Supported wallet extensions. +data WalletExt = GeroExt | LodeExt | EternlExt | LaceExt derive instance Eq WalletExt derive instance Ord WalletExt @@ -144,12 +144,10 @@ type E2ETest = mkE2ETest :: String -> Maybe E2ETest mkE2ETest str = (tryWalletPrefix "eternl" <#> mkTestEntry (WalletExtension EternlExt)) - <|> (tryWalletPrefix "flint" <#> mkTestEntry (WalletExtension FlintExt)) <|> (tryWalletPrefix "gero" <#> mkTestEntry (WalletExtension GeroExt)) <|> (tryWalletPrefix "lode" <#> mkTestEntry (WalletExtension LodeExt)) - <|> (tryWalletPrefix "nami" <#> mkTestEntry (WalletExtension NamiExt)) <|> (tryWalletPrefix "lace" <#> mkTestEntry (WalletExtension LaceExt)) - <|> (tryWalletPrefix "plutip" <#> mkTestEntry LocalTestnet) + <|> (tryWalletPrefix "localnet" <#> mkTestEntry LocalTestnet) <|> (pure $ mkTestEntry NoWallet str) where tryWalletPrefix :: String -> Maybe String diff --git a/src/Internal/Test/E2E/Wallets.purs b/src/Internal/Test/E2E/Wallets.purs index 1d036819e1..50c8bb97ff 100644 --- a/src/Internal/Test/E2E/Wallets.purs +++ b/src/Internal/Test/E2E/Wallets.purs @@ -4,12 +4,8 @@ module Ctl.Internal.Test.E2E.Wallets , eternlSign , geroConfirmAccess , geroSign - , flintConfirmAccess - , flintSign , lodeConfirmAccess , lodeSign - , namiConfirmAccess - , namiSign , laceConfirmAccess , laceSign ) where @@ -165,28 +161,6 @@ eternlSign extId password re = do pattern :: Pattern pattern = wrap $ unExtensionId extId <> "/www/index.html#/signtx" -namiConfirmAccess :: ExtensionId -> RunningE2ETest -> Aff Unit -namiConfirmAccess extId re = do - wasInPage <- isJust <$> inWalletPageOptional extId pattern re - confirmAccessTimeout - (clickButton "Access") - when wasInPage do - waitForWalletPageClose pattern 10.0 re.browser - where - pattern :: Pattern - pattern = wrap $ unExtensionId extId - -namiSign :: ExtensionId -> WalletPassword -> RunningE2ETest -> Aff Unit -namiSign extId wpassword re = do - inWalletPage (Pattern $ unExtensionId extId) re signTimeout \page -> do - void $ Toppokki.pageWaitForSelector (wrap ".chakra-button") {} page - clickButton "Sign" page - void $ Toppokki.pageWaitForSelector (wrap $ unwrap $ inputType "password") - {} - page - typeInto (inputType "password") wpassword page - clickButton "Confirm" page - geroConfirmAccess :: ExtensionId -> RunningE2ETest -> Aff Unit geroConfirmAccess extId re = do wasInPage <- isJust <$> inWalletPageOptional extId pattern re @@ -248,7 +222,7 @@ laceConfirmAccess extId re = do pattern :: Pattern pattern = wrap $ unExtensionId extId <> "/dappConnector.html" --- Not implemented yet +-- TODO: Not implemented yet laceSign :: ExtensionId -> WalletPassword -> RunningE2ETest -> Aff Unit laceSign extId password re = do void $ liftEffect $ throw "Lace support is not implemented" @@ -268,16 +242,6 @@ laceSign extId password re = do where pattern = Pattern $ unExtensionId extId <> "/dappConnector.html#/dapp/sign-tx" --- Not implemented yet -flintConfirmAccess :: ExtensionId -> RunningE2ETest -> Aff Unit -flintConfirmAccess _ _ = - liftEffect $ throw "Flint support is not implemented" - --- Not implemented yet -flintSign :: ExtensionId -> WalletPassword -> RunningE2ETest -> Aff Unit -flintSign _ _ _ = do - liftEffect $ throw "Flint support is not implemented" - getJQuery :: RunningE2ETest -> Aff String getJQuery re = liftM (error errMessage) re.jQuery diff --git a/src/Internal/Test/KeyDir.purs b/src/Internal/Test/KeyDir.purs index 5a9cecba9a..3f81b618a7 100644 --- a/src/Internal/Test/KeyDir.purs +++ b/src/Internal/Test/KeyDir.purs @@ -35,13 +35,11 @@ import Contract.Wallet ( getWalletAddresses , getWalletBalance , ownPaymentPubKeyHashes + , ownStakePubKeyHashes , privateKeysToKeyWallet , withKeyWallet ) -import Contract.Wallet.Key - ( getPrivatePaymentKey - , getPrivateStakeKey - ) +import Contract.Wallet.Key (getPrivatePaymentKey, getPrivateStakeKey) import Contract.Wallet.KeyFile ( privatePaymentKeyFromTextEnvelope , privatePaymentKeyToFile @@ -386,9 +384,13 @@ returnFunds backup env allWalletsArray mbFundTotal hasRun = pkhs <- fold <$> for nonEmptyWallets (snd >>> flip withKeyWallet ownPaymentPubKeyHashes) + skhs <- catMaybes <<< fold <$> for nonEmptyWallets + (snd >>> flip withKeyWallet ownStakePubKeyHashes) + let constraints = flip foldMap (Map.keys utxos) mustSpendPubKeyOutput <> foldMap mustBeSignedBy pkhs + <> foldMap (mustBeSignedBy <<< wrap <<< unwrap) skhs lookups = unspentOutputs utxos unbalancedTx /\ usedUtxos <- liftedE $ mkUnbalancedTxImpl lookups diff --git a/src/Internal/Wallet/Cip30.purs b/src/Internal/Wallet/Cip30.purs index 57e1436caa..38bd3bb729 100644 --- a/src/Internal/Wallet/Cip30.purs +++ b/src/Internal/Wallet/Cip30.purs @@ -66,13 +66,12 @@ type Cip30Wallet = , getNetworkId :: Aff Int -- Returns a list of all UTXOs controlled by the wallet. , getUtxos :: Aff (Maybe (Array TransactionUnspentOutput)) - -- Get the collateral UTxO associated with the Nami wallet + -- Get the collateral UTxO , getCollateral :: Aff (Maybe (Array TransactionUnspentOutput)) -- Get combination of all available UTxOs , getBalance :: Aff Value - -- Get the address associated with the wallet (Nami does not support - -- multiple addresses) + -- Get addresses associated with the wallet , getUsedAddresses :: Aff (Array Address) -- Sign a transaction with the given wallet -- Returns a list of unused addresses controlled by the wallet. diff --git a/src/Internal/Wallet/Spec.purs b/src/Internal/Wallet/Spec.purs index ae440e2846..36f34982e8 100644 --- a/src/Internal/Wallet/Spec.purs +++ b/src/Internal/Wallet/Spec.purs @@ -1,6 +1,6 @@ module Ctl.Internal.Wallet.Spec ( Cip1852DerivationPath - , KnownWallet(Nami, Gero, Flint, Eternl, Lode, Lace, NuFi) + , KnownWallet(Gero, Eternl, Lode, Lace, NuFi) , MnemonicSource(MnemonicString, MnemonicFile) , PrivateDrepKeySource(PrivateDrepKeyValue) , PrivateStakeKeySource(PrivateStakeKeyFile, PrivateStakeKeyValue) @@ -105,13 +105,11 @@ derive instance Generic WalletSpec _ instance Show WalletSpec where show = genericShow -data KnownWallet = Nami | Gero | Flint | Eternl | Lode | Lace | NuFi +data KnownWallet = Gero | Eternl | Lode | Lace | NuFi walletName :: KnownWallet -> String walletName = case _ of - Nami -> "nami" Gero -> "gerowallet" - Flint -> "flint" Eternl -> "eternl" Lode -> "LodeWallet" Lace -> "lace" diff --git a/templates/ctl-scaffold/Makefile b/templates/ctl-scaffold/Makefile index 0e6deadf47..f64e40abd3 100644 --- a/templates/ctl-scaffold/Makefile +++ b/templates/ctl-scaffold/Makefile @@ -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 build create-bundle-entrypoint create-html-entrypoint delete-bundle-entrypoint .SHELLFLAGS := -eu -o pipefail -c ps-sources := $(shell fd --no-ignore-parent -epurs) @@ -21,7 +21,7 @@ preview-node-ipc = $(shell docker volume inspect store_node-preview-ipc | jq -r preprod-node-ipc = $(shell docker volume inspect store_node-preprod-ipc | jq -r '.[0].Mountpoint') serve-port := 4008 -spago-build: +build: @spago build create-bundle-entrypoint: @@ -40,20 +40,20 @@ create-html-entrypoint: delete-bundle-entrypoint: @rm -f ./dist/entrypoint.js -esbuild-bundle: spago-build create-bundle-entrypoint +esbuild-bundle: build create-bundle-entrypoint BROWSER_RUNTIME=${browser-runtime} node esbuild/bundle.js ./dist/entrypoint.js dist/index.js @make delete-bundle-entrypoint -esbuild-serve: spago-build create-bundle-entrypoint create-html-entrypoint +esbuild-serve: build create-bundle-entrypoint create-html-entrypoint BROWSER_RUNTIME=1 node esbuild/serve.js ./dist/entrypoint.js dist/index.js dist/ ${serve-port} -webpack-bundle: spago-build create-bundle-entrypoint +webpack-bundle: build create-bundle-entrypoint BROWSER_RUNTIME=${browser-runtime} webpack --mode=production \ -o dist/ --env entry=./dist/entrypoint.js @make delete-bundle-entrypoint -webpack-serve: spago-build create-bundle-entrypoint create-html-entrypoint +webpack-serve: build create-bundle-entrypoint create-html-entrypoint BROWSER_RUNTIME=1 webpack-dev-server --progress \ --port ${serve-port} \ -o dist/ --env entry=./dist/entrypoint.js diff --git a/templates/ctl-scaffold/exe/Main.purs b/templates/ctl-scaffold/exe/Main.purs index 09189eb35e..265a327543 100644 --- a/templates/ctl-scaffold/exe/Main.purs +++ b/templates/ctl-scaffold/exe/Main.purs @@ -18,5 +18,5 @@ contractParams :: Contract.Config.ContractParams contractParams = Contract.Config.testnetConfig { walletSpec = - Just $ Contract.Config.ConnectToGenericCip30 "nami" { cip95: false } + Just $ Contract.Config.ConnectToGenericCip30 "eternl" { cip95: false } } diff --git a/templates/ctl-scaffold/flake.lock b/templates/ctl-scaffold/flake.lock index 2026f8e8c3..820c395eb6 100644 --- a/templates/ctl-scaffold/flake.lock +++ b/templates/ctl-scaffold/flake.lock @@ -1905,17 +1905,17 @@ "ogmios": "ogmios_2" }, "locked": { - "lastModified": 1740649000, - "narHash": "sha256-8KRWLIZjKiRJg7wv9vWybUIa5A7RS1tgJEQBqUXCDns=", + "lastModified": 1741366419, + "narHash": "sha256-xkBdgMSgKyXhE+p6oXUpT6ogk61sAdEJCs5gKaHOGgY=", "owner": "Plutonomicon", "repo": "cardano-transaction-lib", - "rev": "f932fd33aa328b28d529ef6b97fa0edf4b91371c", + "rev": "87f509e8f426f5fc52b4093f7c77bf9e742f4f1b", "type": "github" }, "original": { "owner": "Plutonomicon", "repo": "cardano-transaction-lib", - "rev": "f932fd33aa328b28d529ef6b97fa0edf4b91371c", + "rev": "87f509e8f426f5fc52b4093f7c77bf9e742f4f1b", "type": "github" } }, diff --git a/templates/ctl-scaffold/flake.nix b/templates/ctl-scaffold/flake.nix index 6f0dc8227a..680b5c18b4 100644 --- a/templates/ctl-scaffold/flake.nix +++ b/templates/ctl-scaffold/flake.nix @@ -16,7 +16,7 @@ type = "github"; owner = "Plutonomicon"; repo = "cardano-transaction-lib"; - rev = "f932fd33aa328b28d529ef6b97fa0edf4b91371c"; + rev = "87f509e8f426f5fc52b4093f7c77bf9e742f4f1b"; }; # To use the same version of `nixpkgs` as we do nixpkgs.follows = "ctl/nixpkgs"; diff --git a/templates/ctl-scaffold/package.json b/templates/ctl-scaffold/package.json index 3fb7714cf3..0ca029c041 100644 --- a/templates/ctl-scaffold/package.json +++ b/templates/ctl-scaffold/package.json @@ -12,9 +12,9 @@ "test": "spago run --main Test.Scaffold.Main", "blockfrost-test": "source ./test/blockfrost.env && spago run --main Scaffold.Test.Blockfrost", "blockfrost-local-test": "source ./test/blockfrost-local.env && spago run --main Scaffold.Test.Blockfrost", - "e2e-serve": "make e2e-serve", + "e2e-serve": "make esbuild-serve", "start-runtime": "nix run -L .#ctl-scaffold-runtime", - "e2e-test": "source ./test/e2e.env && spago test --main Scaffold.Test.E2E -a 'e2e-test run'", + "e2e-test": "source ./test/e2e.env && spago test --main Scaffold.Test.E2E -a 'run'", "e2e-test-debug": "source ./test/e2e.env && spago test --main Scaffold.Test.E2E -a 'e2e-test run --no-headless'", "e2e-browser": "source ./test/e2e.env && spago run --main Scaffold.Test.E2E -a 'e2e-test browser'", "e2e-pack-settings": "source ./test/e2e.env && spago run --main Scaffold.Test.E2E -a 'e2e-test pack'", diff --git a/templates/ctl-scaffold/packages.dhall b/templates/ctl-scaffold/packages.dhall index 02452e2677..060c3636d8 100644 --- a/templates/ctl-scaffold/packages.dhall +++ b/templates/ctl-scaffold/packages.dhall @@ -111,7 +111,7 @@ let additions = , "web-storage" ] , repo = "https://github.com/Plutonomicon/cardano-transaction-lib.git" - , version = "f932fd33aa328b28d529ef6b97fa0edf4b91371c" + , version = "87f509e8f426f5fc52b4093f7c77bf9e742f4f1b" } } diff --git a/templates/ctl-scaffold/spago-packages.nix b/templates/ctl-scaffold/spago-packages.nix index 8245a6e8fd..7b99a91b00 100644 --- a/templates/ctl-scaffold/spago-packages.nix +++ b/templates/ctl-scaffold/spago-packages.nix @@ -319,11 +319,11 @@ let "cardano-transaction-lib" = pkgs.stdenv.mkDerivation { name = "cardano-transaction-lib"; - version = "f932fd33aa328b28d529ef6b97fa0edf4b91371c"; + version = "87f509e8f426f5fc52b4093f7c77bf9e742f4f1b"; src = pkgs.fetchgit { url = "https://github.com/Plutonomicon/cardano-transaction-lib.git"; - rev = "f932fd33aa328b28d529ef6b97fa0edf4b91371c"; - sha256 = "0yqfq92sj0a44ih5njyi1vj1lhkdnbszcbxwhd4j8ak3hqn5d97h"; + rev = "87f509e8f426f5fc52b4093f7c77bf9e742f4f1b"; + sha256 = "01hsrshjjq6f184x20bcmn9j1ajg55ss2ypa2ghjaax0qj05sh66"; }; phases = "installPhase"; installPhase = "ln -s $src $out"; diff --git a/templates/ctl-scaffold/spago.dhall b/templates/ctl-scaffold/spago.dhall index e726079d22..cbb25caceb 100644 --- a/templates/ctl-scaffold/spago.dhall +++ b/templates/ctl-scaffold/spago.dhall @@ -5,20 +5,21 @@ You can edit this file as you like. { name = "ctl-package-example" , dependencies = [ "aff" + , "bifunctors" , "bytearrays" - , "cardano-hd-wallet" - , "cardano-plutus-data-schema" , "cardano-collateral-select" + , "cardano-hd-wallet" , "cardano-key-wallet" , "cardano-message-signing" - , "cip30-mock" - , "uplc-apply-args" + , "cardano-plutus-data-schema" , "cardano-serialization-lib" , "cardano-transaction-builder" , "cardano-transaction-lib" , "cardano-types" + , "cip30-mock" , "datetime" , "effect" + , "exceptions" , "js-bigints" , "maybe" , "mote" @@ -30,6 +31,7 @@ You can edit this file as you like. , "prelude" , "safely" , "spec" + , "uplc-apply-args" ] , packages = ./packages.dhall , sources = [ "src/**/*.purs", "exe/**/*.purs", "test/**/*.purs" ] diff --git a/templates/ctl-scaffold/test/E2E.purs b/templates/ctl-scaffold/test/E2E.purs index acf0922dca..6d67e3a3dc 100644 --- a/templates/ctl-scaffold/test/E2E.purs +++ b/templates/ctl-scaffold/test/E2E.purs @@ -3,47 +3,40 @@ module Scaffold.Test.E2E.Serve where import Contract.Prelude -import Contract.Config - ( ContractParams - , KnownWallet(Nami, Gero, Flint, Eternl, Lode) - , WalletSpec(ConnectToGenericCip30) - , testnetConfig - , walletName - ) +import Contract.Config (ContractParams) import Contract.Monad (Contract) -import Contract.Test.E2E (E2EConfigName, E2ETestName, addLinks, route) +import Contract.Test.E2E + ( E2EConfigName + , E2ETestName + , addLinks + , e2eConfigs + , route + ) +import Data.Bifunctor (lmap) import Data.Map (Map) import Data.Map as Map +import Effect.Exception (error) import Scaffold as Scaffold main :: Effect Unit main = do + configs <- liftEither $ lmap error mkConfigs addLinks configs tests route configs tests -configs :: Map E2EConfigName (ContractParams /\ Maybe String) -configs = map (map walletName) <$> Map.fromFoldable - [ "nami" /\ testnetConfig' Nami /\ Nothing - , "gero" /\ testnetConfig' Gero /\ Nothing - , "flint" /\ testnetConfig' Flint /\ Nothing - , "eternl" /\ testnetConfig' Eternl /\ Nothing - , "lode" /\ testnetConfig' Lode /\ Nothing - , "nami-mock" /\ testnetConfig' Nami /\ Just Nami - , "gero-mock" /\ testnetConfig' Gero /\ Just Gero - , "flint-mock" /\ testnetConfig' Flint /\ Just Flint - , "lode-mock" /\ testnetConfig' Lode /\ Just Lode - , "plutip-nami-mock" /\ testnetConfig' Nami /\ Just Nami - , "plutip-gero-mock" /\ testnetConfig' Gero /\ Just Gero - , "plutip-flint-mock" /\ testnetConfig' Flint /\ Just Flint - , "plutip-lode-mock" /\ testnetConfig' Lode /\ Just Lode - ] - where - testnetConfig' :: KnownWallet -> ContractParams - testnetConfig' wallet = - testnetConfig - { walletSpec = - Just $ ConnectToGenericCip30 (walletName wallet) { cip95: false } - } +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 diff --git a/templates/ctl-scaffold/test/e2e.env b/templates/ctl-scaffold/test/e2e.env index 1ecc9a1c77..045ad81833 100644 --- a/templates/ctl-scaffold/test/e2e.env +++ b/templates/ctl-scaffold/test/e2e.env @@ -12,11 +12,10 @@ export E2E_TESTS=" # possibility of problems caused by concurrent spending with other users. # CTL team cannot guarantee that the default address will always have funds on # the public testnet. -http://localhost:4008/?nami-mock:Contract:58200b07c066ba037344acee5431e6df41f6034bf1c5ffd6f803751e356807c6a209:5820f0db841df6c7fbc4506c58fad6676db0354a02dfd26efca445715a8adeabc338 -plutip:http://localhost:4008/?plutip-nami-mock:Contract +http://localhost:4008/?eternl-mock:Contract:58200b07c066ba037344acee5431e6df41f6034bf1c5ffd6f803751e356807c6a209:5820f0db841df6c7fbc4506c58fad6676db0354a02dfd26efca445715a8adeabc338 +localnet:http://localhost:4008/?localnet-eternl-mock:Contract # These tests use real wallets -nami:http://localhost:4008/?nami:Contract gero:http://localhost:4008/?gero:Contract lode:http://localhost:4008/?lode:Contract eternl:http://localhost:4008/?eternl:Contract @@ -47,11 +46,6 @@ export LODE_CRX_URL="https://github.com/mlabs-haskell/ctl-e2e-assets/releases/do export LODE_PASSWORD=ctlctlctl export LODE_EXTID=glajohhncdfhgdjglmfnoijpdibocada -export NAMI_CRX="test-data/preview/extensions/nami.crx" -export NAMI_CRX_URL="https://github.com/mlabs-haskell/ctl-e2e-assets/releases/download/preview-1/preview-nami-3.4.1_0.crx" -export NAMI_PASSWORD=ctlctlctl -export NAMI_EXTID=lpfcbjknijpeeillifnkikgncikgfhdo - export GERO_CRX="test-data/preview/extensions/gero.crx" export GERO_CRX_URL="https://github.com/mlabs-haskell/ctl-e2e-assets/releases/download/preview-1/preview-gero-1.11.3.crx" export GERO_PASSWORD=VZVfu5rp1rVZVfu5rp1r diff --git a/test/Testnet/Contract.purs b/test/Testnet/Contract.purs index 7bf1b3d658..852a4235a3 100644 --- a/test/Testnet/Contract.purs +++ b/test/Testnet/Contract.purs @@ -50,7 +50,10 @@ import Contract.BalanceTxConstraints , mustUseCollateralUtxos ) import Contract.Chain (currentTime, waitUntilSlot) -import Contract.Config (KnownWallet(Nami, Gero, Flint, Lode, NuFi), walletName) +import Contract.Config + ( KnownWallet(Eternl, Gero, Lode, NuFi) + , walletName + ) import Contract.Hashing (datumHash, nativeScriptHash) import Contract.Keys (privateKeyFromBytes) import Contract.Log (logInfo') @@ -1855,13 +1858,6 @@ suite = do , BigNum.fromInt 50_000_000 ] withWallets distribution \alice -> do - - let nami = walletName Nami - withCip30Mock alice nami do - (liftEffect $ isWalletAvailable nami) >>= shouldEqual true - try (liftEffect $ isWalletAvailable nami) >>= hush >>> shouldEqual - (Just false) - let gerowallet = walletName Gero withCip30Mock alice gerowallet do (liftEffect $ isWalletAvailable gerowallet) >>= shouldEqual true @@ -1869,13 +1865,6 @@ suite = do shouldEqual (Just false) - let flint = walletName Flint - withCip30Mock alice flint do - (liftEffect $ isWalletAvailable flint) >>= shouldEqual true - try (liftEffect $ isWalletAvailable flint) >>= hush >>> - shouldEqual - (Just false) - let nufi = walletName NuFi withCip30Mock alice nufi do (liftEffect $ isWalletAvailable nufi) >>= shouldEqual true @@ -1897,7 +1886,7 @@ suite = do , BigNum.fromInt 50_000_000 ] withWallets distribution \alice -> do - withCip30Mock alice (walletName Nami) do + withCip30Mock alice (walletName Eternl) do getWalletCollateral >>= liftEffect <<< case _ of Nothing -> throw "Unable to get collateral" Just @@ -1920,7 +1909,7 @@ suite = do , BigNum.fromInt 50_000_000 ] withWallets distribution \alice -> do - utxos <- withCip30Mock alice (walletName Nami) do + utxos <- withCip30Mock alice (walletName Eternl) do getWalletUtxos utxos `shouldSatisfy` isJust @@ -1932,7 +1921,7 @@ suite = do , BigNum.fromInt 50_000_000 ] withWallets distribution \alice -> do - mockAddress <- withCip30Mock alice (walletName Nami) do + mockAddress <- withCip30Mock alice (walletName Eternl) do mbAddr <- head <$> getWalletAddresses mbAddr `shouldSatisfy` isJust pure mbAddr @@ -1948,7 +1937,7 @@ suite = do , BigNum.fromInt 50_000_000 ] withWallets distribution \alice -> do - withCip30Mock alice (walletName Nami) do + withCip30Mock alice (walletName Eternl) do pkh <- liftedM "Failed to get PKH" $ head <$> ownPaymentPubKeyHashes stakePkh <- join <<< head <$> ownStakePubKeyHashes @@ -1966,7 +1955,7 @@ suite = do getWalletBalance >>= shouldEqual ( Just $ coinToValue $ Coin $ BigNum.fromInt 1_050_000_000 ) - withCip30Mock alice (walletName Nami) do + withCip30Mock alice (walletName Eternl) do getWalletBalance >>= shouldEqual ( Just $ coinToValue $ Coin $ BigNum.fromInt 1_050_000_000 ) @@ -1980,7 +1969,7 @@ suite = do , BigNum.fromInt 1_000_000 ] withWallets distribution \alice -> do - withCip30Mock alice (walletName Nami) do + withCip30Mock alice (walletName Eternl) do getWalletBalance >>= flip shouldSatisfy (eq $ Just $ coinToValue $ Coin $ BigNum.fromInt 8_000_000) @@ -1996,7 +1985,7 @@ suite = do , drepKey: Just privateDrepKey } withWallets walletSpec \alice -> - withCip30Mock alice (walletName Nami) $ + withCip30Mock alice (walletName Eternl) $ ownDrepPubKey `shouldReturn` PrivateKey.toPublicKey (unwrap privateDrepKey) @@ -2012,7 +2001,7 @@ suite = do , drepKey: Just privateDrepKey } withWallets walletSpec \alice -> - withCip30Mock alice (walletName Nami) $ + withCip30Mock alice (walletName Eternl) $ ownDrepPubKeyHash `shouldReturn` PublicKey.hash (PrivateKey.toPublicKey $ unwrap privateDrepKey) @@ -2028,7 +2017,7 @@ suite = do , drepKey: Nothing } withWallets walletSpec \alice -> - withCip30Mock alice (walletName Nami) $ + withCip30Mock alice (walletName Eternl) $ ownRegisteredPubStakeKeys `shouldReturn` mempty test "ownUnregisteredPubStakeKeys works" do @@ -2043,7 +2032,7 @@ suite = do , drepKey: Nothing } withWallets walletSpec \alice -> - withCip30Mock alice (walletName Nami) $ + withCip30Mock alice (walletName Eternl) $ ownUnregisteredPubStakeKeys `shouldReturn` Array.singleton (PrivateKey.toPublicKey $ unwrap privateStakeKey) @@ -2059,7 +2048,7 @@ suite = do , drepKey: Just privateDrepKey } withWallets walletSpec \alice -> - withCip30Mock alice (walletName Nami) do + withCip30Mock alice (walletName Eternl) do networkId <- getNetworkId drepCred <- wrap <<< PubKeyHashCredential <$> ownDrepPubKeyHash let @@ -2076,9 +2065,9 @@ suite = do ] withWallets (distribution /\ distribution) \(alice /\ bob) -> do bobAddr <- - withCip30Mock bob (walletName Nami) do + withCip30Mock bob (walletName Eternl) do liftedM "Could not get Bob's address" (head <$> getWalletAddresses) - withCip30Mock alice (walletName Nami) do + withCip30Mock alice (walletName Eternl) do expectError $ signData bobAddr mempty test "CIP-30 utilities" do @@ -2089,7 +2078,7 @@ suite = do , BigNum.fromInt 50_000_000 ] withWallets distribution \alice -> do - withCip30Mock alice (walletName Nami) do + withCip30Mock alice (walletName Eternl) do Cip30.contract test "ECDSA example" do @@ -2102,7 +2091,7 @@ suite = do , BigNum.fromInt 2_000_000_000 ] withWallets distribution \alice -> do - withCip30Mock alice (walletName Nami) $ ECDSA.contract + withCip30Mock alice (walletName Eternl) $ ECDSA.contract group "CIP-49 Plutus Crypto Primitives" do test "ECDSA: a script that checks if a signature is correct" do diff --git a/test/e2e-ci.env b/test/e2e-ci.env index 54a8bc2e86..8d47c79daf 100644 --- a/test/e2e-ci.env +++ b/test/e2e-ci.env @@ -1,14 +1,14 @@ export E2E_TESTS=" -# Plutip tests are executed on a temporary cluster started by the test engine -plutip:http://localhost:4008/?plutip-nami-mock:OneShotMinting -plutip:http://localhost:4008/?plutip-nami-mock:SignMultiple -plutip:http://localhost:4008/?plutip-nami-mock:AlwaysSucceeds -plutip:http://localhost:4008/?plutip-nami-mock:AlwaysSucceedsV2 -plutip:http://localhost:4008/?plutip-nami-mock:AlwaysMints -plutip:http://localhost:4008/?plutip-nami-mock:Pkh2Pkh -plutip:http://localhost:4008/?plutip-nami-mock:SendsToken -plutip:http://localhost:4008/?plutip-nami-mock:MintsMultipleTokens -plutip:http://localhost:4008/?plutip-nami-mock:Schnorr -plutip:http://localhost:4008/?plutip-nami-mock:ECDSA -plutip:http://localhost:4008/?plutip-nami-mock:ApplyArgs +# cardano-testnet (localnet) tests are executed on a temporary cluster started by the test engine +localnet:http://localhost:4008/?localnet-eternl-mock:OneShotMinting +localnet:http://localhost:4008/?localnet-eternl-mock:SignMultiple +localnet:http://localhost:4008/?localnet-eternl-mock:AlwaysSucceeds +localnet:http://localhost:4008/?localnet-eternl-mock:AlwaysSucceedsV2 +localnet:http://localhost:4008/?localnet-eternl-mock:AlwaysMints +localnet:http://localhost:4008/?localnet-eternl-mock:Pkh2Pkh +localnet:http://localhost:4008/?localnet-eternl-mock:SendsToken +localnet:http://localhost:4008/?localnet-eternl-mock:MintsMultipleTokens +localnet:http://localhost:4008/?localnet-eternl-mock:Schnorr +localnet:http://localhost:4008/?localnet-eternl-mock:ECDSA +localnet:http://localhost:4008/?localnet-eternl-mock:ApplyArgs " diff --git a/test/e2e.env b/test/e2e.env index 8b0cc2d87f..45040052b1 100755 --- a/test/e2e.env +++ b/test/e2e.env @@ -1,45 +1,29 @@ export E2E_TESTS=" -# Plutip tests are executed on a temporary cluster started by the test engine -plutip:http://localhost:4008/?plutip-nami-mock:Schnorr -plutip:http://localhost:4008/?plutip-nami-mock:ECDSA -plutip:http://localhost:4008/?plutip-nami-mock:OneShotMinting -plutip:http://localhost:4008/?plutip-nami-mock:SignMultiple -plutip:http://localhost:4008/?plutip-nami-mock:AlwaysSucceeds -plutip:http://localhost:4008/?plutip-nami-mock:AlwaysSucceedsV2 -plutip:http://localhost:4008/?plutip-nami-mock:AlwaysMints -plutip:http://localhost:4008/?plutip-nami-mock:Pkh2Pkh -plutip:http://localhost:4008/?plutip-nami-mock:SendsToken -plutip:http://localhost:4008/?plutip-nami-mock:MintsMultipleTokens +# cardano-testnet (localnet) tests are executed on a temporary cluster started by the test engine +localnet:http://localhost:4008/?localnet-eternl-mock:Schnorr +localnet:http://localhost:4008/?localnet-eternl-mock:ECDSA +localnet:http://localhost:4008/?localnet-eternl-mock:OneShotMinting +localnet:http://localhost:4008/?localnet-eternl-mock:SignMultiple +localnet:http://localhost:4008/?localnet-eternl-mock:AlwaysSucceeds +localnet:http://localhost:4008/?localnet-eternl-mock:AlwaysSucceedsV2 +localnet:http://localhost:4008/?localnet-eternl-mock:AlwaysMints +localnet:http://localhost:4008/?localnet-eternl-mock:Pkh2Pkh +localnet:http://localhost:4008/?localnet-eternl-mock:SendsToken +localnet:http://localhost:4008/?localnet-eternl-mock:MintsMultipleTokens # This test does not depend on wallets, we only check that bundling is correct -plutip:http://localhost:4008/?plutip-nami-mock:ApplyArgs -# If you add plutip tests above, please also add them to ./e2e-ci.env - -nami:http://localhost:4008/?nami:Schnorr -nami:http://localhost:4008/?nami:ECDSA -nami:http://localhost:4008/?nami:SignMultiple -nami:http://localhost:4008/?nami:AlwaysMints -nami:http://localhost:4008/?nami:Pkh2Pkh -nami:http://localhost:4008/?nami:SendsToken -nami:http://localhost:4008/?nami:MintsMultipleTokens -nami:http://localhost:4008/?nami:OneShotMinting - -# These two will fail with a timeout, because Nami has a bug that results in a -# 'signature not possible' error. -# https://github.com/berry-pool/nami/issues/757 -# nami:http://localhost:4008/?nami:AlwaysSucceeds -# nami:http://localhost:4008/?nami:AlwaysSucceedsV2 - +localnet:http://localhost:4008/?localnet-eternl-mock:ApplyArgs +# If you add localnet tests above, please also add them to ./e2e-ci.env # Uncomment these to test with Blockfrost. # Run 'npm run e2e-browser' for instructions on how to set up the API key -# nami:http://localhost:4008/?blockfrost-nami-preview:Schnorr -# nami:http://localhost:4008/?blockfrost-nami-preview:ECDSA -# nami:http://localhost:4008/?blockfrost-nami-preview:SignMultiple -# nami:http://localhost:4008/?blockfrost-nami-preview:AlwaysMints -# nami:http://localhost:4008/?blockfrost-nami-preview:Pkh2Pkh -# nami:http://localhost:4008/?blockfrost-nami-preview:SendsToken -# nami:http://localhost:4008/?blockfrost-nami-preview:MintsMultipleTokens -# nami:http://localhost:4008/?blockfrost-nami-preview:OneShotMinting +# eternl:http://localhost:4008/?blockfrost-eternl-preview:Schnorr +# eternl:http://localhost:4008/?blockfrost-eternl-preview:ECDSA +# eternl:http://localhost:4008/?blockfrost-eternl-preview:SignMultiple +# eternl:http://localhost:4008/?blockfrost-eternl-preview:AlwaysMints +# eternl:http://localhost:4008/?blockfrost-eternl-preview:Pkh2Pkh +# eternl:http://localhost:4008/?blockfrost-eternl-preview:SendsToken +# eternl:http://localhost:4008/?blockfrost-eternl-preview:MintsMultipleTokens +# eternl:http://localhost:4008/?blockfrost-eternl-preview:OneShotMinting gero:http://localhost:4008/?gero:Schnorr gero:http://localhost:4008/?gero:ECDSA @@ -84,15 +68,13 @@ export E2E_CHROME_USER_DATA=test-data/chrome-user-data export E2E_SETTINGS_ARCHIVE=test-data/preview/settings.tar.gz export E2E_SETTINGS_ARCHIVE_URL="https://github.com/mlabs-haskell/ctl-e2e-assets/releases/download/preview-1/preview-settings.tar.gz" - export E2E_TEST_TIMEOUT=200 export E2E_BROWSER=chromium export E2E_NO_HEADLESS=true export E2E_PASS_BROWSER_LOGS=false export E2E_EXTRA_BROWSER_ARGS="--disable-web-security" # Bypass CORS for Kupo -# Port numbers used by services when testing with Plutip -export PLUTIP_PORT=8087 +# Port numbers used by services when testing with cardano-testnet (localnet) export OGMIOS_PORT=1345 export ETERNL_CRX="test-data/preview/extensions/eternl.crx" @@ -105,16 +87,6 @@ export LODE_CRX_URL="https://github.com/mlabs-haskell/ctl-e2e-assets/releases/do export LODE_PASSWORD=ctlctlctl export LODE_EXTID=glajohhncdfhgdjglmfnoijpdibocada -export NAMI_CRX="test-data/preview/extensions/nami.crx" -export NAMI_CRX_URL="https://github.com/mlabs-haskell/ctl-e2e-assets/releases/download/preview-1/preview-nami-3.4.1_0.crx" -export NAMI_PASSWORD=ctlctlctl -export NAMI_EXTID=lpfcbjknijpeeillifnkikgncikgfhdo - -# export FLINT_CRX="test-data/preview/extensions/flint.crx" -# export FLINT_CRX_URL="" -# export FLINT_PASSWORD=VZVfu5rp1r -# export FLINT_EXTID=hnhobjmcibchnmglfbldbfabcgaknlkj - export GERO_CRX="test-data/preview/extensions/gero.crx" export GERO_CRX_URL="https://github.com/mlabs-haskell/ctl-e2e-assets/releases/download/preview-1/preview-gero-1.11.3.crx" export GERO_PASSWORD=VZVfu5rp1rVZVfu5rp1r