Safe Haskell | None |
---|---|
Language | Haskell2010 |
Cardano.Api.Value
Description
Currency values
Synopsis
- newtype Coin = Coin {}
- newtype Quantity = Quantity Integer
- parseQuantity :: Parser Quantity
- newtype PolicyId = PolicyId {}
- parsePolicyId :: Parser PolicyId
- scriptPolicyId :: Script lang -> PolicyId
- newtype AssetName = UnsafeAssetName ByteString
- parseAssetName :: Parser AssetName
- data AssetId
- parseAssetId :: Parser AssetId
- data Value
- selectAsset :: Value -> AssetId -> Quantity
- valueFromList :: [(AssetId, Quantity)] -> Value
- valueToList :: Value -> [(AssetId, Quantity)]
- filterValue :: (AssetId -> Bool) -> Value -> Value
- allPositive :: Value -> Bool
- negateValue :: Value -> Value
- negateLedgerValue :: ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value (ShelleyLedgerEra era)
- calcMinimumDeposit :: Value -> Lovelace -> Lovelace
- newtype PolicyAssets = PolicyAssets (Map AssetName Quantity)
- policyAssetsToValue :: PolicyId -> PolicyAssets -> Value
- valueToPolicyAssets :: Value -> Map PolicyId PolicyAssets
- multiAssetToPolicyAssets :: MultiAsset -> Map PolicyId PolicyAssets
- parseUTxOValue :: Parser Value
- parseMintingMultiAssetValue :: MaryEraOnwards era -> Parser MultiAsset
- parseTxOutMultiAssetValue :: Parser Value
- type Lovelace = Coin
- quantityToLovelace :: Quantity -> Lovelace
- lovelaceToQuantity :: Lovelace -> Quantity
- selectLovelace :: Value -> Lovelace
- lovelaceToValue :: Lovelace -> Value
- valueToLovelace :: Value -> Maybe Lovelace
- newtype ValueNestedRep = ValueNestedRep [ValueNestedBundle]
- data ValueNestedBundle
- valueToNestedRep :: Value -> ValueNestedRep
- valueFromNestedRep :: ValueNestedRep -> Value
- renderValue :: Value -> Text
- renderValuePretty :: Value -> Text
- renderMultiAsset :: MultiAsset -> Text
- renderMultiAssetPretty :: MultiAsset -> Text
- toByronLovelace :: Lovelace -> Maybe Lovelace
- fromByronLovelace :: Lovelace -> Lovelace
- fromShelleyDeltaLovelace :: DeltaCoin -> Lovelace
- toMaryValue :: Value -> MaryValue
- fromMaryValue :: MaryValue -> Value
- fromMultiAsset :: MultiAsset -> Value
- fromLedgerValue :: ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
- toLedgerValue :: MaryEraOnwards era -> Value -> Value (ShelleyLedgerEra era)
- data family AsType t
Documentation
The amount of value held by a transaction output.
Instances
Multi-asset values
Instances
FromJSON Quantity Source # | |
Defined in Cardano.Api.Value.Internal | |
ToJSON Quantity Source # | |
Defined in Cardano.Api.Value.Internal | |
Data Quantity Source # | |
Defined in Cardano.Api.Value.Internal Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Quantity -> c Quantity Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Quantity Source # toConstr :: Quantity -> Constr Source # dataTypeOf :: Quantity -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Quantity) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Quantity) Source # gmapT :: (forall b. Data b => b -> b) -> Quantity -> Quantity Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Quantity -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Quantity -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Quantity -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Quantity -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Quantity -> m Quantity Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Quantity -> m Quantity Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Quantity -> m Quantity Source # | |
Monoid Quantity Source # | |
Semigroup Quantity Source # | |
Num Quantity Source # | |
Defined in Cardano.Api.Value.Internal Methods (+) :: Quantity -> Quantity -> Quantity Source # (-) :: Quantity -> Quantity -> Quantity Source # (*) :: Quantity -> Quantity -> Quantity Source # negate :: Quantity -> Quantity Source # abs :: Quantity -> Quantity Source # signum :: Quantity -> Quantity Source # fromInteger :: Integer -> Quantity Source # | |
Show Quantity Source # | |
Eq Quantity Source # | |
Ord Quantity Source # | |
Defined in Cardano.Api.Value.Internal |
parseQuantity :: Parser Quantity Source #
Quantity (word64) parser. Only accepts positive quantities.
Constructors
PolicyId | |
Fields |
Instances
FromJSON PolicyId Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
ToJSON PolicyId Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
Show PolicyId Source # | |||||
HasTypeProxy PolicyId Source # | |||||
Defined in Cardano.Api.Value.Internal Associated Types
| |||||
SerialiseAsRawBytes PolicyId Source # | |||||
Defined in Cardano.Api.Value.Internal Methods serialiseToRawBytes :: PolicyId -> ByteString Source # deserialiseFromRawBytes :: AsType PolicyId -> ByteString -> Either SerialiseAsRawBytesError PolicyId Source # | |||||
Eq PolicyId Source # | |||||
Ord PolicyId Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
data AsType PolicyId Source # | |||||
Defined in Cardano.Api.Value.Internal |
parsePolicyId :: Parser PolicyId Source #
Policy ID parser.
scriptPolicyId :: Script lang -> PolicyId Source #
Constructors
UnsafeAssetName ByteString |
Instances
FromJSON AssetName Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
FromJSONKey AssetName Source # | |||||
Defined in Cardano.Api.Value.Internal Methods fromJSONKey :: FromJSONKeyFunction AssetName fromJSONKeyList :: FromJSONKeyFunction [AssetName] | |||||
ToJSON AssetName Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
ToJSONKey AssetName Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
Show AssetName Source # | |||||
HasTypeProxy AssetName Source # | |||||
Defined in Cardano.Api.Value.Internal Associated Types
| |||||
SerialiseAsRawBytes AssetName Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
Eq AssetName Source # | |||||
Ord AssetName Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
data AsType AssetName Source # | |||||
Defined in Cardano.Api.Value.Internal |
parseAssetName :: Parser AssetName Source #
Asset name parser.
Constructors
AdaAssetId | |
AssetId !PolicyId !AssetName |
Instances
Show AssetId Source # | |
Eq AssetId Source # | |
Ord AssetId Source # | |
Defined in Cardano.Api.Value.Internal |
parseAssetId :: Parser AssetId Source #
Asset ID parser.
Instances
FromJSON Value Source # | |
Defined in Cardano.Api.Value.Internal Methods parseJSON :: Value -> Parser Value # parseJSONList :: Value -> Parser [Value] # omittedField :: Maybe Value # | |
ToJSON Value Source # | |
Defined in Cardano.Api.Value.Internal | |
Monoid Value Source # | |
Semigroup Value Source # | |
IsList Value Source # | |
Show Value Source # | |
Eq Value Source # | |
type Item Value Source # | |
Defined in Cardano.Api.Value.Internal |
negateValue :: Value -> Value Source #
This lets you write a - b
as a <> negateValue b
.
negateLedgerValue :: ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value (ShelleyLedgerEra era) Source #
calcMinimumDeposit :: Value -> Lovelace -> Lovelace Source #
Calculate cost of making a UTxO entry for a given Value
and
mininimum UTxO value derived from the ProtocolParameters
newtype PolicyAssets Source #
Map of non-ADA assets with their quantity, for a single policy
Constructors
PolicyAssets (Map AssetName Quantity) |
Instances
Monoid PolicyAssets Source # | |||||
Defined in Cardano.Api.Value.Internal Methods mempty :: PolicyAssets Source # mappend :: PolicyAssets -> PolicyAssets -> PolicyAssets Source # mconcat :: [PolicyAssets] -> PolicyAssets Source # | |||||
Semigroup PolicyAssets Source # | |||||
Defined in Cardano.Api.Value.Internal Methods (<>) :: PolicyAssets -> PolicyAssets -> PolicyAssets Source # sconcat :: NonEmpty PolicyAssets -> PolicyAssets Source # stimes :: Integral b => b -> PolicyAssets -> PolicyAssets Source # | |||||
IsList PolicyAssets Source # | |||||
Defined in Cardano.Api.Value.Internal Associated Types
Methods fromList :: [Item PolicyAssets] -> PolicyAssets Source # fromListN :: Int -> [Item PolicyAssets] -> PolicyAssets Source # toList :: PolicyAssets -> [Item PolicyAssets] Source # | |||||
Show PolicyAssets Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
Eq PolicyAssets Source # | |||||
Defined in Cardano.Api.Value.Internal Methods (==) :: PolicyAssets -> PolicyAssets -> Bool Source # (/=) :: PolicyAssets -> PolicyAssets -> Bool Source # | |||||
MonoFunctor PolicyAssets Source # | |||||
Defined in Cardano.Api.Value.Internal Methods omap :: (Element PolicyAssets -> Element PolicyAssets) -> PolicyAssets -> PolicyAssets | |||||
type Item PolicyAssets Source # | |||||
Defined in Cardano.Api.Value.Internal | |||||
type Element PolicyAssets Source # | |||||
Defined in Cardano.Api.Value.Internal |
policyAssetsToValue :: PolicyId -> PolicyAssets -> Value Source #
valueToPolicyAssets :: Value -> Map PolicyId PolicyAssets Source #
Converts Value
to PolicyAssets
. Discards any ADA value stored in Value
.
multiAssetToPolicyAssets :: MultiAsset -> Map PolicyId PolicyAssets Source #
Convert cardano-ledger's MultiAsset
to a map of PolicyAssets
parseUTxOValue :: Parser Value Source #
Parse a Value
from its string representation. The resulting amounts must be positive for the parser
to succeed.
parseMintingMultiAssetValue :: MaryEraOnwards era -> Parser MultiAsset Source #
Parse a MintValue
from its string representation. The string representation cannot contain ADA.
parseTxOutMultiAssetValue :: Parser Value Source #
Parse a Value
from its string representation. The resulting amounts must be positive for the parser
to succeed.
Ada / L.Coin specifically
selectLovelace :: Value -> Lovelace Source #
lovelaceToValue :: Lovelace -> Value Source #
valueToLovelace :: Value -> Maybe Lovelace Source #
Check if the Value
consists of only Lovelace
and no other assets,
and if so then return the Lovelace
See also selectLovelace
to select the Lovelace quantity from the Value,
ignoring other assets.
Alternative nested representation
newtype ValueNestedRep Source #
Constructors
ValueNestedRep [ValueNestedBundle] |
Instances
FromJSON ValueNestedRep Source # | |
Defined in Cardano.Api.Value.Internal Methods parseJSON :: Value -> Parser ValueNestedRep # parseJSONList :: Value -> Parser [ValueNestedRep] # | |
ToJSON ValueNestedRep Source # | |
Defined in Cardano.Api.Value.Internal Methods toJSON :: ValueNestedRep -> Value # toEncoding :: ValueNestedRep -> Encoding # toJSONList :: [ValueNestedRep] -> Value # toEncodingList :: [ValueNestedRep] -> Encoding # omitField :: ValueNestedRep -> Bool # | |
Show ValueNestedRep Source # | |
Defined in Cardano.Api.Value.Internal | |
Eq ValueNestedRep Source # | |
Defined in Cardano.Api.Value.Internal Methods (==) :: ValueNestedRep -> ValueNestedRep -> Bool Source # (/=) :: ValueNestedRep -> ValueNestedRep -> Bool Source # | |
Ord ValueNestedRep Source # | |
Defined in Cardano.Api.Value.Internal Methods compare :: ValueNestedRep -> ValueNestedRep -> Ordering Source # (<) :: ValueNestedRep -> ValueNestedRep -> Bool Source # (<=) :: ValueNestedRep -> ValueNestedRep -> Bool Source # (>) :: ValueNestedRep -> ValueNestedRep -> Bool Source # (>=) :: ValueNestedRep -> ValueNestedRep -> Bool Source # max :: ValueNestedRep -> ValueNestedRep -> ValueNestedRep Source # min :: ValueNestedRep -> ValueNestedRep -> ValueNestedRep Source # |
data ValueNestedBundle Source #
A bundle within a ValueNestedRep
for a single PolicyId
, or for the
special case of ada.
Constructors
ValueNestedBundleAda Quantity | |
ValueNestedBundle PolicyId (Map AssetName Quantity) |
Instances
Show ValueNestedBundle Source # | |
Defined in Cardano.Api.Value.Internal | |
Eq ValueNestedBundle Source # | |
Defined in Cardano.Api.Value.Internal Methods (==) :: ValueNestedBundle -> ValueNestedBundle -> Bool Source # (/=) :: ValueNestedBundle -> ValueNestedBundle -> Bool Source # | |
Ord ValueNestedBundle Source # | |
Defined in Cardano.Api.Value.Internal Methods compare :: ValueNestedBundle -> ValueNestedBundle -> Ordering Source # (<) :: ValueNestedBundle -> ValueNestedBundle -> Bool Source # (<=) :: ValueNestedBundle -> ValueNestedBundle -> Bool Source # (>) :: ValueNestedBundle -> ValueNestedBundle -> Bool Source # (>=) :: ValueNestedBundle -> ValueNestedBundle -> Bool Source # max :: ValueNestedBundle -> ValueNestedBundle -> ValueNestedBundle Source # min :: ValueNestedBundle -> ValueNestedBundle -> ValueNestedBundle Source # |
Rendering
renderMultiAsset :: MultiAsset -> Text Source #
Internal conversion functions
fromByronLovelace :: Lovelace -> Lovelace Source #
toMaryValue :: Value -> MaryValue Source #
fromMaryValue :: MaryValue -> Value Source #
fromMultiAsset :: MultiAsset -> Value Source #
fromLedgerValue :: ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value Source #
toLedgerValue :: MaryEraOnwards era -> Value -> Value (ShelleyLedgerEra era) Source #
Data family instances
A family of singleton types used in this API to indicate which type to use where it would otherwise be ambiguous or merely unclear.
Values of this type are passed to deserialisation functions for example.
Instances
data AsType AddressAny Source # | |
Defined in Cardano.Api.Address | |
data AsType ByronAddr Source # | |
Defined in Cardano.Api.Address | |
data AsType ShelleyAddr Source # | |
Defined in Cardano.Api.Address | |
data AsType StakeAddress Source # | |
Defined in Cardano.Api.Address | |
data AsType BlockHeader Source # | |
Defined in Cardano.Api.Block | |
data AsType ByronKey Source # | |
Defined in Cardano.Api.Byron.Internal.Key | |
data AsType ByronKeyLegacy Source # | |
Defined in Cardano.Api.Byron.Internal.Key | |
data AsType ByronUpdateProposal Source # | |
Defined in Cardano.Api.Byron.Internal.Proposal | |
data AsType ByronVote Source # | |
Defined in Cardano.Api.Byron.Internal.Proposal | |
data AsType DRepMetadata Source # | |
data AsType OperationalCertificate Source # | |
data AsType OperationalCertificateIssueCounter Source # | |
data AsType StakePoolMetadata Source # | |
data AsType AllegraEra Source # | |
Defined in Cardano.Api.Era.Internal.Core | |
data AsType AlonzoEra Source # | |
Defined in Cardano.Api.Era.Internal.Core | |
data AsType BabbageEra Source # | |
Defined in Cardano.Api.Era.Internal.Core | |
data AsType ByronEra Source # | |
Defined in Cardano.Api.Era.Internal.Core | |
data AsType ConwayEra Source # | |
Defined in Cardano.Api.Era.Internal.Core | |
data AsType MaryEra Source # | |
Defined in Cardano.Api.Era.Internal.Core | |
data AsType ShelleyEra Source # | |
Defined in Cardano.Api.Era.Internal.Core | |
data AsType GovernancePoll Source # | |
Defined in Cardano.Api.Governance.Internal.Poll | |
data AsType GovernancePollAnswer Source # | |
Defined in Cardano.Api.Governance.Internal.Poll | |
data AsType CommitteeColdExtendedKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType CommitteeColdKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType CommitteeHotExtendedKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType CommitteeHotKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType DRepExtendedKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType DRepKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType GenesisDelegateExtendedKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType GenesisDelegateKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType GenesisExtendedKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType GenesisKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType GenesisUTxOKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType PaymentExtendedKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType PaymentKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType StakeExtendedKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType StakeKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType StakePoolExtendedKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType StakePoolKey Source # | |
Defined in Cardano.Api.Key.Internal | |
data AsType KesKey Source # | |
Defined in Cardano.Api.Key.Internal.Praos | |
data AsType VrfKey Source # | |
Defined in Cardano.Api.Key.Internal.Praos | |
data AsType PlutusScriptV1 Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType PlutusScriptV2 Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType PlutusScriptV3 Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType ScriptHash Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType ScriptInAnyLang Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType SimpleScript' Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType HashableScriptData Source # | |
Defined in Cardano.Api.Plutus.Internal.ScriptData | |
data AsType ScriptData Source # | |
Defined in Cardano.Api.Plutus.Internal.ScriptData | |
data AsType PraosNonce Source # | |
Defined in Cardano.Api.ProtocolParameters | |
data AsType UpdateProposal Source # | |
Defined in Cardano.Api.ProtocolParameters | |
data AsType EraHistory Source # | |
Defined in Cardano.Api.Query.Internal.Type.QueryInMode | |
data AsType TextEnvelope Source # | |
Defined in Cardano.Api.Serialise.TextEnvelope.Internal | |
data AsType TxId Source # | |
Defined in Cardano.Api.Tx.Internal.TxIn | |
data AsType TxMetadata Source # | |
Defined in Cardano.Api.Tx.Internal.TxMetadata | |
data AsType AssetName Source # | |
Defined in Cardano.Api.Value.Internal | |
data AsType PolicyId Source # | |
Defined in Cardano.Api.Value.Internal | |
data AsType GovActionId Source # | |
Defined in Cardano.Api.Internal.Orphans.Serialisation | |
data AsType Term Source # | |
Defined in Cardano.Api.Serialise.Cbor.Canonical | |
data AsType (Address addrtype) Source # | |
Defined in Cardano.Api.Address | |
data AsType (AddressInEra era) Source # | |
Defined in Cardano.Api.Address | |
data AsType (Certificate era) Source # | |
Defined in Cardano.Api.Certificate.Internal | |
data AsType (Proposal era) Source # | |
data AsType (VotingProcedure era) Source # | |
data AsType (VotingProcedures era) Source # | |
data AsType (Hash a) Source # | |
Defined in Cardano.Api.Hash | |
data AsType (SigningKey a) Source # | |
Defined in Cardano.Api.Key.Internal.Class | |
data AsType (VerificationKey a) Source # | |
Defined in Cardano.Api.Key.Internal.Class | |
data AsType (PlutusScript lang) Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType (Script lang) Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType (ScriptInEra era) Source # | |
Defined in Cardano.Api.Plutus.Internal.Script | |
data AsType (KeyWitness era) Source # | |
Defined in Cardano.Api.Tx.Internal.Sign | |
data AsType (Tx era) Source # | |
Defined in Cardano.Api.Tx.Internal.Sign | |
data AsType (TxBody era) Source # | |
Defined in Cardano.Api.Tx.Internal.Sign | |
data AsType (Credential 'ColdCommitteeRole) Source # | |
Defined in Cardano.Api.Internal.Orphans.Serialisation | |
data AsType (Credential 'DRepRole) Source # | |
Defined in Cardano.Api.Internal.Orphans.Serialisation | |
data AsType (Credential 'HotCommitteeRole) Source # | |
Defined in Cardano.Api.Internal.Orphans.Serialisation | |
data AsType (PlutusScriptInEra era lang) Source # | |
Defined in Cardano.Api.Plutus.Internal.Script |