diff --git a/pact-core.cabal b/pact-core.cabal index cda3e50ea..6d8ca2660 100644 --- a/pact-core.cabal +++ b/pact-core.cabal @@ -94,7 +94,7 @@ library Pact.Core.Literal Pact.Core.Guards Pact.Core.Imports - Pact.Core.Pacts.Types + Pact.Core.DefPacts.Types Pact.Core.Hash Pact.Core.Type Pact.Core.Pretty diff --git a/pact-core/Pact/Core/Pacts/Types.hs b/pact-core/Pact/Core/DefPacts/Types.hs similarity index 64% rename from pact-core/Pact/Core/Pacts/Types.hs rename to pact-core/Pact/Core/DefPacts/Types.hs index d37b9531a..7b0bc8e88 100644 --- a/pact-core/Pact/Core/Pacts/Types.hs +++ b/pact-core/Pact/Core/DefPacts/Types.hs @@ -1,14 +1,14 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE OverloadedStrings #-} -module Pact.Core.Pacts.Types - ( PactContinuation(..) +module Pact.Core.DefPacts.Types + ( DefPactContinuation(..) , pcName, pcArgs - , PactStep(..) - , psStep, psRollback, psPactId, psResume - , PactExec(..) - , peStepCount, peYield, peStep, peContinuation, peStepHasRollback, pePactId - , peNestedPactExec + , DefPactStep(..) + , psStep, psRollback, psDefPactId, psResume + , DefPactExec(..) + , peStepCount, peYield, peStep, peContinuation, peStepHasRollback, peDefPactId + , peNestedDefPactExec , Yield(..) , Provenance(..) ) where @@ -22,13 +22,13 @@ import Pact.Core.Names import Pact.Core.Hash import Pact.Core.ChainData -data PactContinuation name v - = PactContinuation +data DefPactContinuation name v + = DefPactContinuation { _pcName :: name , _pcArgs :: [v] } deriving (Eq, Show) -makeLenses ''PactContinuation +makeLenses ''DefPactContinuation -- | Provenance datatype contains all of the necessary -- data to 'endorse' a yield object. @@ -46,28 +46,28 @@ data Yield = Yield { _yData :: Map Field PactValue , _yProvenance :: Maybe Provenance - , _ySourceChain :: Maybe ChainId } - deriving (Show) + , _ySourceChain :: Maybe ChainId + } deriving Show -- | Internal representation of pacts -data PactExec - = PactExec +data DefPactExec + = DefPactExec { _peStepCount :: Int , _peYield :: Maybe Yield , _peStep :: Int - , _pePactId :: PactId - , _peContinuation :: PactContinuation FullyQualifiedName PactValue + , _peDefPactId :: DefPactId + , _peContinuation :: DefPactContinuation FullyQualifiedName PactValue , _peStepHasRollback :: Bool - , _peNestedPactExec :: Map PactId PactExec + , _peNestedDefPactExec :: Map DefPactId DefPactExec } deriving Show -makeLenses ''PactExec +makeLenses ''DefPactExec -data PactStep = PactStep +data DefPactStep = DefPactStep { _psStep :: !Int , _psRollback :: !Bool - , _psPactId :: !PactId + , _psDefPactId :: !DefPactId , _psResume :: !(Maybe Yield) } deriving Show -makeLenses ''PactStep +makeLenses ''DefPactStep diff --git a/pact-core/Pact/Core/Environment.hs b/pact-core/Pact/Core/Environment.hs index 2901f040e..6daf607e6 100644 --- a/pact-core/Pact/Core/Environment.hs +++ b/pact-core/Pact/Core/Environment.hs @@ -17,7 +17,7 @@ module Pact.Core.Environment ( EvalEnv(..) , eeMsgSigs, eePactDb , eeHash, eeMsgBody - , eePactStep + , eeDefPactStep , eePublicData, eeMode, eeFlags , PactState(..) , psLoaded @@ -57,7 +57,7 @@ import Pact.Core.Guards import Pact.Core.PactValue ( PactValue, EnvData ) import Pact.Core.Hash import Pact.Core.Names -import Pact.Core.Pacts.Types +import Pact.Core.DefPacts.Types import Pact.Core.ChainData -- | Execution flags specify behavior of the runtime environment, @@ -95,7 +95,7 @@ data EvalEnv b i , _eeMsgBody :: EnvData PactValue , _eeHash :: Hash , _eePublicData :: PublicData - , _eePactStep :: Maybe PactStep + , _eeDefPactStep :: Maybe DefPactStep , _eeMode :: ExecutionMode -- ^ The pact execution mode: local or transactional , _eeFlags :: Set ExecutionFlag @@ -129,7 +129,7 @@ data EvalState b i , _esStack :: [StackFrame] , _esEvents :: [PactEvent PactValue] , _esLoaded :: Loaded b i - , _esPactExec :: Maybe PactExec + , _esDefPactExec :: Maybe DefPactExec } deriving Show instance Default (EvalState b i) where diff --git a/pact-core/Pact/Core/Errors.hs b/pact-core/Pact/Core/Errors.hs index cf90cd39b..3cd807ed6 100644 --- a/pact-core/Pact/Core/Errors.hs +++ b/pact-core/Pact/Core/Errors.hs @@ -32,7 +32,7 @@ import Pact.Core.Info import Pact.Core.Pretty(Pretty(..)) import Pact.Core.Hash import Pact.Core.Persistence -import Pact.Core.Pacts.Types +import Pact.Core.DefPacts.Types import qualified Pact.Core.Pretty as Pretty @@ -273,43 +273,43 @@ data EvalError | NoSuchKeySet KeySetName -- ^ No such keyset | YieldOutsiteDefPact - -- ^ Yield a value outside a running PactExec - | NoActivePactExec - -- ^ No Active PactExec in the environment - | NoYieldInPactStep PactStep - -- ^ No Yield available in PactStep - | InvalidPactStepSupplied PactStep PactExec - -- ^ Supplied PactStep requests an invalid step - | DefPactIdMissmatch PactId PactId + -- ^ Yield a value outside a running DefPactExec + | NoActiveDefPactExec + -- ^ No Active DefPactExec in the environment + | NoYieldInDefPactStep DefPactStep + -- ^ No Yield available in DefPactStep + | InvalidDefPactStepSupplied DefPactStep DefPactExec + -- ^ Supplied DefPactStep requests an invalid step + | DefPactIdMissmatch DefPactId DefPactId -- ^ Requested PactId does not match context PactId - | CCDefPactContinuationError PactStep PactExec PactExec + | CCDefPactContinuationError DefPactStep DefPactExec DefPactExec -- ^ Crosschain DefPact contunation must be at least 2 steps before CC continuation step -- with - | NoPreviousDefPactExecutionFound PactStep + | NoPreviousDefPactExecutionFound DefPactStep -- ^ No previouse DefPact execution could be found in the environment or database - | DefPactAlreadyCompleted PactStep + | DefPactAlreadyCompleted DefPactStep -- ^ DefPact already completed - | NestedDefPactParentStepCountMissmatch PactId Int Int + | NestedDefPactParentStepCountMissmatch DefPactId Int Int -- ^ Nested DefPact does not match - | NestedDefPactParentRollbackMissmatch PactId Bool Bool + | NestedDefPactParentRollbackMissmatch DefPactId Bool Bool -- ^ Nested DefPact does not match - | NestedDefPactNeverStarted PactStep + | NestedDefPactNeverStarted DefPactStep -- ^ Nested DefPact never started at prior step - | NestedDefPactDoubleExecution PactStep + | NestedDefPactDoubleExecution DefPactStep -- ^ Nested DefPact is executed twice - | MultipleOrNestedDefPactExecFound PactExec - -- ^ Unexpected PactExec found in the environment - | DefPactStepNotFound PactStep Int + | MultipleOrNestedDefPactExecFound DefPactExec + -- ^ Unexpected DefPactExec found in the environment + | DefPactStepNotFound DefPactStep Int -- ^ The expected step could not be found in the DefPact - | PactStepHasNoRollback PactStep - -- ^ The requested PactStep has no rollback - | PactStepNotInEnvironment - -- ^ PactStep is not in the environment + | DefPactStepHasNoRollback DefPactStep + -- ^ The requested DefPactStep has no rollback + | DefPactStepNotInEnvironment + -- ^ DefPactStep is not in the environment | NoDefPactIdAndExecEnvSupplied - -- ^ No PactId supplied and no PactExec found in the environment - | DefPactRollbackMissmatch PactStep PactExec + -- ^ No DefPactId supplied and no DefPactExec found in the environment + | DefPactRollbackMissmatch DefPactStep DefPactExec -- ^ DefPact rollback missmatch - | DefPactStepMissmatch PactStep PactExec + | DefPactStepMissmatch DefPactStep DefPactExec -- ^ DefPact missmatch | CannotUpgradeInterface ModuleName -- ^ Interface cannot be upgrade @@ -329,9 +329,9 @@ data EvalError | NativeIsTopLevelOnly NativeName | EventDoesNotMatchModule ModuleName | InvalidEventCap FullyQualifiedName - | NestedDefpactsNotAdvanced PactId + | NestedDefpactsNotAdvanced DefPactId | ExpectedPactValue - | NotInPactExecution + | NotInDefPactExecution deriving Show @@ -373,29 +373,29 @@ instance Pretty EvalError where -- NoSuchKeySet _ -> error "" YieldOutsiteDefPact -> "Try to yield a value outside a running DefPact execution" - NoActivePactExec -> + NoActiveDefPactExec -> "No active DefPact execution in the environment" - NoYieldInPactStep (PactStep step _ i _) -> + NoYieldInDefPactStep (DefPactStep step _ i _) -> Pretty.hsep ["No yield in DefPactStep:", "Step: " <> pretty step, "DefPactId: " <> pretty i] - InvalidPactStepSupplied (PactStep step _ _ _) pe -> + InvalidDefPactStepSupplied (DefPactStep step _ _ _) pe -> Pretty.hsep - [ "PactStep does not match DefPact properties:" + [ "DefPactStep does not match DefPact properties:" , "requested: "<> pretty step , "step count:" <> pretty (_peStepCount pe)] DefPactIdMissmatch reqId envId -> Pretty.hsep - [ "Requested PactId:", pretty reqId - , "does not match context PactId:", pretty envId + [ "Requested DefPactId:", pretty reqId + , "does not match context DefPactId:", pretty envId ] CCDefPactContinuationError pactStep _ccExec _dbExec -> Pretty.hsep [ "Crosschain DefPact continuation error:" - , "PactId:" <> pretty (_psStep pactStep) + , "DefPactId:" <> pretty (_psStep pactStep) ] NestedDefPactParentRollbackMissmatch pid rollback parentRollback -> Pretty.hsep [ "Nested DefPact execution failed, parameter missmatch:" - , "PactId: " <> pretty pid + , "DefPactId: " <> pretty pid , "Rollback: " <> pretty rollback , "Parent rollback:" <> pretty parentRollback ] @@ -407,35 +407,35 @@ instance Pretty EvalError where , "Parent step count: " <> pretty parentStepCount ] NoPreviousDefPactExecutionFound ps -> - Pretty.hsep ["No previous DefPact exeuction found for PactId: ", pretty (_psPactId ps)] + Pretty.hsep ["No previous DefPact exeuction found for DefPactId: ", pretty (_psDefPactId ps)] DefPactAlreadyCompleted ps -> Pretty.hsep - [ "Requested DefPact already completed: ", "PactId:" <> pretty (_psPactId ps)] + [ "Requested DefPact already completed: ", "DefPactId:" <> pretty (_psDefPactId ps)] NestedDefPactNeverStarted ps -> Pretty.hsep - ["Requested nested DefPact never started:", "PactId: " <> pretty (_psPactId ps)] + ["Requested nested DefPact never started:", "DefPactId: " <> pretty (_psDefPactId ps)] NestedDefPactDoubleExecution ps -> Pretty.hsep - ["Requested nested DefPact double execution:", "PactId: " <> pretty (_psPactId ps)] + ["Requested nested DefPact double execution:", "DefPactId: " <> pretty (_psDefPactId ps)] MultipleOrNestedDefPactExecFound pe -> Pretty.hsep - ["DefPact execution context already in the environment: ", "PactId: " <> pretty (_pePactId pe)] + ["DefPact execution context already in the environment: ", "DefPactId: " <> pretty (_peDefPactId pe)] DefPactStepNotFound ps maxSteps -> Pretty.hsep [ "Requested DefPact step exceeds available steps:" , "requested: " <> pretty (_psStep ps) , "available: " <> pretty maxSteps ] - PactStepHasNoRollback ps -> Pretty.hsep - ["Step has no rollback:", "PactId: " <> pretty (_psPactId ps)] - PactStepNotInEnvironment -> "No PactStep in the environment" - NoDefPactIdAndExecEnvSupplied -> "No PactId or execution environment supplied" + DefPactStepHasNoRollback ps -> Pretty.hsep + ["Step has no rollback:", "DefPactId: " <> pretty (_psDefPactId ps)] + DefPactStepNotInEnvironment -> "No DefPactStep in the environment" + NoDefPactIdAndExecEnvSupplied -> "No DefPactId or execution environment supplied" DefPactRollbackMissmatch ps pe -> Pretty.hsep - [ "Rollback missmatch in PactStep and DefPact exeuction environment:" - , "PactId: " <> pretty (_psPactId ps) + [ "Rollback missmatch in DefPactStep and DefPact exeuction environment:" + , "DefPactId: " <> pretty (_psDefPactId ps) , "step rollback: " <> pretty (_psRollback ps) - , "PactExec rollback: " <> pretty (_peStepHasRollback pe) + , "DefPactExec rollback: " <> pretty (_peStepHasRollback pe) ] DefPactStepMissmatch ps pe -> Pretty.hsep - [ "Step missmatch in PactStep and DefPact exeuction environment:" - , "PactId: " <> pretty (_psPactId ps) + [ "Step missmatch in DefPactStep and DefPact exeuction environment:" + , "DefPactId: " <> pretty (_psDefPactId ps) , "step: " <> pretty (_psStep ps) - , "PactExec step: " <> pretty (_peStep pe + 1) + , "DefPactExec step: " <> pretty (_peStep pe + 1) ] e -> pretty (show e) -- CannotUpgradeInterface _ -> error "" @@ -454,7 +454,7 @@ instance Pretty EvalError where -- InvalidEventCap _ -> error "" -- NestedDefpactsNotAdvanced _ -> error "" -- ExpectedPactValue -> error "" - -- NotInPactExecution -> error "" + -- NotInDefPactExecution -> error "" instance Exception EvalError diff --git a/pact-core/Pact/Core/Guards.hs b/pact-core/Pact/Core/Guards.hs index 28b3601ef..b82cc8641 100644 --- a/pact-core/Pact/Core/Guards.hs +++ b/pact-core/Pact/Core/Guards.hs @@ -112,7 +112,7 @@ data CapabilityGuard name term = CapabilityGuard { _cgName :: !name , _cgArgs :: ![term] - , _cgPactId :: !(Maybe PactId) } + , _cgPactId :: !(Maybe DefPactId) } deriving (Eq, Ord, Show, Functor, Foldable, Traversable) data Guard name term diff --git a/pact-core/Pact/Core/IR/Eval/CEK.hs b/pact-core/Pact/Core/IR/Eval/CEK.hs index 4f7c320fa..bad259b33 100644 --- a/pact-core/Pact/Core/IR/Eval/CEK.hs +++ b/pact-core/Pact/Core/IR/Eval/CEK.hs @@ -63,7 +63,7 @@ import Pact.Core.StableEncoding import Pact.Core.IR.Term hiding (PactStep) import Pact.Core.IR.Eval.Runtime -import Pact.Core.Pacts.Types +import Pact.Core.DefPacts.Types chargeNodeGas :: MonadEval b i m => NodeType -> m () chargeNodeGas _nt = pure () -- gm <- view (eeGasModel . geGasModel . gmNodes) <$> readEnv @@ -242,39 +242,39 @@ mkDefPactClosure info fqn dpact env = case _dpArgs dpact of initPact :: MonadEval b i m => i - -> PactContinuation FullyQualifiedName PactValue + -> DefPactContinuation FullyQualifiedName PactValue -> Cont b i m -> CEKErrorHandler b i m -> CEKEnv b i m -> m (EvalResult b i m) initPact i pc cont handler cenv = do - case view cePactStep cenv of + case view ceDefPactStep cenv of Nothing -> do pHash <- viewCEKEnv eeHash let - pStep = PactStep 0 False (hashToPactId pHash) Nothing - cenv' = set cePactStep (Just pStep) cenv + pStep = DefPactStep 0 False (hashToDefPactId pHash) Nothing + cenv' = set ceDefPactStep (Just pStep) cenv applyPact i pc pStep cont handler cenv' mempty Just ps -> let - PactId p = _psPactId ps - npId = hashToPactId (pactHash (T.encodeUtf8 p <> ":" <> encodeStable pc)) - pStep = PactStep (_psStep ps) (_psRollback ps) npId Nothing + DefPactId p = _psDefPactId ps + npId = hashToDefPactId (pactHash (T.encodeUtf8 p <> ":" <> encodeStable pc)) + pStep = DefPactStep (_psStep ps) (_psRollback ps) npId Nothing in applyNestedPact i pc pStep cont handler cenv where - hashToPactId = PactId . hashToText + hashToDefPactId = DefPactId . hashToText applyPact :: MonadEval b i m => i - -> PactContinuation FullyQualifiedName PactValue - -> PactStep + -> DefPactContinuation FullyQualifiedName PactValue + -> DefPactStep -> Cont b i m -> CEKErrorHandler b i m -> CEKEnv b i m - -> M.Map PactId PactExec + -> M.Map DefPactId DefPactExec -> m (EvalResult b i m) -applyPact i pc ps cont handler cenv nested = useEvalState esPactExec >>= \case +applyPact i pc ps cont handler cenv nested = useEvalState esDefPactExec >>= \case Just pe -> throwExecutionError i (MultipleOrNestedDefPactExecFound pe) Nothing -> lookupFqName (pc ^. pcName) >>= \case Just (DPact defPact) -> do @@ -287,25 +287,25 @@ applyPact i pc ps cont handler cenv nested = useEvalState esPactExec >>= \case step <- maybe (failInvariant i "Step not found") pure $ _dpSteps defPact ^? ix (ps ^. psStep) - let pe = PactExec + let pe = DefPactExec { _peYield = Nothing , _peStepHasRollback = hasRollback step , _peStepCount = nSteps , _peStep = _psStep ps - , _pePactId = _psPactId ps + , _peDefPactId = _psDefPactId ps , _peContinuation = pc - , _peNestedPactExec = nested + , _peNestedDefPactExec = nested } - setEvalState esPactExec (Just pe) - let cont' = PactStepC cenv cont + setEvalState esDefPactExec (Just pe) + let cont' = DefPactStepC cenv cont case (ps ^. psRollback, step) of (False, _) -> - evalWithStackFrame i cont' handler cenv sf Nothing (ordinaryPactStepExec step) + evalWithStackFrame i cont' handler cenv sf Nothing (ordinaryDefPactStepExec step) (True, StepWithRollback _ rollbackExpr _) -> evalWithStackFrame i cont' handler cenv sf Nothing rollbackExpr - (True, Step{}) -> throwExecutionError i (PactStepHasNoRollback ps) + (True, Step{}) -> throwExecutionError i (DefPactStepHasNoRollback ps) _otherwise -> failInvariant i "DefPact not found" where sf = StackFrame (view (pcName . fqName) pc) (view (pcName . fqModule) pc) SFDefPact @@ -313,13 +313,13 @@ applyPact i pc ps cont handler cenv nested = useEvalState esPactExec >>= \case applyNestedPact :: MonadEval b i m => i - -> PactContinuation FullyQualifiedName PactValue - -> PactStep + -> DefPactContinuation FullyQualifiedName PactValue + -> DefPactStep -> Cont b i m -> CEKErrorHandler b i m -> CEKEnv b i m -> m (EvalResult b i m) -applyNestedPact i pc ps cont handler cenv = useEvalState esPactExec >>= \case +applyNestedPact i pc ps cont handler cenv = useEvalState esDefPactExec >>= \case Nothing -> failInvariant i $ "applyNestedPact: Nested DefPact attempted but no pactExec found" <> T.pack (show pc) @@ -333,21 +333,21 @@ applyNestedPact i pc ps cont handler cenv = useEvalState esPactExec >>= \case isRollback = hasRollback step when (stepCount /= _peStepCount pe) $ - throwExecutionError i (NestedDefPactParentStepCountMissmatch (_pePactId pe) stepCount (_peStepCount pe)) + throwExecutionError i (NestedDefPactParentStepCountMissmatch (_peDefPactId pe) stepCount (_peStepCount pe)) when (isRollback /= _peStepHasRollback pe) $ - throwExecutionError i (NestedDefPactParentRollbackMissmatch (_pePactId pe) isRollback (_peStepHasRollback pe)) + throwExecutionError i (NestedDefPactParentRollbackMissmatch (_peDefPactId pe) isRollback (_peStepHasRollback pe)) - exec <- case pe ^. peNestedPactExec . at (_psPactId ps) of + exec <- case pe ^. peNestedDefPactExec . at (_psDefPactId ps) of Nothing - | _psStep ps == 0 -> pure $ PactExec + | _psStep ps == 0 -> pure $ DefPactExec { _peStepCount = stepCount , _peYield = Nothing , _peStep = _psStep ps - , _pePactId = _psPactId ps + , _peDefPactId = _psDefPactId ps , _peContinuation = pc , _peStepHasRollback = isRollback - , _peNestedPactExec = mempty + , _peNestedDefPactExec = mempty } | otherwise -> throwExecutionError i (NestedDefPactDoubleExecution ps) @@ -359,17 +359,17 @@ applyNestedPact i pc ps cont handler cenv = useEvalState esPactExec >>= \case | otherwise -> throwExecutionError i (NestedDefPactNeverStarted ps) - setEvalState esPactExec (Just exec) + setEvalState esDefPactExec (Just exec) let - cenv' = set cePactStep (Just ps) cenv - cont' = NestedPactStepC cenv' cont pe + cenv' = set ceDefPactStep (Just ps) cenv + cont' = NestedDefPactStepC cenv' cont pe case (ps ^. psRollback, step) of (False, _) -> - evalWithStackFrame i cont' handler cenv' sf Nothing (ordinaryPactStepExec step) + evalWithStackFrame i cont' handler cenv' sf Nothing (ordinaryDefPactStepExec step) (True, StepWithRollback _ rollbackExpr _) -> evalWithStackFrame i cont' handler cenv' sf Nothing rollbackExpr - (True, Step{}) -> throwExecutionError i (PactStepHasNoRollback ps) + (True, Step{}) -> throwExecutionError i (DefPactStepHasNoRollback ps) _otherwise -> failInvariant i "applyNestedPact: Expected a DefPact bot got something else" where sf = StackFrame (view (pcName . fqName) pc) (view (pcName . fqModule) pc) SFDefPact @@ -380,18 +380,18 @@ resumePact -> Cont b i m -> CEKErrorHandler b i m -> CEKEnv b i m - -> Maybe PactExec + -> Maybe DefPactExec -> m (EvalResult b i m) -resumePact i cont handler env crossChainContinuation = viewCEKEnv eePactStep >>= \case - Nothing -> throwExecutionError i PactStepNotInEnvironment +resumePact i cont handler env crossChainContinuation = viewCEKEnv eeDefPactStep >>= \case + Nothing -> throwExecutionError i DefPactStepNotInEnvironment Just ps -> do pdb <- viewCEKEnv eePactDb - dbState <- liftDbFunction i (readPacts pdb (_psPactId ps)) + dbState <- liftDbFunction i (readPacts pdb (_psDefPactId ps)) case (dbState, crossChainContinuation) of (Just Nothing, _) -> throwExecutionError i (DefPactAlreadyCompleted ps) (Nothing, Nothing) -> throwExecutionError i (NoPreviousDefPactExecutionFound ps) - (Nothing, Just ccExec) -> resumePactExec ccExec - (Just (Just dbExec), Nothing) -> resumePactExec dbExec + (Nothing, Just ccExec) -> resumeDefPactExec ccExec + (Just (Just dbExec), Nothing) -> resumeDefPactExec dbExec (Just (Just dbExec), Just ccExec) -> do -- Validate CC execution environment progressed far enough @@ -407,15 +407,15 @@ resumePact i cont handler env crossChainContinuation = viewCEKEnv eePactStep >>= when (_peStepCount dbExec /= _peStepCount ccExec) $ throwExecutionError i (CCDefPactContinuationError ps ccExec dbExec) - resumePactExec ccExec + resumeDefPactExec ccExec where - --resumePactExec :: MonadEval b i m => PactExec -> m (EvalResult b i m) - resumePactExec pe = do - when (_psPactId ps /= _pePactId pe) $ - throwExecutionError i (DefPactIdMissmatch (_psPactId ps) (_pePactId pe)) + --resumeDefPactExec :: MonadEval b i m => DefPactExec -> m (EvalResult b i m) + resumeDefPactExec pe = do + when (_psDefPactId ps /= _peDefPactId pe) $ + throwExecutionError i (DefPactIdMissmatch (_psDefPactId ps) (_peDefPactId pe)) when (_psStep ps < 0 || _psStep ps >= _peStepCount pe) $ - throwExecutionError i (InvalidPactStepSupplied ps pe) + throwExecutionError i (InvalidDefPactStepSupplied ps pe) if _psRollback ps then when (_psStep ps /= _peStep pe) $ @@ -428,8 +428,8 @@ resumePact i cont handler env crossChainContinuation = viewCEKEnv eePactStep >>= resume = case _psResume ps of r@Just{} -> r Nothing -> _peYield pe - env' = set ceLocal (RAList.fromList (reverse args)) $ set cePactStep (Just $ set psResume resume ps) env - applyPact i pc ps cont handler env' (_peNestedPactExec pe) + env' = set ceLocal (RAList.fromList (reverse args)) $ set ceDefPactStep (Just $ set psResume resume ps) env + applyPact i pc ps cont handler env' (_peNestedDefPactExec pe) enforceKeyset @@ -1046,42 +1046,42 @@ returnCEKValue (StackPopC i mty cont) handler v = do v' <- (\pv -> maybeTCType i pv mty) =<< enforcePactValue i v -- Todo: unsafe use of tail here. need `tailMay` (esStack %%= tail) *> returnCEKValue cont handler (VPactValue v') -returnCEKValue (PactStepC env cont) handler v = - useEvalState esPactExec >>= \case - Nothing -> failInvariant def "No PactExec found" - Just pe -> case env ^. cePactStep of - Nothing -> failInvariant def "Expected a PactStep in the environment" +returnCEKValue (DefPactStepC env cont) handler v = + useEvalState esDefPactExec >>= \case + Nothing -> failInvariant def "No DefPactExec found" + Just pe -> case env ^. ceDefPactStep of + Nothing -> failInvariant def "Expected a DefPactStep in the environment" Just ps -> do let pdb = view cePactDb env isLastStep = _psStep ps == pred (_peStepCount pe) done = (not (_psRollback ps) && isLastStep) || _psRollback ps when (nestedPactsNotAdvanced pe ps) $ - throwExecutionError def (NestedDefpactsNotAdvanced (_pePactId pe)) + throwExecutionError def (NestedDefpactsNotAdvanced (_peDefPactId pe)) liftDbFunction def - (writePacts pdb Write (_psPactId ps) + (writePacts pdb Write (_psDefPactId ps) (if done then Nothing else Just pe)) returnCEKValue cont handler v -returnCEKValue (NestedPactStepC env cont parentPactExec) handler v = - useEvalState esPactExec >>= \case - Nothing -> failInvariant def "No PactExec found" - Just pe -> case env ^. cePactStep of - Nothing -> failInvariant def "Expected a PactStep in the environment" +returnCEKValue (NestedDefPactStepC env cont parentDefPactExec) handler v = + useEvalState esDefPactExec >>= \case + Nothing -> failInvariant def "No DefPactExec found" + Just pe -> case env ^. ceDefPactStep of + Nothing -> failInvariant def "Expected a DefPactStep in the environment" Just ps -> do when (nestedPactsNotAdvanced pe ps) $ - throwExecutionError def (NestedDefpactsNotAdvanced (_pePactId pe)) + throwExecutionError def (NestedDefpactsNotAdvanced (_peDefPactId pe)) - let npe = parentPactExec & peNestedPactExec %~ M.insert (_psPactId ps) pe - setEvalState esPactExec (Just npe) + let npe = parentDefPactExec & peNestedDefPactExec %~ M.insert (_psDefPactId ps) pe + setEvalState esDefPactExec (Just npe) returnCEKValue cont handler v -- | Important check for nested pacts: -- Nested step must be equal to the parent step after execution. -nestedPactsNotAdvanced :: PactExec -> PactStep -> Bool +nestedPactsNotAdvanced :: DefPactExec -> DefPactStep -> Bool nestedPactsNotAdvanced resultState ps = - any (\npe -> _peStep npe /= _psStep ps) (_peNestedPactExec resultState) + any (\npe -> _peStep npe /= _psStep ps) (_peNestedDefPactExec resultState) {-# INLINE nestedPactsNotAdvanced #-} applyLam @@ -1192,11 +1192,11 @@ applyLam (DPC (DefPactClosure fqn argtys arity env i)) args cont handler ArgClosure cloargs -> do args' <- traverse (enforcePactValue i) args tcArgs <- zipWithM (\arg ty -> maybeTCType i arg ty) args' (NE.toList cloargs) - let pc = PactContinuation fqn tcArgs + let pc = DefPactContinuation fqn tcArgs env' = set ceLocal (RAList.fromList (reverse (VPactValue <$> tcArgs))) env initPact i pc cont handler env' NullaryClosure -> do - let pc = PactContinuation fqn [] + let pc = DefPactContinuation fqn [] env' = set ceLocal mempty env initPact i pc cont handler env' | otherwise = throwExecutionError i ClosureAppliedToTooManyArgs diff --git a/pact-core/Pact/Core/IR/Eval/RawBuiltin.hs b/pact-core/Pact/Core/IR/Eval/RawBuiltin.hs index 680cd15c1..e5f20a157 100644 --- a/pact-core/Pact/Core/IR/Eval/RawBuiltin.hs +++ b/pact-core/Pact/Core/IR/Eval/RawBuiltin.hs @@ -51,7 +51,7 @@ import Pact.Core.Guards import Pact.Core.Type import Pact.Core.PactValue import Pact.Core.Persistence -import Pact.Core.Pacts.Types +import Pact.Core.DefPacts.Types import Pact.Core.Environment import Pact.Core.Capabilities @@ -551,18 +551,18 @@ coreYield info b cont handler _env = \case args -> argsError info b args where go o mcid = do - mpe <- useEvalState esPactExec + mpe <- useEvalState esDefPactExec case mpe of Nothing -> throwExecutionError info YieldOutsiteDefPact Just pe -> case mcid of Nothing -> do - esPactExec . _Just . peYield .== Just (Yield o Nothing Nothing) + esDefPactExec . _Just . peYield .== Just (Yield o Nothing Nothing) returnCEKValue cont handler (VObject o) Just cid -> do sourceChain <- viewCEKEnv (eePublicData . pdPublicMeta . pmChainId) p <- provenanceOf cid when (_peStepHasRollback pe) $ failInvariant info "Cross-chain yield not allowed in step with rollback" - esPactExec . _Just . peYield .== Just (Yield o (Just p) (Just sourceChain)) + esDefPactExec . _Just . peYield .== Just (Yield o (Just p) (Just sourceChain)) returnCEKValue cont handler (VObject o) provenanceOf tid = Provenance tid . _mHash <$> getCallingModule info @@ -571,11 +571,11 @@ coreYield info b cont handler _env = \case coreResume :: (IsBuiltin b, MonadEval b i m) => NativeFunction b i m coreResume = \info b cont handler _env -> \case [VClosure clo] -> do - mps <- viewCEKEnv eePactStep + mps <- viewCEKEnv eeDefPactStep case mps of - Nothing -> throwExecutionError info NoActivePactExec + Nothing -> throwExecutionError info NoActiveDefPactExec Just pactStep -> case _psResume pactStep of - Nothing -> throwExecutionError info (NoYieldInPactStep pactStep) + Nothing -> throwExecutionError info (NoYieldInDefPactStep pactStep) Just (Yield resumeObj _ _) -> applyLam clo [VObject resumeObj] cont handler args -> argsError info b args @@ -734,7 +734,7 @@ enforceCapGuard info cont handler (CapabilityGuard fqn args mpid) = do case mpid of Nothing -> enforceCap Just pid -> do - currPid <- getPactId info + currPid <- getDefPactId info if currPid == pid then enforceCap else returnCEK cont handler (VError "Capability pact guard failed: invalid pact id" info) where @@ -1092,7 +1092,7 @@ createCapGuard = \info b cont handler _env -> \case createCapabilityPactGuard :: (IsBuiltin b, MonadEval b i m) => NativeFunction b i m createCapabilityPactGuard = \info b cont handler _env -> \case [VCapToken ct] -> do - pid <- getPactId info + pid <- getDefPactId info let cg = CapabilityGuard (_ctName ct) (_ctArgs ct) (Just pid) returnCEKValue cont handler (VGuard (GCapabilityGuard cg)) args -> argsError info b args diff --git a/pact-core/Pact/Core/IR/Eval/Runtime/Types.hs b/pact-core/Pact/Core/IR/Eval/Runtime/Types.hs index 7a18013a4..6780d55fc 100644 --- a/pact-core/Pact/Core/IR/Eval/Runtime/Types.hs +++ b/pact-core/Pact/Core/IR/Eval/Runtime/Types.hs @@ -17,7 +17,7 @@ module Pact.Core.IR.Eval.Runtime.Types , ceLocal , cePactDb , ceBuiltins - , cePactStep + , ceDefPactStep , ceInCap , EvalEnv(..) , NativeFunction @@ -104,12 +104,12 @@ import Pact.Core.Hash import Pact.Core.IR.Term import Pact.Core.Literal import Pact.Core.Type -import qualified Pact.Core.Pacts.Types as P +import qualified Pact.Core.DefPacts.Types as P import Pact.Core.Persistence import Pact.Core.ModRefs import Pact.Core.Capabilities import Pact.Core.Environment -import Pact.Core.Pacts.Types (PactExec) +import Pact.Core.DefPacts.Types (DefPactExec) import qualified Pact.Core.Pretty as P @@ -124,7 +124,7 @@ data CEKEnv b i m { _ceLocal :: RAList (CEKValue b i m) , _cePactDb :: PactDb b i , _ceBuiltins :: BuiltinEnv b i m - , _cePactStep :: Maybe P.PactStep + , _ceDefPactStep :: Maybe P.DefPactStep , _ceInCap :: Bool } instance (Show i, Show b) => Show (CEKEnv b i m) where @@ -412,8 +412,8 @@ data Cont b i m -- or a simple return value in the case of `compose-capability` -- - The rest of the continuation | CapPopC CapPopState (Cont b i m) - | PactStepC (CEKEnv b i m) (Cont b i m) - | NestedPactStepC (CEKEnv b i m) (Cont b i m) PactExec + | DefPactStepC (CEKEnv b i m) (Cont b i m) + | NestedDefPactStepC (CEKEnv b i m) (Cont b i m) DefPactExec | UserGuardC (Cont b i m) | StackPopC i (Maybe Type) (Cont b i m) | EnforceErrorC i (Cont b i m) diff --git a/pact-core/Pact/Core/IR/Eval/Runtime/Utils.hs b/pact-core/Pact/Core/IR/Eval/Runtime/Utils.hs index 461fca24a..18293d531 100644 --- a/pact-core/Pact/Core/IR/Eval/Runtime/Utils.hs +++ b/pact-core/Pact/Core/IR/Eval/Runtime/Utils.hs @@ -40,7 +40,7 @@ module Pact.Core.IR.Eval.Runtime.Utils , evalStateToErrorState , restoreFromErrorState , (.==) - , getPactId + , getDefPactId ) where import Control.Lens hiding ((%%=)) @@ -69,7 +69,7 @@ import Pact.Core.Capabilities import Pact.Core.Persistence import Pact.Core.Hash import Pact.Core.Environment -import Pact.Core.Pacts.Types +import Pact.Core.DefPacts.Types mkBuiltinFn :: (IsBuiltin b) @@ -366,11 +366,11 @@ sysOnlyEnv e DUserTables _ -> dbOpDisallowed DKeySets -> _pdbRead pdb DKeySets k DModules -> _pdbRead pdb dom k - DPacts -> _pdbRead pdb dom k + DDefPacts -> _pdbRead pdb dom k -getPactId :: (MonadEval b i m) => i -> m PactId -getPactId info = - useEvalState esPactExec >>= \case - Just pe -> pure (_pePactId pe) +getDefPactId :: (MonadEval b i m) => i -> m DefPactId +getDefPactId info = + useEvalState esDefPactExec >>= \case + Just pe -> pure (_peDefPactId pe) Nothing -> - throwExecutionError info NotInPactExecution + throwExecutionError info NotInDefPactExecution diff --git a/pact-core/Pact/Core/IR/Term.hs b/pact-core/Pact/Core/IR/Term.hs index 51a1f1389..051b139e8 100644 --- a/pact-core/Pact/Core/IR/Term.hs +++ b/pact-core/Pact/Core/IR/Term.hs @@ -60,9 +60,9 @@ hasRollback :: PactStep n t b i -> Bool hasRollback Step{} = False hasRollback StepWithRollback{} = True -ordinaryPactStepExec :: PactStep name ty builtin info -> Term name ty builtin info -ordinaryPactStepExec (Step expr _) = expr -ordinaryPactStepExec (StepWithRollback expr _ _) = expr +ordinaryDefPactStepExec :: PactStep name ty builtin info -> Term name ty builtin info +ordinaryDefPactStepExec (Step expr _) = expr +ordinaryDefPactStepExec (StepWithRollback expr _ _) = expr data DefPact name ty builtin info = DefPact diff --git a/pact-core/Pact/Core/Names.hs b/pact-core/Pact/Core/Names.hs index 8355eec46..dc5146d8f 100644 --- a/pact-core/Pact/Core/Names.hs +++ b/pact-core/Pact/Core/Names.hs @@ -55,7 +55,7 @@ module Pact.Core.Names , fqModule , fqHash , userTable - , PactId(..) + , DefPactId(..) ) where import Control.Lens @@ -340,9 +340,9 @@ userTable (TableName tn) = TableName ("USER_" <> tn) -- generally computed from the continuation, or -- in the case of nested defpacts, the hash of the -- parent + the nested continuation -newtype PactId - = PactId Text +newtype DefPactId + = DefPactId Text deriving (Eq,Ord,Show) -instance Pretty PactId where - pretty (PactId p) = pretty p +instance Pretty DefPactId where + pretty (DefPactId p) = pretty p diff --git a/pact-core/Pact/Core/Persistence.hs b/pact-core/Pact/Core/Persistence.hs index 5ec03fed8..181ef9d24 100644 --- a/pact-core/Pact/Core/Persistence.hs +++ b/pact-core/Pact/Core/Persistence.hs @@ -49,7 +49,7 @@ import Pact.Core.IR.Term import Pact.Core.Guards import Pact.Core.Hash import Pact.Core.PactValue -import Pact.Core.Pacts.Types +import Pact.Core.DefPacts.Types -- import Pact.Core.Errors import qualified Data.Map.Strict as M @@ -137,11 +137,11 @@ data Domain k v b i where DModules :: Domain ModuleName (ModuleData b i) b i -- | Namespaces -- Namespaces :: Domain NamespaceName (Namespace PactValue) - -- | Pacts map to 'Maybe PactExec' where Nothing indicates + -- | Pacts map to 'Maybe DefPactExec' where Nothing indicates -- a terminated pact. -- | DefPact state, `Nothing` implies DefPact with `PactId` is completed. - DPacts :: Domain PactId (Maybe PactExec) b i + DDefPacts :: Domain DefPactId (Maybe DefPactExec) b i data Purity -- | Read-only access to systables. @@ -184,11 +184,11 @@ readKeyset pdb = _pdbRead pdb DKeySets writeKeySet :: PactDb b i -> WriteType -> KeySetName -> FQKS -> IO () writeKeySet pdb wt = _pdbWrite pdb wt DKeySets -readPacts :: PactDb b i -> PactId -> IO (Maybe (Maybe PactExec)) -readPacts pdb = _pdbRead pdb DPacts +readPacts :: PactDb b i -> DefPactId -> IO (Maybe (Maybe DefPactExec)) +readPacts pdb = _pdbRead pdb DDefPacts -writePacts :: PactDb b i -> WriteType -> PactId -> Maybe PactExec -> IO () -writePacts pdb wt = _pdbWrite pdb wt DPacts +writePacts :: PactDb b i -> WriteType -> DefPactId -> Maybe DefPactExec -> IO () +writePacts pdb wt = _pdbWrite pdb wt DDefPacts data DbOpException = WriteException @@ -310,7 +310,7 @@ mockPactDb = do . IORef (Map KeySetName FQKS) -> IORef (Map ModuleName (ModuleData b i)) -> IORef (Map TableName (Map RowKey RowData)) - -> IORef (Map PactId (Maybe PactExec)) + -> IORef (Map DefPactId (Maybe DefPactExec)) -> Domain k v b i -> IO [k] keys refKs refMod refUsrTbl refPacts d = case d of @@ -325,7 +325,7 @@ mockPactDb = do case M.lookup tbl r of Just t -> return (M.keys t) Nothing -> throwIO (NoSuchTable tbl) - DPacts -> do + DDefPacts -> do r <- readIORef refPacts return (M.keys r) @@ -349,7 +349,7 @@ mockPactDb = do . IORef (Map KeySetName FQKS) -> IORef (Map ModuleName (ModuleData b i)) -> IORef (Map TableName (Map RowKey RowData)) - -> IORef (Map PactId (Maybe PactExec)) + -> IORef (Map DefPactId (Maybe DefPactExec)) -> Domain k v b i -> k -> IO (Maybe v) @@ -358,7 +358,7 @@ mockPactDb = do DModules -> readMod refMod k DUserTables tbl -> readRowData refUsrTbl tbl k - DPacts -> readPacts' refPacts k + DDefPacts -> readPacts' refPacts k checkTable tbl ref = do r <- readIORef ref @@ -371,7 +371,7 @@ mockPactDb = do -> IORef (Map TableName (Map RowKey RowData)) -> IORef Word64 -> IORef (Map TableName (Map TxId [TxLog RowData])) - -> IORef (Map PactId (Maybe PactExec)) + -> IORef (Map DefPactId (Maybe DefPactExec)) -> WriteType -> Domain k v b i -> k @@ -381,7 +381,7 @@ mockPactDb = do DKeySets -> writeKS refKs k v DModules -> writeMod refMod v DUserTables tbl -> writeRowData refUsrTbl refTxId refTxLog tbl wt k v - DPacts -> writePacts' refPacts k v + DDefPacts -> writePacts' refPacts k v readRowData ref tbl k = do checkTable tbl ref diff --git a/pact-core/Pact/Core/Repl/Compile.hs b/pact-core/Pact/Core/Repl/Compile.hs index c323b0965..c0d582bb0 100644 --- a/pact-core/Pact/Core/Repl/Compile.hs +++ b/pact-core/Pact/Core/Repl/Compile.hs @@ -133,7 +133,7 @@ interpretReplProgram sc@(SourceCode _ source) display = do throwError (PEExecutionError (EvalError txt) (view termInfo te)) EvalValue v -> do loaded .= view (reState . esLoaded) st - (replEvalState . esPactExec) .= view (reState . esPactExec) st + (replEvalState . esDefPactExec) .= view (reState . esDefPactExec) st case v of VClosure{} -> do pure IPClosure diff --git a/pact-core/Pact/Core/Repl/Runtime.hs b/pact-core/Pact/Core/Repl/Runtime.hs index 4f66063c2..074da72cb 100644 --- a/pact-core/Pact/Core/Repl/Runtime.hs +++ b/pact-core/Pact/Core/Repl/Runtime.hs @@ -102,4 +102,4 @@ runReplCEK -> EvalTerm b i -> IO (Either (PactError i) (EvalResult b i (ReplEvalM b i)), ReplEvalState b i) runReplCEK env st term = - runReplEvalM env st (eval (CEKEnv mempty (view (reEnv . eePactDb) st) (_reBuiltins env) (view (reEnv . eePactStep) st) False) term) + runReplEvalM env st (eval (CEKEnv mempty (view (reEnv . eePactDb) st) (_reBuiltins env) (view (reEnv . eeDefPactStep) st) False) term) diff --git a/pact-core/Pact/Core/Repl/Runtime/ReplBuiltin.hs b/pact-core/Pact/Core/Repl/Runtime/ReplBuiltin.hs index 785980361..d09aaadfb 100644 --- a/pact-core/Pact/Core/Repl/Runtime/ReplBuiltin.hs +++ b/pact-core/Pact/Core/Repl/Runtime/ReplBuiltin.hs @@ -21,7 +21,7 @@ import Pact.Core.Builtin import Pact.Core.Literal import Pact.Core.Hash import Pact.Core.IR.Eval.Runtime -import Pact.Core.Pacts.Types +import Pact.Core.DefPacts.Types import Pact.Core.IR.Eval.CEK import Pact.Core.Names import Pact.Core.IR.Eval.RawBuiltin @@ -119,23 +119,23 @@ continuePact info b cont handler env = \case where go :: Integer -> Bool -> Maybe Text -> Maybe (M.Map Field PactValue) -> ReplEvalM b i (EvalResult b i (ReplEvalM b i)) go step rollback mpid userResume = do - mpe <- useEvalState esPactExec + mpe <- useEvalState esDefPactExec (pid, myield) <- case mpe of Nothing -> do - pid <- maybe (throwExecutionError info NoDefPactIdAndExecEnvSupplied) (pure . PactId) mpid + pid <- maybe (throwExecutionError info NoDefPactIdAndExecEnvSupplied) (pure . DefPactId) mpid pure (pid, (\r -> Yield r Nothing Nothing) <$> userResume) Just pactExec -> let - pid = maybe (_pePactId pactExec) PactId mpid + pid = maybe (_peDefPactId pactExec) DefPactId mpid yield = case userResume of Nothing -> _peYield pactExec Just o -> pure (Yield o Nothing Nothing) in pure (pid, yield) - let pactStep = PactStep (fromInteger step) rollback pid myield - setEvalState esPactExec Nothing - (reEnv . eePactStep) .= Just pactStep + let pactStep = DefPactStep (fromInteger step) rollback pid myield + setEvalState esDefPactExec Nothing + (reEnv . eeDefPactStep) .= Just pactStep s <- tryError $ resumePact info cont handler env Nothing - (reEnv . eePactStep) .= Nothing + (reEnv . eeDefPactStep) .= Nothing liftEither s pactState :: (IsBuiltin b, Default i, Show i) => NativeFunction b i (ReplEvalM b i) @@ -145,14 +145,14 @@ pactState info b cont handler _env = \case args -> argsError info b args where go clear = do - mpe <- useEvalState esPactExec + mpe <- useEvalState esDefPactExec case mpe of Just pe -> do - when clear $ esPactExec .== Nothing + when clear $ esDefPactExec .== Nothing let yield' = case _peYield pe of Nothing -> PLiteral (LBool False) Just (Yield y _ _) -> PObject y - PactId pid = _pePactId pe + DefPactId pid = _peDefPactId pe ps = [(Field "pactId", PString pid) ,(Field "yield", yield') ,(Field "step", PInteger (fromIntegral (_peStep pe)))] diff --git a/pact-core/Pact/Core/StableEncoding.hs b/pact-core/Pact/Core/StableEncoding.hs index ddf8c8345..238047918 100644 --- a/pact-core/Pact/Core/StableEncoding.hs +++ b/pact-core/Pact/Core/StableEncoding.hs @@ -15,7 +15,7 @@ import Pact.Core.Guards import Pact.Core.Names import Pact.Core.ModRefs import Pact.Core.Hash -import Pact.Core.Pacts.Types +import Pact.Core.DefPacts.Types import Pact.Time import Data.Decimal (DecimalRaw(..)) @@ -35,8 +35,8 @@ encodeStable = J.encodeStrict . StableEncoding newtype StableEncoding a = StableEncoding a deriving (Ord, Eq) -instance J.Encode (StableEncoding PactId) where - build (StableEncoding (PactId pid)) = +instance J.Encode (StableEncoding DefPactId) where + build (StableEncoding (DefPactId pid)) = J.build pid -- | Stable encoding of `Literal` @@ -75,7 +75,7 @@ instance J.Encode (StableEncoding (Guard FullyQualifiedName PactValue)) where -- | Stable encoding of `CapabilityGuard FullyQualifiedName PactValue` instance J.Encode (StableEncoding (CapabilityGuard FullyQualifiedName PactValue)) where build (StableEncoding (CapabilityGuard name args mpid)) = J.object - [ "cgPactId" J..= fmap StableEncoding mpid -- TODO: Check availability + [ "cgPactId" J..= fmap StableEncoding mpid , "cgArgs" J..= J.Array (StableEncoding <$> args) , "cgName" J..= StableEncoding name ] @@ -186,9 +186,9 @@ instance J.Encode (StableEncoding PactValue) where PTime pt -> J.build (StableEncoding pt) {-# INLINABLE build #-} --- | Stable encoding of `PactContinuation FullyQualifiedName PactValue` -instance J.Encode (StableEncoding (PactContinuation FullyQualifiedName PactValue)) where - build (StableEncoding (PactContinuation name args))= J.object +-- | Stable encoding of `DefPactContinuation FullyQualifiedName PactValue` +instance J.Encode (StableEncoding (DefPactContinuation FullyQualifiedName PactValue)) where + build (StableEncoding (DefPactContinuation name args))= J.object [ "args" J..= J.Array (StableEncoding <$> args) , "def" J..= J.build (StableEncoding (fqnToQualName name)) ]