Safe Haskell | None |
---|---|
Language | Haskell2010 |
UpgradeableCounterSdu demonstrates the implementation of a simple contract that has upgradeable storage, interface, and implementation and uses storage-driven upgrades. Aside from the latter, this contract is similar to UpgradeableCounter.
In the first version it stores a Natural and allows to add some value to it.
The second version changes the type of the stored value to Integer, and instead of providing Add Natural and Inc () 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 CounterSduV (v :: Nat) :: VersionKind
- 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)
- data Permanent
- = GetCounter (Void_ () Integer)
- | GetNothing Empty
- upgradeableCounterContractSdu :: UpgradeableContract (CounterSduV 0)
- mkEmptyStorage :: (VerInterface ver ~ '[], VerUStoreTemplate ver ~ ()) => Address -> Storage ver
Documentation
data CounterSduV (v :: Nat) :: VersionKind Source #
Version identifier for this contract.
It a bit differs from how we do in other contracts - this type is supposed to be used in all versions of the contract, but it has type parameter which is supposed to designate contract version.
Instances
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 # | |
Instances
mkEmptyStorage :: (VerInterface ver ~ '[], VerUStoreTemplate ver ~ ()) => Address -> Storage ver Source #