Morley-metadata should provide a convenient way to construct `MetadataMap` from `Metadata`.
Clarification and motivation
It's not particularly obvious how to get MetadataMap
suitable for the storage from Metadata
. This particularly comes up in tests, when we may want to construct a dummy contract with some storage and some views, and have to construct the MetadataMap
manually.
The simplest approach is to just do something like this:
toMetadataMap :: Metadata -> MetadataMap
toMetadataMap metadata = metadataURI (tezosStorageUri selfHost "metadata")
<> [([mt|metadata|], BSL.toStrict $ Aeson.encode metadata)]
(NB: this needs OverloadedLists
)
In principle, we may want to have something more flexible, but IIRC we can only test metadata that's hosted in the "self storage", so this would be the primary mode of operation.
Acceptance criteria
-
morley-metadata
provides a convenient way to turnMetadata
intoMetadataMap
.