Skip to content

Commit f8ada82

Browse files
committed
feat(utils): add encoding options to hashPlutusData
1 parent 8195065 commit f8ada82

File tree

1 file changed

+7
-3
lines changed
  • packages/evolution/src/utils

1 file changed

+7
-3
lines changed

packages/evolution/src/utils/Hash.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,14 @@ export const hashAuxiliaryData = (aux: AuxiliaryData.AuxiliaryData): AuxiliaryDa
160160
}
161161

162162
/**
163-
* Compute hash of plutus data using default Data encoding.
163+
* Compute hash of plutus data using specified CBOR encoding options.
164+
* Defaults to CML_DATA_DEFAULT_OPTIONS (indefinite-length arrays/maps).
164165
*/
165-
export const hashPlutusData = (pd: Data.Data): DatumOption.DatumHash => {
166-
const bytes = Data.toCBORBytes(pd)
166+
export const hashPlutusData = (
167+
pd: Data.Data,
168+
options: CBOR.CodecOptions = CBOR.CML_DATA_DEFAULT_OPTIONS
169+
): DatumOption.DatumHash => {
170+
const bytes = Data.toCBORBytes(pd, options)
167171
const digest = blake2b(bytes, { dkLen: 32 })
168172
return new DatumOption.DatumHash({ hash: digest })
169173
}

0 commit comments

Comments
 (0)