Skip to content

Conversation

@aditya-gupta24005
Copy link

Fixes #245

Refactor API for Consistency and Usability

Description

This PR refactors several key Appkit APIs to improve consistency, readability, and usability. The changes aim to align naming conventions across builders and reduce the need for manual collection conversions.

Changes

1. BoxOperations Refactoring (Breaking Change)

Renamed configuration methods to match the UnsignedTransactionBuilder and general builder patterns. The "with" prefix has been removed in favor of more concise names.

  • withAmountToSpend -> value
  • withTokensToSpend -> tokens
  • withFeeAmount -> fee
  • withAttachment -> attachment
  • withMaxInputBoxesToSelect -> maxInputBoxes
  • withMessage -> message
  • withInputBoxesLoader -> inputBoxesLoader

2. UnsignedTransactionBuilder Enhancements

Added List-based overloads for keys methods to avoid the need for converting Lists to Arrays manually.

  • addInputs(List<InputBox>)
  • addDataInputs(List<InputBox>)
  • addOutputs(List<OutBox>)
  • tokensToBurn(List<ErgoToken>)

3. Address Standardization

Standardized conversion methods to use the to prefix, aligning with toErgoContract and toPropositionBytes.

  • Added toP2PK() and toP2S().
  • Deprecated asP2PK() and asP2S().

4. OutBoxBuilder Improvement

  • Removed the restriction that prevented passing an empty collection to tokens(). This makes the builder pattern more robust when building dynamic token lists.

Verification

  • Updated existing tests (TxBuilderSpec, AnonymousAccessSpec, AppkitProvingInterpreterSpec, BabelFeeSpec) to reflect the API changes.
  • Verified that the refactored code compiles and runs correctly.

…actionBuilder`, `BoxOperations`, and `Address` for improved consistency.
…perations` builder methods, and rename `Address` accessors.
…and adding list-based arguments to `UnsignedTransactionBuilder`.
…puts, and tokens to burn, and remove non-empty token validation.
…put, and token burning methods in `UnsignedTransactionBuilder` and remove empty token check in `OutBoxBuilder`.
…methods and update existing API to accept `java.util.List`.
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.

Inconsistent API

1 participant