Open longngn opened 2 years ago
@longngn , yeah this is an unfortunately a "feature" of this API developed a long time ago. The datums parameter in that Rust function is of type Option<PlutusList>
so it cannot be properly passed by reference and is getting passed by value, which consumes that value, by the Rust rules.
Since then we have already made it a rule to never have Option
type in function arguments and are trying to solve it with alternative approaches, but this function still exists yet. It will be deprecated and replaced with a newer API in one of the next versions.
The best recommendation for using it is to clone the datum when you are passing it, e.g:
hash_script_data(
Redeemers.new(),
TxBuilderConstants.plutus_vasil_cost_models(),
datums.clone(),
);
This will preserve the original reference.
Or if you are using the TransactionBuilder
then it is recommended to use the .calc_script_data_hash
function on the builder instead of calculating and setting the hash manually.
How to reproduce:
Logs: