Skip to content

Commit

Permalink
Bump compile time deps
Browse files Browse the repository at this point in the history
- Adjust versions of tree-diff, ansi-wl-pprint, bech32
- wip: fix compilation errors
- Use cardano-addresses with optparse-applicative 0.18.1
- Compilation fixes in BalanceSepec
- Fixes in `Cardano.Api.Gen`
- fixes for balance-tx tests
- Fix and simplify `ErrAssignReedemers`
- Regenerate Wallet CLI goldens
- fixup replaceCosignersWithVerKeys
  • Loading branch information
Anviking committed Jul 9, 2024
1 parent 9701f7a commit f071494
Show file tree
Hide file tree
Showing 15 changed files with 224 additions and 342 deletions.
30 changes: 15 additions & 15 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ repository cardano-haskell-packages
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

-- repeating the index-state for hackage to work around hackage.nix parsing limitation
index-state: 2024-06-04T00:00:00Z
index-state: 2024-06-29T00:00:00Z

index-state:
, hackage.haskell.org 2024-06-04T00:00:00Z
, cardano-haskell-packages 2024-05-29T10:15:00Z
, hackage.haskell.org 2024-06-29T00:00:00Z
, cardano-haskell-packages 2024-06-29T00:00:00Z

packages:
lib/address-derivation-discovery
Expand Down Expand Up @@ -116,9 +116,9 @@ source-repository-package

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-addresses
tag: 126964483d188c2362393d2a6eea8c65dfc43097
--sha256: 1w152imj28ap5dfdc8x9ly0cy7dn500v7k63vw11f70gvgg6x7my
location: https://github.com/Anviking/cardano-addresses
tag: 2bca06deaa60e54a5322ac757387d744bf043367
--sha256: 1y1mzfly7jac40b9g4xc078rcm5zqhc3xxv77kwxi10yph1jwq7z
subdir: command-line
core

Expand Down Expand Up @@ -186,16 +186,14 @@ allow-newer:
, cardano-addresses-cli:mtl
, servant-openapi3:*
, cardano-ledger-alonzo-test:base, plutus-ledger-api
, cardano-crypto-class:vector
, plutus-core:cardano-crypto-class


constraints:
base == 4.18.2.0
base >= 4.18.2.0 && < 5
, bimap >= 0.4.0
, openapi3 >= 3.2.0
, libsystemd-journal >= 1.4.4
, systemd >= 2.3.0
, singletons-th < 3.3
-- dependency of systemd-2.3.0
, network >= 3.1.1.1
-- choose versions that work with base >= 4.12
Expand All @@ -211,14 +209,16 @@ constraints:

-- Cave: This version of `bech32`
-- does not work with optparse-applicative >= 0.18.1.0
, bech32 == 1.1.3
, bech32 >= 1.1.7

-- Cardano Node dependencies:
, any.io-classes ==1.4.1.0
, io-classes >= 1.4
, io-classes -asserts
, any.io-classes-mtl ==0.1.1.0
, optparse-applicative-fork >= 0.18.1
, ouroboros-network ^>= 0.16

, ouroboros-consensus-cardano ^>= 0.17
, ouroboros-network ^>= 0.16.1
, ouroboros-network-protocols ^>= 0.9

-- TH Name shadowing warnings need to be addressed when bumping to 2.13.3.5
, persistent ^>= 2.14.6.0
Expand Down Expand Up @@ -324,4 +324,4 @@ tests: False
-- -------------------------------------------------------------------------

package bitvec
flags: -simd
flags: -simd
30 changes: 18 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ constructAddressFromIx role pTemplate dTemplate ix =
Nothing ->
createEnterpriseAddress pScript

-- | NOTE: The roles 'DRep', 'CCCold', 'CCHot' are not supported.
replaceCosignersWithVerKeys
:: CA.Role
-> ScriptTemplate
Expand Down Expand Up @@ -180,10 +181,22 @@ replaceCosignersWithVerKeys role' (ScriptTemplate xpubs scriptTemplate) ix =
CA.UTxOExternal -> CA.Payment
CA.UTxOInternal -> CA.Payment
CA.Stake -> CA.Delegation
CA.DRep -> unsupportedRole
CA.CCCold -> unsupportedRole
CA.CCHot -> unsupportedRole
deriveMultisigPublicKey accXPub = case role' of
CA.UTxOExternal -> deriveAddressPublicKey accXPub role'
CA.UTxOInternal -> deriveAddressPublicKey accXPub role'
CA.Stake -> deriveDelegationPublicKey accXPub
CA.DRep -> unsupportedRole
CA.CCCold -> unsupportedRole
CA.CCHot -> unsupportedRole

unsupportedRole :: forall a. HasCallStack => a
unsupportedRole = error $ mconcat
[ "replaceCosignersWithVerKeys: unsupported role "
, show role'
]

-- | Convert 'NetworkDiscriminant type parameter to
-- 'Cardano.Address.NetworkTag'.
Expand Down
142 changes: 2 additions & 140 deletions lib/api/src/Cardano/Wallet/Api/Http/Server/Error/AssignReedemers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Wallet.Api.Http.Server.Error.AssignReedemers () where

import Prelude

import Cardano.Ledger.Alonzo.Plutus.TxInfo
( AlonzoContextError (..)
)
import Cardano.Ledger.Babbage.TxInfo
( BabbageContextError (..)
)
import Cardano.Ledger.Conway.TxInfo
( ConwayContextError (..)
)
import Cardano.Wallet.Api.Http.Server.Error.IsServerError
( IsServerError (..)
, apiError
Expand All @@ -32,14 +22,12 @@ import Fmt
)
import Internal.Cardano.Write.Tx
( IsRecentEra (..)
, RecentEra (RecentEraBabbage, RecentEraConway)
)
import Internal.Cardano.Write.Tx.Balance
( ErrAssignRedeemers (..)
)
import Servant.Server
( ServerError
, err400
( err400
)

import qualified Data.Text as T
Expand All @@ -53,7 +41,7 @@ instance IsRecentEra era => IsServerError (ErrAssignRedeemers era) where
, "redeemers:"
, pretty r <> ";"
, "Its execution is failing with the following error:"
, T.pack failure <> "."
, T.pack (show failure) <> "."
]
ErrAssignRedeemersTargetNotFound r ->
apiError err400 RedeemerTargetNotFound
Expand All @@ -72,129 +60,3 @@ instance IsRecentEra era => IsServerError (ErrAssignRedeemers era) where
, "into a valid Plutus data:"
, pretty r <> "."
]
ErrAssignRedeemersTranslationError x -> case recentEra @era of
RecentEraBabbage -> fromBabbageContextError x
RecentEraConway -> fromConwayContextError x

fromAlonzoContextError :: AlonzoContextError era -> ServerError
fromAlonzoContextError = \case
TranslationLogicMissingInput inp ->
apiError err400 UnresolvedInputs
$ T.unwords
[ "The transaction I was given contains inputs I don't know"
, "about. Please ensure all foreign inputs are specified as "
, "part of the API request. The unknown input is:\n\n"
, T.pack $ show inp
]
TimeTranslationPastHorizon t ->
apiError err400 PastHorizon
$ T.unwords
[ "The transaction's validity interval is past the horizon"
, "of safe slot-to-time conversions."
, "This may happen when I know about a future era"
, "which has not yet been confirmed on-chain. Try setting the"
, "bounds of the validity interval to be earlier.\n\n"
, "Here are the full details: " <> t
]

fromBabbageContextError
:: forall era
. IsRecentEra era
=> BabbageContextError era
-> ServerError
fromBabbageContextError = \case
AlonzoContextError e -> fromAlonzoContextError e
ByronTxOutInContext txOut ->
apiError err400 TranslationByronTxOutInContext
$ T.unwords
[ "The transaction I was given contains a Byron-style TxOut"
, "which is not supported when executing Plutus scripts. "
, "The offending TxOut is:\n\n"
, T.pack $ show txOut
]
RedeemerPointerPointsToNothing ptr ->
apiError err400 RedeemerTargetNotFound
$ T.unwords
[ "I was unable to resolve one of your redeemers to the location"
, "indicated in the request payload:"
, T.pack $ show ptr
, "Please double-check both your serialised transaction and"
, "the provided redeemers."
]
InlineDatumsNotSupported x ->
apiError err400 RedeemerInvalidData
$ T.unwords
[ "Inline datum is not supported in Plutus V1"
, "The offending data is:\n\n"
, T.pack $ show x
]
ReferenceScriptsNotSupported x ->
apiError err400 RedeemerScriptFailure
$ T.unwords
[ "Reference scripts are not supported in Plutus V1"
, "The offending script is:\n\n"
, T.pack $ show x
]
ReferenceInputsNotSupported x ->
apiError err400 UnresolvedInputs
$ T.unwords
[ "Reference inputs are not supported in Plutus V1"
, "The offending input is:\n\n"
, T.pack $ show x
]

fromConwayContextError
:: forall era
. IsRecentEra era
=> ConwayContextError era
-> ServerError
fromConwayContextError = \case
BabbageContextError e -> fromBabbageContextError e
CertificateNotSupported x ->
apiError err400 UnsupportedMediaType
$ T.unwords
[ "The transaction I was given contains a certificate which"
, "is not supported in the current era."
, "The offending certificate is:\n\n"
, T.pack $ show x
]
PlutusPurposeNotSupported x ->
apiError err400 UnsupportedMediaType
$ T.unwords
[ "The transaction I was given contains a Plutus script"
, "which is not supported in the current era."
, "The offending script is:\n\n"
, T.pack $ show x
]
CurrentTreasuryFieldNotSupported x ->
apiError err400 UnsupportedMediaType
$ T.unwords
[ "The transaction I was given contains a current treasury"
, "which is not supported in the current era."
, "The offending treasury is:\n\n"
, T.pack $ show x
]
VotingProceduresFieldNotSupported x ->
apiError err400 UnsupportedMediaType
$ T.unwords
[ "The transaction I was given contains a voting procedure"
, "which is not supported in the current era."
, "The offending procedure is:\n\n"
, T.pack $ show x
]
ProposalProceduresFieldNotSupported x ->
apiError err400 UnsupportedMediaType
$ T.unwords
[ "The transaction I was given contains a proposal procedure"
, "which is not supported in the current era."
, "The offending procedure is:\n\n"
, T.pack $ show x
]
TreasuryDonationFieldNotSupported x ->
apiError err400 UnsupportedMediaType
$ T.unwords
[ "The transaction I was given contains a treasury donation"
, "which is not supported in the current era."
, "The offending donation is:\n\n"
, T.pack $ show x
]
6 changes: 5 additions & 1 deletion lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ import Cardano.Crypto.Hash
( Hash (UnsafeHash)
)
import Cardano.Ledger.Allegra.Scripts
( translateTimelock
( AllegraEraScript
, Timelock
, translateTimelock
)
import Cardano.Ledger.Alonzo.Plutus.Context
( EraPlutusContext
Expand Down Expand Up @@ -376,6 +378,8 @@ type RecentEraConstraints era =
, Show (PParams era)
, Show (Script era)
, EraPlutusContext era
, AllegraEraScript era
, Core.NativeScript era ~ Timelock era
)

-- | Returns a proof that the given era is a recent era.
Expand Down
Loading

0 comments on commit f071494

Please sign in to comment.