Resolve off-chain swaps via Allways DAS indexer#31
Open
eureka0928 wants to merge 1 commit intoentrius:testfrom
Open
Resolve off-chain swaps via Allways DAS indexer#31eureka0928 wants to merge 1 commit intoentrius:testfrom
eureka0928 wants to merge 1 commit intoentrius:testfrom
Conversation
Contributor
Author
|
Hi @LandynDev I put the new PR based on your comments from closed one |
906e424 to
035daa2
Compare
When a swap is no longer in contract storage (completed or timed out),
alw view swap <id> now fetches details from the Allways Data Access
Service (indexer API) instead of showing a bare "Swap resolved" message.
- Add das_api.py: API client for the DAS /swaps/{swapId} endpoint
- Fallback in view swap: try DAS when contract returns None
- Configurable via ALLWAYS_DAS_BASE_URL env var (default: test-api.all-ways.io)
- Full test coverage for field mapping, error handling, and edge cases
035daa2 to
4055aeb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a swap completes or times out, the contract removes it from on-chain storage. Currently
alw view swap <id>shows a generic "Swap resolved" message with no details — users lose visibility into their swap history.This PR adds a lightweight fallback to the existing Allways DAS (indexer) API so resolved swaps are displayed with full details instead of a dead-end message.
test-api.all-ways.ioget_swap()returnsNoneChanges
Commit 1: Resolve off-chain swaps via Allways DAS indexer
allways/cli/das_api.py— thin client forGET /swaps/{id}, maps indexer JSON to the existingSwapdataclass_tao_decimal_to_rao)SUPPORTED_CHAINSALLWAYS_DAS_BASE_URLenv varNoneon any transport/parse error (never raises)allways/cli/swap_commands/view.py— whenget_swap()returnsNone, triesfetch_swap_from_das()before falling back to the old messageCommit 2: Clarify SwapTracker docs and add unit tests
SwapTrackerdocstring explaining window pruning,voted_idslifecycle, and cold-start behavior_resolved_blockordering, window pruning,voted_idscleanup on swap resolutionExample
Before:
After:
Test plan
pytest tests/test_das_api.py -v— DAS client mapping and error handlingpytest tests/test_swap_tracker.py -v— SwapTracker pruning and voted_ids cleanupalw view swap <resolved_id>shows full details from indexerALLWAYS_DAS_BASE_URLset to invalid URL, falls back to existing message