{-# LANGUAGE FunctionalDependencies #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Lorentz.Contracts.Upgradeable.Common.Contract
( Parameter(..)
, UTAddress
, UContractRef
, PermConstraint
, Storage
, UpgradeableContract
, PermanentImpl
, InitUpgradeableContract
, OneShotUpgradeParameters
, DVersion (..)
, NiceVersion
, upgradeableContract
, mkEmptyStorage
, pbsContainedInRun
, pbsContainedInRunPerm
) where
import Lorentz
import Prelude (Typeable)
import qualified Data.Text as T
import Fmt (Buildable(..), fmt)
import qualified Michelson.Typed as T
import Util.Instances ()
import Util.Markdown
import Lorentz.Contracts.Upgradeable.Common.Base
import Lorentz.Contracts.Upgradeable.Common.Doc
import Lorentz.UStore
{-# ANN module ("HLint: ignore Reduce duplication" :: Text) #-}
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
deriving stock ((forall x. Parameter ver -> Rep (Parameter ver) x)
-> (forall x. Rep (Parameter ver) x -> Parameter ver)
-> Generic (Parameter ver)
forall x. Rep (Parameter ver) x -> Parameter ver
forall x. Parameter ver -> Rep (Parameter ver) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (ver :: VersionKind) x.
Rep (Parameter ver) x -> Parameter ver
forall (ver :: VersionKind) x.
Parameter ver -> Rep (Parameter ver) x
$cto :: forall (ver :: VersionKind) x.
Rep (Parameter ver) x -> Parameter ver
$cfrom :: forall (ver :: VersionKind) x.
Parameter ver -> Rep (Parameter ver) x
Generic)
deriving stock instance
(Show (VerParam ver), Show (VerPermanent ver)) => Show (Parameter ver)
instance IsoValue (VerPermanent ver) => IsoValue (Parameter ver)
instance ( interface ~ VerInterface ver
, UnpackUParam Buildable interface
, Buildable (VerPermanent ver)
) =>
Buildable (Parameter ver) where
build :: Parameter ver -> Builder
build = \case
Run VerParam ver
uParam ->
case UParam interface
-> Either EntrypointLookupError (MText, ConstrainedSome Buildable)
forall (c :: * -> Constraint) (entries :: [EntrypointKind]).
UnpackUParam c entries =>
UParam entries
-> Either EntrypointLookupError (MText, ConstrainedSome c)
unpackUParam @Buildable @interface UParam interface
VerParam ver
uParam of
Left EntrypointLookupError
err -> Builder
"Run with inconsistent UParam: " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> EntrypointLookupError -> Builder
forall p. Buildable p => p -> Builder
build EntrypointLookupError
err
Right (MText
name, ConstrainedSome Buildable
something) ->
Builder
"Run " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> MText -> Builder
forall p. Buildable p => p -> Builder
build MText
name Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" with argument: " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ConstrainedSome Buildable -> Builder
forall p. Buildable p => p -> Builder
build ConstrainedSome Buildable
something
RunPerm VerPermanent ver
permParam ->
Builder
"Run permanent entrypoint: " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> VerPermanent ver -> Builder
forall p. Buildable p => p -> Builder
build VerPermanent ver
permParam
Upgrade ( Name "currentVersion" -> ("currentVersion" :! Version) -> Version
forall (name :: Symbol) a. Name name -> (name :! a) -> a
arg Name "currentVersion"
forall a. IsLabel "currentVersion" a => a
forall (x :: Symbol) a. IsLabel x a => a
#currentVersion -> Version
curVersion
, Name "newVersion" -> ("newVersion" :! Version) -> Version
forall (name :: Symbol) a. Name name -> (name :! a) -> a
arg Name "newVersion"
forall a. IsLabel "newVersion" a => a
forall (x :: Symbol) a. IsLabel x a => a
#newVersion -> Version
newVersion, "migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver)
_, "newCode" :! Maybe SomeUContractRouter
_, "newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))
_) ->
Builder
"Upgrade " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Version -> Builder
forall p. Buildable p => p -> Builder
build Version
curVersion Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" -> " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Version -> Builder
forall p. Buildable p => p -> Builder
build Version
newVersion
GetVersion View () Version
v ->
Builder
"GetVersion (callback to " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ContractRef Version -> Builder
forall p. Buildable p => p -> Builder
build (View () Version -> ContractRef Version
forall a r. View a r -> ContractRef r
viewCallbackTo View () Version
v) Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")"
SetAdministrator Address
addr ->
Builder
"SetAdministrator " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Address -> Builder
forall p. Buildable p => p -> Builder
build Address
addr
EpwBeginUpgrade (Name "current" -> ("current" :! Version) -> Version
forall (name :: Symbol) a. Name name -> (name :! a) -> a
arg Name "current"
forall a. IsLabel "current" a => a
forall (x :: Symbol) a. IsLabel x a => a
#current -> Version
curVersion, Name "new" -> ("new" :! Version) -> Version
forall (name :: Symbol) a. Name name -> (name :! a) -> a
arg Name "new"
forall a. IsLabel "new" a => a
forall (x :: Symbol) a. IsLabel x a => a
#new -> Version
newVersion) ->
Builder
"Begin EPW upgrade " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Version -> Builder
forall p. Buildable p => p -> Builder
build Version
curVersion Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" -> " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Version -> Builder
forall p. Buildable p => p -> Builder
build Version
newVersion
EpwApplyMigration MigrationScriptFrom (VerUStoreTemplate ver)
_ ->
Builder
"Apply migration during EPW upgrade"
EpwSetCode SomeUContractRouter
_ ->
Builder
"Set code during EPW upgrade"
EpwSetPermCode SomePermanentImpl (VerPermanent ver)
_ ->
Builder
"Set permanent code during EPW upgrade"
Parameter ver
EpwFinishUpgrade ->
Builder
"Finish EPW upgrade"
type PermConstraint ver =
( NiceParameterFull (VerPermanent ver)
, NoExplicitDefaultEntrypoint (VerPermanent ver)
, HasAnnotation (VerPermanent ver)
, RequireAllUniqueEntrypoints (Parameter ver)
, Typeable ver
, Typeable (VerInterface ver)
, Typeable (VerUStoreTemplate ver)
)
instance (PermConstraint ver) =>
ParameterHasEntrypoints (Parameter ver) where
type ParameterEntrypointsDerivation (Parameter ver) = EpdDelegate
type NiceVersion ver =
( Typeable (VerInterface ver), Typeable (VerUStoreTemplate ver)
, UStoreTemplateHasDoc (VerUStoreTemplate ver)
, TypeHasDoc (VerPermanent ver), KnownValue (VerPermanent ver)
, HasAnnotation (VerPermanent ver), Typeable ver, WellTypedIsoValue (VerPermanent ver)
)
instance NiceVersion ver => TypeHasDoc (Parameter ver) where
typeDocName :: Proxy (Parameter ver) -> Text
typeDocName Proxy (Parameter ver)
_ = Text
"Global.Parameter"
typeDocMdDescription :: Builder
typeDocMdDescription =
Builder
"Top-level parameter of upgradeable contract.\n\
\Use `Run` and `RunPerm` entrypoints in order to access contract logic, \
\other top-level entrypoints are intended solely for migrations purposes."
typeDocMdReference :: Proxy (Parameter ver) -> WithinParens -> Builder
typeDocMdReference Proxy (Parameter ver)
tp =
(Text, DType) -> [DType] -> WithinParens -> Builder
customTypeDocMdReference (Text
"Global.Parameter", Proxy (Parameter ver) -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy (Parameter ver)
tp) []
typeDocHaskellRep :: TypeDocHaskellRep (Parameter ver)
typeDocHaskellRep = TypeDocHaskellRep (Parameter ver)
forall a. (Generic a, GTypeHasDoc (Rep a)) => TypeDocHaskellRep a
homomorphicTypeDocHaskellRep
typeDocMichelsonRep :: TypeDocMichelsonRep (Parameter ver)
typeDocMichelsonRep = TypeDocMichelsonRep (Parameter ver)
forall a. SingI (ToT a) => TypeDocMichelsonRep a
homomorphicTypeDocMichelsonRep
type OneShotUpgradeParameters ver =
( "currentVersion" :! Version
, "newVersion" :! Version
, "migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver)
, "newCode" :! Maybe SomeUContractRouter
, "newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))
)
type UTAddress ver = TAddress (Parameter ver)
type UContractRef ver = ContractRef (Parameter ver)
data StorageFields (ver :: VersionKind) = StorageFields
{ StorageFields ver -> UContractRouter ver
code :: UContractRouter ver
, StorageFields ver -> PermanentImpl ver
permCode :: PermanentImpl ver
, StorageFields ver -> Address
admin :: Address
, StorageFields ver -> Version
currentVersion :: Version
, StorageFields ver -> Bool
paused :: Bool
} deriving stock (forall x. StorageFields ver -> Rep (StorageFields ver) x)
-> (forall x. Rep (StorageFields ver) x -> StorageFields ver)
-> Generic (StorageFields ver)
forall x. Rep (StorageFields ver) x -> StorageFields ver
forall x. StorageFields ver -> Rep (StorageFields ver) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (ver :: VersionKind) x.
Rep (StorageFields ver) x -> StorageFields ver
forall (ver :: VersionKind) x.
StorageFields ver -> Rep (StorageFields ver) x
$cto :: forall (ver :: VersionKind) x.
Rep (StorageFields ver) x -> StorageFields ver
$cfrom :: forall (ver :: VersionKind) x.
StorageFields ver -> Rep (StorageFields ver) x
Generic
deriving anyclass instance (WellTypedIsoValue (VerPermanent ver)) => IsoValue (StorageFields ver)
deriving anyclass instance (HasAnnotation (VerPermanent ver)) => HasAnnotation (StorageFields ver)
data Storage (ver :: VersionKind) = Storage
{ Storage ver -> VerUStore ver
dataMap :: VerUStore ver
, Storage ver -> StorageFields ver
fields :: StorageFields ver
} deriving stock (forall x. Storage ver -> Rep (Storage ver) x)
-> (forall x. Rep (Storage ver) x -> Storage ver)
-> Generic (Storage ver)
forall x. Rep (Storage ver) x -> Storage ver
forall x. Storage ver -> Rep (Storage ver) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (ver :: VersionKind) x. Rep (Storage ver) x -> Storage ver
forall (ver :: VersionKind) x. Storage ver -> Rep (Storage ver) x
$cto :: forall (ver :: VersionKind) x. Rep (Storage ver) x -> Storage ver
$cfrom :: forall (ver :: VersionKind) x. Storage ver -> Rep (Storage ver) x
Generic
deriving anyclass instance (WellTypedIsoValue (VerPermanent ver)) => IsoValue (Storage ver)
deriving anyclass instance (HasAnnotation (VerPermanent ver)) => HasAnnotation (Storage ver)
instance NiceVersion ver => TypeHasDoc (StorageFields ver) where
typeDocName :: Proxy (StorageFields ver) -> Text
typeDocName Proxy (StorageFields ver)
_ = Text
"StorageFields"
typeDocMdDescription :: Builder
typeDocMdDescription =
Builder
"StorageFields of upgradeable contract.\n\
\This type keeps general information about upgradeable \
\contract and the logic responsible for calling entrypoints \
\implementations kept in UStore."
typeDocMdReference :: Proxy (StorageFields ver) -> WithinParens -> Builder
typeDocMdReference Proxy (StorageFields ver)
tp =
(Text, DType) -> [DType] -> WithinParens -> Builder
customTypeDocMdReference (Text
"StorageFields", Proxy (StorageFields ver) -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy (StorageFields ver)
tp) []
typeDocHaskellRep :: TypeDocHaskellRep (StorageFields ver)
typeDocHaskellRep = TypeDocHaskellRep (StorageFields ver)
forall a. (Generic a, GTypeHasDoc (Rep a)) => TypeDocHaskellRep a
homomorphicTypeDocHaskellRep
typeDocMichelsonRep :: TypeDocMichelsonRep (StorageFields ver)
typeDocMichelsonRep = TypeDocMichelsonRep (StorageFields ver)
forall a. SingI (ToT a) => TypeDocMichelsonRep a
homomorphicTypeDocMichelsonRep
instance NiceVersion ver => TypeHasDoc (Storage ver) where
typeDocName :: Proxy (Storage ver) -> Text
typeDocName Proxy (Storage ver)
_ = Text
"Storage"
typeDocMdDescription :: Builder
typeDocMdDescription =
Builder
"Type which defines storage of the upgradeable contract.\n\
\It contains UStore with data related to actual contract logic \
\and fields which relate to upgradeability logic."
typeDocMdReference :: Proxy (Storage ver) -> WithinParens -> Builder
typeDocMdReference Proxy (Storage ver)
tp =
(Text, DType) -> [DType] -> WithinParens -> Builder
customTypeDocMdReference (Text
"Storage", Proxy (Storage ver) -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy (Storage ver)
tp) []
typeDocHaskellRep :: TypeDocHaskellRep (Storage ver)
typeDocHaskellRep = TypeDocHaskellRep (Storage ver)
forall a. (Generic a, GTypeHasDoc (Rep a)) => TypeDocHaskellRep a
homomorphicTypeDocHaskellRep
typeDocMichelsonRep :: TypeDocMichelsonRep (Storage ver)
typeDocMichelsonRep = TypeDocMichelsonRep (Storage ver)
forall a. SingI (ToT a) => TypeDocMichelsonRep a
homomorphicTypeDocMichelsonRep
type instance ErrorArg "upgContractIsPaused" = ()
type instance ErrorArg "upgContractIsNotPaused" = ()
type instance ErrorArg "upgVersionMismatch" =
("expectedCurrent" :! Version, "actualCurrent" :! Version)
instance Buildable (CustomError "upgContractIsPaused") where
build :: CustomError "upgContractIsPaused" -> Builder
build (CustomError Label "upgContractIsPaused"
_ (_, ())) =
Builder
"The requested operation requires the contract to be running but \
\it is paused"
instance Buildable (CustomError "upgContractIsNotPaused") where
build :: CustomError "upgContractIsNotPaused" -> Builder
build (CustomError Label "upgContractIsNotPaused"
_ (_, ())) =
Builder
"The requested operation requires the contract to be paused but \
\it is not."
instance Buildable (CustomError "upgVersionMismatch") where
build :: CustomError "upgVersionMismatch" -> Builder
build (CustomError Label "upgVersionMismatch"
_ (_, ( arg #expectedCurrent -> expected
, arg #actualCurrent -> actual))) =
Builder
"The provided expected current version " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Version -> Builder
forall p. Buildable p => p -> Builder
build Version
expected Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" \
\differs from actual one " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Version -> Builder
forall p. Buildable p => p -> Builder
build Version
actual Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
"."
instance CustomErrorHasDoc "upgContractIsPaused" where
customErrClass :: ErrorClass
customErrClass = ErrorClass
ErrClassActionException
customErrDocMdCause :: Builder
customErrDocMdCause =
Builder
"The contract is in paused state (for migrations)."
instance CustomErrorHasDoc "upgContractIsNotPaused" where
customErrClass :: ErrorClass
customErrClass = ErrorClass
ErrClassActionException
customErrDocMdCause :: Builder
customErrDocMdCause =
Builder
"The contract is not in paused state (for migrations)."
instance CustomErrorHasDoc "upgVersionMismatch" where
customErrClass :: ErrorClass
customErrClass = ErrorClass
ErrClassActionException
customErrDocMdCause :: Builder
customErrDocMdCause =
Builder
"Current contract version differs from the one passed in the upgrade."
data DVersion = DVersion Version
instance DocItem DVersion where
docItemPos :: Natural
docItemPos = Natural
103
docItemSectionName :: Maybe Text
docItemSectionName = Maybe Text
forall a. Maybe a
Nothing
docItemToMarkdown :: HeaderLevel -> DVersion -> Builder
docItemToMarkdown HeaderLevel
_ (DVersion (Version Natural
ver)) =
Builder -> Builder -> Builder
mdSubsection Builder
"Version" (Natural -> Builder
forall p. Buildable p => p -> Builder
build Natural
ver)
pbsContainedInRun, pbsContainedInRunPerm :: ParamBuildingStep
(ParamBuildingStep
pbsContainedInRun, ParamBuildingStep
pbsContainedInRunPerm) =
( let uparam :: UParam entries
uparam = (MText, ByteString) -> UParam entries
forall (entries :: [EntrypointKind]).
(MText, ByteString) -> UParam entries
UParamUnsafe ([mt|s|], ByteString
"a")
mich :: ParamBuilder
mich = UParam Any -> Parameter (EmptyContractVersion ()) -> ParamBuilder
forall a a.
(IsoValue a, IsoValue a, ContainsOp (ToT a) ~ 'False,
ContainsOp (ToT a) ~ 'False) =>
a -> a -> ParamBuilder
mkMich UParam Any
forall (entries :: [EntrypointKind]). UParam entries
uparam (VerParam (EmptyContractVersion ())
-> Parameter (EmptyContractVersion ())
forall (ver :: VersionKind). VerParam ver -> Parameter ver
Run @(EmptyContractVersion ()) VerParam (EmptyContractVersion ())
forall (entries :: [EntrypointKind]). UParam entries
uparam)
in Text -> ParamBuilder -> ParamBuildingStep
mkPbsWrapIn Text
"Run" ParamBuilder
mich
, let a :: Integer
a = Integer
999 :: Integer
mich :: ParamBuilder
mich = Integer -> Parameter (EmptyContractVersion Integer) -> ParamBuilder
forall a a.
(IsoValue a, IsoValue a, ContainsOp (ToT a) ~ 'False,
ContainsOp (ToT a) ~ 'False) =>
a -> a -> ParamBuilder
mkMich Integer
a (VerPermanent (EmptyContractVersion Integer)
-> Parameter (EmptyContractVersion Integer)
forall (ver :: VersionKind). VerPermanent ver -> Parameter ver
RunPerm @(EmptyContractVersion Integer) Integer
VerPermanent (EmptyContractVersion Integer)
a)
in Text -> ParamBuilder -> ParamBuildingStep
mkPbsWrapIn Text
"RunPerm" ParamBuilder
mich
)
where
mkMich :: a -> a -> ParamBuilder
mkMich a
woCtor a
wCtor = (Builder -> Builder) -> ParamBuilder
ParamBuilder ((Builder -> Builder) -> ParamBuilder)
-> (Builder -> Builder) -> ParamBuilder
forall a b. (a -> b) -> a -> b
$ \Builder
p ->
Text -> Builder
forall p. Buildable p => p -> Builder
build (Text -> Builder) -> Text -> Builder
forall a b. (a -> b) -> a -> b
$
Text -> Text -> Text -> Text
T.replace
(Builder -> Text
forall b. FromBuilder b => Builder -> b
fmt (Builder -> Text)
-> (Value' Instr (ToT a) -> Builder)
-> Value' Instr (ToT a)
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Builder
forall p. Buildable p => p -> Builder
build (Value -> Builder)
-> (Value' Instr (ToT a) -> Value)
-> Value' Instr (ToT a)
-> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value' Instr (ToT a) -> Value
forall (t :: T). (SingI t, HasNoOp t) => Value' Instr t -> Value
T.untypeValue (Value' Instr (ToT a) -> Text) -> Value' Instr (ToT a) -> Text
forall a b. (a -> b) -> a -> b
$ a -> Value' Instr (ToT a)
forall a. IsoValue a => a -> Value (ToT a)
toVal a
woCtor)
(Text
"(" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Builder -> Text
forall b. FromBuilder b => Builder -> b
fmt Builder
p Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
")")
(Builder -> Text
forall b. FromBuilder b => Builder -> b
fmt (Builder -> Text)
-> (Value' Instr (ToT a) -> Builder)
-> Value' Instr (ToT a)
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Builder
forall p. Buildable p => p -> Builder
build (Value -> Builder)
-> (Value' Instr (ToT a) -> Value)
-> Value' Instr (ToT a)
-> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value' Instr (ToT a) -> Value
forall (t :: T). (SingI t, HasNoOp t) => Value' Instr t -> Value
T.untypeValue (Value' Instr (ToT a) -> Text) -> Value' Instr (ToT a) -> Text
forall a b. (a -> b) -> a -> b
$ a -> Value' Instr (ToT a)
forall a. IsoValue a => a -> Value (ToT a)
toVal a
wCtor)
emptyCode :: (VerInterface ver ~ '[]) => UContractRouter ver
emptyCode :: UContractRouter ver
emptyCode = ('[VerParam ver, VerUStore ver]
:-> '[([Operation], VerUStore ver)])
-> UContractRouter ver
forall (ver :: VersionKind).
('[VerParam ver, VerUStore ver]
:-> '[([Operation], VerUStore ver)])
-> UContractRouter ver
mkUContractRouter ('[UParam '[], VerUStore ver] :-> '[VerUStore ver]
forall a (s :: [*]). (a : s) :-> s
drop ('[UParam '[], VerUStore ver] :-> '[VerUStore ver])
-> ('[VerUStore ver] :-> '[[Operation], VerUStore ver])
-> '[UParam '[], VerUStore ver] :-> '[[Operation], VerUStore ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# '[VerUStore ver] :-> '[[Operation], VerUStore ver]
forall p (s :: [*]). KnownValue p => s :-> (List p : s)
nil ('[UParam '[], VerUStore ver] :-> '[[Operation], VerUStore ver])
-> ('[[Operation], VerUStore ver]
:-> '[([Operation], VerUStore ver)])
-> '[UParam '[], VerUStore ver] :-> '[([Operation], VerUStore ver)]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# '[[Operation], VerUStore ver] :-> '[([Operation], VerUStore ver)]
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair)
notInitPermCode :: PermanentImpl ver
notInitPermCode :: PermanentImpl ver
notInitPermCode = Entrypoint (VerPermanent ver) (VerUStore ver) -> PermanentImpl ver
forall (ver :: VersionKind).
Entrypoint (VerPermanent ver) (VerUStore ver) -> PermanentImpl ver
PermanentImpl (Entrypoint (VerPermanent ver) (VerUStore ver)
-> PermanentImpl ver)
-> Entrypoint (VerPermanent ver) (VerUStore ver)
-> PermanentImpl ver
forall a b. (a -> b) -> a -> b
$
MText -> Entrypoint (VerPermanent ver) (VerUStore ver)
forall e (s :: [*]) (t :: [*]). IsError e => e -> s :-> t
failUsing [mt|Permanent entrypoints implementation is not yet initialized|]
mkEmptyStorage
:: (VerInterface ver ~ '[], VerUStoreTemplate ver ~ ())
=> Address -> Storage ver
mkEmptyStorage :: Address -> Storage ver
mkEmptyStorage Address
admin = Storage :: forall (ver :: VersionKind).
VerUStore ver -> StorageFields ver -> Storage ver
Storage
{ dataMap :: VerUStore ver
dataMap = () -> UStore ()
forall template.
UStoreTraversable MkUStoreTW template =>
template -> UStore template
mkUStore ()
, fields :: StorageFields ver
fields = StorageFields :: forall (ver :: VersionKind).
UContractRouter ver
-> PermanentImpl ver
-> Address
-> Version
-> Bool
-> StorageFields ver
StorageFields
{ code :: UContractRouter ver
code = UContractRouter ver
forall (ver :: VersionKind).
(VerInterface ver ~ '[]) =>
UContractRouter ver
emptyCode
, permCode :: PermanentImpl ver
permCode = PermanentImpl ver
forall (ver :: VersionKind). PermanentImpl ver
notInitPermCode
, admin :: Address
admin = Address
admin
, currentVersion :: Version
currentVersion = Version
0
, paused :: Bool
paused = Bool
False
}
}
type UpgradeableContract ver = Contract (Parameter ver) (Storage ver)
type InitUpgradeableContract perm = UpgradeableContract (EmptyContractVersion perm)
upgradeableContract
:: forall ver. (NiceVersion ver, NiceParameterFull (Parameter ver))
=> UpgradeableContract ver
upgradeableContract :: UpgradeableContract ver
upgradeableContract = ContractCode (Parameter ver) (Storage ver)
-> UpgradeableContract ver
forall cp st.
(NiceParameterFull cp, HasCallStack) =>
ContractCode cp st -> Contract cp st
defaultContract (ContractCode (Parameter ver) (Storage ver)
-> UpgradeableContract ver)
-> ContractCode (Parameter ver) (Storage ver)
-> UpgradeableContract ver
forall a b. (a -> b) -> a -> b
$ do
DUpgradeability
-> '[(Parameter ver, Storage ver)]
:-> '[(Parameter ver, Storage ver)]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DUpgradeability
-> '[(Parameter ver, Storage ver)]
:-> '[(Parameter ver, Storage ver)])
-> DUpgradeability
-> '[(Parameter ver, Storage ver)]
:-> '[(Parameter ver, Storage ver)]
forall a b. (a -> b) -> a -> b
$ Builder -> DUpgradeability
DUpgradeability Builder
contractDoc
DStorageType
-> '[(Parameter ver, Storage ver)]
:-> '[(Parameter ver, Storage ver)]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DStorageType
-> '[(Parameter ver, Storage ver)]
:-> '[(Parameter ver, Storage ver)])
-> DStorageType
-> '[(Parameter ver, Storage ver)]
:-> '[(Parameter ver, Storage ver)]
forall a b. (a -> b) -> a -> b
$ DType -> DStorageType
T.DStorageType (DType -> DStorageType) -> DType -> DStorageType
forall a b. (a -> b) -> a -> b
$ Proxy (Storage ver) -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType (Proxy (Storage ver) -> DType) -> Proxy (Storage ver) -> DType
forall a b. (a -> b) -> a -> b
$ Proxy (Storage ver)
forall k (t :: k). Proxy t
Proxy @(Storage ver)
'[(Parameter ver, Storage ver)] :-> '[Parameter ver, Storage ver]
forall a b (s :: [*]). ((a, b) : s) :-> (a : b : s)
unpair
Proxy UpgradeableEntrypointsKind
-> IsoRecTuple
(Rec
(CaseClauseL '[Storage ver] (ContractOut (Storage ver)))
'[ 'CaseClauseParam "Run" ('OneField (UParam (VerInterface ver))),
'CaseClauseParam "RunPerm" ('OneField (VerPermanent ver)),
'CaseClauseParam
"Upgrade"
('OneField
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver)))),
'CaseClauseParam "GetVersion" ('OneField (View () Version)),
'CaseClauseParam "SetAdministrator" ('OneField Address),
'CaseClauseParam
"EpwBeginUpgrade"
('OneField ("current" :! Version, "new" :! Version)),
'CaseClauseParam
"EpwApplyMigration"
('OneField (MigrationScriptFrom (VerUStoreTemplate ver))),
'CaseClauseParam "EpwSetCode" ('OneField SomeUContractRouter),
'CaseClauseParam
"EpwSetPermCode"
('OneField (SomePermanentImpl (VerPermanent ver))),
'CaseClauseParam "EpwFinishUpgrade" 'NoFields])
-> '[Parameter ver, Storage ver] :-> ContractOut (Storage ver)
forall dt entrypointKind (out :: [*]) (inp :: [*]) clauses.
(CaseTC dt out inp clauses,
DocumentEntrypoints entrypointKind dt) =>
Proxy entrypointKind -> IsoRecTuple clauses -> (dt : inp) :-> out
entryCase @(Parameter ver) (Proxy UpgradeableEntrypointsKind
forall k (t :: k). Proxy t
Proxy @UpgradeableEntrypointsKind)
( Label "cRun"
forall a. IsLabel "cRun" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cRun Label "cRun"
-> ('[UParam (VerInterface ver), Storage ver]
:-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam "Run" ('OneField (UParam (VerInterface ver))))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription
-> '[UParam (VerInterface ver), Storage ver]
:-> '[UParam (VerInterface ver), Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> '[UParam (VerInterface ver), Storage ver]
:-> '[UParam (VerInterface ver), Storage ver])
-> DDescription
-> '[UParam (VerInterface ver), Storage ver]
:-> '[UParam (VerInterface ver), Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
runDoc
('[Storage ver]
:-> '[UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver])
-> '[UParam (VerInterface ver), Storage ver]
:-> '[UParam (VerInterface ver), UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (('[Storage ver]
:-> '[UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver])
-> '[UParam (VerInterface ver), Storage ver]
:-> '[UParam (VerInterface ver), UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver])
-> ('[Storage ver]
:-> '[UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver])
-> '[UParam (VerInterface ver), Storage ver]
:-> '[UParam (VerInterface ver), UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver]
forall a b. (a -> b) -> a -> b
$ do
'[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureNotPaused
Label "dataMap"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "dataMap", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "dataMap"
forall a. IsLabel "dataMap" a => a
forall (x :: Symbol) a. IsLabel x a => a
#dataMap
('[Storage ver]
:-> '[Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver])
-> '[UStore (VerUStoreTemplate ver), Storage ver]
:-> '[UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (('[Storage ver]
:-> '[Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver])
-> '[UStore (VerUStoreTemplate ver), Storage ver]
:-> '[UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver])
-> ('[Storage ver]
:-> '[Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver])
-> '[UStore (VerUStoreTemplate ver), Storage ver]
:-> '[UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver]
forall a b. (a -> b) -> a -> b
$ do
Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields
Label "code"
-> '[StorageFields ver, Storage ver]
:-> '[GetFieldType (StorageFields ver) "code", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "code"
forall a. IsLabel "code" a => a
forall (x :: Symbol) a. IsLabel x a => a
#code; '[UContractRouter ver, Storage ver]
:-> '[Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver]
forall a (s :: [*]). Wrappable a => (a : s) :-> (Unwrappable a : s)
coerceUnwrap
'[UParam (VerInterface ver), UStore (VerUStoreTemplate ver),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver]
:-> '[(UParam (VerInterface ver), UStore (VerUStoreTemplate ver)),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver]
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
'[(UParam (VerInterface ver), UStore (VerUStoreTemplate ver)),
Lambda
(UParam (VerInterface ver), UStore (VerUStoreTemplate ver))
([Operation], UStore (VerUStoreTemplate ver)),
Storage ver]
:-> '[([Operation], UStore (VerUStoreTemplate ver)), Storage ver]
forall a b (s :: [*]). (a : Lambda a b : s) :-> (b : s)
exec
'[([Operation], UStore (VerUStoreTemplate ver)), Storage ver]
:-> '[[Operation], UStore (VerUStoreTemplate ver), Storage ver]
forall a b (s :: [*]). ((a, b) : s) :-> (a : b : s)
unpair
('[UStore (VerUStoreTemplate ver), Storage ver] :-> '[Storage ver])
-> '[[Operation], UStore (VerUStoreTemplate ver), Storage ver]
:-> '[[Operation], Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (('[UStore (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver])
-> '[[Operation], UStore (VerUStoreTemplate ver), Storage ver]
:-> '[[Operation], Storage ver])
-> ('[UStore (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver])
-> '[[Operation], UStore (VerUStoreTemplate ver), Storage ver]
:-> '[[Operation], Storage ver]
forall a b. (a -> b) -> a -> b
$ Label "dataMap"
-> '[GetFieldType (Storage ver) "dataMap", Storage ver]
:-> '[Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "dataMap"
forall a. IsLabel "dataMap" a => a
forall (x :: Symbol) a. IsLabel x a => a
#dataMap
'[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
, Label "cRunPerm"
forall a. IsLabel "cRunPerm" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cRunPerm Label "cRunPerm"
-> ('[VerPermanent ver, Storage ver] :-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam "RunPerm" ('OneField (VerPermanent ver)))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription
-> '[VerPermanent ver, Storage ver]
:-> '[VerPermanent ver, Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> '[VerPermanent ver, Storage ver]
:-> '[VerPermanent ver, Storage ver])
-> DDescription
-> '[VerPermanent ver, Storage ver]
:-> '[VerPermanent ver, Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
runPermDoc
('[Storage ver] :-> '[UStore (VerUStoreTemplate ver), Storage ver])
-> '[VerPermanent ver, Storage ver]
:-> '[VerPermanent ver, UStore (VerUStoreTemplate ver),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (('[Storage ver]
:-> '[UStore (VerUStoreTemplate ver), Storage ver])
-> '[VerPermanent ver, Storage ver]
:-> '[VerPermanent ver, UStore (VerUStoreTemplate ver),
Storage ver])
-> ('[Storage ver]
:-> '[UStore (VerUStoreTemplate ver), Storage ver])
-> '[VerPermanent ver, Storage ver]
:-> '[VerPermanent ver, UStore (VerUStoreTemplate ver),
Storage ver]
forall a b. (a -> b) -> a -> b
$ do
'[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureNotPaused
Label "dataMap"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "dataMap", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "dataMap"
forall a. IsLabel "dataMap" a => a
forall (x :: Symbol) a. IsLabel x a => a
#dataMap
forall (s :: [*]) (s' :: [*]) a.
ConstraintDUPNLorentz (ToPeano 3) s s' a =>
s :-> (a : s)
forall (n :: Nat) (s :: [*]) (s' :: [*]) a.
ConstraintDUPNLorentz (ToPeano n) s s' a =>
s :-> (a : s)
duupX @3; Label "fields"
-> '[Storage ver, VerPermanent ver, UStore (VerUStoreTemplate ver),
Storage ver]
:-> '[GetFieldType (Storage ver) "fields", VerPermanent ver,
UStore (VerUStoreTemplate ver), Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields; Label "permCode"
-> '[StorageFields ver, VerPermanent ver,
UStore (VerUStoreTemplate ver), Storage ver]
:-> '[GetFieldType (StorageFields ver) "permCode",
VerPermanent ver, UStore (VerUStoreTemplate ver), Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "permCode"
forall a. IsLabel "permCode" a => a
forall (x :: Symbol) a. IsLabel x a => a
#permCode; '[PermanentImpl ver, VerPermanent ver,
UStore (VerUStoreTemplate ver), Storage ver]
:-> '['[VerPermanent ver, UStore (VerUStoreTemplate ver)]
:-> ContractOut (UStore (VerUStoreTemplate ver)),
VerPermanent ver, UStore (VerUStoreTemplate ver), Storage ver]
forall a (s :: [*]). Wrappable a => (a : s) :-> (Unwrappable a : s)
coerceUnwrap
'['[VerPermanent ver, UStore (VerUStoreTemplate ver)]
:-> ContractOut (UStore (VerUStoreTemplate ver)),
VerPermanent ver, UStore (VerUStoreTemplate ver), Storage ver]
:-> '[([Operation], UStore (VerUStoreTemplate ver)), Storage ver]
forall (i :: [*]) (o :: [*]) (s :: [*]).
Each '[KnownList, ZipInstr] '[i, o] =>
((i :-> o) : (i ++ s)) :-> (o ++ s)
execute
'[([Operation], UStore (VerUStoreTemplate ver)), Storage ver]
:-> '[[Operation], UStore (VerUStoreTemplate ver), Storage ver]
forall a b (s :: [*]). ((a, b) : s) :-> (a : b : s)
unpair
('[UStore (VerUStoreTemplate ver), Storage ver] :-> '[Storage ver])
-> '[[Operation], UStore (VerUStoreTemplate ver), Storage ver]
:-> '[[Operation], Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (('[UStore (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver])
-> '[[Operation], UStore (VerUStoreTemplate ver), Storage ver]
:-> '[[Operation], Storage ver])
-> ('[UStore (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver])
-> '[[Operation], UStore (VerUStoreTemplate ver), Storage ver]
:-> '[[Operation], Storage ver]
forall a b. (a -> b) -> a -> b
$ Label "dataMap"
-> '[GetFieldType (Storage ver) "dataMap", Storage ver]
:-> '[Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "dataMap"
forall a. IsLabel "dataMap" a => a
forall (x :: Symbol) a. IsLabel x a => a
#dataMap
'[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
, Label "cUpgrade"
forall a. IsLabel "cUpgrade" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cUpgrade Label "cUpgrade"
-> ('[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam
"Upgrade"
('OneField
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver)))))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver])
-> DDescription
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
upgradeDoc
('[Storage ver] :-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip ('[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureAdmin ('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[Storage ver])
-> '[Storage ver] :-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# '[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureNotPaused)
'[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a (s :: [*]). (a : s) :-> (a : a : s)
dup; ('[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (Label "currentVersion"
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[GetFieldType
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver)))
"currentVersion",
Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "currentVersion"
forall a. IsLabel "currentVersion" a => a
forall (x :: Symbol) a. IsLabel x a => a
#currentVersion ('[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[Version, Storage ver])
-> ('[Version, Storage ver]
:-> '["current" :! Version, Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '["current" :! Version, Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
>> Label "current"
-> '[Version, Storage ver] :-> '["current" :! Version, Storage ver]
forall (name :: Symbol) a (s :: [*]).
Label name -> (a : s) :-> (NamedF Identity a name : s)
toNamed Label "current"
forall a. IsLabel "current" a => a
forall (x :: Symbol) a. IsLabel x a => a
#current ('[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '["current" :! Version, Storage ver])
-> ('["current" :! Version, Storage ver] :-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
>> (WellTypedIsoValue (VerPermanent ver) =>
'["current" :! Version, Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'["current" :! Version, Storage ver] :-> '[Storage ver]
checkVersion @ver))
'[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a (s :: [*]). (a : s) :-> (a : a : s)
dup; ('[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (Label "newVersion"
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[GetFieldType
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver)))
"newVersion",
Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "newVersion"
forall a. IsLabel "newVersion" a => a
forall (x :: Symbol) a. IsLabel x a => a
#newVersion ('[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[Version, Storage ver])
-> ('[Version, Storage ver] :-> '["new" :! Version, Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '["new" :! Version, Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
>> Label "new"
-> '[Version, Storage ver] :-> '["new" :! Version, Storage ver]
forall (name :: Symbol) a (s :: [*]).
Label name -> (a : s) :-> (NamedF Identity a name : s)
toNamed Label "new"
forall a. IsLabel "new" a => a
forall (x :: Symbol) a. IsLabel x a => a
#new ('[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '["new" :! Version, Storage ver])
-> ('["new" :! Version, Storage ver] :-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
>> '["new" :! Version, Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'["new" :! Version, Storage ver] :-> '[Storage ver]
updateVersion)
Label "migrationScript"
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[GetFieldType
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver)))
"migrationScript",
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "migrationScript"
forall a. IsLabel "migrationScript" a => a
forall (x :: Symbol) a. IsLabel x a => a
#migrationScript; '[MigrationScriptFrom (VerUStoreTemplate ver),
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
forall a b (s :: [*]). (a : b : s) :-> (b : a : s)
swap; ('[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver]
applyMigration
Label "newCode"
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[GetFieldType
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver)))
"newCode",
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "newCode"
forall a. IsLabel "newCode" a => a
forall (x :: Symbol) a. IsLabel x a => a
#newCode; '[Maybe SomeUContractRouter,
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Maybe SomeUContractRouter, Storage ver]
forall a b (s :: [*]). (a : b : s) :-> (b : a : s)
swap; ('[Maybe SomeUContractRouter, Storage ver] :-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Maybe SomeUContractRouter, Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (('[Maybe SomeUContractRouter, Storage ver] :-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Maybe SomeUContractRouter, Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver])
-> ('[Maybe SomeUContractRouter, Storage ver] :-> '[Storage ver])
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Maybe SomeUContractRouter, Storage ver]
:-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
forall a b. (a -> b) -> a -> b
$ ('[SomeUContractRouter, Storage ver] :-> '[Storage ver])
-> '[Maybe SomeUContractRouter, Storage ver] :-> '[Storage ver]
forall a (s :: [*]). ((a : s) :-> s) -> (Maybe a : s) :-> s
whenSome '[SomeUContractRouter, Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[SomeUContractRouter, Storage ver] :-> '[Storage ver]
migrateCode
Label "newPermCode"
-> '[("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver))),
Storage ver]
:-> '[GetFieldType
("currentVersion" :! Version, "newVersion" :! Version,
"migrationScript" :! MigrationScriptFrom (VerUStoreTemplate ver),
"newCode" :! Maybe SomeUContractRouter,
"newPermCode" :! Maybe (SomePermanentImpl (VerPermanent ver)))
"newPermCode",
Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "newPermCode"
forall a. IsLabel "newPermCode" a => a
forall (x :: Symbol) a. IsLabel x a => a
#newPermCode; ('[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[Storage ver])
-> '[Maybe (SomePermanentImpl (VerPermanent ver)), Storage ver]
:-> '[Storage ver]
forall a (s :: [*]). ((a : s) :-> s) -> (Maybe a : s) :-> s
whenSome '[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[Storage ver]
migratePermCode
'[Storage ver] :-> '[[Operation], Storage ver]
forall p (s :: [*]). KnownValue p => s :-> (List p : s)
nil; '[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
, Label "cGetVersion"
forall a. IsLabel "cGetVersion" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cGetVersion Label "cGetVersion"
-> ('[View () Version, Storage ver] :-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam "GetVersion" ('OneField (View () Version)))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> (forall (s0 :: [*]). (() : Storage ver : s0) :-> (Version : s0))
-> '[View () Version, Storage ver] :-> ContractOut (Storage ver)
forall r a storage (s :: [*]).
NiceParameter r =>
(forall (s0 :: [*]). (a : storage : s0) :-> (r : s0))
-> (View a r : storage : s) :-> (([Operation], storage) : s)
view_ ((forall (s0 :: [*]). (() : Storage ver : s0) :-> (Version : s0))
-> '[View () Version, Storage ver] :-> ContractOut (Storage ver))
-> (forall (s0 :: [*]). (() : Storage ver : s0) :-> (Version : s0))
-> '[View () Version, Storage ver] :-> ContractOut (Storage ver)
forall a b. (a -> b) -> a -> b
$ do
DDescription -> (() : Storage ver : s0) :-> (() : Storage ver : s0)
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> (() : Storage ver : s0) :-> (() : Storage ver : s0))
-> DDescription
-> (() : Storage ver : s0) :-> (() : Storage ver : s0)
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
getVersionDoc
forall (s :: [*]). (() : s) :-> s
forall a (s :: [*]). (a : s) :-> s
drop @(); Label "fields"
-> (Storage ver : s0)
:-> (GetFieldType (Storage ver) "fields" : s0)
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields; Label "currentVersion"
-> (StorageFields ver : s0)
:-> (GetFieldType (StorageFields ver) "currentVersion" : s0)
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "currentVersion"
forall a. IsLabel "currentVersion" a => a
forall (x :: Symbol) a. IsLabel x a => a
#currentVersion
, Label "cSetAdministrator"
forall a. IsLabel "cSetAdministrator" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cSetAdministrator Label "cSetAdministrator"
-> ('[Address, Storage ver] :-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam "SetAdministrator" ('OneField Address))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription -> '[Address, Storage ver] :-> '[Address, Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> '[Address, Storage ver] :-> '[Address, Storage ver])
-> DDescription
-> '[Address, Storage ver] :-> '[Address, Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
setAdministratorDoc
('[Storage ver] :-> '[StorageFields ver, Storage ver])
-> '[Address, Storage ver]
:-> '[Address, StorageFields ver, Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip ('[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureAdmin ('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[StorageFields ver, Storage ver])
-> '[Storage ver] :-> '[StorageFields ver, Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields)
Label "admin"
-> '[GetFieldType (StorageFields ver) "admin", StorageFields ver,
Storage ver]
:-> '[StorageFields ver, Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "admin"
forall a. IsLabel "admin" a => a
forall (x :: Symbol) a. IsLabel x a => a
#admin
Label "fields"
-> '[GetFieldType (Storage ver) "fields", Storage ver]
:-> '[Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields
'[Storage ver] :-> '[[Operation], Storage ver]
forall p (s :: [*]). KnownValue p => s :-> (List p : s)
nil; '[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
, Label "cEpwBeginUpgrade"
forall a. IsLabel "cEpwBeginUpgrade" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cEpwBeginUpgrade Label "cEpwBeginUpgrade"
-> ('[("current" :! Version, "new" :! Version), Storage ver]
:-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam
"EpwBeginUpgrade"
('OneField ("current" :! Version, "new" :! Version)))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription
-> '[("current" :! Version, "new" :! Version), Storage ver]
:-> '[("current" :! Version, "new" :! Version), Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> '[("current" :! Version, "new" :! Version), Storage ver]
:-> '[("current" :! Version, "new" :! Version), Storage ver])
-> DDescription
-> '[("current" :! Version, "new" :! Version), Storage ver]
:-> '[("current" :! Version, "new" :! Version), Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
epwBeginUpgradeDoc
('[Storage ver] :-> '[Storage ver])
-> '[("current" :! Version, "new" :! Version), Storage ver]
:-> '[("current" :! Version, "new" :! Version), Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip ('[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureAdmin ('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[Storage ver])
-> '[Storage ver] :-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# '[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureNotPaused)
'[("current" :! Version, "new" :! Version), Storage ver]
:-> '[("current" :! Version, "new" :! Version),
("current" :! Version, "new" :! Version), Storage ver]
forall a (s :: [*]). (a : s) :-> (a : a : s)
dup; ('[("current" :! Version, "new" :! Version), Storage ver]
:-> '[Storage ver])
-> '[("current" :! Version, "new" :! Version),
("current" :! Version, "new" :! Version), Storage ver]
:-> '[("current" :! Version, "new" :! Version), Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (Label "current"
-> '[("current" :! Version, "new" :! Version), Storage ver]
:-> '["current"
:! GetFieldType ("current" :! Version, "new" :! Version) "current",
Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> ((name :! GetFieldType dt name) : st)
toFieldNamed Label "current"
forall a. IsLabel "current" a => a
forall (x :: Symbol) a. IsLabel x a => a
#current ('[("current" :! Version, "new" :! Version), Storage ver]
:-> '["current" :! Version, Storage ver])
-> ('["current" :! Version, Storage ver] :-> '[Storage ver])
-> '[("current" :! Version, "new" :! Version), Storage ver]
:-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
>> (WellTypedIsoValue (VerPermanent ver) =>
'["current" :! Version, Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'["current" :! Version, Storage ver] :-> '[Storage ver]
checkVersion @ver))
Label "new"
-> '[("current" :! Version, "new" :! Version), Storage ver]
:-> '["new"
:! GetFieldType ("current" :! Version, "new" :! Version) "new",
Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> ((name :! GetFieldType dt name) : st)
toFieldNamed Label "new"
forall a. IsLabel "new" a => a
forall (x :: Symbol) a. IsLabel x a => a
#new ('[("current" :! Version, "new" :! Version), Storage ver]
:-> '["new" :! Version, Storage ver])
-> ('["new" :! Version, Storage ver] :-> '[Storage ver])
-> '[("current" :! Version, "new" :! Version), Storage ver]
:-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
>> '["new" :! Version, Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'["new" :! Version, Storage ver] :-> '[Storage ver]
updateVersion
Bool -> '[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
Bool -> '[Storage ver] :-> '[Storage ver]
setPaused Bool
True
'[Storage ver] :-> '[[Operation], Storage ver]
forall p (s :: [*]). KnownValue p => s :-> (List p : s)
nil; '[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
, Label "cEpwApplyMigration"
forall a. IsLabel "cEpwApplyMigration" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cEpwApplyMigration Label "cEpwApplyMigration"
-> ('[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam
"EpwApplyMigration"
('OneField (MigrationScriptFrom (VerUStoreTemplate ver))))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription
-> '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver])
-> DDescription
-> '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
epwApplyMigrationDoc
('[Storage ver] :-> '[Storage ver])
-> '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip ('[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureAdmin ('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[Storage ver])
-> '[Storage ver] :-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# '[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensurePaused)
'[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver]
applyMigration
'[Storage ver] :-> '[[Operation], Storage ver]
forall p (s :: [*]). KnownValue p => s :-> (List p : s)
nil; '[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
, Label "cEpwSetCode"
forall a. IsLabel "cEpwSetCode" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cEpwSetCode Label "cEpwSetCode"
-> ('[SomeUContractRouter, Storage ver]
:-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam "EpwSetCode" ('OneField SomeUContractRouter))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription
-> '[SomeUContractRouter, Storage ver]
:-> '[SomeUContractRouter, Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> '[SomeUContractRouter, Storage ver]
:-> '[SomeUContractRouter, Storage ver])
-> DDescription
-> '[SomeUContractRouter, Storage ver]
:-> '[SomeUContractRouter, Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
epwSetCodeDoc
('[Storage ver] :-> '[Storage ver])
-> '[SomeUContractRouter, Storage ver]
:-> '[SomeUContractRouter, Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip ('[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureAdmin ('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[Storage ver])
-> '[Storage ver] :-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# '[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensurePaused)
'[SomeUContractRouter, Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[SomeUContractRouter, Storage ver] :-> '[Storage ver]
migrateCode
'[Storage ver] :-> '[[Operation], Storage ver]
forall p (s :: [*]). KnownValue p => s :-> (List p : s)
nil; '[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
, Label "cEpwSetPermCode"
forall a. IsLabel "cEpwSetPermCode" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cEpwSetPermCode Label "cEpwSetPermCode"
-> ('[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam
"EpwSetPermCode"
('OneField (SomePermanentImpl (VerPermanent ver))))
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription
-> '[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[SomePermanentImpl (VerPermanent ver), Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription
-> '[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[SomePermanentImpl (VerPermanent ver), Storage ver])
-> DDescription
-> '[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[SomePermanentImpl (VerPermanent ver), Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
epwSetPermCodeDoc
('[Storage ver] :-> '[Storage ver])
-> '[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[SomePermanentImpl (VerPermanent ver), Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip ('[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureAdmin ('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[Storage ver])
-> '[Storage ver] :-> '[Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# '[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensurePaused)
'[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[Storage ver]
migratePermCode
'[Storage ver] :-> '[[Operation], Storage ver]
forall p (s :: [*]). KnownValue p => s :-> (List p : s)
nil; '[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
, Label "cEpwFinishUpgrade"
forall a. IsLabel "cEpwFinishUpgrade" a => a
forall (x :: Symbol) a. IsLabel x a => a
#cEpwFinishUpgrade Label "cEpwFinishUpgrade"
-> ('[Storage ver] :-> ContractOut (Storage ver))
-> CaseClauseL
'[Storage ver]
(ContractOut (Storage ver))
('CaseClauseParam "EpwFinishUpgrade" 'NoFields)
forall (name :: Symbol) body clause.
CaseArrow name body clause =>
Label name -> body -> clause
/-> do
DDescription -> '[Storage ver] :-> '[Storage ver]
forall di (s :: [*]). DocItem di => di -> s :-> s
doc (DDescription -> '[Storage ver] :-> '[Storage ver])
-> DDescription -> '[Storage ver] :-> '[Storage ver]
forall a b. (a -> b) -> a -> b
$ Builder -> DDescription
DDescription Builder
epwFinishUpgradeDoc
'[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensureAdmin
'[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
'[Storage ver] :-> '[Storage ver]
ensurePaused
Bool -> '[Storage ver] :-> '[Storage ver]
forall (ver :: VersionKind).
WellTypedIsoValue (VerPermanent ver) =>
Bool -> '[Storage ver] :-> '[Storage ver]
setPaused Bool
False
'[Storage ver] :-> '[[Operation], Storage ver]
forall p (s :: [*]). KnownValue p => s :-> (List p : s)
nil; '[[Operation], Storage ver] :-> ContractOut (Storage ver)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair
)
ensureAdmin :: (WellTypedIsoValue (VerPermanent ver)) => '[Storage ver] :-> '[Storage ver]
ensureAdmin :: '[Storage ver] :-> '[Storage ver]
ensureAdmin = do
Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields; Label "admin"
-> '[StorageFields ver, Storage ver]
:-> '[GetFieldType (StorageFields ver) "admin", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "admin"
forall a. IsLabel "admin" a => a
forall (x :: Symbol) a. IsLabel x a => a
#admin
'[Address, Storage ver] :-> '[Address, Address, Storage ver]
forall (s :: [*]). s :-> (Address : s)
sender; '[Address, Address, Storage ver] :-> '[Bool, Storage ver]
forall n (s :: [*]). NiceComparable n => (n : n : s) :-> (Bool : s)
eq
('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[Storage ver])
-> '[Bool, Storage ver] :-> '[Storage ver]
forall (s :: [*]) (s' :: [*]).
(s :-> s') -> (s :-> s') -> (Bool : s) :-> s'
if_ ('[Storage ver] :-> '[Storage ver]
forall (s :: [*]). s :-> s
nop) (Label "senderIsNotAdmin" -> '[Storage ver] :-> '[Storage ver]
forall (tag :: Symbol) (s :: [*]) (any :: [*]).
(MustHaveErrorArg tag (MText, ()), CustomErrorHasDoc tag) =>
Label tag -> s :-> any
failCustom_ Label "senderIsNotAdmin"
forall a. IsLabel "senderIsNotAdmin" a => a
forall (x :: Symbol) a. IsLabel x a => a
#senderIsNotAdmin)
setPaused :: (WellTypedIsoValue (VerPermanent ver)) => Bool -> '[Storage ver] :-> '[Storage ver]
setPaused :: Bool -> '[Storage ver] :-> '[Storage ver]
setPaused Bool
newState = do
Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields
Bool
-> '[StorageFields ver, Storage ver]
:-> '[Bool, StorageFields ver, Storage ver]
forall t (s :: [*]). NiceConstant t => t -> s :-> (t : s)
push Bool
newState
Label "paused"
-> '[GetFieldType (StorageFields ver) "paused", StorageFields ver,
Storage ver]
:-> '[StorageFields ver, Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "paused"
forall a. IsLabel "paused" a => a
forall (x :: Symbol) a. IsLabel x a => a
#paused
Label "fields"
-> '[GetFieldType (Storage ver) "fields", Storage ver]
:-> '[Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields
ensurePaused :: (WellTypedIsoValue (VerPermanent ver)) => '[Storage ver] :-> '[Storage ver]
ensurePaused :: '[Storage ver] :-> '[Storage ver]
ensurePaused = do
Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields; Label "paused"
-> '[StorageFields ver, Storage ver]
:-> '[GetFieldType (StorageFields ver) "paused", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "paused"
forall a. IsLabel "paused" a => a
forall (x :: Symbol) a. IsLabel x a => a
#paused
('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[Storage ver])
-> '[Bool, Storage ver] :-> '[Storage ver]
forall (s :: [*]) (s' :: [*]).
(s :-> s') -> (s :-> s') -> (Bool : s) :-> s'
if_ ('[Storage ver] :-> '[Storage ver]
forall (s :: [*]). s :-> s
nop) (Label "upgContractIsNotPaused" -> '[Storage ver] :-> '[Storage ver]
forall (tag :: Symbol) (s :: [*]) (any :: [*]).
(MustHaveErrorArg tag (MText, ()), CustomErrorHasDoc tag) =>
Label tag -> s :-> any
failCustom_ Label "upgContractIsNotPaused"
forall a. IsLabel "upgContractIsNotPaused" a => a
forall (x :: Symbol) a. IsLabel x a => a
#upgContractIsNotPaused)
ensureNotPaused :: (WellTypedIsoValue (VerPermanent ver)) => '[Storage ver] :-> '[Storage ver]
ensureNotPaused :: '[Storage ver] :-> '[Storage ver]
ensureNotPaused = do
Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields; Label "paused"
-> '[StorageFields ver, Storage ver]
:-> '[GetFieldType (StorageFields ver) "paused", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "paused"
forall a. IsLabel "paused" a => a
forall (x :: Symbol) a. IsLabel x a => a
#paused
('[Storage ver] :-> '[Storage ver])
-> ('[Storage ver] :-> '[Storage ver])
-> '[Bool, Storage ver] :-> '[Storage ver]
forall (s :: [*]) (s' :: [*]).
(s :-> s') -> (s :-> s') -> (Bool : s) :-> s'
if_ (Label "upgContractIsPaused" -> '[Storage ver] :-> '[Storage ver]
forall (tag :: Symbol) (s :: [*]) (any :: [*]).
(MustHaveErrorArg tag (MText, ()), CustomErrorHasDoc tag) =>
Label tag -> s :-> any
failCustom_ Label "upgContractIsPaused"
forall a. IsLabel "upgContractIsPaused" a => a
forall (x :: Symbol) a. IsLabel x a => a
#upgContractIsPaused) ('[Storage ver] :-> '[Storage ver]
forall (s :: [*]). s :-> s
nop)
checkVersion :: forall ver. (WellTypedIsoValue (VerPermanent ver)) => '["current" :! Version, Storage ver] :-> '[Storage ver]
checkVersion :: '["current" :! Version, Storage ver] :-> '[Storage ver]
checkVersion = do
Label "current"
-> '["current" :! Version, Storage ver] :-> '[Version, Storage ver]
forall (name :: Symbol) a (s :: [*]).
Label name -> (NamedF Identity a name : s) :-> (a : s)
fromNamed Label "current"
forall a. IsLabel "current" a => a
forall (x :: Symbol) a. IsLabel x a => a
#current; Label "expectedCurrent"
-> '[Version, Storage ver]
:-> '[NamedF Identity Version "expectedCurrent", Storage ver]
forall (name :: Symbol) a (s :: [*]).
Label name -> (a : s) :-> (NamedF Identity a name : s)
toNamed Label "expectedCurrent"
forall a. IsLabel "expectedCurrent" a => a
forall (x :: Symbol) a. IsLabel x a => a
#expectedCurrent
('[Storage ver]
:-> '[NamedF Identity Version "actualCurrent", Storage ver])
-> '[NamedF Identity Version "expectedCurrent", Storage ver]
:-> '[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields ('[Storage ver] :-> '[StorageFields ver, Storage ver])
-> ('[StorageFields ver, Storage ver] :-> '[Version, Storage ver])
-> '[Storage ver] :-> '[Version, Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
>> Label "currentVersion"
-> '[StorageFields ver, Storage ver]
:-> '[GetFieldType (StorageFields ver) "currentVersion",
Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : st)
toField Label "currentVersion"
forall a. IsLabel "currentVersion" a => a
forall (x :: Symbol) a. IsLabel x a => a
#currentVersion ('[Storage ver] :-> '[Version, Storage ver])
-> ('[Version, Storage ver]
:-> '[NamedF Identity Version "actualCurrent", Storage ver])
-> '[Storage ver]
:-> '[NamedF Identity Version "actualCurrent", Storage ver]
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
>> Label "actualCurrent"
-> '[Version, Storage ver]
:-> '[NamedF Identity Version "actualCurrent", Storage ver]
forall (name :: Symbol) a (s :: [*]).
Label name -> (a : s) :-> (NamedF Identity a name : s)
toNamed Label "actualCurrent"
forall a. IsLabel "actualCurrent" a => a
forall (x :: Symbol) a. IsLabel x a => a
#actualCurrent)
if (forall (st :: [*]) (o :: [*]).
Condition
(NamedF Identity Version "expectedCurrent"
: NamedF Identity Version "actualCurrent" : st)
st
st
o
o)
-> Condition
'[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
'[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
'[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
'[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
'[Storage ver]
forall a b (s :: [*]).
(forall (st :: [*]) (o :: [*]). Condition (a : b : st) st st o o)
-> Condition (a : b : s) (a : b : s) (a : b : s) (a : b : s) s
keepIfArgs (Label "expectedCurrent"
forall a. IsLabel "expectedCurrent" a => a
forall (x :: Symbol) a. IsLabel x a => a
#expectedCurrent Label "expectedCurrent"
-> Label "actualCurrent"
-> Condition
(NamedF Identity Version "expectedCurrent"
: NamedF Identity Version "actualCurrent" : st)
st
st
o
o
forall a (n1 :: Symbol) (n2 :: Symbol) (s :: [*]) (o :: [*]).
NiceComparable a =>
Label n1
-> Label n2 -> Condition ((n1 :! a) : (n2 :! a) : s) s s o o
==. Label "actualCurrent"
forall a. IsLabel "actualCurrent" a => a
forall (x :: Symbol) a. IsLabel x a => a
#actualCurrent)
then '[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
:-> '[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
forall (s :: [*]). s :-> s
nop
else do '[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
:-> '[(NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent"),
Storage ver]
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
pair; Label "upgVersionMismatch"
-> '[(NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent"),
Storage ver]
:-> '[NamedF Identity Version "expectedCurrent",
NamedF Identity Version "actualCurrent", Storage ver]
forall (tag :: Symbol) err (s :: [*]) (any :: [*]).
(MustHaveErrorArg tag (MText, err), CustomErrorHasDoc tag,
KnownError err) =>
Label tag -> (err : s) :-> any
failCustom Label "upgVersionMismatch"
forall a. IsLabel "upgVersionMismatch" a => a
forall (x :: Symbol) a. IsLabel x a => a
#upgVersionMismatch
updateVersion :: forall ver.(WellTypedIsoValue (VerPermanent ver)) => '["new" :! Version, Storage ver] :-> '[Storage ver]
updateVersion :: '["new" :! Version, Storage ver] :-> '[Storage ver]
updateVersion = do
Label "new"
-> '["new" :! Version, Storage ver] :-> '[Version, Storage ver]
forall (name :: Symbol) a (s :: [*]).
Label name -> (NamedF Identity a name : s) :-> (a : s)
fromNamed Label "new"
forall a. IsLabel "new" a => a
forall (x :: Symbol) a. IsLabel x a => a
#new
('[Storage ver] :-> '[StorageFields ver, Storage ver])
-> '[Version, Storage ver]
:-> '[Version, StorageFields ver, Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (('[Storage ver] :-> '[StorageFields ver, Storage ver])
-> '[Version, Storage ver]
:-> '[Version, StorageFields ver, Storage ver])
-> ('[Storage ver] :-> '[StorageFields ver, Storage ver])
-> '[Version, Storage ver]
:-> '[Version, StorageFields ver, Storage ver]
forall a b. (a -> b) -> a -> b
$ Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields
Label "currentVersion"
-> '[GetFieldType (StorageFields ver) "currentVersion",
StorageFields ver, Storage ver]
:-> '[StorageFields ver, Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "currentVersion"
forall a. IsLabel "currentVersion" a => a
forall (x :: Symbol) a. IsLabel x a => a
#currentVersion; Label "fields"
-> '[GetFieldType (Storage ver) "fields", Storage ver]
:-> '[Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields
applyMigration
:: (WellTypedIsoValue (VerPermanent ver)) => '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver] :-> '[Storage ver]
applyMigration :: '[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '[Storage ver]
applyMigration = do
'[MigrationScriptFrom (VerUStoreTemplate ver), Storage ver]
:-> '['[UStore_] :-> '[UStore_], Storage ver]
forall a (s :: [*]). Wrappable a => (a : s) :-> (Unwrappable a : s)
coerceUnwrap
('[Storage ver] :-> '[UStore (VerUStoreTemplate ver), Storage ver])
-> '['[UStore_] :-> '[UStore_], Storage ver]
:-> '['[UStore_] :-> '[UStore_], UStore (VerUStoreTemplate ver),
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (('[Storage ver]
:-> '[UStore (VerUStoreTemplate ver), Storage ver])
-> '['[UStore_] :-> '[UStore_], Storage ver]
:-> '['[UStore_] :-> '[UStore_], UStore (VerUStoreTemplate ver),
Storage ver])
-> ('[Storage ver]
:-> '[UStore (VerUStoreTemplate ver), Storage ver])
-> '['[UStore_] :-> '[UStore_], Storage ver]
:-> '['[UStore_] :-> '[UStore_], UStore (VerUStoreTemplate ver),
Storage ver]
forall a b. (a -> b) -> a -> b
$ Label "dataMap"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "dataMap", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "dataMap"
forall a. IsLabel "dataMap" a => a
forall (x :: Symbol) a. IsLabel x a => a
#dataMap
'['[UStore_] :-> '[UStore_], UStore (VerUStoreTemplate ver),
Storage ver]
:-> '[Lambda
(UStore (VerUStoreTemplate ver)) (UStore (VerUStoreTemplate ver)),
UStore (VerUStoreTemplate ver), Storage ver]
forall a b (s :: [*]). Castable_ a b => (a : s) :-> (b : s)
checkedCoerce_
'[Lambda
(UStore (VerUStoreTemplate ver)) (UStore (VerUStoreTemplate ver)),
UStore (VerUStoreTemplate ver), Storage ver]
:-> '[UStore (VerUStoreTemplate ver),
Lambda
(UStore (VerUStoreTemplate ver)) (UStore (VerUStoreTemplate ver)),
Storage ver]
forall a b (s :: [*]). (a : b : s) :-> (b : a : s)
swap
'[UStore (VerUStoreTemplate ver),
Lambda
(UStore (VerUStoreTemplate ver)) (UStore (VerUStoreTemplate ver)),
Storage ver]
:-> '[UStore (VerUStoreTemplate ver), Storage ver]
forall a b (s :: [*]). (a : Lambda a b : s) :-> (b : s)
exec
Label "dataMap"
-> '[GetFieldType (Storage ver) "dataMap", Storage ver]
:-> '[Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "dataMap"
forall a. IsLabel "dataMap" a => a
forall (x :: Symbol) a. IsLabel x a => a
#dataMap
migrateCode
:: (WellTypedIsoValue (VerPermanent ver)) => '[SomeUContractRouter, Storage ver]
:-> '[Storage ver]
migrateCode :: '[SomeUContractRouter, Storage ver] :-> '[Storage ver]
migrateCode = do
('[Storage ver] :-> '[StorageFields ver, Storage ver])
-> '[SomeUContractRouter, Storage ver]
:-> '[SomeUContractRouter, StorageFields ver, Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields)
'[SomeUContractRouter, StorageFields ver, Storage ver]
:-> '[UContractRouter ver, StorageFields ver, Storage ver]
forall a b (s :: [*]). Castable_ a b => (a : s) :-> (b : s)
checkedCoerce_
Label "code"
-> '[GetFieldType (StorageFields ver) "code", StorageFields ver,
Storage ver]
:-> '[StorageFields ver, Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "code"
forall a. IsLabel "code" a => a
forall (x :: Symbol) a. IsLabel x a => a
#code
Label "fields"
-> '[GetFieldType (Storage ver) "fields", Storage ver]
:-> '[Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields
migratePermCode
:: (WellTypedIsoValue (VerPermanent ver)) => '[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[Storage ver]
migratePermCode :: '[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[Storage ver]
migratePermCode = do
('[Storage ver] :-> '[StorageFields ver, Storage ver])
-> '[SomePermanentImpl (VerPermanent ver), Storage ver]
:-> '[SomePermanentImpl (VerPermanent ver), StorageFields ver,
Storage ver]
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (Label "fields"
-> '[Storage ver]
:-> '[GetFieldType (Storage ver) "fields", Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrGetFieldC dt name =>
Label name -> (dt : st) :-> (GetFieldType dt name : dt : st)
getField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields)
'[SomePermanentImpl (VerPermanent ver), StorageFields ver,
Storage ver]
:-> '[PermanentImpl ver, StorageFields ver, Storage ver]
forall a b (s :: [*]). Castable_ a b => (a : s) :-> (b : s)
checkedCoerce_
Label "permCode"
-> '[GetFieldType (StorageFields ver) "permCode",
StorageFields ver, Storage ver]
:-> '[StorageFields ver, Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "permCode"
forall a. IsLabel "permCode" a => a
forall (x :: Symbol) a. IsLabel x a => a
#permCode
Label "fields"
-> '[GetFieldType (Storage ver) "fields", Storage ver]
:-> '[Storage ver]
forall dt (name :: Symbol) (st :: [*]).
InstrSetFieldC dt name =>
Label name -> (GetFieldType dt name : dt : st) :-> (dt : st)
setField Label "fields"
forall a. IsLabel "fields" a => a
forall (x :: Symbol) a. IsLabel x a => a
#fields