Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust the fee calculation when reference script bytes are present in the input UTXOs of a transaction #455

Merged
merged 9 commits into from
Oct 15, 2024

Conversation

satran004
Copy link
Member

@satran004 satran004 commented Oct 10, 2024

To fix #450

  1. A script reference can be part of the regular inputs in a script transaction. For example, if the reference script is part of the spending UTXO, a reference input is not required.

  2. Update the FeeCalculator to calculate the reference script size in inputs and adjust the fee accordingly.

  3. If both a script reference and a script witness (transaction.getWitnessSet().getPlutusXScript()) are present, ExtraneousScriptWitnessesUTXOW is thrown. To fix this, DuplicateScriptWitnessChecker is introduced, which returns a composable function to remove any duplicate witnesses.

  4. A new API removeDuplicateScriptWitnesses(boolean flag) has been added to QuickTxBuilder to enable the removal of duplicate witnesses in the above scenario. By default, this flag is false, but it can be enabled by calling the above method if required.

Result<String> result1 = quickTxBuilder.compose(scriptTx)
    ...
    .removeDuplicateScriptWitnesses(true)
    .completeAndWait(System.out::println);
  1. A new overloaded method in Tx api.
public T payToContract(String address, Amount amount, PlutusData datum, Script refScript)

Introduce getOrElse to return a default value if an exception occurs. Add orElseThrow to allow custom exceptions when computation fails.
Introduced the getRefScriptHashes method in TxBuilderContext. This method aggregates reference script hashes from UTXOs and internal reference scripts, returning them as a Set of Strings.
Reorganized serialization and deserialization methods across Script, PlutusScript, and NativeScript classes. Updated tests to verify the correct handling of multiple script types, including PlutusV1, PlutusV2, PlutusV3, and NativeScript.
Introduced a new method to check for multi-asset minting in transactions. Updated the transaction builder to account for multi-asset minting when removing duplicate script witnesses. Made adjustments in the `DuplicateScriptWitnessChecker` to handle native scripts.
Copy link
Contributor

@nemo83 nemo83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Handle NativeScript as ScriptRef
@satran004 satran004 merged commit 3f3ed72 into master Oct 15, 2024
1 of 3 checks passed
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust the fee calculation when reference script bytes are present in the input UTXOs of a transaction.
4 participants