Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype PolicyID c = PolicyID {
- policyID ∷ ScriptHash c
- newtype AssetName = AssetName {}
- data MaryValue c = MaryValue !Coin !(MultiAsset c)
- newtype MultiAsset c = MultiAsset (Map (PolicyID c) (Map AssetName Integer))
- insert ∷ (Integer → Integer → Integer) → PolicyID c → AssetName → Integer → MultiAsset c → MultiAsset c
- insertMultiAsset ∷ (Integer → Integer → Integer) → PolicyID c → AssetName → Integer → MultiAsset c → MultiAsset c
- lookup ∷ PolicyID c → AssetName → MaryValue c → Integer
- lookupMultiAsset ∷ PolicyID c → AssetName → MaryValue c → Integer
- multiAssetFromList ∷ [(PolicyID era, AssetName, Integer)] → MultiAsset era
- policies ∷ MultiAsset c → Set (PolicyID c)
- mapMaybeMultiAsset ∷ (PolicyID c → AssetName → Integer → Maybe Integer) → MultiAsset c → MultiAsset c
- filterMultiAsset ∷ (PolicyID c → AssetName → Integer → Bool) → MultiAsset c → MultiAsset c
- pruneZeroMultiAsset ∷ MultiAsset c → MultiAsset c
- representationSize ∷ ∀ c. Crypto c ⇒ [(PolicyID c, AssetName, Integer)] → Int
- showValue ∷ MaryValue c → String
- flattenMultiAsset ∷ MultiAsset c → [(PolicyID c, AssetName, Integer)]
- valueFromList ∷ Coin → [(PolicyID era, AssetName, Integer)] → MaryValue era
- data CompactValue c
- data family CompactForm a
- isMultiAssetSmallEnough ∷ MultiAsset c → Bool
- assetNameToTextAsHex ∷ AssetName → Text
- prune ∷ Map (PolicyID c) (Map AssetName Integer) → Map (PolicyID c) (Map AssetName Integer)
Documentation
Policy ID
Instances
Crypto c ⇒ FromJSON (PolicyID c) Source # | |
Crypto c ⇒ FromJSONKey (PolicyID c) Source # | |
Defined in Cardano.Ledger.Mary.Value | |
Crypto c ⇒ ToJSON (PolicyID c) Source # | |
Crypto c ⇒ ToJSONKey (PolicyID c) Source # | |
Defined in Cardano.Ledger.Mary.Value | |
Generic (PolicyID c) Source # | |
Show (PolicyID c) Source # | |
Crypto c ⇒ DecCBOR (PolicyID c) Source # | |
Crypto c ⇒ EncCBOR (PolicyID c) Source # | |
NFData (PolicyID c) Source # | |
Defined in Cardano.Ledger.Mary.Value | |
Eq (PolicyID c) Source # | |
Ord (PolicyID c) Source # | |
Defined in Cardano.Ledger.Mary.Value | |
NoThunks (PolicyID c) Source # | |
type Rep (PolicyID c) Source # | |
Defined in Cardano.Ledger.Mary.Value type Rep (PolicyID c) = D1 ('MetaData "PolicyID" "Cardano.Ledger.Mary.Value" "cardano-ledger-mary-1.7.1.0-inplace" 'True) (C1 ('MetaCons "PolicyID" 'PrefixI 'True) (S1 ('MetaSel ('Just "policyID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ScriptHash c)))) |
Asset Name
Instances
The Value representing MultiAssets
MaryValue !Coin !(MultiAsset c) |
Instances
newtype MultiAsset c Source #
The MultiAssets map
Instances
insert ∷ (Integer → Integer → Integer) → PolicyID c → AssetName → Integer → MultiAsset c → MultiAsset c Source #
Deprecated: In favor of insertMultiAsset
insert 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
insertMultiAsset ∷ (Integer → Integer → Integer) → PolicyID c → AssetName → Integer → MultiAsset c → MultiAsset c 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
lookup ∷ PolicyID c → AssetName → MaryValue c → Integer Source #
Deprecated: In favor of lookupMultiAsset
multiAssetFromList ∷ [(PolicyID era, AssetName, Integer)] → MultiAsset era 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 c → Set (PolicyID c) 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 c → AssetName → Integer → Maybe Integer) → MultiAsset c → MultiAsset c Source #
Map a function over each multi asset value while optionally filtering values out. Canonical form is preserved.
∷ (PolicyID c → AssetName → Integer → Bool) | Predicate that needs to return |
→ MultiAsset c | |
→ MultiAsset c |
Filter multi assets. Canonical form is preserved.
pruneZeroMultiAsset ∷ MultiAsset c → MultiAsset c Source #
Remove all assets with that have zero amount specified
flattenMultiAsset ∷ MultiAsset c → [(PolicyID c, AssetName, Integer)] Source #
data CompactValue c Source #
CompactValueAdaOnly !(CompactForm Coin) | |
CompactValueMultiAsset !(CompactForm Coin) !Word32 !ShortByteString |
Instances
data family CompactForm a Source #
Instances
isMultiAssetSmallEnough ∷ MultiAsset c → 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