Skip to content

Commit

Permalink
Update createAnchor to use hashAnchorData
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Aug 22, 2023
1 parent 1e6c852 commit bc39163
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ createAnchor :: Url -> ByteString -> Anchor StandardCrypto
createAnchor url anchorData =
Ledger.Anchor
{ anchorUrl = url
, anchorDataHash = unsafeBytesToSafeHash anchorData
, anchorDataHash = hashAnchorData $ Ledger.AnchorData anchorData
}

-- ----------------------------------------------------------------------------
Expand All @@ -249,14 +249,4 @@ fromCommitteeMember = (. coerceKeyRole) $ \case
L.KeyHashObj keyhash -> StakeKeyHash keyhash
L.ScriptHashObj _scripthash -> error "TODO script committee members not yet supported"

-- | TODO: I'm very unsure whether it's correct to use 'unsafeMakeSafeHash'
-- here? I've asked Alexey if maybe this doesn't need to actually be a
-- 'SafeHash', which would let us remove it.
unsafeBytesToSafeHash
:: Crypto.HashAlgorithm (HASH c)
=> ByteString
-> SafeHash c a
unsafeBytesToSafeHash bs = case Crypto.hashFromBytes bs of
Nothing ->
error "unsafeBytesToSafeHash: input data is not a valid hash"
Just h -> unsafeMakeSafeHash h

0 comments on commit bc39163

Please sign in to comment.