Documentation
¶
Overview ¶
Package storage defines structures for data storage and organistion in Ethereum smart contracts together with routines to generate them.
Index ¶
- func FormatSol(files []string) error
- func WriteBucketStorage(s BucketStorage, w io.Writer) error
- func WriteFeaturesContracts[G FeatureGroup, S BucketStorage](groups []G, stores []S, mt *merkletree.MerkleTree, outputDir string) ([]string, error)
- func WriteFeaturesJSON[G FeatureGroup](gs []G, ts []types.Token, w io.Writer) error
- func WriteFeaturesJSONToFile[G FeatureGroup](gs []G, ts []types.Token, path string) (retErr error)
- func WriteFeaturesLib[F FeatureGroup](groups []F, mt *merkletree.MerkleTree, w io.Writer) error
- func WriteGroupStorage[G FieldsGroup, S BucketStorage](name string, groups []G, stores []S, outputDir string) ([]string, error)
- func WriteLabelledStorageMappingFeatures[S BucketStorage](name string, stores []S, w io.Writer) error
- func WriteSequentialStorageMapping[G FieldsGroup, S BucketStorage](name string, groups []G, stores []S, w io.Writer) error
- func WriteStorageDeployer[S BucketStorage](name string, storagePath string, stores []S, w io.Writer) error
- type Bucket
- type BucketStorage
- type FeatureGroup
- type Field
- type FieldsGroup
- type LabelledBucket
- type LabelledField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteBucketStorage ¶
func WriteBucketStorage(s BucketStorage, w io.Writer) error
WriteBucketStorage writes the storage contract file for a given BucketStorage.
func WriteFeaturesContracts ¶
func WriteFeaturesContracts[G FeatureGroup, S BucketStorage](groups []G, stores []S, mt *merkletree.MerkleTree, outputDir string) ([]string, error)
WriteFeaturesContracts is a convenience wrapper that writes all contracts relevant for storing and working with the features on-chain.
func WriteFeaturesJSON ¶
WriteFeaturesJSON writes the features of a set of tokens as JSON. This is intended to be used with forge's vm.parseJson for testing.
func WriteFeaturesJSONToFile ¶
func WriteFeaturesJSONToFile[G FeatureGroup](gs []G, ts []types.Token, path string) (retErr error)
WriteFeaturesJSONToFile is a convenience wrapper to write the JSON created by `WriteFeaturesJSON` to a file.
func WriteFeaturesLib ¶
func WriteFeaturesLib[F FeatureGroup](groups []F, mt *merkletree.MerkleTree, w io.Writer) error
WriteFeaturesLib writes a solidity file defining the Features struct and a helper library to work with it.
func WriteGroupStorage ¶
func WriteGroupStorage[G FieldsGroup, S BucketStorage](name string, groups []G, stores []S, outputDir string) ([]string, error)
WriteGroupStorage is a convenience wrapper that writes all contracts relating to a grouping of fields and corresponding BucketStorages to a given output directory. Returns the paths of then written files.
func WriteLabelledStorageMappingFeatures ¶
func WriteLabelledStorageMappingFeatures[S BucketStorage](name string, stores []S, w io.Writer) error
WriteLabelledStorageMappingFeatures writes the storage mapping to retrieve data from storage contracts.
func WriteSequentialStorageMapping ¶
func WriteSequentialStorageMapping[G FieldsGroup, S BucketStorage](name string, groups []G, stores []S, w io.Writer) error
WriteSequentialStorageMapping writes the storage mapping library translating between groups of fields (e.g. grouped by layer type) and storage coordinates sequentially. For example, the sequential association works like this FieldGroups | BucketStorage 0 ├── BAR Bucket 0 ──┤ │ └── bax <> Field 0 ──┤ | │ │ | └── FOO │ |
├── bar <> Field 1 ──┘ | │ Bucket 1 ──┘ ├── foo <> Field 0 ──┘ | BucketStorage 1 │ Bucket 0 ──┘ └── qux <> Field 0 ──┘
func WriteStorageDeployer ¶
func WriteStorageDeployer[S BucketStorage](name string, storagePath string, stores []S, w io.Writer) error
WriteStorageDeployer writes a helper contract to deploy a set of BucketStorage contracts located at storagePath.
Types ¶
type Bucket ¶
A Bucket aggregates and compresses a list of Fields, adding additional indexing metadata.
type BucketStorage ¶
type BucketStorage interface { Name() string Buckets() []Bucket NumFields() int Size() (int, error) }
A BucketStorage is a named list of Buckets that will mapped to a single contract file.
type FeatureGroup ¶
FeatureGroup denotes a certain types of features. E.g. "Background" with values "Black" and "White"
type FieldsGroup ¶
FieldsGroup is a generic grouping of fields (e.g. all layers with a certain layer type)
type LabelledBucket ¶
LabelledBucket is a bucket that contains labelled fields
type LabelledField ¶
LabelledField is a field with an additional label