Repository navigation
fix(stellar): validate DEX and trustline asset references - #157
Merged
Merged
Conversation
Reject malformed asset codes and issuers before loading the source account or constructing a DEX offer. Errors now name the offending side (base, counter, or trustline) and explain the expected Stellar format. Refs Chulilee#58
Exercise valid native and credit assets, malformed codes, missing or invalid issuers, and verify the transaction builders reject bad references before any Horizon request. Closes Chulilee#58
|
@akargi is attempting to deploy a commit to the Akargi Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The merge left both the new assertValidAssetRef and the old validateAssetRef running in buildDexOfferTx. The new validator throws first with a descriptive InvalidAssetError, so the old block was dead code that never produced its own messages. Drop the old block, delete the superseded module and its suite, and keep one validator wired into horizon.toSdkAsset and the DEX offer builder.
The offer builder now fails fast through assertValidAssetRef, whose messages name the side, the offending value, and the expected format. Update the assertions to match so the suite pins the new contract.
This branch was successfully 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
Closes #58.
buildDexOfferTxonly rejected the case where both sides were native XLM. Malformed asset codes or issuers were left to the Stellar SDK, whose errors do not identify which side is wrong, and the source account was loaded from Horizon before any validation. This change adds explicit asset-reference validation and runs it before network I/O.Acceptance criteria
Changes
src/lib/stellar/assetValidation.ts:G...) issuer check viaStrKey.isValidEd25519PublicKey.InvalidAssetErrorwith side-specific messages.buildDexOfferTxand trustline assets inbuildTrustlineTx/buildRemoveTrustlineTxbeforehorizon.loadAccount.toSdkAsset.Validation
Ran from the frontend repository with the existing dependency tree:
npm test -- src/lib/stellar --runInBand— 3 suites, 47 tests passed.npm run type-check— passed.npm run lint— passed with pre-existing<img>warnings only.Not run locally:
npm run build— CI runs this.npm run test:e2e— requires a running app and wallet setup.No live Testnet transaction was submitted. The tests exercise transaction construction and stop before Horizon I/O.
Compatibility and scope
InvalidAssetErrorinstead of a generic SDK/Horizon error.Non-goals