Safe Haskell | None |
---|---|
Language | Haskell2010 |
Composability helper for UStore
.
Synopsis
- liftUStore :: (Generic template, RequireAllUniqueFields template) => Label name -> (UStore (GetFieldType template name) ': s) :-> (UStore template ': s)
- unliftUStore :: Generic template => Label name -> (UStore template ': s) :-> (UStore (GetFieldType template name) ': s)
- type UStoreFieldsAreUnique template = AllUnique (UStoreFields template)
Documentation
liftUStore :: (Generic template, RequireAllUniqueFields template) => Label name -> (UStore (GetFieldType template name) ': s) :-> (UStore template ': s) Source #
Lift an UStore
to another UStore
which contains all the entries
of the former under given field.
This function is not intended for use in migrations, only in normal entry points.
Note that this function ensures that template of resulting store
does not contain inner nested templates with duplicated fields,
otherwise UStore
invariants could get broken.
unliftUStore :: Generic template => Label name -> (UStore template ': s) :-> (UStore (GetFieldType template name) ': s) Source #
Unlift an UStore
to a smaller UStore
which is part of the former.
This function is not intended for use in migrations, only in normal entry points.
Surprisingly, despite smaller UStore
may have extra entries,
this function is safe when used in contract code.
Truly, all getters and setters are still safe to use.
Also, there is no way for the resulting small UStore
to leak outside
of the contract since the only place where big_map
can appear
is contract storage, so this small UStore
can be either dropped
or lifted back via liftUStore
to appear as part of the new contract's state.
When this function is run as part of standalone instructions sequence,
not as part of contract code (e.g. in tests), you may get an UStore
with entries not inherent to it.
Internals
type UStoreFieldsAreUnique template = AllUnique (UStoreFields template) Source #