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 |
c0a8b78 to
d208503
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
d208503 to
f886495
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.
alw view swap <id>previously showed a generic "Swap resolved" message with no details — users lost 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
allways/cli/das_api.py— thin client forGET /swaps/{id}, maps indexer JSON to the existingSwapdataclassTAO_TO_RAOconstantSUPPORTED_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 existing resolved-swap messageExample
Before:
```
$ alw view swap 1
Swap 1 has been resolved (completed or timed out).
Resolved swaps are removed from on-chain storage.
```
After:
```
$ alw view swap 1
Swap no longer on-chain; showing indexer record.
Swap #1 — COMPLETED
BTC -> TAO | 0.005 BTC -> 1.72650000 TAO | Rate: 345.3
Timeline:
● Initiated Block 8000
● Fulfilled Block 8050
● Completed Block 8120
⏱ Timeout Block 9000
Source TX: abc123...
Dest TX: def456...
User: 5GrwvaEF...
Miner: 5FHneW46...
```
Test plan