Skip to content

fix(common): experimentalSelectUtxos selects utxos for assets that are not required - #884

Open
takinanton wants to merge 3 commits into
MeshJS:mainfrom
takinanton:fix/experimental-select-unrequired-assets
Open

takinanton wants to merge 3 commits into
MeshJS:mainfrom
takinanton:fix/experimental-select-unrequired-assets

Conversation

@takinanton

Copy link
Copy Markdown
Contributor

Summary

experimentalSelectUtxos subtracts every asset of a picked UTxO from the required map even when that asset was never required. The missing entry turns into the string NaN and the loop over required units then treats it as one more unit to cover so it grabs every UTxO holding that token. With one required token and three UTxOs where the first carries the token plus an unrelated one and the other two carry only the unrelated one the function returns all three instead of the first.

Now only units that are already in the required map get reduced. Added a test with that case which fails on main and passes with the change.

Affect components

  • @meshsdk/common
  • @meshsdk/contract
  • @meshsdk/core
  • @meshsdk/core-cst
  • @meshsdk/hydra
  • @meshsdk/provider
  • @meshsdk/react
  • @meshsdk/svelte
  • @meshsdk/transaction
  • @meshsdk/wallet
  • Mesh playground (i.e. https://meshjs.dev/)
  • Mesh CLI

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Code refactoring (improving code quality without changing its behavior)
  • Documentation update (adding or updating documentation related to the project)

Related Issues

None that I could find.

Checklist

  • My code is appropriately commented and includes relevant documentation, if necessary
  • I have added tests to cover my changes, if necessary
  • I have updated the documentation, if necessary
  • All new and existing tests pass (i.e. npm run test)
  • The build is pass (i.e. npm run build)

Additional Information

I only built @meshsdk/common with build:mesh and ran its jest suite. 18 suites and 207 tests pass. The other 7 suites did not load because they import @meshsdk/core or @meshsdk/core-cst which I did not build. Prettier is clean on both files. I did not run the full turbo build or the other packages.

🤖 Generated with Claude Code

…e not required

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants