Skip to content

Commit

Permalink
A tad more concise StableEncoding for Principals
Browse files Browse the repository at this point in the history
  • Loading branch information
0xd34df00d committed Oct 20, 2023
1 parent 7ada5c3 commit 66d3650
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pact-core/Pact/Core/StableEncoding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ instance J.Encode (StableEncoding UTCTime) where
-- | Stable encoding of `Principal`.
instance J.Encode (StableEncoding Principal) where
build (StableEncoding principal) = case principal of
K pk -> J.object [ kind 'K', "pk" J..= StableEncoding pk ]
W ph n -> J.object [ kind 'W', "ph" J..= ph, "pred" J..= n ]
R ksn -> J.object [ kind 'R', "ksn" J..= StableEncoding ksn ]
U fqn args -> J.object [ kind 'U', "fqn" J..= fqn, "args" J..= args ]
M mn n -> J.object [ kind 'M', "modname" J..= StableEncoding mn, "guard" J..= n ]
P pid n -> J.object [ kind 'P', "pid" J..= StableEncoding pid, "fun" J..= n ]
C c -> J.object [ kind 'C', "cap" J..= c ]
K pk -> kind 'K' [ "pk" J..= StableEncoding pk ]
W ph n -> kind 'W' [ "ph" J..= ph, "pred" J..= n ]
R ksn -> kind 'R' [ "ksn" J..= StableEncoding ksn ]
U fqn args -> kind 'U' [ "fqn" J..= fqn, "args" J..= args ]
M mn n -> kind 'M' [ "modname" J..= StableEncoding mn, "guard" J..= n ]
P pid n -> kind 'P' [ "pid" J..= StableEncoding pid, "fun" J..= n ]
C c -> kind 'C' [ "cap" J..= c ]
where
kind c = "kind" J..= T.singleton c
kind c rest = J.object $ "kind" J..= T.singleton c : rest

-- | Stable encoding of `PactValue`
instance J.Encode (StableEncoding PactValue) where
Expand Down

0 comments on commit 66d3650

Please sign in to comment.