Skip to content

Commit

Permalink
Fix hash ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcardon committed Oct 24, 2024
1 parent 96a5da9 commit 7f17548
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pact-tests/pact-tests/hash.repl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
(insert-hash "c" (hash [my-mod, {'a:my-mod}, (create-user-guard (f my-mod))]))
(insert-hash "d" (hash [my-mod, {'a:my-mod}, (create-user-guard (f my-mod))]))

(expect "Hash of objects with multiple values:" "JRdgzVN17Xy4-8dWegAKj_BPNv6ffNpbtT6YOCiUcY8" (hash (chain-data)))

(let*
( (h1 (get-hash "a"))
(h2 (get-hash "b"))
Expand Down
5 changes: 3 additions & 2 deletions pact/Pact/Core/StableEncoding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import qualified Data.Map.Strict as M
import qualified Data.Set as S
import qualified Pact.JSON.Decode as JD
import qualified Pact.JSON.Encode as J
import qualified Pact.JSON.Legacy.Utils as J
import Unsafe.Coerce (unsafeCoerce)

import Pact.Core.Capabilities
Expand Down Expand Up @@ -389,9 +390,9 @@ instance J.Encode (StableEncoding KeySet) where

-- | Stable encoding of `Map Field PactValue`
instance J.Encode (StableEncoding v) => J.Encode (StableEncoding (Map Field v)) where
build (StableEncoding o) = J.build $ J.Object $ c (M.toList o)
build (StableEncoding o) = J.build $ J.legacyMap _field (c o)
where
c :: [(Field, v)] -> [(T.Text, StableEncoding v)]
c :: Map k v -> Map k (StableEncoding v)
c = coerce
{-# INLINABLE build #-}

Expand Down

0 comments on commit 7f17548

Please sign in to comment.