fix(orders): resolve 64-hex order ids directly without re-hashing in dispatch and refund (closes #67) - #298
Open
Ranjeet2063 wants to merge 1 commit into
Conversation
…dispatch and refund (closes Movalabs-crew#67)
|
@Ranjeet2063 is attempting to deploy a commit to the Oluremi's projects Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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 of Changes
This PR resolves issue #67 where
dispatchOrderandrefundOrder(andreadOrder) inlib/stellar/orders.tsunconditionally ranawait hashOrderId(orderId). When called fromapp/admin/orders/page.tsx, the order ID is already the 32-byte event-derived SHA-256 hash formatted as a 64-character hex string. Re-hashing the 64-hex ASCII string produced a completely different SHA-256 digest, resulting in contract calls failing withOrderNotFound.Key Changes
resolveOrderIdHashinlib/stellar/orders.ts:orderIdmatches a 64-character hex string (^[0-9a-fA-F]{64}$, with optional0xprefix and trimmed whitespace).hexToByteswithout re-hashing."SS-2024-0001"), it computes SHA-256 viahashOrderId.dispatchOrder,refundOrder, andreadOrderinlib/stellar/orders.ts.app/admin/orders/page.tsxpassing the indexer event-derived hex ID unmodified.tests/lib/stellar/orders.test.ts: Verifies 64-hex bypass (lower/upper/mixed case, 0x prefix, whitespace) and SHA-256 computation for raw pre-images.tests/app/admin/orders-dispatch.test.tsx: Asserts the admin page passes the event-derived hex ID directly todispatchOrderandrefundOrderwithout modification.Verification (2x Verified)
npx vitest run tests/lib/stellar/orders.test.ts tests/app/admin/orders-dispatch.test.tsx(8/8 tests pass, 0 warnings)npm run type-check(0 errors)npm run lint(0 errors)npx prettier --check(100% formatted)Closes #67