fix(sdk-custody): implement custody dispute filing and tracking (#203) - #259
Open
joshuaolabodebello2020-cyber wants to merge 1 commit into
Conversation
) - Add DisputeStatus enum, DisputeOptions, DisputeStatusResult, and DisputeResolutionEvent types to sdk/src/types.ts - Implement CustodyClient.fileDispute() with bond validation (throws InsufficientBondError for zero/negative bonds before submission) - Implement CustodyClient.getDisputeStatus() with in-memory cache and chain fallback stub - Implement CustodyClient.getRecentDisputes(custodian, limit) returning records sorted newest-first, indexed by both custodian and challenger - Add CustodyClient.onDisputeResolution() event listener registration with fault-tolerant dispatch (faulty listeners do not block others) - Update CustodyClient.getDispute() to delegate to getDisputeStatus() rather than throwing 'Not implemented' - Add private notifyResolutionListeners() and fetchDisputeFromChain() helpers - Fix pre-existing syntax bug in sdk/src/errors.ts line 441 (bad quote in TX_BAD_SEQ entry) - Fix import in custody.ts: use 'stellar-sdk' instead of '@stellar/stellar-sdk' - Add jest.config.js with ts-jest preset so all TS tests can run - Add 38-test suite sdk/src/__tests__/custody.dispute.test.ts covering dispute filing, bond validation, status tracking, recent disputes, event listeners, and legacy getDispute() adapter Closes Kevin737866#203
|
@joshuaolabodebello2020-cyber Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
Implements the full custody dispute lifecycle in the TypeScript SDK, closing issue #203.
Changes
sdk/src/types.tsDisputeStatusenum with values:PENDING,UNDER_REVIEW,RESOLVED_UPHELD,RESOLVED_REJECTED,CANCELLEDDisputeOptionsinterface (input forfileDispute)DisputeStatusResultinterface (full dispute record with nullableresolvedAt/resolution)DisputeResolutionEventinterface (emitted to listeners on terminal resolution)sdk/src/custody.tsfileDispute(signerKeypair, options): Validates bond (throwsInsufficientBondErrorfor zero/negative amounts), broadcastsdispute_attestationcontract call, persists record locally indexed by challenger and custodiangetDisputeStatus(disputeId): Returns cachedDisputeStatusResult; falls back tofetchDisputeFromChainfor unknown IDsgetRecentDisputes(custodian, limit): Returns disputes for a custodian/challenger address sorted newest-first, capped atlimit(1–100, default 20)onDisputeResolution(listener): Registers resolution event callbacks; faulty listeners are swallowed so others still firegetDispute(disputeId): Updated to delegate togetDisputeStatusinstead of throwingNot implementednotifyResolutionListeners(),fetchDisputeFromChain()initiateDispute()retained for backward compatibilitysdk/src/errors.ts[ErrorCode.TX_BAD_SEQ'→[ErrorCode.TX_BAD_SEQ]jest.config.js(new)npm testsdk/src/__tests__/custody.dispute.test.ts(new)fileDispute()success path and returned shapegetDisputeStatus()hit/miss/immutabilitygetRecentDisputes()ordering, limit, empty results, invalid inputsonDisputeResolution()listener registration, multi-listener dispatch, faulty listener isolationgetDispute()legacy adapter shapeAcceptance Criteria
fileDispute(attestationId, reason, evidenceHash, bondAmount)getDisputeStatus(disputeId)returnsDisputeRecordgetRecentDisputes(custodian, limit)Test Results
Closes #203
Closes #202