Documentation
¶
Overview ¶
Package types defines frequently used data primitives for the solidify toolchain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeMerkleTree ¶
func ComputeMerkleTree(tokens []Token) (*merkletree.MerkleTree, error)
ComputeMerkleTree computes the merkle tree for a list of tokens. This routine uses keccak256 for hashing and sorts leafs by size before doing so to be compatible with OpenZeppelin's merkle proof validator in Solidity.
func DecodeImage ¶
DecodeImage decodes image data. Currently supported types (BMP, PNG)
Types ¶
type FeatureGroup ¶
type FeatureGroup struct { Type string NonZeroValues []string // contains filtered or unexported fields }
FeatureGroup is an implementation of storage.FeatureGroup treating the zero- and non-zero values separately.
func (FeatureGroup) Name ¶
func (g FeatureGroup) Name() string
Name returns the name (i.e. type) of the FeatureGroup. E.g. "Background"
func (FeatureGroup) NumValues ¶
func (g FeatureGroup) NumValues() uint8
NumValues returns the number of values in this group. E.g. 3 for Backgrounds being either "None", "White" or "Black".
func (*FeatureGroup) SetZeroValue ¶
func (g *FeatureGroup) SetZeroValue(zero string)
SetZeroValue sets the zero value of this feature. Defaults to "None"
func (FeatureGroup) Values ¶
func (g FeatureGroup) Values() []string
Values returns the values in that the feature of given type can take. The zero value is always at first position.
func (FeatureGroup) ZeroValue ¶
func (g FeatureGroup) ZeroValue() string
ZeroValue returns te current zero value
type Image ¶
Image wraps around the standard go image library and provides an encoding function that it can be used to build buckets.
func (Image) Encode ¶
Encode encodes the image as a data blob compatible with the raw BMP row and channel ordering + additional alpha and frame rectangle metadata.
| hasAlpha (byte) | frameRectangle (4 bytes) | blob [(A)BGR (4 or 3 bytes) | ...] |
The blob contains only data for the subframe of the original image with non-zero alpha values to save storage space. Further, it does not have an alpha channel if all alpha values are 255 anyway. Depending on the Image.CleanSpuriousAlpha flag, we map all alpha values of 254->255 before encoding if alpha=254 is the lowest value in the image.
func (*Image) IgnoreSpuriousAlpha ¶
IgnoreSpuriousAlpha sets the threshold for the alpha cleaning during the serialisation. This means that if the image only contains `alpha >= threshold`, all alpha values will be set to 255.
type StringField ¶
type StringField string
StringField is a string implementing the storage.Field interface.
func (StringField) Encode ¶
func (v StringField) Encode() ([]byte, error)
Encode encodes a string as UTF-8 bytes
type Token ¶
Token fully defines an collection token by specifying its tokenID and features.
func (Token) CalculateHash ¶
CalculateHash calculates the hash of a token. Needed in the computation of merkle trees.