From 8c9106a908ac8e25efee876b14a525f0cdf2ec07 Mon Sep 17 00:00:00 2001 From: Szabo Gergely Date: Thu, 14 Jul 2022 16:01:00 +0200 Subject: [PATCH 1/3] Update cardano-wallet to latest --- flake.lock | 70 ++++++++++++++++++++++++++++++++++-------------------- flake.nix | 25 +++++++++++++------ 2 files changed, 62 insertions(+), 33 deletions(-) diff --git a/flake.lock b/flake.lock index 144622b5..b46685f4 100644 --- a/flake.lock +++ b/flake.lock @@ -155,34 +155,34 @@ "cardano-ledger": { "flake": false, "locked": { - "lastModified": 1655762257, - "narHash": "sha256-SaMhULHXgY0FiSKWc2dAYlgtbfPaFh/bUTgGqoNnMqY=", + "lastModified": 1657127204, + "narHash": "sha256-4wcSA61TwoDTvJ6rx7tjEAJjQLO/cs8WGTHcOghNdTc=", "owner": "input-output-hk", "repo": "cardano-ledger", - "rev": "ce3057e0863304ccb3f79d78c77136219dc786c6", + "rev": "3be8a19083fc13d9261b1640e27dd389b51bb08e", "type": "github" }, "original": { "owner": "input-output-hk", "repo": "cardano-ledger", - "rev": "ce3057e0863304ccb3f79d78c77136219dc786c6", + "rev": "3be8a19083fc13d9261b1640e27dd389b51bb08e", "type": "github" } }, "cardano-node": { "flake": false, "locked": { - "lastModified": 1656166930, - "narHash": "sha256-R7YGQ6UMG16ed9sGguDWq2cUgFnADeRdx8O2s2HqWRk=", + "lastModified": 1657227628, + "narHash": "sha256-CP58qcHZJGYq1FzXCj8ll085TvnJoYMeXnVGVGLYH/w=", "owner": "input-output-hk", "repo": "cardano-node", - "rev": "9f1d7dc163ee66410d912e48509d6a2300cfa68a", + "rev": "c75451f0ffd7a60b5ad6c4263891e6c8acac105a", "type": "github" }, "original": { "owner": "input-output-hk", - "ref": "1.35.0", "repo": "cardano-node", + "rev": "c75451f0ffd7a60b5ad6c4263891e6c8acac105a", "type": "github" } }, @@ -222,17 +222,17 @@ "cardano-wallet": { "flake": false, "locked": { - "lastModified": 1656432713, - "narHash": "sha256-ncoAaIPWRhJ2FShesmrp4q5LK1PtWuzqOKuhlwerWac=", + "lastModified": 1657745277, + "narHash": "sha256-+PrfQH6m7ROpHKNyo54MzLrL31tIvSZUQYnbBT70ekc=", "owner": "input-output-hk", "repo": "cardano-wallet", - "rev": "a73d8c9717dc4e174745f8568d6f3fe84f0f9d76", + "rev": "2ac308b00d9d4a3435f6b9594ded9495e2b217eb", "type": "github" }, "original": { "owner": "input-output-hk", "repo": "cardano-wallet", - "rev": "a73d8c9717dc4e174745f8568d6f3fe84f0f9d76", + "rev": "2ac308b00d9d4a3435f6b9594ded9495e2b217eb", "type": "github" } }, @@ -482,17 +482,17 @@ "hysterical-screams": { "flake": false, "locked": { - "lastModified": 1653758250, - "narHash": "sha256-NLgHKpCFPExmm6YgQwbsTf0/LhgQNp2iPrzv8PWgyes=", + "lastModified": 1654007733, + "narHash": "sha256-d4N3rUzg45BUs5Lx/kK7vXYsLMNoO15dlzo7t8lGIXA=", "owner": "raduom", "repo": "hysterical-screams", - "rev": "f3bbd38a19f99de5c8ddc650c94330b2d09a865b", + "rev": "4c523469e9efd3f0d10d17da3304923b7b0e0674", "type": "github" }, "original": { "owner": "raduom", "repo": "hysterical-screams", - "rev": "f3bbd38a19f99de5c8ddc650c94330b2d09a865b", + "rev": "4c523469e9efd3f0d10d17da3304923b7b0e0674", "type": "github" } }, @@ -747,34 +747,34 @@ "plutus": { "flake": false, "locked": { - "lastModified": 1655404007, - "narHash": "sha256-8ZCD/f321fFs8k+FBfxnpYlm1+C+rKM8Io9K0CDCEqA=", + "lastModified": 1656585904, + "narHash": "sha256-ATwDR5LX2RN9YfoPhTxV7REvFoJnM4x/CN9XZVZlalg=", "owner": "input-output-hk", "repo": "plutus", - "rev": "f680ac6979e069fcc013e4389ee607ff5fa6672f", + "rev": "69ab98c384703172f898eb5bcad1078ded521426", "type": "github" }, "original": { "owner": "input-output-hk", "repo": "plutus", - "rev": "f680ac6979e069fcc013e4389ee607ff5fa6672f", + "rev": "69ab98c384703172f898eb5bcad1078ded521426", "type": "github" } }, "plutus-apps": { "flake": false, "locked": { - "lastModified": 1656024944, - "narHash": "sha256-uUM0aTHvZ2LRos+XhU329ElNyL4wvnHU4hcjsc+Q0TQ=", - "owner": "input-output-hk", + "lastModified": 1657805529, + "narHash": "sha256-b/cDxN3e1TQMDlYmDlUIS53eSxeMPq7YtlUdJOpgV50=", + "owner": "gege251", "repo": "plutus-apps", - "rev": "c2b310968d0915e2af0ea4680186b41ad88ffbe9", + "rev": "59e269d3a2bc66ab99b0070d16c81dc13636f9c4", "type": "github" }, "original": { - "owner": "input-output-hk", + "owner": "gege251", "repo": "plutus-apps", - "rev": "c2b310968d0915e2af0ea4680186b41ad88ffbe9", + "rev": "59e269d3a2bc66ab99b0070d16c81dc13636f9c4", "type": "github" } }, @@ -795,6 +795,23 @@ "type": "github" } }, + "quickcheck-dynamic": { + "flake": false, + "locked": { + "lastModified": 1656927450, + "narHash": "sha256-TioJQASNrQX6B3n2Cv43X2olyT67//CFQqcpvNW7N60=", + "owner": "input-output-hk", + "repo": "quickcheck-dynamic", + "rev": "c272906361471d684440f76c297e29ab760f6a1e", + "type": "github" + }, + "original": { + "owner": "input-output-hk", + "repo": "quickcheck-dynamic", + "rev": "c272906361471d684440f76c297e29ab760f6a1e", + "type": "github" + } + }, "root": { "inputs": { "Win32-network": "Win32-network", @@ -827,6 +844,7 @@ "plutus": "plutus", "plutus-apps": "plutus-apps", "purescript-bridge": "purescript-bridge", + "quickcheck-dynamic": "quickcheck-dynamic", "servant-purescript": "servant-purescript", "typed-protocols": "typed-protocols" } diff --git a/flake.nix b/flake.nix index 7875f531..5ed8ec2b 100644 --- a/flake.nix +++ b/flake.nix @@ -37,12 +37,12 @@ }; cardano-ledger = { url = - "github:input-output-hk/cardano-ledger/ce3057e0863304ccb3f79d78c77136219dc786c6"; + "github:input-output-hk/cardano-ledger/3be8a19083fc13d9261b1640e27dd389b51bb08e"; flake = false; }; cardano-node = { url = - "github:input-output-hk/cardano-node/1.35.0"; + "github:input-output-hk/cardano-node/c75451f0ffd7a60b5ad6c4263891e6c8acac105a"; flake = false; # we need it to be available in shell }; cardano-prelude = { @@ -51,7 +51,7 @@ flake = false; }; cardano-wallet = { - url = "github:input-output-hk/cardano-wallet/a73d8c9717dc4e174745f8568d6f3fe84f0f9d76"; + url = "github:input-output-hk/cardano-wallet/2ac308b00d9d4a3435f6b9594ded9495e2b217eb"; flake = false; }; ekg-forward = { @@ -78,7 +78,7 @@ flake = false; }; hysterical-screams = { - url = "github:raduom/hysterical-screams/f3bbd38a19f99de5c8ddc650c94330b2d09a865b"; + url = "github:raduom/hysterical-screams/4c523469e9efd3f0d10d17da3304923b7b0e0674"; flake = false; }; hw-aeson = { @@ -107,12 +107,12 @@ }; plutus = { url = - "github:input-output-hk/plutus/f680ac6979e069fcc013e4389ee607ff5fa6672f"; + "github:input-output-hk/plutus/69ab98c384703172f898eb5bcad1078ded521426"; flake = false; }; plutus-apps = { url = - "github:input-output-hk/plutus-apps/c2b310968d0915e2af0ea4680186b41ad88ffbe9"; + "github:gege251/plutus-apps/59e269d3a2bc66ab99b0070d16c81dc13636f9c4"; flake = false; }; purescript-bridge = { @@ -120,6 +120,10 @@ "github:input-output-hk/purescript-bridge/47a1f11825a0f9445e0f98792f79172efef66c00"; flake = false; }; + quickcheck-dynamic = { + url = "github:input-output-hk/quickcheck-dynamic/c272906361471d684440f76c297e29ab760f6a1e"; + flake = false; + }; servant-purescript = { url = "github:input-output-hk/servant-purescript/44e7cacf109f84984cd99cd3faf185d161826963"; @@ -206,6 +210,7 @@ src = inputs.cardano-ledger; subdirs = [ "eras/alonzo/impl" + "eras/alonzo/test-suite" "eras/babbage/impl" "eras/byron/chain/executable-spec" "eras/byron/crypto" @@ -216,6 +221,7 @@ "eras/shelley/impl" "eras/shelley/test-suite" "eras/shelley-ma/impl" + "eras/shelley-ma/test-suite" "libs/cardano-data" "libs/cardano-ledger-core" "libs/cardano-ledger-pretty" @@ -359,8 +365,9 @@ "plutus-pab" "plutus-playground-server" "plutus-script-utils" + "plutus-streaming" + "plutus-tx-constraints" "plutus-use-cases" - "quickcheck-dynamic" "web-ghc" ]; } @@ -368,6 +375,10 @@ src = inputs.purescript-bridge; subdirs = [ "." ]; } + { + src = inputs.quickcheck-dynamic; + subdirs = [ "." ]; + } { src = inputs.servant-purescript; subdirs = [ "." ]; From 6f3ba0f7da5b6d7c0c878c54cca97addc2c633c5 Mon Sep 17 00:00:00 2001 From: Szabo Gergely Date: Thu, 14 Jul 2022 17:09:58 +0200 Subject: [PATCH 2/3] Address API changes --- src/BotPlutusInterface/Balance.hs | 6 ++++-- src/BotPlutusInterface/CardanoCLI.hs | 4 ++-- src/BotPlutusInterface/Contract.hs | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/BotPlutusInterface/Balance.hs b/src/BotPlutusInterface/Balance.hs index 012ef9fc..4665fc3d 100644 --- a/src/BotPlutusInterface/Balance.hs +++ b/src/BotPlutusInterface/Balance.hs @@ -56,6 +56,7 @@ import Ledger.Tx ( TxOutRef (..), ) import Ledger.Tx qualified as Tx +import Ledger.Tx.CardanoAPI (CardanoBuildTx) import Ledger.Value (Value) import Ledger.Value qualified as Value import Plutus.V1.Ledger.Api ( @@ -394,9 +395,10 @@ addValidRange :: forall (w :: Type) (effs :: [Type -> Type]). Member (PABEffect w) effs => POSIXTimeRange -> - Tx -> + Either CardanoBuildTx Tx -> Eff effs (Either Text Tx) -addValidRange timeRange tx = +addValidRange _ (Left _) = pure $ Left "BPI is not using CardanoBuildTx" +addValidRange timeRange (Right tx) = if validateRange timeRange then bimap (Text.pack . show) (setRange tx) diff --git a/src/BotPlutusInterface/CardanoCLI.hs b/src/BotPlutusInterface/CardanoCLI.hs index 3b57cfee..0e627424 100644 --- a/src/BotPlutusInterface/CardanoCLI.hs +++ b/src/BotPlutusInterface/CardanoCLI.hs @@ -75,7 +75,7 @@ import Ledger.Scripts qualified as Scripts import Ledger.Tx (ChainIndexTxOut, RedeemerPtr (..), Redeemers, ScriptTag (..), Tx (..), TxId (..), TxIn (..), TxInType (..), TxOut (..), TxOutRef (..), txId) import Ledger.Value (Value) import Ledger.Value qualified as Value -import Plutus.Contract.CardanoAPI (toCardanoAddress) +import Ledger.Tx.CardanoAPI (toCardanoAddressInEra) import Plutus.V1.Ledger.Api ( CurrencySymbol (..), ExBudget (..), @@ -399,7 +399,7 @@ valueToCliArg val = unsafeSerialiseAddress :: NetworkId -> Address -> Text unsafeSerialiseAddress network address = - case serialiseAddress <$> toCardanoAddress network address of + case serialiseAddress <$> toCardanoAddressInEra network address of Right a -> a Left _ -> error "Couldn't create address" diff --git a/src/BotPlutusInterface/Contract.hs b/src/BotPlutusInterface/Contract.hs index 38c24ff2..4a99c4c2 100644 --- a/src/BotPlutusInterface/Contract.hs +++ b/src/BotPlutusInterface/Contract.hs @@ -48,6 +48,7 @@ import Data.Aeson.Extras (encodeByteString) import Data.Aeson.KeyMap qualified as KeyMap import Data.Function (fix) import Data.Kind (Type) +import Data.List.NonEmpty (NonEmpty ((:|))) import Data.Map qualified as Map import Data.Row (Row) import Data.Text (Text) @@ -171,8 +172,13 @@ handlePABReq contractEnv req = do ---------------------- -- Handled requests -- ---------------------- - OwnPaymentPublicKeyHashReq -> - pure $ OwnPaymentPublicKeyHashResp $ PaymentPubKeyHash contractEnv.cePABConfig.pcOwnPubKeyHash + OwnAddressesReq -> + pure + . OwnAddressesResp + . nonEmptySingleton + $ Ledger.pubKeyHashAddress + (PaymentPubKeyHash contractEnv.cePABConfig.pcOwnPubKeyHash) + contractEnv.cePABConfig.pcOwnStakePubKeyHash OwnContractInstanceIdReq -> pure $ OwnContractInstanceIdResp (ceContractInstanceId contractEnv) ChainIndexQueryReq query -> @@ -451,3 +457,9 @@ currentTime contractEnv = currentSlot @w contractEnv >>= slotToPOSIXTime @w >>= either (error . show) return + +{- | Construct a 'NonEmpty' list from a single element. + Should be replaced by NonEmpty.singleton after updating to base 4.15 +-} +nonEmptySingleton :: a -> NonEmpty a +nonEmptySingleton = (:| []) From 2808c5e403c37df302742d71125c83a5787d3dec Mon Sep 17 00:00:00 2001 From: Szabo Gergely Date: Mon, 18 Jul 2022 20:48:29 +0200 Subject: [PATCH 3/3] Bump plutus-apps --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 5ed8ec2b..2db0618c 100644 --- a/flake.nix +++ b/flake.nix @@ -112,7 +112,7 @@ }; plutus-apps = { url = - "github:gege251/plutus-apps/59e269d3a2bc66ab99b0070d16c81dc13636f9c4"; + "github:gege251/plutus-apps/62342808fa7422ebea3233a7e031d3aa00c04672"; flake = false; }; purescript-bridge = {