Skip to content

Commit

Permalink
add legacy defpact id
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcardon committed Sep 13, 2024
1 parent 695e31b commit 3c3f7dc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pact/Pact/Core/Names.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ module Pact.Core.Names
, parseQualifiedName
, parseFullyQualifiedName
, VerifierName(..)
, LegacyDefPactId(..)
, renderLegacyDefpactId
) where

import Control.Lens
Expand Down Expand Up @@ -420,6 +422,10 @@ instance Pretty DefPactId where

type Parser = MP.Parsec () Text

newtype LegacyDefPactId
= LegacyDefPactId { _unLegacyDefpactId :: DefPactId }
deriving (Eq, Ord, Show, NFData)

identParser :: Parser Text
identParser = do
c1 <- MP.letterChar <|> MP.oneOf specials
Expand Down Expand Up @@ -502,6 +508,15 @@ renderParsedTyName :: ParsedTyName -> Text
renderParsedTyName (TBN (BareName n)) = n
renderParsedTyName (TQN qn) = renderQualName qn

-- | Legacy hack.
-- Turns out many years ago, we used the `show` instance,
-- for pact Ids. Turns out, this actually resulted in all pact ID's having
-- db entries such as `PactId "<hash>"`. This makes it explicit.
-- It was clobbered.
renderLegacyDefpactId :: LegacyDefPactId -> Text
renderLegacyDefpactId (LegacyDefPactId t) =
"PactId \"" <> renderDefPactId t <> "\""

newtype VerifierName = VerifierName Text
deriving newtype (J.Encode, NFData, Eq, Show, Ord, FromJSON)
deriving stock Generic

0 comments on commit 3c3f7dc

Please sign in to comment.