cardano-ledger-mary-1.12.0.0: Cardano ledger with multiasset support.
Safe HaskellNone
LanguageHaskell2010

Cardano.Ledger.Mary.Value

Synopsis

Documentation

newtype PolicyID Source #

Policy ID

Constructors

PolicyID 

Fields

Instances

Instances details
FromJSON PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

FromJSONKey PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

ToJSON PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

ToJSONKey PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

DecCBOR PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

EncCBOR PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NFData PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

rnf ∷ PolicyID → () #

Generic PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Associated Types

type Rep PolicyID 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep PolicyID = D1 ('MetaData "PolicyID" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.12.0.0-inplace" 'True) (C1 ('MetaCons "PolicyID" 'PrefixI 'True) (S1 ('MetaSel ('Just "policyID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ScriptHash)))

Methods

from ∷ PolicyID → Rep PolicyID x #

to ∷ Rep PolicyID x → PolicyID #

Show PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

showsPrec ∷ Int → PolicyID → ShowS #

show ∷ PolicyID → String #

showList ∷ [PolicyID] → ShowS #

Eq PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

(==) ∷ PolicyID → PolicyID → Bool #

(/=) ∷ PolicyID → PolicyID → Bool #

Ord PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NoThunks PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep PolicyID Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep PolicyID = D1 ('MetaData "PolicyID" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.12.0.0-inplace" 'True) (C1 ('MetaCons "PolicyID" 'PrefixI 'True) (S1 ('MetaSel ('Just "policyID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ScriptHash)))

newtype AssetName Source #

Asset Name

Constructors

AssetName 

Instances

Instances details
FromJSON AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

FromJSONKey AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

ToJSON AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

ToJSONKey AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

DecCBOR AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

EncCBOR AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NFData AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

rnf ∷ AssetName → () #

Show AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

showsPrec ∷ Int → AssetName → ShowS #

show ∷ AssetName → String #

showList ∷ [AssetName] → ShowS #

Eq AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

(==) ∷ AssetName → AssetName → Bool #

(/=) ∷ AssetName → AssetName → Bool #

Ord AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NoThunks AssetName Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

data MaryValue Source #

The Value representing MultiAssets

Note that the Ord instance isn't semantically meaningful and is used only to satisfy constraints on Haskell containers such as Set and Map. Do not use it for any purpose that would directly affect chain behavior.

Constructors

MaryValue !Coin !MultiAsset 

Instances

Instances details
FromJSON MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

ToJSON MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

DecCBOR MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

EncCBOR MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

ToKeyValuePairs MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

toKeyValuePairs ∷ KeyValue e kv ⇒ MaryValue → [kv] Source #

Compactible MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Associated Types

newtype CompactForm MaryValue 
Instance details

Defined in Cardano.Ledger.Mary.Value

Val MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NFData MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

rnf ∷ MaryValue → () #

Monoid MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Semigroup MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Generic MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Associated Types

type Rep MaryValue 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep MaryValue = D1 ('MetaData "MaryValue" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.12.0.0-inplace" 'False) (C1 ('MetaCons "MaryValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MultiAsset)))

Methods

from ∷ MaryValue → Rep MaryValue x #

to ∷ Rep MaryValue x → MaryValue #

Show MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

showsPrec ∷ Int → MaryValue → ShowS #

show ∷ MaryValue → String #

showList ∷ [MaryValue] → ShowS #

Eq MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

(==) ∷ MaryValue → MaryValue → Bool #

(/=) ∷ MaryValue → MaryValue → Bool #

Ord MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Abelian MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Group MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NoThunks MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Inject Coin MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

inject ∷ Coin → MaryValue Source #

DecCBOR (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

EncCBOR (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NFData (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

rnf ∷ CompactForm MaryValue → () #

Show (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Eq (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Ord (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

MemPack (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NoThunks (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

newtype CompactForm MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep MaryValue = D1 ('MetaData "MaryValue" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.12.0.0-inplace" 'False) (C1 ('MetaCons "MaryValue" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Coin) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MultiAsset)))

newtype MultiAsset Source #

The MultiAssets map

Note that the Ord instance isn't semantically meaningful and is used only to satisfy constraints on Haskell containers such as Set and Map. Do not use it for any purpose that would directly affect chain behavior.

Instances

Instances details
FromJSON MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

ToJSON MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

DecCBOR MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

EncCBOR MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NFData MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

rnf ∷ MultiAsset → () #

Monoid MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Semigroup MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Generic MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Associated Types

type Rep MultiAsset 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep MultiAsset = D1 ('MetaData "MultiAsset" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.12.0.0-inplace" 'True) (C1 ('MetaCons "MultiAsset" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PolicyID (Map AssetName Integer)))))
Show MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Eq MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

(==) ∷ MultiAsset → MultiAsset → Bool #

(/=) ∷ MultiAsset → MultiAsset → Bool #

Ord MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Group MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NoThunks MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep MultiAsset Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep MultiAsset = D1 ('MetaData "MultiAsset" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.12.0.0-inplace" 'True) (C1 ('MetaCons "MultiAsset" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PolicyID (Map AssetName Integer)))))
type MemoHashIndex (MaryTxBodyRaw l) Source # 
Instance details

Defined in Cardano.Ledger.Mary.TxBody

insertMultiAsset ∷ (Integer → Integer → Integer) → PolicyID → AssetName → Integer → MultiAsset → MultiAsset Source #

insertMultiAsset comb policy asset n v, if comb = old new -> old, the integer in the MultiAsset is prefered over n if comb = old new -> new, then n is prefered over the integer in the MultiAsset if (comb old new) == 0, then that value should not be stored in the MultiAsset

multiAssetFromList ∷ [(PolicyID, AssetName, Integer)] → MultiAsset Source #

Rather than using prune to remove 0 assets, when can avoid adding them in the first place by using valueFromList to construct a MultiAsset

policies ∷ MultiAsset → Set PolicyID Source #

Extract the set of policies in the Value.

This function is equivalent to computing the support of the value in the spec.

mapMaybeMultiAsset ∷ (PolicyID → AssetName → Integer → Maybe Integer) → MultiAsset → MultiAsset Source #

Map a function over each multi asset value while optionally filtering values out. Canonical form is preserved.

filterMultiAsset Source #

Arguments

∷ (PolicyID → AssetName → Integer → Bool)

Predicate that needs to return True whenever an asset should be retained.

→ MultiAsset 
→ MultiAsset 

Filter multi assets. Canonical form is preserved.

pruneZeroMultiAsset ∷ MultiAsset → MultiAsset Source #

Remove all assets with that have zero amount specified

showValue ∷ MaryValue → String Source #

Display a MaryValue as a String, one token per line

data CompactValue Source #

Instances

Instances details
DecCBOR CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

EncCBOR CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NFData CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

rnf ∷ CompactValue → () #

Generic CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Associated Types

type Rep CompactValue 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep CompactValue = D1 ('MetaData "CompactValue" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.12.0.0-inplace" 'False) (C1 ('MetaCons "CompactValueAdaOnly" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (CompactForm Coin))) :+: C1 ('MetaCons "CompactValueMultiAsset" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (CompactForm Coin)) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 ShortByteString))))
Show CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Eq CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Ord CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

MemPack CompactValue Source #

We need to manually pack/unpack `CompactForm Coin` here because its MemPack instance can't be used due to the requirement of it being compatible with the first case of CompactValueAdaOnly. In other words MemPack instance for `CompactForm Coin` also prefixes a zero Tag for binary compatibility with CompactValueAdaOnly case.

Instance details

Defined in Cardano.Ledger.Mary.Value

NoThunks CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep CompactValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep CompactValue = D1 ('MetaData "CompactValue" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.12.0.0-inplace" 'False) (C1 ('MetaCons "CompactValueAdaOnly" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (CompactForm Coin))) :+: C1 ('MetaCons "CompactValueMultiAsset" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (CompactForm Coin)) :*: (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Word32) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 ShortByteString))))

data family CompactForm a Source #

Instances

Instances details
FromJSON (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

ToJSON (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

ToJSON (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

ToCBOR (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Methods

toCBOR ∷ CompactForm Coin → Encoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (CompactForm Coin) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [CompactForm Coin] → Size Source #

DecCBOR (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

DecCBOR (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

DecCBOR (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

EncCBOR (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

EncCBOR (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

EncCBOR (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

HasZero (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

ToPlutusData (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Plutus.ToPlutusData

NFData (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Methods

rnf ∷ CompactForm Coin → () #

NFData (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

Methods

rnf ∷ CompactForm DeltaCoin → () #

NFData (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Methods

rnf ∷ CompactForm MaryValue → () #

Monoid (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Semigroup (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Storable (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Generic (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Associated Types

type Rep (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

type Rep (CompactForm Coin) = D1 ('MetaData "CompactForm" "Cardano.Ledger.Coin" "cardano-ledger-core-1.22.0.0-inplace" 'True) (C1 ('MetaCons "CompactCoin" 'PrefixI 'True) (S1 ('MetaSel ('Just "unCompactCoin") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))
Show (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Show (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

Show (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Eq (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Eq (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

Eq (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Ord (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Ord (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

Ord (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Abelian (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Group (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

MemPack (CompactForm Coin)

This instance prefixes with a 0 Tag for binary compatibility with compact form of multiassets.

Instance details

Defined in Cardano.Ledger.Coin

MemPack (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

NoThunks (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

NoThunks (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

NoThunks (CompactForm MaryValue) Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

Prim (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Prim (CompactForm DeltaCoin) 
Instance details

Defined in Cardano.Ledger.Coin

Uniform (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

Methods

uniformM ∷ StatefulGen g m ⇒ g → m (CompactForm Coin) Source #

UniformRange (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

newtype CompactForm Coin 
Instance details

Defined in Cardano.Ledger.Coin

newtype CompactForm DeltaCoin 
Instance details

Defined in Cardano.Ledger.Coin

newtype CompactForm MaryValue Source # 
Instance details

Defined in Cardano.Ledger.Mary.Value

type Rep (CompactForm Coin) 
Instance details

Defined in Cardano.Ledger.Coin

type Rep (CompactForm Coin) = D1 ('MetaData "CompactForm" "Cardano.Ledger.Coin" "cardano-ledger-core-1.22.0.0-inplace" 'True) (C1 ('MetaCons "CompactCoin" 'PrefixI 'True) (S1 ('MetaSel ('Just "unCompactCoin") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64)))

isMultiAssetSmallEnough ∷ MultiAsset → Bool Source #

Unlike representationSize, this function cheaply checks whether any offset within a MultiAsset compact representation is likely to overflow Word16.

compact form inequality: 8n (Word64) + 2n (Word16) + 2n (Word16) + 28p (policy ids) + sum of lengths of unique asset names <= 65535 maximum size for the asset name is 32 bytes, so: 8n + 2n + 2n + 28p + 32n <= 65535 where: n = total number of assets, p = number of unique policy ids