Skip to content

fix(transactions): handle all DECIDED states in waitForTransactionReceipt - #116

Merged
cristiam86 merged 3 commits into
mainfrom
devin/DXP-667-1757949440
Sep 18, 2025
Merged

cristiam86 merged 3 commits into
mainfrom
devin/DXP-667-1757949440

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Fixes DXP-667

What

  • Added DECIDED_STATES constant defining all terminal transaction states (ACCEPTED, UNDETERMINED, LEADER_TIMEOUT, VALIDATORS_TIMEOUT, CANCELED, FINALIZED)
  • Added isDecidedState() utility function to check if a transaction status is in a decided/terminal state
  • Modified waitForTransactionReceipt() logic to accept any decided state when status = ACCEPTED is requested, instead of only accepting FINALIZED

Why

The current implementation incorrectly handles waiting for transactions in "DECIDED" states. When users call waitForTransactionReceipt with status = ACCEPTED, the function only accepts ACCEPTED or FINALIZED states as valid terminal states. However, several other transaction states (UNDETERMINED, LEADER_TIMEOUT, VALIDATORS_TIMEOUT, CANCELED) are also considered "decided" and should satisfy the wait condition.

This fix allows users to properly wait for transaction completion without getting stuck when transactions reach other valid terminal states.

Testing done

  • All existing TypeScript compilation checks pass
  • All existing tests pass (5/5 tests)
  • Verified that the new isDecidedState() function correctly identifies decided states using the status number mappings

Decisions made

  • Used a utility function approach for cleaner, more maintainable code
  • Maintained backward compatibility - existing code using specific status checks will continue to work
  • Chose to include all terminal states that represent a final decision on the transaction

Checks

  • I have tested this code
  • I have reviewed my own PR
  • I have created an issue for this PR (DXP-667)
  • I have set a descriptive PR title compliant with conventional commits

Reviewing tips

⚠️ Critical items to verify:

  1. DECIDED_STATES completeness: Confirm the list includes all appropriate terminal states and doesn't include any that shouldn't be there
  2. Python SDK consistency: This PR is for the JS SDK - ensure matching changes are made to the Python SDK
  3. Backward compatibility: Verify this change doesn't break existing user code

Key areas to focus review:

  • The isDecidedState() logic correctly uses transactionsStatusNameToNumber mapping
  • The modified condition in waitForTransactionReceipt() maintains the original behavior for exact status matches
  • Consider if any additional states should be included/excluded from DECIDED_STATES

User facing release notes

🔧 Fixed: waitForTransactionReceipt() now properly handles all decided transaction states when waiting for ACCEPTED status. Previously, only FINALIZED transactions would satisfy ACCEPTED waits, but now UNDETERMINED, LEADER_TIMEOUT, VALIDATORS_TIMEOUT, and CANCELED states are also accepted as valid terminal states.


Link to Devin run: https://app.devin.ai/sessions/80954022f93e4bf9a08ebdb0af8edcd8
Requested by: @danielrc888

…eipt

- Add DECIDED_STATES constant with all terminal transaction states
- Add isDecidedState utility function for status checking
- Update waitForTransactionReceipt to accept any decided state when ACCEPTED is requested
- Maintains backward compatibility while fixing DXP-667

Fixes: DXP-667
Co-Authored-By: daniel@genlayerlabs.com <danielrojasc888@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@coderabbitai

coderabbitai Bot commented Sep 15, 2025

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

devin-ai-integration Bot and others added 2 commits September 15, 2025 15:20
Fixes ESLint error for unused variable after refactoring to use isDecidedState utility function.

Co-Authored-By: daniel@genlayerlabs.com <danielrojasc888@gmail.com>
- Add tests for DECIDED_STATES constant and isDecidedState utility function
- Test waitForTransactionReceipt accepts all decided states when ACCEPTED requested
- Test backward compatibility for non-ACCEPTED status requests
- Test edge cases with invalid statuses
- Comprehensive test coverage for new decided states logic

Co-Authored-By: daniel@genlayerlabs.com <danielrojasc888@gmail.com>
@cristiam86
cristiam86 merged commit 78433d7 into main Sep 18, 2025
2 checks passed
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