Safe Haskell | None |
---|---|
Language | Haskell2010 |
UpgradeableCounter demonstrates the implementation of a simple contract that has upgradeable storage, interface, and implementation.
In the first version it stores a Natural and allows to add some value to it or multiply the current value by a certain natural number.
The second version changes the type of the stored value to Integer, and instead of providing Mul Natural and Add Natural endpoints, it just allows to increment or decrement the current value.
While the contract does not have any advanced functionality, it provides a birds-eye view on all the aspects of the upgradeable contracts concept and serves as an example on how to apply this concept.
Synopsis
- data Parameter (ver :: VersionKind)
- = Run (VerParam ver)
- | RunPerm (VerPermanent ver)
- | Upgrade (OneShotUpgradeParameters ver)
- | GetVersion (View () Version)
- | SetAdministrator Address
- | EpwBeginUpgrade ("current" :! Version, "new" :! Version)
- | EpwApplyMigration (MigrationScriptFrom (VerUStoreTemplate ver))
- | EpwSetCode SomeUContractRouter
- | EpwSetPermCode (SomePermanentImpl (VerPermanent ver))
- | EpwFinishUpgrade
- data Storage (ver :: VersionKind)
- type CounterV0 = EmptyContractVersion Empty
- upgradeableCounterContract :: UpgradeableContract CounterV0
- mkEmptyStorage :: (VerInterface ver ~ '[], VerUStoreTemplate ver ~ ()) => Address -> Storage ver
Documentation
data Parameter (ver :: VersionKind) Source #
Parameter of upgradeable contract. It contains, among others:
- Entrypoint for running one of upgradeable entrypoints.
- Entrypoint for running one of permanent entrypoints, suitable e.g. for implementing interfaces. 3a. Entrypoint for upgrade in a single call. 3b. Entrypoints for entrypoint-wise upgrade.
Run (VerParam ver) | |
RunPerm (VerPermanent ver) | |
Upgrade (OneShotUpgradeParameters ver) | |
GetVersion (View () Version) | |
SetAdministrator Address | |
EpwBeginUpgrade ("current" :! Version, "new" :! Version) | |
EpwApplyMigration (MigrationScriptFrom (VerUStoreTemplate ver)) | |
EpwSetCode SomeUContractRouter | |
EpwSetPermCode (SomePermanentImpl (VerPermanent ver)) | |
EpwFinishUpgrade |
Instances
data Storage (ver :: VersionKind) Source #
Instances
Generic (Storage ver) Source # | |
HasAnnotation (VerPermanent ver) => HasAnnotation (Storage ver) Source # | |
Defined in Lorentz.Contracts.Upgradeable.Common.Contract getAnnotation :: FollowEntrypointFlag -> Notes (ToT (Storage ver)) # | |
WellTypedIsoValue (VerPermanent ver) => IsoValue (Storage ver) Source # | |
NiceVersion ver => TypeHasDoc (Storage ver) Source # | |
Defined in Lorentz.Contracts.Upgradeable.Common.Contract type TypeDocFieldDescriptions (Storage ver) :: FieldDescriptions # typeDocName :: Proxy (Storage ver) -> Text # typeDocMdDescription :: Markdown # typeDocMdReference :: Proxy (Storage ver) -> WithinParens -> Markdown # typeDocDependencies :: Proxy (Storage ver) -> [SomeDocDefinitionItem] # typeDocHaskellRep :: TypeDocHaskellRep (Storage ver) # typeDocMichelsonRep :: TypeDocMichelsonRep (Storage ver) # | |
type Rep (Storage ver) Source # | |
type ToT (Storage ver) Source # | |
type TypeDocFieldDescriptions (Storage ver) Source # | |
type CounterV0 = EmptyContractVersion Empty Source #
mkEmptyStorage :: (VerInterface ver ~ '[], VerUStoreTemplate ver ~ ()) => Address -> Storage ver Source #