feat(config): validate each asset with AssetSchema in AnchorKitConfig…#324
Conversation
|
@helenahelenavanbeek-png 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! 🚀 |
There was a problem hiding this comment.
Code Review
This pull request introduces asset validation logic in src/utils/validation.ts to ensure configured assets have a non-empty string code and a valid Stellar public key issuer, accompanied by comprehensive unit tests. Feedback highlights that an accidental git log file (ersDELLDesktop∀) was committed and should be removed. Additionally, it is recommended to safely handle the code property when formatting the validation error message to prevent displaying [object Object] if the code is not a string.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| @@ -0,0 +1,30 @@ | |||
| [33ma107de2[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeat/asset-validation[m[33m, [m[1;31morigin/main[m[33m, [m[1;31morigin/HEAD[m[33m, [m[1;32mmain[m[33m)[m Test/malformed bearer (#278) | |||
| const code = (asset as Record<string, unknown>)?.code; | ||
| throw new Error( | ||
| `Invalid asset at index ${i} ${code ? `(code: "${code}")` : ''}: asset.code must be a non-empty string and asset.issuer must be a valid Stellar public key.`, | ||
| ); |
There was a problem hiding this comment.
If the configured asset is invalid, asset.code might not be a string (it could be an object, array, or other type). Directly interpolating it in the error message could result in confusing output like (code: "[object Object]"). It is safer to verify that code is a non-empty string before displaying it in the error message.
const code = (asset as Record<string, unknown>)?.code;
const codeStr = typeof code === 'string' && code ? ` (code: "${code}")` : '';
throw new Error(
`Invalid asset at index ${i}${codeStr}: asset.code must be a non-empty string and asset.issuer must be a valid Stellar public key.`,
);ad65810 to
354c8d1
Compare
…Schema - Update AnchorKitConfigSchema.validate to validate each asset with AssetSchema.isValid - Add clear error messages for invalid assets - Add comprehensive asset validation tests - All 10 asset validation tests pass Closes 0xNgoo#254
3f12132 to
d27c5e8
Compare
Closes #254