Skip to content

Commit

Permalink
Update module hashing for namespaced keysets
Browse files Browse the repository at this point in the history
  • Loading branch information
0xd34df00d committed Dec 1, 2023
1 parent 80020f3 commit 338c319
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pact-core/Pact/Core/IR/ModuleHashing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,14 @@ encodeModule (Module mname mgov defs mblessed imports mimps _mh _mi) = parens $
<> hsep (encodeDef <$> defs)
where
encodeGov :: Governance Name -> Builder
encodeGov (KeyGov (KeySetName ksn)) = encodeText ksn
encodeGov (KeyGov (KeySetName name mNs)) = encodeMNamespace mNs <> encodeText name
encodeGov (CapGov (ResolvedGov fqn)) = encodeFqnAsQual fqn
encodeBless (ModuleHash (Hash s)) = parens ("bless" <+> B.shortByteString s)

encodeMNamespace :: Maybe NamespaceName -> Builder
encodeMNamespace Nothing = mempty
encodeMNamespace (Just (NamespaceName ns)) = encodeText ns <> "."

encodeInterface :: (IsBuiltin b) => Interface Name Type b i -> Builder
encodeInterface (Interface ifn idefs imports _h _i) = parens $
"interface"
Expand Down Expand Up @@ -214,7 +218,7 @@ encodeGuard = \case
KeysAll -> "keys-all"
Keys2 -> "keys-2"
KeysAny -> "keys-any"
GKeySetRef (KeySetName ksn) -> "KeySetName" <> parens (encodeText ksn)
GKeySetRef (KeySetName name mNs) -> "KeySetName" <> parens (encodeMNamespace mNs <> encodeText name)
GUserGuard (UserGuard fn args) ->
"UG" <> encodeApp (encodeFqnAsQual fn) (encodePactValue <$> args)
GCapabilityGuard (CapabilityGuard ct args _) ->
Expand Down

0 comments on commit 338c319

Please sign in to comment.