From 4bd664c81ba653ad44b1d9766966391b000b465f Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 14:51:44 +0000 Subject: [PATCH 01/11] Fix importing list in Primitive.Types --- lib/wallet/src/Cardano/Wallet/Primitive/Types.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs b/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs index 8e23f7e4e58..c5098baaacf 100644 --- a/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs +++ b/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs @@ -147,6 +147,9 @@ import Cardano.Wallet.Orphans import Cardano.Wallet.Primitive.Passphrase.Types ( WalletPassphraseInfo (..) ) +import Cardano.Wallet.Primitive.Slotting + ( StartTime (..) + ) import Cardano.Wallet.Primitive.Types.Block ( Block (..) , BlockHeader (..) @@ -172,6 +175,10 @@ import Cardano.Wallet.Primitive.Types.DelegationCertificate , dlgCertPoolId ) import Cardano.Wallet.Primitive.Types.EpochNo + ( EpochNo (..) + , isValidEpochNo + , unsafeEpochNo + ) import Cardano.Wallet.Primitive.Types.EraInfo ( EraInfo (..) , emptyEraInfo @@ -189,6 +196,10 @@ import Cardano.Wallet.Primitive.Types.Hash import Cardano.Wallet.Primitive.Types.ProtocolParameters ( ProtocolParameters (..) ) +import Cardano.Wallet.Primitive.Types.SlotId + ( SlotId (..) + , SlotInEpoch (..) + ) import Cardano.Wallet.Primitive.Types.SlottingParameters ( ActiveSlotCoefficient (..) , EpochLength (..) @@ -302,10 +313,6 @@ import Network.URI , uriToString ) -import Cardano.Wallet.Primitive.Slotting - ( StartTime (..) - ) -import Cardano.Wallet.Primitive.Types.SlotId import qualified Data.Text as T import qualified Data.Text.Encoding as T From 8e9a6a0c7bb2d444da4449393148248e76c427dd Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 09:58:46 +0000 Subject: [PATCH 02/11] Move ValiditiIntervalExplicit to primitive --- lib/primitive/cardano-wallet-primitive.cabal | 1 + .../Types/ValidityIntervalExplicit.hs | 31 +++++++++++++++++++ lib/wallet/src/Cardano/Wallet/Transaction.hs | 10 ++---- 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 lib/primitive/lib/Cardano/Wallet/Primitive/Types/ValidityIntervalExplicit.hs diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index 4a2e62cce08..eeccca7dfbd 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -156,6 +156,7 @@ library Cardano.Wallet.Primitive.Types.TxParameters Cardano.Wallet.Primitive.Types.UTxO Cardano.Wallet.Primitive.Types.UTxO.Gen + Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit Cardano.Wallet.Unsafe Cardano.Wallet.Util Control.Monad.Random.NonRandom diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/ValidityIntervalExplicit.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/ValidityIntervalExplicit.hs new file mode 100644 index 00000000000..18101127388 --- /dev/null +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/ValidityIntervalExplicit.hs @@ -0,0 +1,31 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DerivingStrategies #-} + +module Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit (..) + ) +where + +import Prelude + +import Control.DeepSeq + ( NFData + ) +import Data.Quantity + ( Quantity + ) +import Data.Word + ( Word64 + ) +import GHC.Generics + ( Generic + ) + +data ValidityIntervalExplicit = ValidityIntervalExplicit + { invalidBefore :: !(Quantity "slot" Word64) + , invalidHereafter :: !(Quantity "slot" Word64) + } + deriving (Generic, Eq, Show) + deriving anyclass NFData diff --git a/lib/wallet/src/Cardano/Wallet/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Transaction.hs index 81acde4801b..2b56066b57c 100644 --- a/lib/wallet/src/Cardano/Wallet/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Transaction.hs @@ -123,6 +123,9 @@ import Cardano.Wallet.Primitive.Types.Tx.TxIn import Cardano.Wallet.Primitive.Types.Tx.TxOut ( TxOut (..) ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit (..) + ) import Control.DeepSeq ( NFData (..) ) @@ -506,10 +509,3 @@ data ErrCannotQuit = ErrNotDelegatingOrAboutTo | ErrNonNullRewards Coin deriving (Eq, Show) - -data ValidityIntervalExplicit = ValidityIntervalExplicit - { invalidBefore :: !(Quantity "slot" Word64) - , invalidHereafter :: !(Quantity "slot" Word64) - } - deriving (Generic, Eq, Show) - deriving anyclass NFData From dbe574837fcfb787d6269ec65c78c8fd2df7454d Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 10:00:14 +0000 Subject: [PATCH 03/11] Move TokenMapWithScripts to primitive --- lib/primitive/cardano-wallet-primitive.cabal | 2 + .../Primitive/Types/TokenMapWithScripts.hs | 111 ++++++++++++++++++ lib/wallet/src/Cardano/Wallet/Transaction.hs | 80 ++----------- 3 files changed, 122 insertions(+), 71 deletions(-) create mode 100644 lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenMapWithScripts.hs diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index eeccca7dfbd..3bd13b396ed 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -56,6 +56,7 @@ library , cardano-ledger-mary , cardano-ledger-shelley , cardano-numeric + , cardano-protocol-tpraos , cardano-slotting , cardano-strict-containers , cardano-wallet-read @@ -139,6 +140,7 @@ library Cardano.Wallet.Primitive.Types.TokenBundleMaxSize Cardano.Wallet.Primitive.Types.TokenMap Cardano.Wallet.Primitive.Types.TokenMap.Gen + Cardano.Wallet.Primitive.Types.TokenMapWithScripts Cardano.Wallet.Primitive.Types.TokenPolicy Cardano.Wallet.Primitive.Types.TokenPolicy.Gen Cardano.Wallet.Primitive.Types.TokenQuantity diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenMapWithScripts.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenMapWithScripts.hs new file mode 100644 index 00000000000..4fe2f1b3f8b --- /dev/null +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenMapWithScripts.hs @@ -0,0 +1,111 @@ +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DerivingStrategies #-} + +module Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( TokenMapWithScripts (..) + , emptyTokenMapWithScripts + , AnyScript (..) + , PlutusScriptInfo (..) + , PlutusVersion (..) + , ScriptReference (..) + , ReferenceInput (..) + ) +where + +import Prelude + +import Cardano.Address.Script + ( KeyHash + , Script + , ScriptHash + ) +import Cardano.Wallet.Primitive.Types.TokenMap + ( TokenMap + ) +import Cardano.Wallet.Primitive.Types.TokenPolicy + ( TokenPolicyId + ) +import Cardano.Wallet.Primitive.Types.Tx.TxIn + ( TxIn + ) +import Control.DeepSeq + ( NFData + ) +import Data.Map.Strict + ( Map + ) +import Data.Text.Class + ( FromText (..) + , TextDecodingError (TextDecodingError) + , ToText (..) + ) +import GHC.Generics + ( Generic + ) + +import qualified Data.Map.Strict as Map + +data PlutusVersion = PlutusVersionV1 | PlutusVersionV2 | PlutusVersionV3 + deriving (Eq, Generic, Show) + deriving anyclass (NFData) + +instance ToText PlutusVersion where + toText PlutusVersionV1 = "v1" + toText PlutusVersionV2 = "v2" + toText PlutusVersionV3 = "v3" + +instance FromText PlutusVersion where + fromText txt = case txt of + "v1" -> Right PlutusVersionV1 + "v2" -> Right PlutusVersionV2 + "v3" -> Right PlutusVersionV3 + _ -> + Left + $ TextDecodingError + $ unwords + [ "I couldn't parse the given plutus version." + , "I am expecting one of the words 'v1' or" + , "'v2'." + ] + +data PlutusScriptInfo = PlutusScriptInfo + { languageVersion :: PlutusVersion + , scriptHash :: ScriptHash + } + deriving (Eq, Generic, Show) + deriving anyclass (NFData) + +newtype ReferenceInput = ReferenceInput TxIn + deriving (Eq, Generic, Show) + deriving anyclass (NFData) + +-- | ScriptReference depicts whether the script is referenced via spending +-- and is bound to be used in the same transaction or is referenced via +-- reference inputs and is to be used in other transactions. The the latter +-- case the script is referenced in other trasactions +data ScriptReference + = ViaSpending + | ViaReferenceInput ReferenceInput + deriving (Eq, Generic, Show) + deriving anyclass (NFData) + +data AnyScript + = NativeScript !(Script KeyHash) !ScriptReference + | PlutusScript !PlutusScriptInfo !ScriptReference + | AnyScriptReference !ScriptHash ![ReferenceInput] + deriving (Eq, Generic, Show) + deriving anyclass (NFData) + +data TokenMapWithScripts = TokenMapWithScripts + { txTokenMap :: !TokenMap + , txScripts :: !(Map TokenPolicyId AnyScript) + } + deriving (Show, Generic, Eq) + +emptyTokenMapWithScripts :: TokenMapWithScripts +emptyTokenMapWithScripts = + TokenMapWithScripts + { txTokenMap = mempty + , txScripts = Map.empty + } diff --git a/lib/wallet/src/Cardano/Wallet/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Transaction.hs index 2b56066b57c..cc650bc9c1d 100644 --- a/lib/wallet/src/Cardano/Wallet/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Transaction.hs @@ -66,7 +66,6 @@ import Cardano.Address.Script ( KeyHash (..) , KeyRole (..) , Script (..) - , ScriptHash , ScriptTemplate ) import Cardano.Api @@ -107,8 +106,14 @@ import Cardano.Wallet.Primitive.Types.TokenMap ( AssetId , TokenMap ) -import Cardano.Wallet.Primitive.Types.TokenPolicy - ( TokenPolicyId +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( AnyScript (..) + , PlutusScriptInfo (..) + , PlutusVersion (..) + , ReferenceInput (..) + , ScriptReference (..) + , TokenMapWithScripts (..) + , emptyTokenMapWithScripts ) import Cardano.Wallet.Primitive.Types.TokenQuantity ( TokenQuantity @@ -141,20 +146,11 @@ import Data.Map.Strict import Data.Monoid.Monus ( (<\>) ) -import Data.Quantity - ( Quantity (..) - ) import Data.Text ( Text ) -import Data.Text.Class - ( FromText (..) - , TextDecodingError (..) - , ToText (..) - ) import Data.Word - ( Word64 - , Word8 + ( Word8 ) import Fmt ( Buildable (..) @@ -335,64 +331,6 @@ data DelegationAction instance Buildable DelegationAction where build = genericF -data PlutusVersion = PlutusVersionV1 | PlutusVersionV2 | PlutusVersionV3 - deriving (Eq, Generic, Show) - deriving anyclass NFData - -instance ToText PlutusVersion where - toText PlutusVersionV1 = "v1" - toText PlutusVersionV2 = "v2" - toText PlutusVersionV3 = "v3" - -instance FromText PlutusVersion where - fromText txt = case txt of - "v1" -> Right PlutusVersionV1 - "v2" -> Right PlutusVersionV2 - "v3" -> Right PlutusVersionV3 - _ -> Left $ TextDecodingError $ unwords - [ "I couldn't parse the given plutus version." - , "I am expecting one of the words 'v1' or" - , "'v2'."] - -data PlutusScriptInfo = PlutusScriptInfo - { languageVersion :: PlutusVersion - , scriptHash :: ScriptHash - } - deriving (Eq, Generic, Show) - deriving anyclass NFData - -newtype ReferenceInput = ReferenceInput TxIn - deriving (Eq, Generic, Show) - deriving anyclass NFData - --- | ScriptReference depicts whether the script is referenced via spending --- and is bound to be used in the same transaction or is referenced via --- reference inputs and is to be used in other transactions. The the latter --- case the script is referenced in other trasactions -data ScriptReference = - ViaSpending - | ViaReferenceInput ReferenceInput - deriving (Eq, Generic, Show) - deriving anyclass NFData - -data AnyScript = - NativeScript !(Script KeyHash) !ScriptReference - | PlutusScript !PlutusScriptInfo !ScriptReference - | AnyScriptReference !ScriptHash ![ReferenceInput] - deriving (Eq, Generic, Show) - deriving anyclass NFData - -data TokenMapWithScripts = TokenMapWithScripts - { txTokenMap :: !TokenMap - , txScripts :: !(Map TokenPolicyId AnyScript) - } deriving (Show, Generic, Eq) - -emptyTokenMapWithScripts :: TokenMapWithScripts -emptyTokenMapWithScripts = TokenMapWithScripts - { txTokenMap = mempty - , txScripts = Map.empty - } - data AnyExplicitScript = NativeExplicitScript !(Script KeyHash) !ScriptReference | PlutusExplicitScript !PlutusScriptInfo !ScriptReference From 1acaf8936127bf6ba6f0de8b92633335e039b218 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 10:11:31 +0000 Subject: [PATCH 04/11] Move AnyExplicitScript to primitive --- lib/primitive/cardano-wallet-primitive.cabal | 1 + .../Primitive/Types/AnyExplicitScripts.hs | 56 +++++++++++++++++++ lib/wallet/src/Cardano/Wallet/Transaction.hs | 38 +++---------- 3 files changed, 64 insertions(+), 31 deletions(-) create mode 100644 lib/primitive/lib/Cardano/Wallet/Primitive/Types/AnyExplicitScripts.hs diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index 3bd13b396ed..917cd0c1a3c 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -112,6 +112,7 @@ library Cardano.Wallet.Primitive.SyncProgress Cardano.Wallet.Primitive.Types.Address Cardano.Wallet.Primitive.Types.Address.Gen + Cardano.Wallet.Primitive.Types.AnyExplicitScripts Cardano.Wallet.Primitive.Types.Block Cardano.Wallet.Primitive.Types.Block.Gen Cardano.Wallet.Primitive.Types.BlockSummary diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/AnyExplicitScripts.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/AnyExplicitScripts.hs new file mode 100644 index 00000000000..381355a9348 --- /dev/null +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/AnyExplicitScripts.hs @@ -0,0 +1,56 @@ +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE LambdaCase #-} + +module Cardano.Wallet.Primitive.Types.AnyExplicitScripts + ( AnyExplicitScript (..) + , changeRoleInAnyExplicitScript + ) +where + +import Prelude + +import Cardano.Address.Script + ( KeyHash (KeyHash) + , KeyRole + , Script (..) + ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( PlutusScriptInfo + , ScriptReference + ) +import Control.DeepSeq + ( NFData + ) +import GHC.Generics + ( Generic + ) + +data AnyExplicitScript + = NativeExplicitScript !(Script KeyHash) !ScriptReference + | PlutusExplicitScript !PlutusScriptInfo !ScriptReference + deriving (Eq, Generic, Show) + deriving anyclass (NFData) + +changeRoleInAnyExplicitScript + :: KeyRole + -> AnyExplicitScript + -> AnyExplicitScript +changeRoleInAnyExplicitScript newrole = \case + NativeExplicitScript script scriptRole -> + let changeRole' = \case + RequireSignatureOf (KeyHash _ p) -> + RequireSignatureOf $ KeyHash newrole p + RequireAllOf xs -> + RequireAllOf (map changeRole' xs) + RequireAnyOf xs -> + RequireAnyOf (map changeRole' xs) + RequireSomeOf m xs -> + RequireSomeOf m (map changeRole' xs) + ActiveFromSlot s -> + ActiveFromSlot s + ActiveUntilSlot s -> + ActiveUntilSlot s + in NativeExplicitScript (changeRole' script) scriptRole + PlutusExplicitScript _ _ -> error "wrong usage" diff --git a/lib/wallet/src/Cardano/Wallet/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Transaction.hs index cc650bc9c1d..6bca38b04d9 100644 --- a/lib/wallet/src/Cardano/Wallet/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Transaction.hs @@ -73,9 +73,6 @@ import Cardano.Api ) import Cardano.Api.Extra () -import Cardano.Pool.Types - ( PoolId - ) import Cardano.Wallet.Address.Derivation ( Depth (..) , DerivationIndex @@ -93,12 +90,19 @@ import Cardano.Wallet.Primitive.Types import Cardano.Wallet.Primitive.Types.Address ( Address (..) ) +import Cardano.Wallet.Primitive.Types.AnyExplicitScripts + ( AnyExplicitScript (..) + , changeRoleInAnyExplicitScript + ) import Cardano.Wallet.Primitive.Types.Coin ( Coin (..) ) import Cardano.Wallet.Primitive.Types.Hash ( Hash (..) ) +import Cardano.Wallet.Primitive.Types.PoolId + ( PoolId + ) import Cardano.Wallet.Primitive.Types.RewardAccount ( RewardAccount ) @@ -331,34 +335,6 @@ data DelegationAction instance Buildable DelegationAction where build = genericF -data AnyExplicitScript = - NativeExplicitScript !(Script KeyHash) !ScriptReference - | PlutusExplicitScript !PlutusScriptInfo !ScriptReference - deriving (Eq, Generic, Show) - deriving anyclass NFData - -changeRoleInAnyExplicitScript - :: KeyRole - -> AnyExplicitScript - -> AnyExplicitScript -changeRoleInAnyExplicitScript newrole = \case - NativeExplicitScript script scriptRole -> - let changeRole' = \case - RequireSignatureOf (KeyHash _ p) -> - RequireSignatureOf $ KeyHash newrole p - RequireAllOf xs -> - RequireAllOf (map changeRole' xs) - RequireAnyOf xs -> - RequireAnyOf (map changeRole' xs) - RequireSomeOf m xs -> - RequireSomeOf m (map changeRole' xs) - ActiveFromSlot s -> - ActiveFromSlot s - ActiveUntilSlot s -> - ActiveUntilSlot s - in NativeExplicitScript (changeRole' script) scriptRole - PlutusExplicitScript _ _ -> error "wrong usage" - data WitnessCount = WitnessCount { verificationKey :: Word8 , scripts :: [AnyExplicitScript] From dcb8e82f7ec1e2f86a69814ae32da6695bc5a45d Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 15:25:38 +0000 Subject: [PATCH 05/11] Move WitnessCount and WitnessCountCtx to primitive --- lib/primitive/cardano-wallet-primitive.cabal | 1 + .../Wallet/Primitive/Types/WitnessCount.hs | 80 +++++++++++++++++++ lib/wallet/src/Cardano/Wallet/Transaction.hs | 62 ++------------ 3 files changed, 89 insertions(+), 54 deletions(-) create mode 100644 lib/primitive/lib/Cardano/Wallet/Primitive/Types/WitnessCount.hs diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index 917cd0c1a3c..cacffaf3e51 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -160,6 +160,7 @@ library Cardano.Wallet.Primitive.Types.UTxO Cardano.Wallet.Primitive.Types.UTxO.Gen Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + Cardano.Wallet.Primitive.Types.WitnessCount Cardano.Wallet.Unsafe Cardano.Wallet.Util Control.Monad.Random.NonRandom diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/WitnessCount.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/WitnessCount.hs new file mode 100644 index 00000000000..dc3bbc9adf0 --- /dev/null +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/WitnessCount.hs @@ -0,0 +1,80 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DerivingStrategies #-} + +module Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount (..) + , WitnessCountCtx (..) + , emptyWitnessCount + , toKeyRole + ) +where + +import Prelude + +import Cardano.Address.Script + ( KeyHash (KeyHash) + , KeyRole (..) + ) +import Cardano.Wallet.Primitive.Types.AnyExplicitScripts + ( AnyExplicitScript + ) +import Cardano.Wallet.Primitive.Types.Hash + ( Hash (Hash) + ) +import Control.DeepSeq + ( NFData + ) +import Data.Word + ( Word8 + ) +import GHC.Generics + ( Generic + ) + +data WitnessCount = WitnessCount + { verificationKey :: Word8 + , scripts :: [AnyExplicitScript] + , bootstrap :: Word8 + } + deriving (Eq, Generic, Show) + deriving anyclass (NFData) + +emptyWitnessCount :: WitnessCount +emptyWitnessCount = + WitnessCount + { verificationKey = 0 + , scripts = [] + , bootstrap = 0 + } + +-- WitnessCount context is needed to differentiate verification keys present +-- in native scripts. +-- In shelley wallets they could be present due to only policy verification key. +-- In multisig wallet they could stem from payment, policy and delegation roles, +-- and as minting/burning and delegation support comes will be extended in additional +-- data attached in SharedWalletCtx to differentiate that. +-- WitnessCount is needed only during or after signing, in other phases it is not used. +data WitnessCountCtx = + ShelleyWalletCtx KeyHash -- Policy + | SharedWalletCtx [KeyHash] -- Delegation key hashes of all cosigners + | AnyWitnessCountCtx + deriving (Eq, Generic, Show) + deriving anyclass NFData + +toKeyRole :: WitnessCountCtx -> Hash "VerificationKey" -> KeyRole +toKeyRole witCtx (Hash key) = case witCtx of + ShelleyWalletCtx (KeyHash _ mypolicykey) -> + if key == mypolicykey then + Policy + else + Unknown + SharedWalletCtx stakingKeyHashes -> + let toStakeKey (KeyHash _ k) = k + isStakeKey = elem key (map toStakeKey stakingKeyHashes) + in if isStakeKey then + Delegation + else + Payment + AnyWitnessCountCtx -> Unknown diff --git a/lib/wallet/src/Cardano/Wallet/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Transaction.hs index 6bca38b04d9..18f95aae915 100644 --- a/lib/wallet/src/Cardano/Wallet/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Transaction.hs @@ -1,6 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE DuplicateRecordFields #-} @@ -64,7 +63,6 @@ import Cardano.Address.Derivation ) import Cardano.Address.Script ( KeyHash (..) - , KeyRole (..) , Script (..) , ScriptTemplate ) @@ -97,9 +95,6 @@ import Cardano.Wallet.Primitive.Types.AnyExplicitScripts import Cardano.Wallet.Primitive.Types.Coin ( Coin (..) ) -import Cardano.Wallet.Primitive.Types.Hash - ( Hash (..) - ) import Cardano.Wallet.Primitive.Types.PoolId ( PoolId ) @@ -135,6 +130,14 @@ import Cardano.Wallet.Primitive.Types.Tx.TxOut import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit ( ValidityIntervalExplicit (..) ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount (..) + , WitnessCount (..) + , WitnessCountCtx (..) + , emptyWitnessCount + , emptyWitnessCount + , toKeyRole + ) import Control.DeepSeq ( NFData (..) ) @@ -153,9 +156,6 @@ import Data.Monoid.Monus import Data.Text ( Text ) -import Data.Word - ( Word8 - ) import Fmt ( Buildable (..) , genericF @@ -170,7 +170,6 @@ import Internal.Cardano.Write.Tx.SizeEstimation import qualified Cardano.Wallet.Primitive.Types.TokenMap as TokenMap import qualified Cardano.Wallet.Primitive.Types.Tx.TxOut as TxOut import qualified Data.Foldable as F -import qualified Data.List as L import qualified Data.Map.Strict as Map data TransactionLayer (k :: Depth -> Type -> Type) ktype tx = TransactionLayer @@ -335,51 +334,6 @@ data DelegationAction instance Buildable DelegationAction where build = genericF -data WitnessCount = WitnessCount - { verificationKey :: Word8 - , scripts :: [AnyExplicitScript] - , bootstrap :: Word8 - } - deriving (Eq, Generic, Show) - deriving anyclass NFData - -emptyWitnessCount :: WitnessCount -emptyWitnessCount = WitnessCount - { verificationKey = 0 - , scripts = [] - , bootstrap = 0 - } - --- WitnessCount context is needed to differentiate verification keys present --- in native scripts. --- In shelley wallets they could be present due to only policy verification key. --- In multisig wallet they could stem from payment, policy and delegation roles, --- and as minting/burning and delegation support comes will be extended in additional --- data attached in SharedWalletCtx to differentiate that. --- WitnessCount is needed only during or after signing, in other phases it is not used. -data WitnessCountCtx = - ShelleyWalletCtx KeyHash -- Policy - | SharedWalletCtx [KeyHash] -- Delegation key hashes of all cosigners - | AnyWitnessCountCtx - deriving (Eq, Generic, Show) - deriving anyclass NFData - -toKeyRole :: WitnessCountCtx -> Hash "VerificationKey" -> KeyRole -toKeyRole witCtx (Hash key) = case witCtx of - ShelleyWalletCtx (KeyHash _ mypolicykey) -> - if key == mypolicykey then - Policy - else - Unknown - SharedWalletCtx stakingKeyHashes -> - let toStakeKey (KeyHash _ k) = k - isStakeKey = L.elem key (map toStakeKey stakingKeyHashes) - in if isStakeKey then - Delegation - else - Payment - AnyWitnessCountCtx -> Unknown - data ErrMkTransaction = ErrMkTransactionTxBodyError Text -- ^ We failed to construct a transaction for some reasons. From ce350dd062c075d5302e03f39540b0d5ac454ff4 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 15:43:31 +0000 Subject: [PATCH 06/11] Move StakePoolMetadataHash and StakePoolMetadataUrl to primitive --- lib/primitive/cardano-wallet-primitive.cabal | 1 + .../Primitive/Types/StakePoolMetadata.hs | 65 +++++++++++++++++++ lib/wallet/src/Cardano/Pool/Metadata/Types.hs | 60 ++++------------- .../Primitive/Tx/Features/Certificates.hs | 11 ++-- 4 files changed, 86 insertions(+), 51 deletions(-) create mode 100644 lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolMetadata.hs diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index cacffaf3e51..f3061753737 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -135,6 +135,7 @@ library Cardano.Wallet.Primitive.Types.SlotId Cardano.Wallet.Primitive.Types.SlottingParameters Cardano.Wallet.Primitive.Types.SlottingParameters.Gen + Cardano.Wallet.Primitive.Types.StakePoolMetadata Cardano.Wallet.Primitive.Types.StakePoolSummary Cardano.Wallet.Primitive.Types.TokenBundle Cardano.Wallet.Primitive.Types.TokenBundle.Gen diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolMetadata.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolMetadata.hs new file mode 100644 index 00000000000..caaeac8d334 --- /dev/null +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolMetadata.hs @@ -0,0 +1,65 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE TypeApplications #-} +module Cardano.Wallet.Primitive.Types.StakePoolMetadata + ( StakePoolMetadataHash (..) + , StakePoolMetadataUrl (..) + ) +where + +import Prelude + +import Cardano.Wallet.Primitive.Types.Hash + ( Hash (Hash, getHash) + , hashFromText + ) +import Control.DeepSeq + ( NFData + ) +import Data.ByteString + ( ByteString + ) +import Data.Text + ( Text + ) +import Data.Text.Class + ( FromText (..) + , ToText (..) + ) +import Fmt + ( Buildable (..) + ) +import GHC.Generics + ( Generic + ) + +-- | A newtype to wrap metadata hash. +-- +-- NOTE: not using the 'Hash' type as this newtype is primarily for database +-- interop which doesn't quite like DataKinds. +newtype StakePoolMetadataHash = StakePoolMetadataHash ByteString + deriving (Eq, Ord, Show, Generic) + +instance NFData StakePoolMetadataHash + +instance ToText StakePoolMetadataHash where + toText (StakePoolMetadataHash bytes) = toText (Hash bytes) + +instance FromText StakePoolMetadataHash where + fromText = fmap (StakePoolMetadataHash . getHash @"_") . hashFromText 32 + +instance Buildable StakePoolMetadataHash where + build (StakePoolMetadataHash hash) = build (Hash hash) + +-- | A newtype to wrap metadata Url, mostly needed for database lookups and +-- signature clarity. +newtype StakePoolMetadataUrl = StakePoolMetadataUrl Text + deriving (Eq, Ord, Show, Generic) + +instance NFData StakePoolMetadataUrl + +instance ToText StakePoolMetadataUrl where + toText (StakePoolMetadataUrl url) = url + +instance FromText StakePoolMetadataUrl where + fromText = pure . StakePoolMetadataUrl diff --git a/lib/wallet/src/Cardano/Pool/Metadata/Types.hs b/lib/wallet/src/Cardano/Pool/Metadata/Types.hs index 9f463fd0316..184024b71a6 100644 --- a/lib/wallet/src/Cardano/Pool/Metadata/Types.hs +++ b/lib/wallet/src/Cardano/Pool/Metadata/Types.hs @@ -3,7 +3,16 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE TypeApplications #-} -module Cardano.Pool.Metadata.Types where +{-# OPTIONS_GHC -Wno-orphans #-} + +module Cardano.Pool.Metadata.Types + ( StakePoolMetadata (..) + , StakePoolMetadataHash (..) + , StakePoolMetadataUrl (..) + , PoolMetadataGCStatus (..) + , UrlBuilder + ) +where import Prelude @@ -11,12 +20,9 @@ import Cardano.Pool.Types ( PoolId , StakePoolTicker (unStakePoolTicker) ) -import Cardano.Wallet.Primitive.Types.Hash - ( Hash (..) - , hashFromText - ) -import Control.DeepSeq - ( NFData +import Cardano.Wallet.Primitive.Types.StakePoolMetadata + ( StakePoolMetadataHash (..) + , StakePoolMetadataUrl (..) ) import Control.Monad ( when @@ -34,9 +40,6 @@ import Data.Aeson.Types ( ToJSON (toJSON) , Value (String) ) -import Data.ByteString - ( ByteString - ) import Data.Proxy ( Proxy (Proxy) ) @@ -44,8 +47,7 @@ import Data.Text ( Text ) import Data.Text.Class.Extended - ( FromText (fromText) - , ToText (toText) + ( ToText (toText) , fromText' , fromTextMaybe ) @@ -59,9 +61,6 @@ import Database.Persist.Sql ( PersistField (..) , PersistFieldSql (..) ) -import Fmt - ( Buildable (build) - ) import GHC.Generics ( Generic ) @@ -90,24 +89,6 @@ data PoolMetadataGCStatus | HasRun POSIXTime -- shows last GC deriving (Eq, Show, Generic) --- | A newtype to wrap metadata hash. --- --- NOTE: not using the 'Hash' type as this newtype is primarily for database --- interop which doesn't quite like DataKinds. -newtype StakePoolMetadataHash = StakePoolMetadataHash ByteString - deriving (Eq, Ord, Show, Generic) - -instance NFData StakePoolMetadataHash - -instance ToText StakePoolMetadataHash where - toText (StakePoolMetadataHash bytes) = toText (Hash bytes) - -instance FromText StakePoolMetadataHash where - fromText = fmap (StakePoolMetadataHash . getHash @"_") . hashFromText 32 - -instance Buildable StakePoolMetadataHash where - build (StakePoolMetadataHash hash) = build (Hash hash) - instance PersistField StakePoolMetadataHash where toPersistValue = toPersistValue . toText fromPersistValue = fromPersistValueFromText @@ -134,19 +115,6 @@ instance PathPiece StakePoolMetadataHash where fromPathPiece = fromTextMaybe toPathPiece = toText --- | A newtype to wrap metadata Url, mostly needed for database lookups and --- signature clarity. -newtype StakePoolMetadataUrl = StakePoolMetadataUrl Text - deriving (Eq, Ord, Show, Generic) - -instance NFData StakePoolMetadataUrl - -instance ToText StakePoolMetadataUrl where - toText (StakePoolMetadataUrl url) = url - -instance FromText StakePoolMetadataUrl where - fromText = pure . StakePoolMetadataUrl - instance PersistField StakePoolMetadataUrl where toPersistValue = toPersistValue . toText fromPersistValue = fromPersistValueFromText diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs b/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs index 8834aa96112..135a90a1375 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs +++ b/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs @@ -41,10 +41,6 @@ import Cardano.Ledger.Shelley.API import Cardano.Ledger.Shelley.TxBody ( DCert ) -import Cardano.Pool.Metadata.Types - ( StakePoolMetadataHash (..) - , StakePoolMetadataUrl (..) - ) import Cardano.Pool.Types ( PoolId (PoolId) , PoolOwner (PoolOwner) @@ -57,6 +53,10 @@ import Cardano.Wallet.Primitive.Types , PoolRegistrationCertificate (..) , PoolRetirementCertificate (..) ) +import Cardano.Wallet.Primitive.Types.StakePoolMetadata + ( StakePoolMetadataHash (..) + , StakePoolMetadataUrl (..) + ) import Cardano.Wallet.Read.Eras ( EraFun (..) , K (..) @@ -184,7 +184,8 @@ fromShelleyCert = \case SL.DCertGenesis{} -> W.CertificateOther W.GenesisCertificate SL.DCertMir{} -> W.CertificateOther W.MIRCertificate -fromPoolMetadata :: SL.PoolMetadata -> (StakePoolMetadataUrl, StakePoolMetadataHash) +fromPoolMetadata :: SL.PoolMetadata + -> (StakePoolMetadataUrl, StakePoolMetadataHash) fromPoolMetadata meta = ( StakePoolMetadataUrl (urlToText (pmUrl meta)) , StakePoolMetadataHash (pmHash meta) From 75e55c2132203e37a547537f617aa6d10b90a05a Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 12:42:54 +0000 Subject: [PATCH 07/11] Move PoolOwner to primitive --- lib/primitive/cardano-wallet-primitive.cabal | 4 +- .../Primitive/Types/DelegationCertificate.hs | 2 +- .../Primitive/Types/{PoolId.hs => Pool.hs} | 41 +++++++++++++- .../Primitive/Types/StakePoolSummary.hs | 2 +- .../Types/{PoolIdSpec.hs => PoolSpec.hs} | 6 +- lib/wallet/src/Cardano/Pool/Types.hs | 55 ++----------------- lib/wallet/src/Cardano/Wallet/Transaction.hs | 2 +- prototypes/light-mode-test/src/Light.hs | 2 +- 8 files changed, 53 insertions(+), 61 deletions(-) rename lib/primitive/lib/Cardano/Wallet/Primitive/Types/{PoolId.hs => Pool.hs} (67%) rename lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/{PoolIdSpec.hs => PoolSpec.hs} (79%) diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index f3061753737..0da0ed333aa 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -126,7 +126,7 @@ library Cardano.Wallet.Primitive.Types.ExecutionUnitPrices Cardano.Wallet.Primitive.Types.FeePolicy Cardano.Wallet.Primitive.Types.Hash - Cardano.Wallet.Primitive.Types.PoolId + Cardano.Wallet.Primitive.Types.Pool Cardano.Wallet.Primitive.Types.ProtocolMagic Cardano.Wallet.Primitive.Types.ProtocolParameters Cardano.Wallet.Primitive.Types.Range @@ -230,7 +230,7 @@ test-suite test Cardano.Wallet.Primitive.Types.BlockSummarySpec Cardano.Wallet.Primitive.Types.CoinSpec Cardano.Wallet.Primitive.Types.HashSpec - Cardano.Wallet.Primitive.Types.PoolIdSpec + Cardano.Wallet.Primitive.Types.PoolSpec Cardano.Wallet.Primitive.Types.RangeSpec Cardano.Wallet.Primitive.Types.TokenBundleSpec Cardano.Wallet.Primitive.Types.TokenMapSpec diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/DelegationCertificate.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/DelegationCertificate.hs index 8ab71ce4b4b..88949aebde6 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/DelegationCertificate.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/DelegationCertificate.hs @@ -10,7 +10,7 @@ where import Prelude -import Cardano.Wallet.Primitive.Types.PoolId +import Cardano.Wallet.Primitive.Types.Pool ( PoolId ) import Cardano.Wallet.Primitive.Types.RewardAccount diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/PoolId.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Pool.hs similarity index 67% rename from lib/primitive/lib/Cardano/Wallet/Primitive/Types/PoolId.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Types/Pool.hs index fbe6f19cf02..9c05e88555a 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/PoolId.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Pool.hs @@ -1,11 +1,13 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE QuasiQuotes #-} -module Cardano.Wallet.Primitive.Types.PoolId +module Cardano.Wallet.Primitive.Types.Pool ( PoolId (..) , poolIdBytesLength , decodePoolIdBech32 , encodePoolIdBech32 + , PoolOwner (..) + , poolOwnerPrefix ) where @@ -109,3 +111,40 @@ decodePoolIdBech32 t = [ "Invalid stake pool id: expecting a Bech32 encoded value" , "with human readable part of 'pool'." ] + +-- | A stake pool owner, which is a public key encoded in bech32 with prefix +-- ed25519_pk. +newtype PoolOwner = PoolOwner { getPoolOwner :: ByteString } + deriving (Generic, Eq, Show, Ord) + +poolOwnerPrefix :: Bech32.HumanReadablePart +poolOwnerPrefix = [Bech32.humanReadablePart|ed25519_pk|] + +instance NFData PoolOwner + +instance Buildable PoolOwner where + build poolId = build (toText poolId) + +instance ToText PoolOwner where + toText = Bech32.encodeLenient poolOwnerPrefix + . Bech32.dataPartFromBytes + . getPoolOwner + +instance FromText PoolOwner where + fromText t = case fmap Bech32.dataPartToBytes <$> Bech32.decode t of + Left err -> + Left $ TextDecodingError $ + "Stake pool owner is not a valid bech32 string: " + <> show err + Right (hrp, Just bytes) + | hrp == poolOwnerPrefix -> + Right $ PoolOwner bytes + | otherwise -> + Left $ TextDecodingError $ + "Stake pool owner has wrong prefix:" + <> " expected " + <> T.unpack (Bech32.humanReadablePartToText poolOwnerPrefix) + <> " but got " + <> show hrp + Right (_, Nothing) -> + Left $ TextDecodingError "Stake pool owner is invalid" diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolSummary.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolSummary.hs index b4221a3e4ae..b86053f893f 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolSummary.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/StakePoolSummary.hs @@ -9,7 +9,7 @@ import Prelude import Cardano.Wallet.Primitive.Types.Coin ( Coin (..) ) -import Cardano.Wallet.Primitive.Types.PoolId +import Cardano.Wallet.Primitive.Types.Pool ( PoolId (..) ) import Data.Map diff --git a/lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/PoolIdSpec.hs b/lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/PoolSpec.hs similarity index 79% rename from lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/PoolIdSpec.hs rename to lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/PoolSpec.hs index a9fc4fe9837..f5a19df48c3 100644 --- a/lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/PoolIdSpec.hs +++ b/lib/primitive/test/spec/Cardano/Wallet/Primitive/Types/PoolSpec.hs @@ -1,13 +1,13 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -Wno-orphans #-} -module Cardano.Wallet.Primitive.Types.PoolIdSpec +module Cardano.Wallet.Primitive.Types.PoolSpec ( spec ) where import Prelude -import Cardano.Wallet.Primitive.Types.PoolId +import Cardano.Wallet.Primitive.Types.Pool ( PoolId (..) , decodePoolIdBech32 , encodePoolIdBech32 @@ -27,7 +27,7 @@ import Test.QuickCheck import qualified Data.ByteString as BS spec :: Spec -spec = describe "Cardano.Wallet.Primitive.Types.PoolId" $ do +spec = describe "Cardano.Wallet.Primitive.Types.Pool" $ do it "Can roundtrip {decode,encode}PoolIdBech32" $ withMaxSuccess 1000 $ forAll (PoolId . BS.pack <$> vector 32) diff --git a/lib/wallet/src/Cardano/Pool/Types.hs b/lib/wallet/src/Cardano/Pool/Types.hs index de5e09fabd4..e82070338f3 100644 --- a/lib/wallet/src/Cardano/Pool/Types.hs +++ b/lib/wallet/src/Cardano/Pool/Types.hs @@ -2,10 +2,10 @@ {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -{-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} + module Cardano.Pool.Types ( StakePoolsSummary (..) , PoolId(..) @@ -18,8 +18,9 @@ module Cardano.Pool.Types import Prelude -import Cardano.Wallet.Primitive.Types.PoolId +import Cardano.Wallet.Primitive.Types.Pool ( PoolId (..) + , PoolOwner (..) , decodePoolIdBech32 , encodePoolIdBech32 , poolIdBytesLength @@ -30,9 +31,6 @@ import Cardano.Wallet.Primitive.Types.StakePoolSummary import Cardano.Wallet.Util ( ShowFmt (..) ) -import Control.DeepSeq - ( NFData - ) import Control.Monad ( (>=>) ) @@ -40,9 +38,6 @@ import Data.Aeson ( FromJSON (parseJSON) , ToJSON (toJSON) ) -import Data.ByteString - ( ByteString - ) import Data.Proxy ( Proxy (..) ) @@ -63,15 +58,10 @@ import Database.Persist.PersistValue.Extended import Database.Persist.Sqlite ( PersistFieldSql (..) ) -import Fmt - ( Buildable (..) - ) import GHC.Generics ( Generic ) -import qualified Codec.Binary.Bech32 as Bech32 -import qualified Codec.Binary.Bech32.TH as Bech32 import qualified Data.Text as T -- | Very short name for a stake pool. @@ -101,43 +91,6 @@ instance PersistField StakePoolTicker where instance PersistFieldSql StakePoolTicker where sqlType _ = sqlType (Proxy @Text) --- | A stake pool owner, which is a public key encoded in bech32 with prefix --- ed25519_pk. -newtype PoolOwner = PoolOwner { getPoolOwner :: ByteString } - deriving (Generic, Eq, Show, Ord) - -poolOwnerPrefix :: Bech32.HumanReadablePart -poolOwnerPrefix = [Bech32.humanReadablePart|ed25519_pk|] - -instance NFData PoolOwner - -instance Buildable PoolOwner where - build poolId = build (toText poolId) - -instance ToText PoolOwner where - toText = Bech32.encodeLenient poolOwnerPrefix - . Bech32.dataPartFromBytes - . getPoolOwner - -instance FromText PoolOwner where - fromText t = case fmap Bech32.dataPartToBytes <$> Bech32.decode t of - Left err -> - Left $ TextDecodingError $ - "Stake pool owner is not a valid bech32 string: " - <> show err - Right (hrp, Just bytes) - | hrp == poolOwnerPrefix -> - Right $ PoolOwner bytes - | otherwise -> - Left $ TextDecodingError $ - "Stake pool owner has wrong prefix:" - <> " expected " - <> T.unpack (Bech32.humanReadablePartToText poolOwnerPrefix) - <> " but got " - <> show hrp - Right (_, Nothing) -> - Left $ TextDecodingError "Stake pool owner is invalid" - instance FromJSON PoolOwner where parseJSON = parseJSON >=> either (fail . show . ShowFmt) pure . fromText diff --git a/lib/wallet/src/Cardano/Wallet/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Transaction.hs index 18f95aae915..63398c2aac0 100644 --- a/lib/wallet/src/Cardano/Wallet/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Transaction.hs @@ -95,7 +95,7 @@ import Cardano.Wallet.Primitive.Types.AnyExplicitScripts import Cardano.Wallet.Primitive.Types.Coin ( Coin (..) ) -import Cardano.Wallet.Primitive.Types.PoolId +import Cardano.Wallet.Primitive.Types.Pool ( PoolId ) import Cardano.Wallet.Primitive.Types.RewardAccount diff --git a/prototypes/light-mode-test/src/Light.hs b/prototypes/light-mode-test/src/Light.hs index af5f2689617..0f91512145c 100644 --- a/prototypes/light-mode-test/src/Light.hs +++ b/prototypes/light-mode-test/src/Light.hs @@ -37,7 +37,7 @@ module Light ( , ChainPoint (..) , SyncProgress , Pool - , Light.Types.PoolId + , Light.Types.Pool ) where import Control.Monad From 686d23df5aaac66c810fcfcaf1204a0a8a47cd3e Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 14:19:17 +0000 Subject: [PATCH 08/11] Move Certificates to primitive --- lib/primitive/cardano-wallet-primitive.cabal | 2 +- .../Cardano/Wallet/Primitive/Types/Block.hs | 2 +- .../Wallet/Primitive/Types/BlockSummary.hs | 2 +- .../Wallet/Primitive/Types/Certificates.hs | 232 ++++++++++++++++++ .../Primitive/Types/DelegationCertificate.hs | 44 ---- lib/wallet/src/Cardano/Pool/Types.hs | 1 + .../src/Cardano/Wallet/Primitive/Types.hs | 181 ++------------ 7 files changed, 255 insertions(+), 209 deletions(-) create mode 100644 lib/primitive/lib/Cardano/Wallet/Primitive/Types/Certificates.hs delete mode 100644 lib/primitive/lib/Cardano/Wallet/Primitive/Types/DelegationCertificate.hs diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index 0da0ed333aa..ff0b5b7c0a6 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -116,11 +116,11 @@ library Cardano.Wallet.Primitive.Types.Block Cardano.Wallet.Primitive.Types.Block.Gen Cardano.Wallet.Primitive.Types.BlockSummary + Cardano.Wallet.Primitive.Types.Certificates Cardano.Wallet.Primitive.Types.Checkpoints.Policy Cardano.Wallet.Primitive.Types.Coin Cardano.Wallet.Primitive.Types.Coin.Gen Cardano.Wallet.Primitive.Types.DecentralizationLevel - Cardano.Wallet.Primitive.Types.DelegationCertificate Cardano.Wallet.Primitive.Types.EpochNo Cardano.Wallet.Primitive.Types.EraInfo Cardano.Wallet.Primitive.Types.ExecutionUnitPrices diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Block.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Block.hs index cbbd695d30f..fe32933afde 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Block.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Block.hs @@ -25,7 +25,7 @@ import Cardano.Slotting.Slot ( SlotNo , WithOrigin (..) ) -import Cardano.Wallet.Primitive.Types.DelegationCertificate +import Cardano.Wallet.Primitive.Types.Certificates ( DelegationCertificate ) import Cardano.Wallet.Primitive.Types.Hash diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/BlockSummary.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/BlockSummary.hs index 55c5ab62650..876f964d5ad 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/BlockSummary.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/BlockSummary.hs @@ -49,7 +49,7 @@ import Cardano.Wallet.Primitive.Types.Block , chainPointFromBlockHeader , toSlot ) -import Cardano.Wallet.Primitive.Types.DelegationCertificate +import Cardano.Wallet.Primitive.Types.Certificates ( DelegationCertificate , dlgCertAccount ) diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Certificates.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Certificates.hs new file mode 100644 index 00000000000..80e26e31fe7 --- /dev/null +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/Certificates.hs @@ -0,0 +1,232 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedLabels #-} + +module Cardano.Wallet.Primitive.Types.Certificates + ( DelegationCertificate (..) + , dlgCertAccount + , dlgCertPoolId + , StakeKeyCertificate (..) + , PoolCertificate (..) + , getPoolCertificatePoolId + , setPoolCertificatePoolId + , PoolRegistrationCertificate (..) + , PoolRetirementCertificate (..) + , NonWalletCertificate (..) + , Certificate (..) + , CertificatePublicationTime (..) + , PoolLifeCycleStatus (..) + , getPoolRegistrationCertificate + , getPoolRetirementCertificate + ) +where + +import Prelude + +import Cardano.Slotting.Slot + ( SlotNo + ) +import Cardano.Wallet.Primitive.Types.Coin + ( Coin + ) +import Cardano.Wallet.Primitive.Types.EpochNo + ( EpochNo + ) +import Cardano.Wallet.Primitive.Types.Pool + ( PoolId + , PoolOwner + ) +import Cardano.Wallet.Primitive.Types.RewardAccount + ( RewardAccount + ) +import Cardano.Wallet.Primitive.Types.StakePoolMetadata + ( StakePoolMetadataHash + , StakePoolMetadataUrl + ) +import Control.DeepSeq + ( NFData + ) +import Control.Lens + ( set + , view + ) +import Data.Generics.Labels + () +import Data.Quantity + ( Percentage + ) +import Data.Text.Class + ( FromText (..) + , TextDecodingError (TextDecodingError) + , ToText (..) + ) +import Data.Word + ( Word64 + ) +import Fmt + ( Buildable (..) + ) +import GHC.Generics + ( Generic + ) + +data DelegationCertificate + = CertDelegateNone RewardAccount + | CertDelegateFull RewardAccount PoolId + | CertRegisterKey RewardAccount + deriving (Generic, Show, Eq, Ord) + +instance NFData DelegationCertificate + +dlgCertAccount :: DelegationCertificate -> RewardAccount +dlgCertAccount = \case + CertDelegateNone acc -> acc + CertDelegateFull acc _ -> acc + CertRegisterKey acc -> acc + +dlgCertPoolId :: DelegationCertificate -> Maybe PoolId +dlgCertPoolId = \case + CertDelegateNone{} -> Nothing + CertDelegateFull _ poolId -> Just poolId + CertRegisterKey _ -> Nothing + +data StakeKeyCertificate + = StakeKeyRegistration + | StakeKeyDeregistration + deriving (Generic, Show, Read, Eq) + +instance NFData StakeKeyCertificate + +-- | Sum-type of pool registration- and retirement- certificates. Mirrors the +-- @PoolCert@ type in cardano-ledger-specs. +data PoolCertificate + = Registration PoolRegistrationCertificate + | Retirement PoolRetirementCertificate + deriving (Generic, Show, Eq, Ord) + +instance NFData PoolCertificate + +getPoolCertificatePoolId :: PoolCertificate -> PoolId +getPoolCertificatePoolId = \case + Registration cert -> + view #poolId cert + Retirement cert -> + view #poolId cert + +setPoolCertificatePoolId :: PoolId -> PoolCertificate -> PoolCertificate +setPoolCertificatePoolId newPoolId = \case + Registration cert -> + Registration + $ set #poolId newPoolId cert + Retirement cert -> + Retirement + $ set #poolId newPoolId cert + +-- | Pool ownership data from the stake pool registration certificate. +data PoolRegistrationCertificate = PoolRegistrationCertificate + { poolId :: !PoolId + , poolOwners :: ![PoolOwner] + , poolMargin :: Percentage + , poolCost :: Coin + , poolPledge :: Coin + , poolMetadata :: Maybe (StakePoolMetadataUrl, StakePoolMetadataHash) + } + deriving (Generic, Show, Eq, Ord) + +instance NFData PoolRegistrationCertificate + +instance Buildable PoolRegistrationCertificate where + build (PoolRegistrationCertificate{poolId, poolOwners}) = + mempty + <> "Registration of " + <> build poolId + <> " owned by " + <> build poolOwners + +data PoolRetirementCertificate = PoolRetirementCertificate + { poolId :: !PoolId + , retirementEpoch :: !EpochNo + -- ^ The first epoch when the pool becomes inactive. + } + deriving (Generic, Show, Eq, Ord) + +instance NFData PoolRetirementCertificate + +instance Buildable PoolRetirementCertificate where + build (PoolRetirementCertificate p e) = + mempty + <> "Pool " + <> build p + <> " with retirement epoch " + <> build e + +data NonWalletCertificate + = GenesisCertificate + | MIRCertificate + deriving (Generic, Show, Read, Eq) + +instance ToText NonWalletCertificate where + toText GenesisCertificate = "genesis" + toText MIRCertificate = "mir" + +instance FromText NonWalletCertificate where + fromText "genesis" = Right GenesisCertificate + fromText "mir" = Right MIRCertificate + fromText _ = + Left + $ TextDecodingError + "expecting either 'genesis' or 'mir' for NonWalletCertificate text value" + +instance NFData NonWalletCertificate + +data Certificate + = CertificateOfDelegation DelegationCertificate + | CertificateOfPool PoolCertificate + | CertificateOther NonWalletCertificate + deriving (Generic, Show, Eq) + +instance NFData Certificate + +-- | Represents an abstract notion of a certificate publication time. +-- +-- Certificates published at later times take precedence over certificates +-- published at earlier times. +data CertificatePublicationTime = CertificatePublicationTime + { slotNo + :: SlotNo + , slotInternalIndex + :: Word64 + -- ^ Indicates the relative position of a publication within a slot. + } + deriving (Eq, Generic, Ord, Show) + +-- | Indicates the current life cycle status of a pool. +data PoolLifeCycleStatus + = -- | Indicates that a pool is not registered. + PoolNotRegistered + | -- | Indicates that a pool is registered BUT NOT marked for retirement. + -- Records the latest registration certificate. + PoolRegistered + PoolRegistrationCertificate + | -- | Indicates that a pool is registered AND ALSO marked for retirement. + -- Records the latest registration and retirement certificates. + PoolRegisteredAndRetired + PoolRegistrationCertificate + PoolRetirementCertificate + deriving (Eq, Ord, Show) + +getPoolRegistrationCertificate + :: PoolLifeCycleStatus -> Maybe PoolRegistrationCertificate +getPoolRegistrationCertificate = \case + PoolNotRegistered -> Nothing + PoolRegistered c -> Just c + PoolRegisteredAndRetired c _ -> Just c + +getPoolRetirementCertificate + :: PoolLifeCycleStatus -> Maybe PoolRetirementCertificate +getPoolRetirementCertificate = \case + PoolNotRegistered -> Nothing + PoolRegistered _ -> Nothing + PoolRegisteredAndRetired _ c -> Just c diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/DelegationCertificate.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/DelegationCertificate.hs deleted file mode 100644 index 88949aebde6..00000000000 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/DelegationCertificate.hs +++ /dev/null @@ -1,44 +0,0 @@ -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE LambdaCase #-} - -module Cardano.Wallet.Primitive.Types.DelegationCertificate - ( DelegationCertificate (..) - , dlgCertAccount - , dlgCertPoolId - ) -where - -import Prelude - -import Cardano.Wallet.Primitive.Types.Pool - ( PoolId - ) -import Cardano.Wallet.Primitive.Types.RewardAccount - ( RewardAccount - ) -import Control.DeepSeq - ( NFData - ) -import GHC.Generics - ( Generic - ) - -data DelegationCertificate - = CertDelegateNone RewardAccount - | CertDelegateFull RewardAccount PoolId - | CertRegisterKey RewardAccount - deriving (Generic, Show, Eq, Ord) - -instance NFData DelegationCertificate - -dlgCertAccount :: DelegationCertificate -> RewardAccount -dlgCertAccount = \case - CertDelegateNone acc -> acc - CertDelegateFull acc _ -> acc - CertRegisterKey acc -> acc - -dlgCertPoolId :: DelegationCertificate -> Maybe PoolId -dlgCertPoolId = \case - CertDelegateNone{} -> Nothing - CertDelegateFull _ poolId -> Just poolId - CertRegisterKey _ -> Nothing diff --git a/lib/wallet/src/Cardano/Pool/Types.hs b/lib/wallet/src/Cardano/Pool/Types.hs index e82070338f3..127d7c8da97 100644 --- a/lib/wallet/src/Cardano/Pool/Types.hs +++ b/lib/wallet/src/Cardano/Pool/Types.hs @@ -3,6 +3,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-orphans #-} {-# OPTIONS_GHC -Wno-orphans #-} diff --git a/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs b/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs index c5098baaacf..5835b6b0df9 100644 --- a/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs +++ b/lib/wallet/src/Cardano/Wallet/Primitive/Types.hs @@ -9,7 +9,6 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -130,14 +129,6 @@ module Cardano.Wallet.Primitive.Types import Prelude -import Cardano.Pool.Metadata.Types - ( StakePoolMetadataHash - , StakePoolMetadataUrl - ) -import Cardano.Pool.Types - ( PoolId - , PoolOwner - ) import Cardano.Slotting.Slot ( SlotNo (..) , WithOrigin (..) @@ -160,8 +151,22 @@ import Cardano.Wallet.Primitive.Types.Block , isGenesisBlockHeader , toSlot ) -import Cardano.Wallet.Primitive.Types.Coin - ( Coin (..) +import Cardano.Wallet.Primitive.Types.Certificates + ( Certificate (..) + , CertificatePublicationTime (..) + , DelegationCertificate (..) + , NonWalletCertificate (..) + , PoolCertificate (..) + , PoolLifeCycleStatus (..) + , PoolRegistrationCertificate (..) + , PoolRetirementCertificate (..) + , StakeKeyCertificate (..) + , dlgCertAccount + , dlgCertPoolId + , getPoolCertificatePoolId + , getPoolRegistrationCertificate + , getPoolRetirementCertificate + , setPoolCertificatePoolId ) import Cardano.Wallet.Primitive.Types.DecentralizationLevel ( DecentralizationLevel (getDecentralizationLevel) @@ -169,11 +174,6 @@ import Cardano.Wallet.Primitive.Types.DecentralizationLevel , fromFederationPercentage , getFederationPercentage ) -import Cardano.Wallet.Primitive.Types.DelegationCertificate - ( DelegationCertificate (..) - , dlgCertAccount - , dlgCertPoolId - ) import Cardano.Wallet.Primitive.Types.EpochNo ( EpochNo (..) , isValidEpochNo @@ -193,6 +193,9 @@ import Cardano.Wallet.Primitive.Types.FeePolicy import Cardano.Wallet.Primitive.Types.Hash ( Hash (..) ) +import Cardano.Wallet.Primitive.Types.Pool + ( PoolId + ) import Cardano.Wallet.Primitive.Types.ProtocolParameters ( ProtocolParameters (..) ) @@ -252,18 +255,11 @@ import Data.ByteString import Data.Data ( Proxy (..) ) -import Data.Generics.Internal.VL.Lens - ( set - , view - ) import Data.Generics.Labels () import Data.Kind ( Type ) -import Data.Quantity - ( Percentage (..) - ) import Data.Text ( Text ) @@ -287,7 +283,6 @@ import Data.Time.Format ) import Data.Word ( Word32 - , Word64 ) import Database.Persist.Class.PersistField ( PersistField (fromPersistValue, toPersistValue) @@ -551,17 +546,6 @@ instance Buildable GenesisParameters where genesisF = build . T.decodeUtf8 . convertToBase Base16 . getHash startTimeF (StartTime s) = build s -{------------------------------------------------------------------------------- - Stake Pool Delegation and Registration Certificates --------------------------------------------------------------------------------} - -data StakeKeyCertificate - = StakeKeyRegistration - | StakeKeyDeregistration - deriving (Generic, Show, Read, Eq) - -instance NFData StakeKeyCertificate - instance PersistField StakeKeyCertificate where toPersistValue = toPersistValue . show fromPersistValue = fromPersistValueRead @@ -569,133 +553,6 @@ instance PersistField StakeKeyCertificate where instance PersistFieldSql StakeKeyCertificate where sqlType _ = sqlType (Proxy @Text) --- | Sum-type of pool registration- and retirement- certificates. Mirrors the --- @PoolCert@ type in cardano-ledger-specs. -data PoolCertificate - = Registration PoolRegistrationCertificate - | Retirement PoolRetirementCertificate - deriving (Generic, Show, Eq, Ord) - -instance NFData PoolCertificate - -getPoolCertificatePoolId :: PoolCertificate -> PoolId -getPoolCertificatePoolId = \case - Registration cert -> - view #poolId cert - Retirement cert -> - view #poolId cert - -setPoolCertificatePoolId :: PoolId -> PoolCertificate -> PoolCertificate -setPoolCertificatePoolId newPoolId = \case - Registration cert -> Registration - $ set #poolId newPoolId cert - Retirement cert -> Retirement - $ set #poolId newPoolId cert - --- | Pool ownership data from the stake pool registration certificate. -data PoolRegistrationCertificate = PoolRegistrationCertificate - { poolId :: !PoolId - , poolOwners :: ![PoolOwner] - , poolMargin :: Percentage - , poolCost :: Coin - , poolPledge :: Coin - , poolMetadata :: Maybe (StakePoolMetadataUrl, StakePoolMetadataHash) - } deriving (Generic, Show, Eq, Ord) - -instance NFData PoolRegistrationCertificate - -instance Buildable PoolRegistrationCertificate where - build (PoolRegistrationCertificate {poolId, poolOwners}) = mempty - <> "Registration of " - <> build poolId - <> " owned by " - <> build poolOwners - -data PoolRetirementCertificate = PoolRetirementCertificate - { poolId :: !PoolId - - -- | The first epoch when the pool becomes inactive. - , retirementEpoch :: !EpochNo - } deriving (Generic, Show, Eq, Ord) - -instance NFData PoolRetirementCertificate - -instance Buildable PoolRetirementCertificate where - build (PoolRetirementCertificate p e) = mempty - <> "Pool " - <> build p - <> " with retirement epoch " - <> build e - -data NonWalletCertificate - = GenesisCertificate - | MIRCertificate - deriving (Generic, Show, Read, Eq) - -instance ToText NonWalletCertificate where - toText GenesisCertificate = "genesis" - toText MIRCertificate = "mir" - -instance FromText NonWalletCertificate where - fromText "genesis" = Right GenesisCertificate - fromText "mir" = Right MIRCertificate - fromText _ = Left $ TextDecodingError - "expecting either 'genesis' or 'mir' for NonWalletCertificate text value" - -instance NFData NonWalletCertificate - -data Certificate = - CertificateOfDelegation DelegationCertificate - | CertificateOfPool PoolCertificate - | CertificateOther NonWalletCertificate - deriving (Generic, Show, Eq) - -instance NFData Certificate - --- | Represents an abstract notion of a certificate publication time. --- --- Certificates published at later times take precedence over certificates --- published at earlier times. --- -data CertificatePublicationTime = CertificatePublicationTime - { slotNo - :: SlotNo - , slotInternalIndex - :: Word64 - -- ^ Indicates the relative position of a publication within a slot. - } - deriving (Eq, Generic, Ord, Show) - --- | Indicates the current life cycle status of a pool. --- -data PoolLifeCycleStatus - = PoolNotRegistered - -- ^ Indicates that a pool is not registered. - | PoolRegistered - PoolRegistrationCertificate - -- ^ Indicates that a pool is registered BUT NOT marked for retirement. - -- Records the latest registration certificate. - | PoolRegisteredAndRetired - PoolRegistrationCertificate - PoolRetirementCertificate - -- ^ Indicates that a pool is registered AND ALSO marked for retirement. - -- Records the latest registration and retirement certificates. - deriving (Eq, Ord, Show) - -getPoolRegistrationCertificate - :: PoolLifeCycleStatus -> Maybe PoolRegistrationCertificate -getPoolRegistrationCertificate = \case - PoolNotRegistered -> Nothing - PoolRegistered c -> Just c - PoolRegisteredAndRetired c _ -> Just c - -getPoolRetirementCertificate - :: PoolLifeCycleStatus -> Maybe PoolRetirementCertificate -getPoolRetirementCertificate = \case - PoolNotRegistered -> Nothing - PoolRegistered _ -> Nothing - PoolRegisteredAndRetired _ c -> Just c - {------------------------------------------------------------------------------- Polymorphic Types -------------------------------------------------------------------------------} From 60596d3ae1f86fc50f5fc5ff4e219640ea8fe608 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 09:43:05 +0000 Subject: [PATCH 09/11] Move Read.Primitive hierarchy from wallet to primitive lib --- lib/primitive/cardano-wallet-primitive.cabal | 29 ++++++++++++ .../Cardano/Wallet/Read/Primitive/Block.hs | 3 +- .../Wallet/Read/Primitive/Block/Header.hs | 2 +- .../lib}/Cardano/Wallet/Read/Primitive/Tx.hs | 22 +++++---- .../Wallet/Read/Primitive/Tx/Allegra.hs | 24 ++++++---- .../Wallet/Read/Primitive/Tx/Alonzo.hs | 30 ++++++++----- .../Wallet/Read/Primitive/Tx/Babbage.hs | 45 +++++++++++-------- .../Cardano/Wallet/Read/Primitive/Tx/Byron.hs | 0 .../Wallet/Read/Primitive/Tx/Conway.hs | 32 +++++++------ .../Primitive/Tx/Features/Certificates.hs | 13 +++--- .../Primitive/Tx/Features/CollateralInputs.hs | 0 .../Tx/Features/CollateralOutputs.hs | 0 .../Read/Primitive/Tx/Features/ExtraSigs.hs | 0 .../Wallet/Read/Primitive/Tx/Features/Fee.hs | 0 .../Read/Primitive/Tx/Features/Inputs.hs | 0 .../Read/Primitive/Tx/Features/Integrity.hs | 0 .../Read/Primitive/Tx/Features/Metadata.hs | 0 .../Wallet/Read/Primitive/Tx/Features/Mint.hs | 18 ++++---- .../Read/Primitive/Tx/Features/Outputs.hs | 0 .../Primitive/Tx/Features/ScriptValidity.hs | 0 .../Read/Primitive/Tx/Features/Validity.hs | 6 +-- .../Read/Primitive/Tx/Features/Withdrawals.hs | 0 .../Cardano/Wallet/Read/Primitive/Tx/Mary.hs | 26 ++++++----- .../Wallet/Read/Primitive/Tx/Sealed.hs | 0 .../Wallet/Read/Primitive/Tx/Shelley.hs | 26 ++++++----- lib/wallet/cardano-wallet.cabal | 24 ---------- 26 files changed, 173 insertions(+), 127 deletions(-) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Block.hs (95%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Block/Header.hs (98%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx.hs (89%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs (89%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs (89%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs (89%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Byron.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Conway.hs (93%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs (96%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralInputs.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/ExtraSigs.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Inputs.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Integrity.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Metadata.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs (97%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/ScriptValidity.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs (97%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Mary.hs (88%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Sealed.hs (100%) rename lib/{wallet/src => primitive/lib}/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs (91%) diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index ff0b5b7c0a6..eee18ff5a41 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -49,9 +49,13 @@ library , cardano-binary , cardano-crypto , cardano-crypto-class + , cardano-crypto-wrapper , cardano-ledger-allegra , cardano-ledger-alonzo + , cardano-ledger-api , cardano-ledger-babbage + , cardano-ledger-byron + , cardano-ledger-conway , cardano-ledger-core , cardano-ledger-mary , cardano-ledger-shelley @@ -88,6 +92,7 @@ library , OddWord , ouroboros-consensus , ouroboros-consensus-cardano + , ouroboros-network-api , pretty-simple , QuickCheck , quiet @@ -162,6 +167,30 @@ library Cardano.Wallet.Primitive.Types.UTxO.Gen Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit Cardano.Wallet.Primitive.Types.WitnessCount + Cardano.Wallet.Read.Primitive.Block + Cardano.Wallet.Read.Primitive.Block.Header + Cardano.Wallet.Read.Primitive.Tx + Cardano.Wallet.Read.Primitive.Tx.Allegra + Cardano.Wallet.Read.Primitive.Tx.Alonzo + Cardano.Wallet.Read.Primitive.Tx.Babbage + Cardano.Wallet.Read.Primitive.Tx.Byron + Cardano.Wallet.Read.Primitive.Tx.Conway + Cardano.Wallet.Read.Primitive.Tx.Features.Certificates + Cardano.Wallet.Read.Primitive.Tx.Features.CollateralInputs + Cardano.Wallet.Read.Primitive.Tx.Features.CollateralOutputs + Cardano.Wallet.Read.Primitive.Tx.Features.ExtraSigs + Cardano.Wallet.Read.Primitive.Tx.Features.Fee + Cardano.Wallet.Read.Primitive.Tx.Features.Inputs + Cardano.Wallet.Read.Primitive.Tx.Features.Integrity + Cardano.Wallet.Read.Primitive.Tx.Features.Metadata + Cardano.Wallet.Read.Primitive.Tx.Features.Mint + Cardano.Wallet.Read.Primitive.Tx.Features.Outputs + Cardano.Wallet.Read.Primitive.Tx.Features.ScriptValidity + Cardano.Wallet.Read.Primitive.Tx.Features.Validity + Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals + Cardano.Wallet.Read.Primitive.Tx.Mary + Cardano.Wallet.Read.Primitive.Tx.Sealed + Cardano.Wallet.Read.Primitive.Tx.Shelley Cardano.Wallet.Unsafe Cardano.Wallet.Util Control.Monad.Random.NonRandom diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Block.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block.hs similarity index 95% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Block.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block.hs index 31b193e3fe7..09056c694dd 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Block.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block.hs @@ -54,7 +54,8 @@ import Control.Error ( partitionEithers ) -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Block as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Block/Header.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block/Header.hs similarity index 98% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Block/Header.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block/Header.hs index c8ff8713a0a..39f15c81dc2 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Block/Header.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block/Header.hs @@ -70,7 +70,7 @@ import Ouroboros.Consensus.Shelley.Protocol.Abstract import qualified Cardano.Crypto.Hashing as CC import qualified Cardano.Protocol.TPraos.BHeader as SL -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Block as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Ouroboros.Network.Block as O diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx.hs similarity index 89% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx.hs index 83197ecb237..3a90e808d0d 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx.hs @@ -11,6 +11,18 @@ module Cardano.Wallet.Read.Primitive.Tx ( import Prelude +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( TokenMapWithScripts + , emptyTokenMapWithScripts + ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit + ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount + , WitnessCountCtx + , emptyWitnessCount + ) import Cardano.Wallet.Read ( Tx (..) ) @@ -44,14 +56,6 @@ import Cardano.Wallet.Read.Primitive.Tx.Shelley ( fromShelleyTx , fromShelleyTx' ) -import Cardano.Wallet.Transaction - ( TokenMapWithScripts (..) - , ValidityIntervalExplicit (..) - , WitnessCount - , WitnessCountCtx - , emptyTokenMapWithScripts - , emptyWitnessCount - ) import Generics.SOP ( K (..) ) @@ -61,7 +65,7 @@ import qualified Cardano.Api.Byron as Cardano ( Tx (ByronTx) ) import qualified Cardano.Api.Shelley as Cardano -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Tx as W fromCardanoTx :: diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs similarity index 89% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs index 5e66e377e56..1f53c984ecd 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs @@ -51,6 +51,20 @@ import Cardano.Ledger.Shelley.Tx import Cardano.Wallet.Primitive.Convert ( toWalletScript ) +import Cardano.Wallet.Primitive.Types.AnyExplicitScripts + ( AnyExplicitScript (NativeExplicitScript) + ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( ScriptReference (ViaSpending) + , TokenMapWithScripts + , emptyTokenMapWithScripts + ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit + ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount (WitnessCount) + ) import Cardano.Wallet.Read.Eras ( allegra , inject @@ -85,14 +99,6 @@ import Cardano.Wallet.Read.Tx.Hash import Cardano.Wallet.Read.Tx.Withdrawals ( shelleyWithdrawals ) -import Cardano.Wallet.Transaction - ( AnyExplicitScript (..) - , ScriptReference (..) - , TokenMapWithScripts (..) - , ValidityIntervalExplicit (..) - , WitnessCount (..) - , emptyTokenMapWithScripts - ) import Control.Lens ( folded , (^.) @@ -105,7 +111,7 @@ import Data.Foldable import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Wallet.Primitive.Convert as Ledger -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W import qualified Data.Set as Set diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs similarity index 89% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs index e1e67ab8b91..a98d1389da8 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs @@ -41,6 +41,23 @@ import Cardano.Ledger.Api import Cardano.Wallet.Primitive.Convert ( toWalletScript ) +import Cardano.Wallet.Primitive.Types.AnyExplicitScripts + ( AnyExplicitScript (NativeExplicitScript, PlutusExplicitScript) + ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( PlutusScriptInfo (PlutusScriptInfo) + , PlutusVersion (PlutusVersionV1, PlutusVersionV2, PlutusVersionV3) + , ScriptReference (ViaSpending) + , TokenMapWithScripts + ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit + ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount (WitnessCount) + , WitnessCountCtx + , toKeyRole + ) import Cardano.Wallet.Read.Eras ( alonzo , inject @@ -79,17 +96,6 @@ import Cardano.Wallet.Read.Tx.Hash import Cardano.Wallet.Read.Tx.Withdrawals ( shelleyWithdrawals ) -import Cardano.Wallet.Transaction - ( AnyExplicitScript (..) - , PlutusScriptInfo (..) - , PlutusVersion (..) - , ScriptReference (..) - , TokenMapWithScripts (..) - , ValidityIntervalExplicit (..) - , WitnessCount (..) - , WitnessCountCtx - , toKeyRole - ) import Control.Lens ( folded , (^.) @@ -103,7 +109,7 @@ import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Core as Core import qualified Cardano.Ledger.Language as Language import qualified Cardano.Wallet.Primitive.Convert as Ledger -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W import qualified Data.Set as Set diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs similarity index 89% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs index 3747617bbb5..d76ad9570b7 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs @@ -21,11 +21,9 @@ import Prelude import Cardano.Api ( BabbageEra ) -import Cardano.Ledger.Alonzo - ( AlonzoScript - ) import Cardano.Ledger.Api - ( StandardCrypto + ( ScriptHash + , StandardCrypto , addrTxWitsL , auxDataTxL , bodyTxL @@ -94,15 +92,26 @@ import Cardano.Wallet.Read.Tx.Hash import Cardano.Wallet.Read.Tx.Withdrawals ( shelleyWithdrawals ) -import Cardano.Wallet.Transaction + +import Cardano.Ledger.Babbage + ( AlonzoScript + , BabbageTxOut + ) +import Cardano.Wallet.Primitive.Types.AnyExplicitScripts ( AnyExplicitScript (..) - , PlutusScriptInfo (..) - , PlutusVersion (..) - , ReferenceInput (..) - , ScriptReference (..) - , TokenMapWithScripts (..) - , ValidityIntervalExplicit (..) - , WitnessCount (..) + ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( PlutusScriptInfo (PlutusScriptInfo) + , PlutusVersion (PlutusVersionV1, PlutusVersionV2, PlutusVersionV3) + , ReferenceInput (ReferenceInput) + , ScriptReference (ViaReferenceInput, ViaSpending) + , TokenMapWithScripts + ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit + ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount (WitnessCount) , WitnessCountCtx , toKeyRole ) @@ -121,21 +130,19 @@ import Data.Maybe.Strict import Data.Word ( Word32 ) -import Internal.Cardano.Write.Tx - ( BabbageTxOut - , StandardBabbage +import Ouroboros.Consensus.Cardano.Block + ( StandardBabbage ) import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo import qualified Cardano.Ledger.Alonzo.Tx as Alonzo -import qualified Cardano.Ledger.Api.Scripts as Ledger import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Core as Core import qualified Cardano.Ledger.Language as Language import qualified Cardano.Ledger.Mary.Value as SL import qualified Cardano.Wallet.Primitive.Convert as Ledger -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W import qualified Data.List as L @@ -180,7 +187,7 @@ fromBabbageTx tx witCtx = -> BabbageTxOut StandardBabbage -> Maybe ( ScriptReference - , Ledger.ScriptHash StandardCrypto + , ScriptHash StandardCrypto , AlonzoScript StandardBabbage ) scriptWithHashIx ix txout = @@ -205,7 +212,7 @@ fromBabbageTx tx witCtx = fromLedgerToAnyScript :: ( ScriptReference - , Ledger.ScriptHash StandardCrypto + , ScriptHash StandardCrypto , AlonzoScript StandardBabbage ) -> (TokenPolicyId, AnyExplicitScript) diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Byron.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Byron.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Byron.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Byron.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Conway.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs similarity index 93% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Conway.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs index f257640f14b..e990767f8a2 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Conway.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs @@ -50,6 +50,16 @@ import Cardano.Wallet.Primitive.Convert ( toWalletScript , toWalletTokenPolicyId ) +import Cardano.Wallet.Primitive.Types.AnyExplicitScripts + ( AnyExplicitScript (..) + ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( PlutusScriptInfo (PlutusScriptInfo) + , PlutusVersion (PlutusVersionV1, PlutusVersionV2, PlutusVersionV3) + , ReferenceInput (ReferenceInput) + , ScriptReference (..) + , TokenMapWithScripts + ) import Cardano.Wallet.Primitive.Types.TokenPolicy ( TokenPolicyId (..) ) @@ -59,6 +69,14 @@ import Cardano.Wallet.Primitive.Types.Tx import Cardano.Wallet.Primitive.Types.Tx.TxIn ( TxIn (..) ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit + ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount (WitnessCount) + , WitnessCountCtx + , toKeyRole + ) import Cardano.Wallet.Read.Eras ( conway , inject @@ -97,18 +115,6 @@ import Cardano.Wallet.Read.Tx.Hash import Cardano.Wallet.Read.Tx.Withdrawals ( shelleyWithdrawals ) -import Cardano.Wallet.Transaction - ( AnyExplicitScript (..) - , PlutusScriptInfo (..) - , PlutusVersion (..) - , ReferenceInput (..) - , ScriptReference (..) - , TokenMapWithScripts (..) - , ValidityIntervalExplicit (..) - , WitnessCount (..) - , WitnessCountCtx - , toKeyRole - ) import Control.Lens ( folded , (<&>) @@ -140,7 +146,7 @@ import qualified Cardano.Ledger.Core as Core import qualified Cardano.Ledger.Language as Language import qualified Cardano.Ledger.Mary.Value as SL import qualified Cardano.Wallet.Primitive.Convert as Ledger -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W import qualified Data.List as L diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs similarity index 96% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs index 135a90a1375..1691862fae7 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs @@ -41,18 +41,18 @@ import Cardano.Ledger.Shelley.API import Cardano.Ledger.Shelley.TxBody ( DCert ) -import Cardano.Pool.Types - ( PoolId (PoolId) - , PoolOwner (PoolOwner) - ) import Cardano.Slotting.Slot ( EpochNo (..) ) -import Cardano.Wallet.Primitive.Types +import Cardano.Wallet.Primitive.Types.Certificates ( PoolCertificate (..) , PoolRegistrationCertificate (..) , PoolRetirementCertificate (..) ) +import Cardano.Wallet.Primitive.Types.Pool + ( PoolId (PoolId) + , PoolOwner (PoolOwner) + ) import Cardano.Wallet.Primitive.Types.StakePoolMetadata ( StakePoolMetadataHash (..) , StakePoolMetadataUrl (..) @@ -86,9 +86,10 @@ import GHC.Stack import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Credential as SL import qualified Cardano.Ledger.Shelley.API as SL -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Coin as Coin import qualified Cardano.Wallet.Primitive.Types.Coin as W +import qualified Cardano.Wallet.Primitive.Types.EpochNo as W import qualified Cardano.Wallet.Primitive.Types.RewardAccount as W import qualified Data.Set as Set diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralInputs.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralInputs.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralInputs.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralInputs.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/ExtraSigs.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ExtraSigs.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/ExtraSigs.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ExtraSigs.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Inputs.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Inputs.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Inputs.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Inputs.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Integrity.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Integrity.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Integrity.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Integrity.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Metadata.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Metadata.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Metadata.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Metadata.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs similarity index 97% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs index ad1dbc01dcd..fd1a92f2439 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs @@ -55,6 +55,15 @@ import Cardano.Wallet.Primitive.Types.TokenMap , toNestedList , toNestedMap ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( AnyScript (..) + , PlutusScriptInfo (PlutusScriptInfo) + , PlutusVersion (..) + , ReferenceInput (ReferenceInput) + , ScriptReference (ViaSpending) + , TokenMapWithScripts (TokenMapWithScripts) + , emptyTokenMapWithScripts + ) import Cardano.Wallet.Primitive.Types.TokenPolicy ( TokenPolicyId (..) ) @@ -75,15 +84,6 @@ import Cardano.Wallet.Read.Tx.ReferenceInputs import Cardano.Wallet.Read.Tx.Witnesses ( Witnesses (..) ) -import Cardano.Wallet.Transaction - ( AnyScript (..) - , PlutusScriptInfo (..) - , PlutusVersion (..) - , ReferenceInput (..) - , ScriptReference (..) - , TokenMapWithScripts (..) - , emptyTokenMapWithScripts - ) import Data.Foldable ( toList ) diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/ScriptValidity.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ScriptValidity.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/ScriptValidity.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ScriptValidity.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs similarity index 97% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs index ed21ae22844..d9aebc2bdff 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs @@ -20,6 +20,9 @@ import Prelude import Cardano.Ledger.Api ( ValidityInterval (..) ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit (ValidityIntervalExplicit) + ) import Cardano.Wallet.Read.Eras ( EraFun (..) , K (..) @@ -27,9 +30,6 @@ import Cardano.Wallet.Read.Eras import Cardano.Wallet.Read.Tx.Validity ( Validity (..) ) -import Cardano.Wallet.Transaction - ( ValidityIntervalExplicit (ValidityIntervalExplicit) - ) import Data.Maybe.Strict ( StrictMaybe (..) ) diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Mary.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs similarity index 88% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Mary.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs index 75d3a4a2400..fa4502e218f 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Mary.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs @@ -36,6 +36,21 @@ import Cardano.Ledger.Api import Cardano.Wallet.Primitive.Convert ( toWalletScript ) +import Cardano.Wallet.Primitive.Types.AnyExplicitScripts + ( AnyExplicitScript (NativeExplicitScript) + ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( ScriptReference (ViaSpending) + , TokenMapWithScripts + ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit + ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount (WitnessCount) + , WitnessCountCtx + , toKeyRole + ) import Cardano.Wallet.Read.Eras ( inject , mary @@ -73,15 +88,6 @@ import Cardano.Wallet.Read.Tx.Hash import Cardano.Wallet.Read.Tx.Withdrawals ( shelleyWithdrawals ) -import Cardano.Wallet.Transaction - ( AnyExplicitScript (..) - , ScriptReference (..) - , TokenMapWithScripts (..) - , ValidityIntervalExplicit (..) - , WitnessCount (..) - , WitnessCountCtx - , toKeyRole - ) import Control.Lens ( folded , (^.) @@ -92,7 +98,7 @@ import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Shelley.API as SL import qualified Cardano.Wallet.Primitive.Convert as Ledger -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W import qualified Data.Set as Set diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Sealed.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Sealed.hs similarity index 100% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Sealed.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Sealed.hs diff --git a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs similarity index 91% rename from lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs rename to lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs index c6631dad250..86ef4313795 100644 --- a/lib/wallet/src/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs @@ -44,6 +44,20 @@ import Cardano.Ledger.Shelley.TxBody import Cardano.Wallet.Primitive.Convert ( toWalletScriptFromShelley ) +import Cardano.Wallet.Primitive.Types.AnyExplicitScripts + ( AnyExplicitScript (NativeExplicitScript) + ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( ScriptReference (..) + , TokenMapWithScripts (..) + , emptyTokenMapWithScripts + ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit + ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount (..) + ) import Cardano.Wallet.Read.Eras ( inject , shelley @@ -76,14 +90,6 @@ import Cardano.Wallet.Read.Tx.Hash import Cardano.Wallet.Read.Tx.Withdrawals ( shelleyWithdrawals ) -import Cardano.Wallet.Transaction - ( AnyExplicitScript (..) - , ScriptReference (..) - , TokenMapWithScripts (..) - , ValidityIntervalExplicit (..) - , WitnessCount (..) - , emptyTokenMapWithScripts - ) import Control.Lens ( folded , (^.) @@ -99,12 +105,10 @@ import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Shelley.API as SL import qualified Cardano.Wallet.Primitive.Convert as Ledger -import qualified Cardano.Wallet.Primitive.Types as W +import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W import qualified Cardano.Wallet.Primitive.Types.Tx.TxIn as W - ( TxIn (TxIn) - ) import qualified Data.Set as Set fromShelleyTxIn diff --git a/lib/wallet/cardano-wallet.cabal b/lib/wallet/cardano-wallet.cabal index 40473078381..86d99bde240 100644 --- a/lib/wallet/cardano-wallet.cabal +++ b/lib/wallet/cardano-wallet.cabal @@ -310,30 +310,6 @@ library Cardano.Wallet.Primitive.Types.Tx.TxSeq Cardano.Wallet.Primitive.Types.Tx.TxSeq.Gen Cardano.Wallet.Primitive.Types.UTxOStatistics - Cardano.Wallet.Read.Primitive.Block - Cardano.Wallet.Read.Primitive.Block.Header - Cardano.Wallet.Read.Primitive.Tx - Cardano.Wallet.Read.Primitive.Tx.Allegra - Cardano.Wallet.Read.Primitive.Tx.Alonzo - Cardano.Wallet.Read.Primitive.Tx.Babbage - Cardano.Wallet.Read.Primitive.Tx.Byron - Cardano.Wallet.Read.Primitive.Tx.Conway - Cardano.Wallet.Read.Primitive.Tx.Features.Certificates - Cardano.Wallet.Read.Primitive.Tx.Features.CollateralInputs - Cardano.Wallet.Read.Primitive.Tx.Features.CollateralOutputs - Cardano.Wallet.Read.Primitive.Tx.Features.ExtraSigs - Cardano.Wallet.Read.Primitive.Tx.Features.Fee - Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - Cardano.Wallet.Read.Primitive.Tx.Features.Integrity - Cardano.Wallet.Read.Primitive.Tx.Features.Metadata - Cardano.Wallet.Read.Primitive.Tx.Features.Mint - Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - Cardano.Wallet.Read.Primitive.Tx.Features.ScriptValidity - Cardano.Wallet.Read.Primitive.Tx.Features.Validity - Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals - Cardano.Wallet.Read.Primitive.Tx.Mary - Cardano.Wallet.Read.Primitive.Tx.Sealed - Cardano.Wallet.Read.Primitive.Tx.Shelley Cardano.Wallet.Registry Cardano.Wallet.Shelley.BlockchainSource Cardano.Wallet.Shelley.Compatibility From 27e87d31e20f3cd3d38319088a78756a485ac5d3 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 16:21:57 +0000 Subject: [PATCH 10/11] Rename Primitive.Convert as Primitive.Ledger.Convert --- .../lib/internal/Internal/Cardano/Write/Tx.hs | 2 +- .../Internal/Cardano/Write/Tx/Balance.hs | 2 +- .../Write/Tx/Balance/TokenBundleSize.hs | 2 +- .../Internal/Cardano/Write/Tx/Sign.hs | 2 +- lib/primitive/cardano-wallet-primitive.cabal | 4 +- .../Wallet/Primitive/{ => Ledger}/Convert.hs | 2 +- .../Wallet/Read/Primitive/Tx/Allegra.hs | 4 +- .../Wallet/Read/Primitive/Tx/Alonzo.hs | 4 +- .../Wallet/Read/Primitive/Tx/Babbage.hs | 4 +- .../Wallet/Read/Primitive/Tx/Conway.hs | 4 +- .../Tx/Features/CollateralOutputs.hs | 2 +- .../Wallet/Read/Primitive/Tx/Features/Fee.hs | 2 +- .../Wallet/Read/Primitive/Tx/Features/Mint.hs | 2 +- .../Read/Primitive/Tx/Features/Outputs.hs | 4 +- .../Read/Primitive/Tx/Features/Withdrawals.hs | 2 +- .../Cardano/Wallet/Read/Primitive/Tx/Mary.hs | 4 +- .../Wallet/Read/Primitive/Tx/Shelley.hs | 4 +- .../Cardano/Wallet/Primitive/ConvertSpec.hs | 194 ------------------ .../Cardano/Wallet/Api/Http/Server/Error.hs | 2 +- .../Cardano/Wallet/Api/Http/Shelley/Server.hs | 8 +- lib/wallet/src/Cardano/Wallet.hs | 2 +- .../Wallet/Address/Discovery/RandomAny.hs | 2 +- .../Wallet/Address/Discovery/SequentialAny.hs | 2 +- .../Cardano/Wallet/Shelley/Compatibility.hs | 2 +- .../Cardano/Wallet/Shelley/Network/Node.hs | 2 +- .../src/Cardano/Wallet/Shelley/Transaction.hs | 4 +- .../Internal/Cardano/Write/Tx/BalanceSpec.hs | 2 +- 27 files changed, 38 insertions(+), 232 deletions(-) rename lib/primitive/lib/Cardano/Wallet/Primitive/{ => Ledger}/Convert.hs (99%) delete mode 100644 lib/primitive/test/spec/Cardano/Wallet/Primitive/ConvertSpec.hs diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs index bfcc6ec4434..4204dc1ef6c 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs @@ -282,7 +282,7 @@ import qualified Cardano.Ledger.Keys as Ledger import qualified Cardano.Ledger.Shelley.API.Wallet as Shelley import qualified Cardano.Ledger.Shelley.UTxO as Shelley import qualified Cardano.Ledger.TxIn as Ledger -import qualified Cardano.Wallet.Primitive.Convert as Convert +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert import qualified Cardano.Wallet.Primitive.Types.Tx.Constraints as W ( txOutMaxCoin ) diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs index 8fcfb5e99f1..9bcb6e47adb 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance.hs @@ -291,7 +291,7 @@ import qualified Cardano.Api.Shelley as CardanoApi import qualified Cardano.CoinSelection.UTxOIndex as UTxOIndex import qualified Cardano.CoinSelection.UTxOSelection as UTxOSelection import qualified Cardano.Ledger.Core as Core -import qualified Cardano.Wallet.Primitive.Convert as Convert +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert import qualified Cardano.Wallet.Primitive.Types.Address as W ( Address ) diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance/TokenBundleSize.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance/TokenBundleSize.hs index e034c33674d..3ea356ae8a2 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance/TokenBundleSize.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Balance/TokenBundleSize.hs @@ -35,7 +35,7 @@ import Internal.Cardano.Write.Tx , Version ) -import qualified Cardano.Wallet.Primitive.Convert as Convert +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert import qualified Cardano.Wallet.Primitive.Types.TokenBundle as W ( TokenBundle ) diff --git a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Sign.hs b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Sign.hs index 909749ea335..91565b5617e 100644 --- a/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Sign.hs +++ b/lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx/Sign.hs @@ -74,7 +74,7 @@ import qualified Cardano.Api.Byron as CardanoApi import qualified Cardano.Api.Shelley as CardanoApi import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo import qualified Cardano.Ledger.Api as Ledger -import qualified Cardano.Wallet.Primitive.Convert as Convert +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert import qualified Cardano.Wallet.Primitive.Types.Coin as W ( Coin (..) ) diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index eee18ff5a41..9708f64bdae 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -110,7 +110,7 @@ library exposed-modules: Cardano.Wallet.Orphans Cardano.Wallet.Primitive.Collateral - Cardano.Wallet.Primitive.Convert + Cardano.Wallet.Primitive.Ledger.Convert Cardano.Wallet.Primitive.NetworkId Cardano.Wallet.Primitive.Slotting Cardano.Wallet.Primitive.Slotting.Legacy @@ -252,7 +252,7 @@ test-suite test build-tool-depends: hspec-discover:hspec-discover other-modules: Cardano.Wallet.Primitive.CollateralSpec - Cardano.Wallet.Primitive.ConvertSpec + Cardano.Wallet.Primitive.Ledger.ConvertSpec Cardano.Wallet.Primitive.SlottingSpec Cardano.Wallet.Primitive.SyncProgressSpec Cardano.Wallet.Primitive.Types.AddressSpec diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Convert.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs similarity index 99% rename from lib/primitive/lib/Cardano/Wallet/Primitive/Convert.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs index a064ec59684..e4cbf9e6ee8 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Convert.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs @@ -12,7 +12,7 @@ -- Exposes a wallet-friendly interface to types and functions exported by the -- ledger specification. -- -module Cardano.Wallet.Primitive.Convert +module Cardano.Wallet.Primitive.Ledger.Convert ( -- * Conversions from wallet types to ledger specification types toLedgerAddress diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs index 1f53c984ecd..64b4a51bb9d 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs @@ -48,7 +48,7 @@ import Cardano.Ledger.Core import Cardano.Ledger.Shelley.Tx ( ShelleyTx ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts @@ -110,7 +110,7 @@ import Data.Foldable import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Ledger.BaseTypes as SL -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs index a98d1389da8..c65ad8cfd86 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs @@ -38,7 +38,7 @@ import Cardano.Ledger.Api , vldtTxBodyL , witsTxL ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts @@ -108,7 +108,7 @@ import qualified Cardano.Ledger.Alonzo.Tx as Alonzo import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Core as Core import qualified Cardano.Ledger.Language as Language -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs index d76ad9570b7..4e15bfea951 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs @@ -41,7 +41,7 @@ import Cardano.Ledger.Api , vldtTxBodyL , witsTxL ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript , toWalletTokenPolicyId ) @@ -141,7 +141,7 @@ import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Core as Core import qualified Cardano.Ledger.Language as Language import qualified Cardano.Ledger.Mary.Value as SL -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs index e990767f8a2..057bc872813 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs @@ -46,7 +46,7 @@ import Cardano.Ledger.Api import Cardano.Ledger.Babbage ( BabbageTxOut ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript , toWalletTokenPolicyId ) @@ -145,7 +145,7 @@ import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Core as Core import qualified Cardano.Ledger.Language as Language import qualified Cardano.Ledger.Mary.Value as SL -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs index 6151ee5a7f2..c8f6e2e0c84 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs @@ -7,7 +7,7 @@ module Cardano.Wallet.Read.Primitive.Tx.Features.CollateralOutputs import Prelude -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletTokenBundle ) import Cardano.Wallet.Read.Eras diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs index c2f691c6d32..1dd68f87af0 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs @@ -18,7 +18,7 @@ import Cardano.Wallet.Read.Tx.Fee , FeeType ) -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Coin as W getFee :: EraFun Fee (K (Maybe W.Coin)) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs index fd1a92f2439..81eacaa70d1 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs @@ -41,7 +41,7 @@ import Cardano.Ledger.Shelley.TxWits ( ShelleyTxWits , scriptWits ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript , toWalletTokenName , toWalletTokenPolicyId diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs index efbf220206b..a82f126fc74 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs @@ -28,7 +28,7 @@ import Cardano.Ledger.Alonzo import Cardano.Ledger.Shelley.API ( StrictMaybe (SJust, SNothing) ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletTokenBundle ) import Cardano.Wallet.Read.Eras @@ -66,7 +66,7 @@ import qualified Cardano.Ledger.Babbage.TxBody as Babbage import qualified Cardano.Ledger.Conway as Conway import qualified Cardano.Ledger.Crypto as SL import qualified Cardano.Ledger.Shelley.API as SL -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Address as W import qualified Cardano.Wallet.Primitive.Types.Coin as Coin import qualified Cardano.Wallet.Primitive.Types.Coin as W diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs index 72aaffd24cf..2078e4dd3db 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs @@ -34,7 +34,7 @@ import Data.Map.Strict import qualified Cardano.Ledger.Api as Ledger import qualified Cardano.Ledger.Coin as Ledger -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Coin as W import qualified Cardano.Wallet.Read.Primitive.Tx.Features.Certificates as Certificates import qualified Data.Map as Map diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs index fa4502e218f..5a4c78d9dfc 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs @@ -33,7 +33,7 @@ import Cardano.Ledger.Api , vldtTxBodyL , witsTxL ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts @@ -97,7 +97,7 @@ import Control.Lens import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Shelley.API as SL -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs index 86ef4313795..dfcb1c12b58 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs +++ b/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs @@ -41,7 +41,7 @@ import Cardano.Ledger.Shelley.TxBody ( certsTxBodyL , ttlTxBodyL ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScriptFromShelley ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts @@ -104,7 +104,7 @@ import Data.Word import qualified Cardano.Api.Shelley as Cardano import qualified Cardano.Ledger.BaseTypes as SL import qualified Cardano.Ledger.Shelley.API as SL -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types.Certificates as W import qualified Cardano.Wallet.Primitive.Types.Hash as W import qualified Cardano.Wallet.Primitive.Types.Tx as W diff --git a/lib/primitive/test/spec/Cardano/Wallet/Primitive/ConvertSpec.hs b/lib/primitive/test/spec/Cardano/Wallet/Primitive/ConvertSpec.hs deleted file mode 100644 index 873fe29d836..00000000000 --- a/lib/primitive/test/spec/Cardano/Wallet/Primitive/ConvertSpec.hs +++ /dev/null @@ -1,194 +0,0 @@ -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -fno-warn-orphans #-} - -module Cardano.Wallet.Primitive.ConvertSpec - ( spec - ) where - -import Prelude - -import Cardano.Address.Script - ( KeyHash (..) - , KeyRole (..) - , Script (..) - ) -import Cardano.Wallet.Primitive.Convert - ( Convert (..) - , toLedgerTimelockScript - , toWalletScript - ) -import Cardano.Wallet.Primitive.Types.Coin - ( Coin (..) - ) -import Cardano.Wallet.Primitive.Types.TokenBundle - ( TokenBundle - ) -import Cardano.Wallet.Primitive.Types.TokenBundle.Gen - ( genTokenBundleSmallRange - , shrinkTokenBundleSmallRange - ) -import Cardano.Wallet.Primitive.Types.TokenPolicy - ( TokenName - , TokenPolicyId - ) -import Cardano.Wallet.Primitive.Types.TokenPolicy.Gen - ( genTokenNameLargeRange - , genTokenPolicyIdLargeRange - ) -import Cardano.Wallet.Primitive.Types.TokenQuantity - ( TokenQuantity (..) - ) -import Cardano.Wallet.Primitive.Types.TokenQuantity.Gen - ( genTokenQuantityFullRange - , shrinkTokenQuantityFullRange - ) -import Cardano.Wallet.Primitive.Types.Tx.TxIn - ( TxIn (..) - ) -import Cardano.Wallet.Primitive.Types.Tx.TxIn.Gen - ( genTxIn - , shrinkTxIn - ) -import Cardano.Wallet.Primitive.Types.Tx.TxOut.Gen - ( genTxOutCoin - , shrinkTxOutCoin - ) -import Data.Proxy - ( Proxy (..) - ) -import Data.Typeable - ( Typeable - , typeRep - ) -import Ouroboros.Consensus.Shelley.Eras - ( StandardBabbage - ) -import Test.Cardano.Ledger.Allegra.Arbitrary - () -import Test.Hspec - ( Spec - , describe - , it - ) -import Test.Hspec.Core.QuickCheck - ( modifyMaxSuccess - ) -import Test.QuickCheck - ( Arbitrary (..) - , Gen - , Positive (Positive) - , arbitrarySizedNatural - , choose - , elements - , oneof - , property - , scale - , sized - , vectorOf - , (===) - ) - -import qualified Data.ByteString as BS - -spec :: Spec -spec = describe "Cardano.Wallet.Primitive.ConvertSpec" $ - - modifyMaxSuccess (const 1000) $ do - - describe "Roundtrip conversions" $ do - - ledgerRoundtrip $ Proxy @Coin - ledgerRoundtrip $ Proxy @TokenBundle - ledgerRoundtrip $ Proxy @TokenName - ledgerRoundtrip $ Proxy @TokenPolicyId - ledgerRoundtrip $ Proxy @TokenQuantity - ledgerRoundtrip $ Proxy @TxIn - - describe "Timelock roundtrips (toLedgerTimelockScript, toWalletScript)" $ do - let ledger = toLedgerTimelockScript @StandardBabbage - let wallet = toWalletScript (const Unknown) - - it "ledger . wallet . ledger == ledger" $ property $ \s -> do - -- Ignore key role by doing one extra conversion - ledger (wallet $ ledger s) === ledger s - - it "ledger . wallet == id" $ property $ \s -> do - ledger (wallet s) === s - --------------------------------------------------------------------------------- --- Utilities --------------------------------------------------------------------------------- - -ledgerRoundtrip - :: forall w l. (Arbitrary w, Eq w, Show w, Typeable w, Convert w l) - => Proxy w - -> Spec -ledgerRoundtrip proxy = it title $ - property $ \a -> toWallet (toLedger @w a) === a - where - title = mconcat - [ "Can perform roundtrip conversion for values of type '" - , show (typeRep proxy) - , "'" - ] - --------------------------------------------------------------------------------- --- Arbitraries --------------------------------------------------------------------------------- - -instance Arbitrary Coin where - -- This instance is used to test roundtrip conversions, so it's important - -- that we generate coins across the full range available. - arbitrary = genTxOutCoin - shrink = shrinkTxOutCoin - -instance Arbitrary TokenBundle where - arbitrary = genTokenBundleSmallRange - shrink = shrinkTokenBundleSmallRange - -instance Arbitrary TokenName where - arbitrary = genTokenNameLargeRange - -- No shrinking - -instance Arbitrary TokenPolicyId where - arbitrary = genTokenPolicyIdLargeRange - -- No shrinking - -instance Arbitrary TokenQuantity where - arbitrary = genTokenQuantityFullRange - shrink = shrinkTokenQuantityFullRange - -instance Arbitrary TxIn where - arbitrary = genTxIn - shrink = shrinkTxIn - -instance Arbitrary (Script KeyHash) where - arbitrary = do - keyHashes <- vectorOf 10 arbitrary - genScript keyHashes - where - genScript :: [a] -> Gen (Script a) - genScript elems = scale (`div` 3) $ sized scriptTree - where - scriptTree 0 = oneof - [ RequireSignatureOf <$> elements elems - , ActiveFromSlot <$> arbitrarySizedNatural - , ActiveUntilSlot <$> arbitrarySizedNatural - ] - scriptTree n = do - Positive m <- arbitrary - let n' = n `div` (m + 1) - scripts' <- vectorOf m (scriptTree n') - atLeast <- choose (1, fromIntegral m) - elements - [ RequireAllOf scripts' - , RequireAnyOf scripts' - , RequireSomeOf atLeast scripts' - ] - -instance Arbitrary KeyHash where - arbitrary = do - cred <- elements [Payment, Delegation, Policy, Unknown] - KeyHash cred . BS.pack <$> vectorOf 28 arbitrary diff --git a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Error.hs b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Error.hs index 078abe421e3..71902d41de1 100644 --- a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Error.hs +++ b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Error.hs @@ -101,7 +101,7 @@ import Cardano.Wallet.Api.Types.Error , ApiErrorSharedWalletNoSuchCosigner (..) , ApiErrorTxOutputLovelaceInsufficient (..) ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( Convert (toWallet) , toWalletAddress , toWalletCoin diff --git a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs index 045db5bd564..4c13fb8ab96 100644 --- a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs +++ b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs @@ -520,12 +520,12 @@ import Cardano.Wallet.Pools ( EpochInfo (..) , toEpochInfo ) -import Cardano.Wallet.Primitive.Convert - ( toLedger - ) import Cardano.Wallet.Primitive.Delegation.UTxO ( stakeKeyCoinDistr ) +import Cardano.Wallet.Primitive.Ledger.Convert + ( toLedger + ) import Cardano.Wallet.Primitive.Model ( Wallet , availableBalance @@ -886,7 +886,7 @@ import qualified Cardano.Wallet.Api.Types as Api import qualified Cardano.Wallet.DB as W import qualified Cardano.Wallet.Delegation as WD import qualified Cardano.Wallet.Network as NW -import qualified Cardano.Wallet.Primitive.Convert as Convert +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert import qualified Cardano.Wallet.Primitive.Types as W import qualified Cardano.Wallet.Primitive.Types.Coin as Coin import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TokenBundle diff --git a/lib/wallet/src/Cardano/Wallet.hs b/lib/wallet/src/Cardano/Wallet.hs index e917e8aa0c8..f14902ac293 100644 --- a/lib/wallet/src/Cardano/Wallet.hs +++ b/lib/wallet/src/Cardano/Wallet.hs @@ -427,7 +427,7 @@ import Cardano.Wallet.Network , ErrPostTx (..) , NetworkLayer (..) ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toLedgerAddress , toWallet , toWalletCoin diff --git a/lib/wallet/src/Cardano/Wallet/Address/Discovery/RandomAny.hs b/lib/wallet/src/Cardano/Wallet/Address/Discovery/RandomAny.hs index 6c6c94e6dd9..84cf828f0a8 100644 --- a/lib/wallet/src/Cardano/Wallet/Address/Discovery/RandomAny.hs +++ b/lib/wallet/src/Cardano/Wallet/Address/Discovery/RandomAny.hs @@ -59,7 +59,7 @@ import Cardano.Wallet.Address.States.Families , KeyOf , NetworkOf ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toLedger ) import Cardano.Wallet.Primitive.NetworkId diff --git a/lib/wallet/src/Cardano/Wallet/Address/Discovery/SequentialAny.hs b/lib/wallet/src/Cardano/Wallet/Address/Discovery/SequentialAny.hs index 6e849fbd45b..9cc55a79d18 100644 --- a/lib/wallet/src/Cardano/Wallet/Address/Discovery/SequentialAny.hs +++ b/lib/wallet/src/Cardano/Wallet/Address/Discovery/SequentialAny.hs @@ -77,7 +77,7 @@ import Cardano.Wallet.Address.States.Families , KeyOf , NetworkOf ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( toLedger ) import Cardano.Wallet.Primitive.NetworkId diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Compatibility.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Compatibility.hs index 14dca180c9e..19d861e6687 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Compatibility.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Compatibility.hs @@ -383,7 +383,7 @@ import qualified Cardano.Ledger.Shelley.API as SL import qualified Cardano.Ledger.Shelley.API as SLAPI import qualified Cardano.Ledger.Shelley.BlockChain as SL import qualified Cardano.Protocol.TPraos.BHeader as SL -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.Types as W import qualified Cardano.Wallet.Primitive.Types.Address as W import qualified Cardano.Wallet.Primitive.Types.Coin as Coin diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs index 3fa7075ae3e..98522383de3 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs @@ -400,7 +400,7 @@ import qualified Cardano.Ledger.Credential as SL import qualified Cardano.Ledger.Crypto as SL import qualified Cardano.Ledger.Shelley.API as SL import qualified Cardano.Ledger.Shelley.LedgerState as SL -import qualified Cardano.Wallet.Primitive.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger import qualified Cardano.Wallet.Primitive.SyncProgress as SP import qualified Cardano.Wallet.Primitive.Types as W import qualified Cardano.Wallet.Primitive.Types.Coin as W diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs index aa00c31f380..6c8656e1b18 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs @@ -98,7 +98,7 @@ import Cardano.Wallet.Address.Keys.WalletKey import Cardano.Wallet.Flavor ( KeyFlavorS (..) ) -import Cardano.Wallet.Primitive.Convert +import Cardano.Wallet.Primitive.Ledger.Convert ( Convert (toLedger) ) import Cardano.Wallet.Primitive.Passphrase @@ -250,7 +250,7 @@ import qualified Cardano.Crypto.Hash.Class as Crypto import qualified Cardano.Crypto.Wallet as Crypto.HD import qualified Cardano.Ledger.Api as Ledger import qualified Cardano.Ledger.Keys.Bootstrap as SL -import qualified Cardano.Wallet.Primitive.Convert as Convert +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert import qualified Cardano.Wallet.Primitive.Types.TokenMap as TokenMap import qualified Cardano.Wallet.Shelley.Compatibility as Compatibility import qualified Data.ByteString as BS diff --git a/lib/wallet/test/unit/Internal/Cardano/Write/Tx/BalanceSpec.hs b/lib/wallet/test/unit/Internal/Cardano/Write/Tx/BalanceSpec.hs index 6dcbd55f3db..0e53289a3bc 100644 --- a/lib/wallet/test/unit/Internal/Cardano/Write/Tx/BalanceSpec.hs +++ b/lib/wallet/test/unit/Internal/Cardano/Write/Tx/BalanceSpec.hs @@ -416,7 +416,7 @@ import qualified Cardano.Slotting.Slot as Slotting import qualified Cardano.Slotting.Time as Slotting import qualified Cardano.Wallet.Address.Derivation.Byron as Byron import qualified Cardano.Wallet.Address.Derivation.Shelley as Shelley -import qualified Cardano.Wallet.Primitive.Convert as Convert +import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert import qualified Cardano.Wallet.Primitive.Types as W ( Block (..) , BlockHeader (..) From c43fe2124227a0d1bce265cd324d0cd413eb2408 Mon Sep 17 00:00:00 2001 From: paolino Date: Thu, 23 Nov 2023 16:34:35 +0000 Subject: [PATCH 11/11] Rename Read.Primitive namesapace as Primitive.Ledger.Read --- lib/primitive/cardano-wallet-primitive.cabal | 48 ++--- .../Ledger/Read}/Block.hs | 20 +- .../Ledger/Read}/Block/Header.hs | 2 +- .../Primitive => Primitive/Ledger/Read}/Tx.hs | 52 ++--- .../Ledger/Read}/Tx/Allegra.hs | 38 ++-- .../Ledger/Read}/Tx/Alonzo.hs | 46 ++--- .../Ledger/Read}/Tx/Babbage.hs | 42 ++-- .../Ledger/Read}/Tx/Byron.hs | 14 +- .../Ledger/Read}/Tx/Conway.hs | 46 ++--- .../Ledger/Read}/Tx/Features/Certificates.hs | 2 +- .../Read}/Tx/Features/CollateralInputs.hs | 8 +- .../Read}/Tx/Features/CollateralOutputs.hs | 8 +- .../Ledger/Read}/Tx/Features/ExtraSigs.hs | 2 +- .../Ledger/Read}/Tx/Features/Fee.hs | 2 +- .../Ledger/Read}/Tx/Features/Inputs.hs | 2 +- .../Ledger/Read}/Tx/Features/Integrity.hs | 2 +- .../Ledger/Read}/Tx/Features/Metadata.hs | 2 +- .../Ledger/Read}/Tx/Features/Mint.hs | 8 +- .../Ledger/Read}/Tx/Features/Outputs.hs | 2 +- .../Read}/Tx/Features/ScriptValidity.hs | 2 +- .../Ledger/Read}/Tx/Features/Validity.hs | 2 +- .../Ledger/Read}/Tx/Features/Withdrawals.hs | 4 +- .../Ledger/Read}/Tx/Mary.hs | 44 ++-- .../Ledger/Read}/Tx/Sealed.hs | 2 +- .../Ledger/Read}/Tx/Shelley.hs | 32 +-- .../Wallet/Primitive/Ledger/ConvertSpec.hs | 194 ++++++++++++++++++ .../Wallet/Api/Http/Server/Handlers/TxCBOR.hs | 10 +- lib/wallet/bench/EraFun.hs | 2 +- lib/wallet/bench/restore-bench.hs | 6 +- lib/wallet/src/Cardano/Wallet.hs | 6 +- .../src/Cardano/Wallet/Byron/Compatibility.hs | 6 +- lib/wallet/src/Cardano/Wallet/DB.hs | 6 +- .../DB/Store/Transactions/Decoration.hs | 12 +- .../DB/Store/Transactions/TransactionInfo.hs | 42 ++-- lib/wallet/src/Cardano/Wallet/Pools.hs | 12 +- .../Cardano/Wallet/Shelley/Compatibility.hs | 16 +- .../Cardano/Wallet/Shelley/Network/Node.hs | 6 +- .../src/Cardano/Wallet/Shelley/Transaction.hs | 6 +- .../Cardano/Wallet/Shelley/TransactionSpec.hs | 6 +- 39 files changed, 478 insertions(+), 284 deletions(-) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Block.hs (91%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Block/Header.hs (98%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx.hs (86%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Allegra.hs (90%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Alonzo.hs (91%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Babbage.hs (93%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Byron.hs (89%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Conway.hs (93%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Certificates.hs (99%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/CollateralInputs.hs (87%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/CollateralOutputs.hs (91%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/ExtraSigs.hs (95%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Fee.hs (93%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Inputs.hs (97%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Integrity.hs (96%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Metadata.hs (97%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Mint.hs (98%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Outputs.hs (98%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/ScriptValidity.hs (93%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Validity.hs (96%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Features/Withdrawals.hs (90%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Mary.hs (88%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Sealed.hs (94%) rename lib/primitive/lib/Cardano/Wallet/{Read/Primitive => Primitive/Ledger/Read}/Tx/Shelley.hs (92%) create mode 100644 lib/primitive/test/spec/Cardano/Wallet/Primitive/Ledger/ConvertSpec.hs diff --git a/lib/primitive/cardano-wallet-primitive.cabal b/lib/primitive/cardano-wallet-primitive.cabal index 9708f64bdae..e71bc9f4ca6 100644 --- a/lib/primitive/cardano-wallet-primitive.cabal +++ b/lib/primitive/cardano-wallet-primitive.cabal @@ -167,30 +167,30 @@ library Cardano.Wallet.Primitive.Types.UTxO.Gen Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit Cardano.Wallet.Primitive.Types.WitnessCount - Cardano.Wallet.Read.Primitive.Block - Cardano.Wallet.Read.Primitive.Block.Header - Cardano.Wallet.Read.Primitive.Tx - Cardano.Wallet.Read.Primitive.Tx.Allegra - Cardano.Wallet.Read.Primitive.Tx.Alonzo - Cardano.Wallet.Read.Primitive.Tx.Babbage - Cardano.Wallet.Read.Primitive.Tx.Byron - Cardano.Wallet.Read.Primitive.Tx.Conway - Cardano.Wallet.Read.Primitive.Tx.Features.Certificates - Cardano.Wallet.Read.Primitive.Tx.Features.CollateralInputs - Cardano.Wallet.Read.Primitive.Tx.Features.CollateralOutputs - Cardano.Wallet.Read.Primitive.Tx.Features.ExtraSigs - Cardano.Wallet.Read.Primitive.Tx.Features.Fee - Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - Cardano.Wallet.Read.Primitive.Tx.Features.Integrity - Cardano.Wallet.Read.Primitive.Tx.Features.Metadata - Cardano.Wallet.Read.Primitive.Tx.Features.Mint - Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - Cardano.Wallet.Read.Primitive.Tx.Features.ScriptValidity - Cardano.Wallet.Read.Primitive.Tx.Features.Validity - Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals - Cardano.Wallet.Read.Primitive.Tx.Mary - Cardano.Wallet.Read.Primitive.Tx.Sealed - Cardano.Wallet.Read.Primitive.Tx.Shelley + Cardano.Wallet.Primitive.Ledger.Read.Block + Cardano.Wallet.Primitive.Ledger.Read.Block.Header + Cardano.Wallet.Primitive.Ledger.Read.Tx + Cardano.Wallet.Primitive.Ledger.Read.Tx.Allegra + Cardano.Wallet.Primitive.Ledger.Read.Tx.Alonzo + Cardano.Wallet.Primitive.Ledger.Read.Tx.Babbage + Cardano.Wallet.Primitive.Ledger.Read.Tx.Byron + Cardano.Wallet.Primitive.Ledger.Read.Tx.Conway + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralInputs + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralOutputs + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.ExtraSigs + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Fee + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Integrity + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.ScriptValidity + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity + Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals + Cardano.Wallet.Primitive.Ledger.Read.Tx.Mary + Cardano.Wallet.Primitive.Ledger.Read.Tx.Sealed + Cardano.Wallet.Primitive.Ledger.Read.Tx.Shelley Cardano.Wallet.Unsafe Cardano.Wallet.Util Control.Monad.Random.NonRandom diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Block.hs similarity index 91% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Block.hs index 09056c694dd..62af0bb0341 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Block.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ApplicativeDo #-} {-# LANGUAGE DataKinds #-} -module Cardano.Wallet.Read.Primitive.Block +module Cardano.Wallet.Primitive.Ledger.Read.Block ( primitiveBlock , fromCardanoBlock ) @@ -12,6 +12,15 @@ import Prelude hiding , (.) ) +import Cardano.Wallet.Primitive.Ledger.Read.Block.Header + ( primitiveBlockHeader + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx + ( primitiveTx + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates + ( primitiveCertificates + ) import Cardano.Wallet.Read ( Block , ConsensusBlock @@ -35,15 +44,6 @@ import Cardano.Wallet.Read.Eras.EraFun , (*&&&*) , (*****) ) -import Cardano.Wallet.Read.Primitive.Block.Header - ( primitiveBlockHeader - ) -import Cardano.Wallet.Read.Primitive.Tx - ( primitiveTx - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Certificates - ( primitiveCertificates - ) import Cardano.Wallet.Read.Tx.Certificates ( getEraCertificates ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block/Header.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Block/Header.hs similarity index 98% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block/Header.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Block/Header.hs index 39f15c81dc2..489a8525783 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Block/Header.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Block/Header.hs @@ -3,7 +3,7 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} -module Cardano.Wallet.Read.Primitive.Block.Header +module Cardano.Wallet.Primitive.Ledger.Read.Block.Header ( getBlockHeader , primitiveBlockHeader ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx.hs similarity index 86% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx.hs index 3a90e808d0d..b5b2e6ea44b 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx.hs @@ -4,58 +4,58 @@ -- | -- Copyright: © 2020 IOHK -- License: Apache-2.0 -module Cardano.Wallet.Read.Primitive.Tx ( +module Cardano.Wallet.Primitive.Ledger.Read.Tx ( fromCardanoTx, primitiveTx, ) where import Prelude -import Cardano.Wallet.Primitive.Types.TokenMapWithScripts - ( TokenMapWithScripts - , emptyTokenMapWithScripts - ) -import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit - ( ValidityIntervalExplicit - ) -import Cardano.Wallet.Primitive.Types.WitnessCount - ( WitnessCount - , WitnessCountCtx - , emptyWitnessCount - ) -import Cardano.Wallet.Read - ( Tx (..) - ) -import Cardano.Wallet.Read.Eras - ( EraFun (..) - ) -import Cardano.Wallet.Read.Primitive.Tx.Allegra +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Allegra ( fromAllegraTx , fromAllegraTx' ) -import Cardano.Wallet.Read.Primitive.Tx.Alonzo +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Alonzo ( fromAlonzoTx , fromAlonzoTx' ) -import Cardano.Wallet.Read.Primitive.Tx.Babbage +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Babbage ( fromBabbageTx , fromBabbageTx' ) -import Cardano.Wallet.Read.Primitive.Tx.Byron +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Byron ( fromTxAux ) -import Cardano.Wallet.Read.Primitive.Tx.Conway +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Conway ( fromConwayTx , fromConwayTx' ) -import Cardano.Wallet.Read.Primitive.Tx.Mary +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Mary ( fromMaryTx , fromMaryTx' ) -import Cardano.Wallet.Read.Primitive.Tx.Shelley +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Shelley ( fromShelleyTx , fromShelleyTx' ) +import Cardano.Wallet.Primitive.Types.TokenMapWithScripts + ( TokenMapWithScripts + , emptyTokenMapWithScripts + ) +import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit + ( ValidityIntervalExplicit + ) +import Cardano.Wallet.Primitive.Types.WitnessCount + ( WitnessCount + , WitnessCountCtx + , emptyWitnessCount + ) +import Cardano.Wallet.Read + ( Tx (..) + ) +import Cardano.Wallet.Read.Eras + ( EraFun (..) + ) import Generics.SOP ( K (..) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Allegra.hs similarity index 90% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Allegra.hs index 64b4a51bb9d..009d05931d6 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Allegra.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Allegra.hs @@ -16,7 +16,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Allegra +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Allegra ( fromAllegraTx , fromAllegraTx' ) @@ -51,6 +51,24 @@ import Cardano.Ledger.Shelley.Tx import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates + ( anyEraCerts + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + ( fromShelleyTxIn + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata + ( fromAllegraMetadata + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs + ( fromAllegraTxOut + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity + ( afterShelleyValidityInterval + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals + ( fromLedgerWithdrawals + ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts ( AnyExplicitScript (NativeExplicitScript) ) @@ -69,24 +87,6 @@ import Cardano.Wallet.Read.Eras ( allegra , inject ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Certificates - ( anyEraCerts - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - ( fromShelleyTxIn - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Metadata - ( fromAllegraMetadata - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - ( fromAllegraTxOut - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Validity - ( afterShelleyValidityInterval - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals - ( fromLedgerWithdrawals - ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Alonzo.hs similarity index 91% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Alonzo.hs index c65ad8cfd86..b92bac519ee 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Alonzo.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Alonzo.hs @@ -11,7 +11,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Alonzo +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Alonzo ( fromAlonzoTx , fromAlonzoTx' ) @@ -41,6 +41,28 @@ import Cardano.Ledger.Api import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates + ( anyEraCerts + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + ( fromShelleyTxIn + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata + ( fromAlonzoMetadata + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint + ( alonzoMint + , fromLedgerScriptHash + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs + ( fromAlonzoTxOut + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity + ( afterShelleyValidityInterval + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals + ( fromLedgerWithdrawals + ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts ( AnyExplicitScript (NativeExplicitScript, PlutusExplicitScript) ) @@ -62,28 +84,6 @@ import Cardano.Wallet.Read.Eras ( alonzo , inject ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Certificates - ( anyEraCerts - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - ( fromShelleyTxIn - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Metadata - ( fromAlonzoMetadata - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Mint - ( alonzoMint - , fromLedgerScriptHash - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - ( fromAlonzoTxOut - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Validity - ( afterShelleyValidityInterval - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals - ( fromLedgerWithdrawals - ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Babbage.hs similarity index 93% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Babbage.hs index 4e15bfea951..28c4a463845 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Babbage.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Babbage.hs @@ -10,7 +10,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Babbage +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Babbage ( fromBabbageTx , fromBabbageTx' ) @@ -45,41 +45,41 @@ import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript , toWalletTokenPolicyId ) -import Cardano.Wallet.Primitive.Types.TokenPolicy - ( TokenPolicyId - ) -import Cardano.Wallet.Primitive.Types.Tx - ( Tx (txId) - ) -import Cardano.Wallet.Primitive.Types.Tx.TxIn - ( TxIn (..) - ) -import Cardano.Wallet.Read.Eras - ( babbage - , inject - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Certificates +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates ( anyEraCerts ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs ( fromShelleyTxIn ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Metadata +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata ( fromBabbageMetadata ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Mint +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint ( babbageMint , fromLedgerScriptHash ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs ( fromBabbageTxOut ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Validity +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity ( afterShelleyValidityInterval ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals ( fromLedgerWithdrawals ) +import Cardano.Wallet.Primitive.Types.TokenPolicy + ( TokenPolicyId + ) +import Cardano.Wallet.Primitive.Types.Tx + ( Tx (txId) + ) +import Cardano.Wallet.Primitive.Types.Tx.TxIn + ( TxIn (..) + ) +import Cardano.Wallet.Read.Eras + ( babbage + , inject + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Byron.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Byron.hs similarity index 89% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Byron.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Byron.hs index a167f5f11d5..aa115b92ad0 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Byron.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Byron.hs @@ -6,7 +6,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Byron +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Byron ( fromTxAux ) where @@ -18,16 +18,16 @@ import Cardano.Chain.UTxO , Tx (..) , taTx ) -import Cardano.Wallet.Read.Eras - ( byron - , inject - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs ( fromByronTxIn ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs ( fromByronTxOut ) +import Cardano.Wallet.Read.Eras + ( byron + , inject + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Conway.hs similarity index 93% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Conway.hs index 057bc872813..313eb8dedc4 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Conway.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Conway.hs @@ -10,7 +10,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Conway +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Conway ( fromConwayTx , fromConwayTx' ) @@ -50,6 +50,28 @@ import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript , toWalletTokenPolicyId ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates + ( fromConwayCerts + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + ( fromShelleyTxIn + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata + ( fromConwayMetadata + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint + ( conwayMint + , fromLedgerScriptHash + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs + ( fromConwayTxOut + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity + ( afterShelleyValidityInterval + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals + ( fromLedgerWithdrawals + ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts ( AnyExplicitScript (..) ) @@ -81,28 +103,6 @@ import Cardano.Wallet.Read.Eras ( conway , inject ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Certificates - ( fromConwayCerts - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - ( fromShelleyTxIn - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Metadata - ( fromConwayMetadata - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Mint - ( conwayMint - , fromLedgerScriptHash - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - ( fromConwayTxOut - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Validity - ( afterShelleyValidityInterval - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals - ( fromLedgerWithdrawals - ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Certificates.hs similarity index 99% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Certificates.hs index 1691862fae7..b0200d58034 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Certificates.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Certificates.hs @@ -6,7 +6,7 @@ -- | -- Copyright: © 2020 IOHK -- License: Apache-2.0 -module Cardano.Wallet.Read.Primitive.Tx.Features.Certificates +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates ( primitiveCertificates , anyEraCerts , fromStakeCredential diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralInputs.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/CollateralInputs.hs similarity index 87% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralInputs.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/CollateralInputs.hs index 2db2e957519..0e96c67f6c8 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralInputs.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/CollateralInputs.hs @@ -1,19 +1,19 @@ {-# LANGUAGE TypeFamilies #-} -module Cardano.Wallet.Read.Primitive.Tx.Features.CollateralInputs +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralInputs ( getCollateralInputs ) where import Prelude +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + ( fromShelleyTxIns + ) import Cardano.Wallet.Read.Eras ( EraFun (..) , K (..) ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - ( fromShelleyTxIns - ) import Cardano.Wallet.Read.Tx.CollateralInputs ( CollateralInputs (..) , CollateralInputsType diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/CollateralOutputs.hs similarity index 91% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/CollateralOutputs.hs index c8f6e2e0c84..e25e8251df1 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/CollateralOutputs.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/CollateralOutputs.hs @@ -1,6 +1,6 @@ {-# LANGUAGE TypeFamilies #-} -module Cardano.Wallet.Read.Primitive.Tx.Features.CollateralOutputs +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralOutputs ( getCollateralOutputs ) where @@ -10,13 +10,13 @@ import Prelude import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletTokenBundle ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs + ( fromShelleyAddress + ) import Cardano.Wallet.Read.Eras ( EraFun (..) , K (..) ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - ( fromShelleyAddress - ) import Cardano.Wallet.Read.Tx.CollateralOutputs ( CollateralOutputs (..) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ExtraSigs.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/ExtraSigs.hs similarity index 95% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ExtraSigs.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/ExtraSigs.hs index e1982a87b0c..98580ea4c39 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ExtraSigs.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/ExtraSigs.hs @@ -8,7 +8,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Features.ExtraSigs +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.ExtraSigs ( extraSigs ) where diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Fee.hs similarity index 93% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Fee.hs index 1dd68f87af0..78cc97de61e 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Fee.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Fee.hs @@ -1,6 +1,6 @@ {-# LANGUAGE TypeFamilies #-} -module Cardano.Wallet.Read.Primitive.Tx.Features.Fee +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Fee ( getFee) where diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Inputs.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Inputs.hs similarity index 97% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Inputs.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Inputs.hs index 048ada2debf..941e75b2da2 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Inputs.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Inputs.hs @@ -1,6 +1,6 @@ {-# LANGUAGE TypeFamilies #-} -module Cardano.Wallet.Read.Primitive.Tx.Features.Inputs +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs ( getInputs , fromByronTxIn , fromShelleyTxIns diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Integrity.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Integrity.hs similarity index 96% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Integrity.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Integrity.hs index a384f33ebbd..455dd298bcf 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Integrity.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Integrity.hs @@ -7,7 +7,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Features.Integrity +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Integrity ( integrity , txIntegrity ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Metadata.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Metadata.hs similarity index 97% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Metadata.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Metadata.hs index 2b7582a472d..570dec234f5 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Metadata.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Metadata.hs @@ -8,7 +8,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Features.Metadata +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata ( getMetadata , fromShelleyMetadata , fromAllegraMetadata diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Mint.hs similarity index 98% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Mint.hs index 81eacaa70d1..b0644c209e0 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Mint.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Mint.hs @@ -11,7 +11,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Features.Mint +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint ( mint , maryMint , alonzoMint @@ -47,6 +47,9 @@ import Cardano.Wallet.Primitive.Ledger.Convert , toWalletTokenPolicyId , toWalletTokenQuantity ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + ( fromShelleyTxIn + ) import Cardano.Wallet.Primitive.Types.Hash ( Hash (..) ) @@ -72,9 +75,6 @@ import Cardano.Wallet.Read.Eras , EraFun (..) , K (..) ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - ( fromShelleyTxIn - ) import Cardano.Wallet.Read.Tx.Mint ( Mint (..) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Outputs.hs similarity index 98% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Outputs.hs index a82f126fc74..cdb2aadc927 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Outputs.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Outputs.hs @@ -1,6 +1,6 @@ {-# LANGUAGE TypeFamilies #-} -module Cardano.Wallet.Read.Primitive.Tx.Features.Outputs +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs ( getOutputs , fromShelleyTxOut , fromMaryTxOut diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ScriptValidity.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/ScriptValidity.hs similarity index 93% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ScriptValidity.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/ScriptValidity.hs index 38266352608..f82872ecacc 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/ScriptValidity.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/ScriptValidity.hs @@ -8,7 +8,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Features.ScriptValidity +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.ScriptValidity ( getScriptValidity ) where diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Validity.hs similarity index 96% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Validity.hs index d9aebc2bdff..816b2dc0e41 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Validity.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Validity.hs @@ -8,7 +8,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Features.Validity +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity ( getValidity , afterShelleyValidityInterval , shelleyValidityInterval diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Withdrawals.hs similarity index 90% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Withdrawals.hs index 2078e4dd3db..a66325983aa 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Features/Withdrawals.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/Withdrawals.hs @@ -7,7 +7,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals ( getWithdrawals , fromLedgerWithdrawals ) @@ -35,8 +35,8 @@ import Data.Map.Strict import qualified Cardano.Ledger.Api as Ledger import qualified Cardano.Ledger.Coin as Ledger import qualified Cardano.Wallet.Primitive.Ledger.Convert as Ledger +import qualified Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates as Certificates import qualified Cardano.Wallet.Primitive.Types.Coin as W -import qualified Cardano.Wallet.Read.Primitive.Tx.Features.Certificates as Certificates import qualified Data.Map as Map getWithdrawals :: EraFun Withdrawals (K (Maybe (Map RewardAccount Coin))) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Mary.hs similarity index 88% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Mary.hs index 5a4c78d9dfc..1fa6e728ef0 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Mary.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Mary.hs @@ -8,7 +8,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Mary +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Mary ( fromMaryTx , fromMaryTx' ) @@ -36,6 +36,27 @@ import Cardano.Ledger.Api import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScript ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates + ( anyEraCerts + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + ( fromShelleyTxIn + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata + ( fromMaryMetadata + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint + ( maryMint + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs + ( fromMaryTxOut + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity + ( afterShelleyValidityInterval + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals + ( fromLedgerWithdrawals + ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts ( AnyExplicitScript (NativeExplicitScript) ) @@ -55,27 +76,6 @@ import Cardano.Wallet.Read.Eras ( inject , mary ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Certificates - ( anyEraCerts - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - ( fromShelleyTxIn - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Metadata - ( fromMaryMetadata - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Mint - ( maryMint - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - ( fromMaryTxOut - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Validity - ( afterShelleyValidityInterval - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals - ( fromLedgerWithdrawals - ) import Cardano.Wallet.Read.Tx ( Tx (Tx) ) diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Sealed.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Sealed.hs similarity index 94% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Sealed.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Sealed.hs index cfc04d5cbab..202fd03070c 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Sealed.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Sealed.hs @@ -5,7 +5,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Sealed +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Sealed ( fromSealedTx , anythingFromSealedTx ) where diff --git a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Shelley.hs similarity index 92% rename from lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs rename to lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Shelley.hs index dfcb1c12b58..de7c468f825 100644 --- a/lib/primitive/lib/Cardano/Wallet/Read/Primitive/Tx/Shelley.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Shelley.hs @@ -9,7 +9,7 @@ -- License: Apache-2.0 -- -module Cardano.Wallet.Read.Primitive.Tx.Shelley +module Cardano.Wallet.Primitive.Ledger.Read.Tx.Shelley ( fromShelleyTx , fromShelleyTx' ) @@ -44,6 +44,21 @@ import Cardano.Ledger.Shelley.TxBody import Cardano.Wallet.Primitive.Ledger.Convert ( toWalletScriptFromShelley ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates + ( anyEraCerts + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata + ( fromShelleyMetadata + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs + ( fromShelleyTxOut + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity + ( shelleyValidityInterval + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals + ( fromLedgerWithdrawals + ) import Cardano.Wallet.Primitive.Types.AnyExplicitScripts ( AnyExplicitScript (NativeExplicitScript) ) @@ -62,21 +77,6 @@ import Cardano.Wallet.Read.Eras ( inject , shelley ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Certificates - ( anyEraCerts - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Metadata - ( fromShelleyMetadata - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - ( fromShelleyTxOut - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Validity - ( shelleyValidityInterval - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals - ( fromLedgerWithdrawals - ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/primitive/test/spec/Cardano/Wallet/Primitive/Ledger/ConvertSpec.hs b/lib/primitive/test/spec/Cardano/Wallet/Primitive/Ledger/ConvertSpec.hs new file mode 100644 index 00000000000..8195f3a887b --- /dev/null +++ b/lib/primitive/test/spec/Cardano/Wallet/Primitive/Ledger/ConvertSpec.hs @@ -0,0 +1,194 @@ +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} + +module Cardano.Wallet.Primitive.Ledger.ConvertSpec + ( spec + ) where + +import Prelude + +import Cardano.Address.Script + ( KeyHash (..) + , KeyRole (..) + , Script (..) + ) +import Cardano.Wallet.Primitive.Ledger.Convert + ( Convert (..) + , toLedgerTimelockScript + , toWalletScript + ) +import Cardano.Wallet.Primitive.Types.Coin + ( Coin (..) + ) +import Cardano.Wallet.Primitive.Types.TokenBundle + ( TokenBundle + ) +import Cardano.Wallet.Primitive.Types.TokenBundle.Gen + ( genTokenBundleSmallRange + , shrinkTokenBundleSmallRange + ) +import Cardano.Wallet.Primitive.Types.TokenPolicy + ( TokenName + , TokenPolicyId + ) +import Cardano.Wallet.Primitive.Types.TokenPolicy.Gen + ( genTokenNameLargeRange + , genTokenPolicyIdLargeRange + ) +import Cardano.Wallet.Primitive.Types.TokenQuantity + ( TokenQuantity (..) + ) +import Cardano.Wallet.Primitive.Types.TokenQuantity.Gen + ( genTokenQuantityFullRange + , shrinkTokenQuantityFullRange + ) +import Cardano.Wallet.Primitive.Types.Tx.TxIn + ( TxIn (..) + ) +import Cardano.Wallet.Primitive.Types.Tx.TxIn.Gen + ( genTxIn + , shrinkTxIn + ) +import Cardano.Wallet.Primitive.Types.Tx.TxOut.Gen + ( genTxOutCoin + , shrinkTxOutCoin + ) +import Data.Proxy + ( Proxy (..) + ) +import Data.Typeable + ( Typeable + , typeRep + ) +import Ouroboros.Consensus.Shelley.Eras + ( StandardBabbage + ) +import Test.Cardano.Ledger.Allegra.Arbitrary + () +import Test.Hspec + ( Spec + , describe + , it + ) +import Test.Hspec.Core.QuickCheck + ( modifyMaxSuccess + ) +import Test.QuickCheck + ( Arbitrary (..) + , Gen + , Positive (Positive) + , arbitrarySizedNatural + , choose + , elements + , oneof + , property + , scale + , sized + , vectorOf + , (===) + ) + +import qualified Data.ByteString as BS + +spec :: Spec +spec = describe "Cardano.Wallet.Primitive.Ledger.ConvertSpec" $ + + modifyMaxSuccess (const 1000) $ do + + describe "Roundtrip conversions" $ do + + ledgerRoundtrip $ Proxy @Coin + ledgerRoundtrip $ Proxy @TokenBundle + ledgerRoundtrip $ Proxy @TokenName + ledgerRoundtrip $ Proxy @TokenPolicyId + ledgerRoundtrip $ Proxy @TokenQuantity + ledgerRoundtrip $ Proxy @TxIn + + describe "Timelock roundtrips (toLedgerTimelockScript, toWalletScript)" $ do + let ledger = toLedgerTimelockScript @StandardBabbage + let wallet = toWalletScript (const Unknown) + + it "ledger . wallet . ledger == ledger" $ property $ \s -> do + -- Ignore key role by doing one extra conversion + ledger (wallet $ ledger s) === ledger s + + it "ledger . wallet == id" $ property $ \s -> do + ledger (wallet s) === s + +-------------------------------------------------------------------------------- +-- Utilities +-------------------------------------------------------------------------------- + +ledgerRoundtrip + :: forall w l. (Arbitrary w, Eq w, Show w, Typeable w, Convert w l) + => Proxy w + -> Spec +ledgerRoundtrip proxy = it title $ + property $ \a -> toWallet (toLedger @w a) === a + where + title = mconcat + [ "Can perform roundtrip conversion for values of type '" + , show (typeRep proxy) + , "'" + ] + +-------------------------------------------------------------------------------- +-- Arbitraries +-------------------------------------------------------------------------------- + +instance Arbitrary Coin where + -- This instance is used to test roundtrip conversions, so it's important + -- that we generate coins across the full range available. + arbitrary = genTxOutCoin + shrink = shrinkTxOutCoin + +instance Arbitrary TokenBundle where + arbitrary = genTokenBundleSmallRange + shrink = shrinkTokenBundleSmallRange + +instance Arbitrary TokenName where + arbitrary = genTokenNameLargeRange + -- No shrinking + +instance Arbitrary TokenPolicyId where + arbitrary = genTokenPolicyIdLargeRange + -- No shrinking + +instance Arbitrary TokenQuantity where + arbitrary = genTokenQuantityFullRange + shrink = shrinkTokenQuantityFullRange + +instance Arbitrary TxIn where + arbitrary = genTxIn + shrink = shrinkTxIn + +instance Arbitrary (Script KeyHash) where + arbitrary = do + keyHashes <- vectorOf 10 arbitrary + genScript keyHashes + where + genScript :: [a] -> Gen (Script a) + genScript elems = scale (`div` 3) $ sized scriptTree + where + scriptTree 0 = oneof + [ RequireSignatureOf <$> elements elems + , ActiveFromSlot <$> arbitrarySizedNatural + , ActiveUntilSlot <$> arbitrarySizedNatural + ] + scriptTree n = do + Positive m <- arbitrary + let n' = n `div` (m + 1) + scripts' <- vectorOf m (scriptTree n') + atLeast <- choose (1, fromIntegral m) + elements + [ RequireAllOf scripts' + , RequireAnyOf scripts' + , RequireSomeOf atLeast scripts' + ] + +instance Arbitrary KeyHash where + arbitrary = do + cred <- elements [Payment, Delegation, Policy, Unknown] + KeyHash cred . BS.pack <$> vectorOf 28 arbitrary diff --git a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Handlers/TxCBOR.hs b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Handlers/TxCBOR.hs index 62999f91e15..9fa40d2e1ff 100644 --- a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Handlers/TxCBOR.hs +++ b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Server/Handlers/TxCBOR.hs @@ -89,11 +89,11 @@ import Servant.Server , err500 ) -import qualified Cardano.Wallet.Read.Primitive.Tx.Features.Certificates as Feature -import qualified Cardano.Wallet.Read.Primitive.Tx.Features.ExtraSigs as Feature -import qualified Cardano.Wallet.Read.Primitive.Tx.Features.Integrity as Feature -import qualified Cardano.Wallet.Read.Primitive.Tx.Features.Mint as Feature -import qualified Cardano.Wallet.Read.Primitive.Tx.Features.Validity as Feature +import qualified Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates as Feature +import qualified Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.ExtraSigs as Feature +import qualified Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Integrity as Feature +import qualified Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint as Feature +import qualified Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity as Feature import qualified Data.ByteString.Lazy as BL import qualified Data.Text as T diff --git a/lib/wallet/bench/EraFun.hs b/lib/wallet/bench/EraFun.hs index 9fcad8e1ad1..206c8f9bae9 100644 --- a/lib/wallet/bench/EraFun.hs +++ b/lib/wallet/bench/EraFun.hs @@ -26,8 +26,8 @@ import Data.Time.Clock.POSIX ( posixSecondsToUTCTime ) +import qualified Cardano.Wallet.Primitive.Ledger.Read.Block as New import qualified Cardano.Wallet.Primitive.Types as W -import qualified Cardano.Wallet.Read.Primitive.Block as New import qualified Data.ByteString.Char8 as B8 -- Our benchmark harness. diff --git a/lib/wallet/bench/restore-bench.hs b/lib/wallet/bench/restore-bench.hs index 1131abab9c5..7a411757085 100644 --- a/lib/wallet/bench/restore-bench.hs +++ b/lib/wallet/bench/restore-bench.hs @@ -150,6 +150,9 @@ import Cardano.Wallet.Network.Config ( NetworkConfiguration (..) , parseGenesisData ) +import Cardano.Wallet.Primitive.Ledger.Read.Block + ( fromCardanoBlock + ) import Cardano.Wallet.Primitive.Model ( Wallet , availableUTxO @@ -207,9 +210,6 @@ import Cardano.Wallet.Primitive.Types.Tx.TxOut import Cardano.Wallet.Primitive.Types.UTxOStatistics ( UTxOStatistics (..) ) -import Cardano.Wallet.Read.Primitive.Block - ( fromCardanoBlock - ) import Cardano.Wallet.Shelley.Compatibility ( AnyCardanoEra (..) , CardanoBlock diff --git a/lib/wallet/src/Cardano/Wallet.hs b/lib/wallet/src/Cardano/Wallet.hs index f14902ac293..0f63717b34e 100644 --- a/lib/wallet/src/Cardano/Wallet.hs +++ b/lib/wallet/src/Cardano/Wallet.hs @@ -432,6 +432,9 @@ import Cardano.Wallet.Primitive.Ledger.Convert , toWallet , toWalletCoin ) +import Cardano.Wallet.Primitive.Ledger.Read.Block + ( fromCardanoBlock + ) import Cardano.Wallet.Primitive.Model ( BlockData (..) , Wallet @@ -554,9 +557,6 @@ import Cardano.Wallet.Primitive.Types.UTxO import Cardano.Wallet.Primitive.Types.UTxOStatistics ( UTxOStatistics ) -import Cardano.Wallet.Read.Primitive.Block - ( fromCardanoBlock - ) import Cardano.Wallet.Read.Tx.CBOR ( TxCBOR ) diff --git a/lib/wallet/src/Cardano/Wallet/Byron/Compatibility.hs b/lib/wallet/src/Cardano/Wallet/Byron/Compatibility.hs index cebddddd364..b5dced75343 100644 --- a/lib/wallet/src/Cardano/Wallet/Byron/Compatibility.hs +++ b/lib/wallet/src/Cardano/Wallet/Byron/Compatibility.hs @@ -59,13 +59,13 @@ import Cardano.Crypto.ProtocolMagic ( ProtocolMagicId , unProtocolMagicId ) -import Cardano.Wallet.Read.Primitive.Tx.Byron +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Byron ( fromTxAux ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs ( fromByronTxIn ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs ( fromByronTxOut ) import Cardano.Wallet.Unsafe diff --git a/lib/wallet/src/Cardano/Wallet/DB.hs b/lib/wallet/src/Cardano/Wallet/DB.hs index 68b6000a2a2..62eb8f32340 100644 --- a/lib/wallet/src/Cardano/Wallet/DB.hs +++ b/lib/wallet/src/Cardano/Wallet/DB.hs @@ -64,6 +64,9 @@ import Cardano.Wallet.DB.WalletState , WalletState (submissions) , updateSubmissions ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Sealed + ( fromSealedTx + ) import Cardano.Wallet.Primitive.Model ( Wallet , currentTip @@ -111,9 +114,6 @@ import Cardano.Wallet.Primitive.Types.Tx.TxOut import Cardano.Wallet.Read.Eras ( EraValue ) -import Cardano.Wallet.Read.Primitive.Tx.Sealed - ( fromSealedTx - ) import Cardano.Wallet.Submissions.Submissions ( TxStatusMeta (..) , txStatus diff --git a/lib/wallet/src/Cardano/Wallet/DB/Store/Transactions/Decoration.hs b/lib/wallet/src/Cardano/Wallet/DB/Store/Transactions/Decoration.hs index 8fc9618faea..e618894cbeb 100644 --- a/lib/wallet/src/Cardano/Wallet/DB/Store/Transactions/Decoration.hs +++ b/lib/wallet/src/Cardano/Wallet/DB/Store/Transactions/Decoration.hs @@ -46,6 +46,12 @@ import Cardano.Wallet.DB.Store.Transactions.Model , fromTxCollateralOut , fromTxOut ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralInputs + ( getCollateralInputs + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + ( getInputs + ) import Cardano.Wallet.Read.Eras ( EraValue , extractEraValue @@ -53,12 +59,6 @@ import Cardano.Wallet.Read.Eras import Cardano.Wallet.Read.Eras.EraFun ( applyEraFun ) -import Cardano.Wallet.Read.Primitive.Tx.Features.CollateralInputs - ( getCollateralInputs - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - ( getInputs - ) import Cardano.Wallet.Read.Tx.CollateralInputs ( getEraCollateralInputs ) diff --git a/lib/wallet/src/Cardano/Wallet/DB/Store/Transactions/TransactionInfo.hs b/lib/wallet/src/Cardano/Wallet/DB/Store/Transactions/TransactionInfo.hs index 92fb98d1caf..d44691709e1 100644 --- a/lib/wallet/src/Cardano/Wallet/DB/Store/Transactions/TransactionInfo.hs +++ b/lib/wallet/src/Cardano/Wallet/DB/Store/Transactions/TransactionInfo.hs @@ -43,45 +43,45 @@ import Cardano.Wallet.DB.Store.Transactions.Model , fromTxOut , txCBORPrism ) -import Cardano.Wallet.Primitive.Slotting - ( TimeInterpreter - , interpretQuery - , slotToUTCTime - ) -import Cardano.Wallet.Read.Eras - ( EraFun - , EraValue - , K - , applyEraFun - , extractEraValue - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.CollateralInputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralInputs ( getCollateralInputs ) -import Cardano.Wallet.Read.Primitive.Tx.Features.CollateralOutputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralOutputs ( getCollateralOutputs ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Fee +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Fee ( getFee ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs ( getInputs ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Metadata +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata ( getMetadata ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs ( getOutputs ) -import Cardano.Wallet.Read.Primitive.Tx.Features.ScriptValidity +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.ScriptValidity ( getScriptValidity ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Validity +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity ( getValidity ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Withdrawals +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals ( getWithdrawals ) +import Cardano.Wallet.Primitive.Slotting + ( TimeInterpreter + , interpretQuery + , slotToUTCTime + ) +import Cardano.Wallet.Read.Eras + ( EraFun + , EraValue + , K + , applyEraFun + , extractEraValue + ) import Cardano.Wallet.Read.Tx.CBOR ( TxCBOR , renderTxToCBOR diff --git a/lib/wallet/src/Cardano/Wallet/Pools.hs b/lib/wallet/src/Cardano/Wallet/Pools.hs index 53cd33c2afc..c99c5251907 100644 --- a/lib/wallet/src/Cardano/Wallet/Pools.hs +++ b/lib/wallet/src/Cardano/Wallet/Pools.hs @@ -82,6 +82,12 @@ import Cardano.Wallet.Network , ChainFollower (..) , NetworkLayer (..) ) +import Cardano.Wallet.Primitive.Ledger.Read.Block + ( fromCardanoBlock + ) +import Cardano.Wallet.Primitive.Ledger.Read.Block.Header + ( getBlockHeader + ) import Cardano.Wallet.Primitive.Slotting ( PastHorizonException (..) , Qry @@ -116,12 +122,6 @@ import Cardano.Wallet.Primitive.Types import Cardano.Wallet.Primitive.Types.Coin ( Coin (..) ) -import Cardano.Wallet.Read.Primitive.Block - ( fromCardanoBlock - ) -import Cardano.Wallet.Read.Primitive.Block.Header - ( getBlockHeader - ) import Cardano.Wallet.Registry ( AfterThreadLog , traceAfterThread diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Compatibility.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Compatibility.hs index 19d861e6687..fb1f7f2bea9 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Compatibility.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Compatibility.hs @@ -228,6 +228,14 @@ import Cardano.Wallet.Byron.Compatibility ( fromTxAux , maryTokenBundleMaxSize ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs + ( fromShelleyTxIn + ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs + ( fromCardanoValue + , fromShelleyAddress + , fromShelleyTxOut + ) import Cardano.Wallet.Primitive.Types ( ChainPoint (..) , PoolCertificate @@ -235,14 +243,6 @@ import Cardano.Wallet.Primitive.Types , ProtocolParameters (txParameters) , TxParameters (getTokenBundleMaxSize) ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Inputs - ( fromShelleyTxIn - ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Outputs - ( fromCardanoValue - , fromShelleyAddress - , fromShelleyTxOut - ) import Cardano.Wallet.Read.Tx.Hash ( fromShelleyTxId ) diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs index 98522383de3..bd382db9098 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Network/Node.hs @@ -77,6 +77,9 @@ import Cardano.Wallet.Network , mapChainSyncLog , withFollowStatsMonitoring ) +import Cardano.Wallet.Primitive.Ledger.Read.Block.Header + ( getBlockHeader + ) import Cardano.Wallet.Primitive.Slotting ( TimeInterpreter , TimeInterpreterLog @@ -93,9 +96,6 @@ import Cardano.Wallet.Primitive.Types import Cardano.Wallet.Primitive.Types.Tx ( SealedTx (..) ) -import Cardano.Wallet.Read.Primitive.Block.Header - ( getBlockHeader - ) import Cardano.Wallet.Shelley.Compatibility ( StandardCrypto , fromAllegraPParams diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs index 6c8656e1b18..763db699dce 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs @@ -101,6 +101,9 @@ import Cardano.Wallet.Flavor import Cardano.Wallet.Primitive.Ledger.Convert ( Convert (toLedger) ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx + ( fromCardanoTx + ) import Cardano.Wallet.Primitive.Passphrase ( Passphrase (..) ) @@ -145,9 +148,6 @@ import Cardano.Wallet.Primitive.Types.Tx.TxIn import Cardano.Wallet.Primitive.Types.Tx.TxOut ( TxOut (..) ) -import Cardano.Wallet.Read.Primitive.Tx - ( fromCardanoTx - ) import Cardano.Wallet.Shelley.Compatibility ( cardanoCertKeysForWitnesses , fromCardanoAddress diff --git a/lib/wallet/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs b/lib/wallet/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs index c3fde31d6f4..d83d32f6a6e 100644 --- a/lib/wallet/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs +++ b/lib/wallet/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs @@ -84,6 +84,9 @@ import Cardano.Wallet.Gen ( genMnemonic , genScript ) +import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Integrity + ( txIntegrity + ) import Cardano.Wallet.Primitive.NetworkId ( SNetworkId (..) ) @@ -158,9 +161,6 @@ import Cardano.Wallet.Primitive.Types.Tx.TxOut.Gen import Cardano.Wallet.Primitive.Types.UTxO ( UTxO (..) ) -import Cardano.Wallet.Read.Primitive.Tx.Features.Integrity - ( txIntegrity - ) import Cardano.Wallet.Read.Tx.Cardano ( fromCardanoApiTx )