IntersectMBO / cardano-api

Cardano API
Apache License 2.0
26 stars 23 forks source link

[FR] - Misleading `unsafeHashableScriptData` #474

Open jonathangenlambda opened 8 months ago

jonathangenlambda commented 8 months ago

External

Area Other HashableScriptData

Describe the feature you'd like We have been successfully using unsafeHashableScriptData however its description recommends NOT to use it:

Warning: Creating HashableScriptData from a ScriptData value pretty much guarantees the original bytes used to create the value will be different if we serialize again. Do not use this.

However it is unclear how to construct a ScriptRedeemer from ScriptData if we shouldn't use unsafeHashableScriptData - in general, if usage of unsafeHashableScriptData is discouraged, it is unclear how to go from ScriptData to HashableScriptData.

Please either change the description of unsafeHashableScriptData or provide other (safe?) means going from ScriptData to HashableScriptData.

github-actions[bot] commented 7 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

Swordlash commented 1 month ago

You can use fromAlonzoData in this way:

import qualified Cardano.Ledger.Plutus.Data as LPD
import qualified PlutusLedgerApi.V1                as PV1
import qualified Cardano.Api.Shelley               as C

toHashableScriptData = C.fromAlonzoData . LPD.Data @ledgerEra . PV1.toData
Swordlash commented 1 month ago

But I don't think it matters if you're creating the data from scratch (programatically) rather than by deserialisation from a bytestring.

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.