Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype PolicyID = PolicyID {}
- newtype AssetName = AssetName {}
- data MaryValue = MaryValue !Coin !MultiAsset
- newtype MultiAsset = MultiAsset (Map PolicyID (Map AssetName Integer))
- insert ∷ (Integer → Integer → Integer) → PolicyID → AssetName → Integer → MultiAsset → MultiAsset
- insertMultiAsset ∷ (Integer → Integer → Integer) → PolicyID → AssetName → Integer → MultiAsset → MultiAsset
- lookup ∷ PolicyID → AssetName → MaryValue → Integer
- lookupMultiAsset ∷ PolicyID → AssetName → MaryValue → Integer
- multiAssetFromList ∷ [(PolicyID, AssetName, Integer)] → MultiAsset
- policies ∷ MultiAsset → Set PolicyID
- mapMaybeMultiAsset ∷ (PolicyID → AssetName → Integer → Maybe Integer) → MultiAsset → MultiAsset
- filterMultiAsset ∷ (PolicyID → AssetName → Integer → Bool) → MultiAsset → MultiAsset
- pruneZeroMultiAsset ∷ MultiAsset → MultiAsset
- representationSize ∷ [(PolicyID, AssetName, Integer)] → Int
- showValue ∷ MaryValue → String
- flattenMultiAsset ∷ MultiAsset → [(PolicyID, AssetName, Integer)]
- valueFromList ∷ Coin → [(PolicyID, AssetName, Integer)] → MaryValue
- data CompactValue
- data family CompactForm a
- isMultiAssetSmallEnough ∷ MultiAsset → Bool
- assetNameToTextAsHex ∷ AssetName → Text
- prune ∷ Map PolicyID (Map AssetName Integer) → Map PolicyID (Map AssetName Integer)
Documentation
Policy ID
Instances
Asset Name
Instances
The Value representing MultiAssets
Instances
newtype MultiAsset Source #
The MultiAssets map
Instances
insert ∷ (Integer → Integer → Integer) → PolicyID → AssetName → Integer → MultiAsset → MultiAsset 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 → 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
lookup ∷ PolicyID → AssetName → MaryValue → Integer Source #
Deprecated: In favor of lookupMultiAsset
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.
∷ (PolicyID → AssetName → Integer → Bool) | Predicate that needs to return |
→ MultiAsset | |
→ MultiAsset |
Filter multi assets. Canonical form is preserved.
pruneZeroMultiAsset ∷ MultiAsset → MultiAsset Source #
Remove all assets with that have zero amount specified
flattenMultiAsset ∷ MultiAsset → [(PolicyID, AssetName, Integer)] Source #
data CompactValue Source #
CompactValueAdaOnly !(CompactForm Coin) | |
CompactValueMultiAsset !(CompactForm Coin) !Word32 !ShortByteString |
Instances
data family CompactForm a Source #
Instances
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