Skip to content

Refactor extrinsic receipt event parsing with shared helpers#287

Merged
thewhaleking merged 3 commits intolatent-to:stagingfrom
it-education-md:refactor/receipt-event-parsing
Apr 7, 2026
Merged

Refactor extrinsic receipt event parsing with shared helpers#287
thewhaleking merged 3 commits intolatent-to:stagingfrom
it-education-md:refactor/receipt-event-parsing

Conversation

@it-education-md
Copy link
Copy Markdown

Summary

This PR refactors extrinsic receipt event parsing for both the sync and async clients.

Problem

Before this change, the same event parsing logic lived in both sync_substrate.py and async_substrate.py.
Both implementations had become hard to read, harder to maintain, and more error-prone to change.
This cleanup was also already called out by inline TODOs in both files.

Solution

This PR is a behavior-preserving refactor to clean up receipt event parsing without changing the existing behavior contract.

The work was done in three steps:

  1. Add dedicated sync and async unit tests first to lock down current receipt parsing behavior.
  2. Extract the shared event parsing logic into utils/receipt.py.
  3. Wire the shared helper functions into both implementations.

Test

In the dedicated sync and async unit test files, this PR adds essential but complete test coverage for the current receipt event parsing logic.

pytest -c tests/pytest.ini tests/unit_tests/sync/test_substrate_interface.py::TestExtrinsicReceiptProcessEvents -q
pytest -c tests/pytest.ini tests/unit_tests/asyncio_/test_substrate_interface.py::TestAsyncExtrinsicReceiptProcessEvents -q
pytest -c tests/pytest.ini tests/unit_tests -q

@it-education-md it-education-md changed the base branch from master to staging April 2, 2026 16:42
@it-education-md it-education-md force-pushed the refactor/receipt-event-parsing branch from 3aeccc5 to 0803855 Compare April 2, 2026 16:51
@thewhaleking
Copy link
Copy Markdown
Collaborator

Nice. I've always hated this. I'm going to modify this a bit and include it as part of ASI 2.0

@thewhaleking thewhaleking mentioned this pull request Apr 2, 2026
7 tasks
@thewhaleking thewhaleking added run-bittensor-sdk-tests Runs Bittensor SDK tests. run-bittensor-cli-tests Runs BTCLI tests. labels Apr 7, 2026
@thewhaleking
Copy link
Copy Markdown
Collaborator

Tests blocked by #288

@thewhaleking thewhaleking self-requested a review April 7, 2026 15:36
@thewhaleking thewhaleking merged commit d5beef9 into latent-to:staging Apr 7, 2026
132 of 135 checks passed
@it-education-md
Copy link
Copy Markdown
Author

Thank you. Happy to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-bittensor-cli-tests Runs BTCLI tests. run-bittensor-sdk-tests Runs Bittensor SDK tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants