Skip to content

feat(config): validate each asset with AssetSchema in AnchorKitConfig…#324

Merged
0xNgoo merged 3 commits into
0xNgoo:mainfrom
helenahelenavanbeek-png:feat/asset-validation
Jul 1, 2026
Merged

feat(config): validate each asset with AssetSchema in AnchorKitConfig…#324
0xNgoo merged 3 commits into
0xNgoo:mainfrom
helenahelenavanbeek-png:feat/asset-validation

Conversation

@helenahelenavanbeek-png

Copy link
Copy Markdown
Contributor

Closes #254

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ersDELLDesktop Outdated
@@ -0,0 +1,30 @@
a107de2 (HEAD -> feat/asset-validation, origin/main, origin/HEAD, main) Test/malformed bearer (#278)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

It appears that a temporary file containing git log output (ersDELLDesktop) was accidentally committed to the repository. This file should be deleted before merging.

Comment thread src/utils/validation.ts Outdated
Comment on lines +243 to +246
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.`,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.`,
        );

helenahelenavanbeek-png pushed a commit to helenahelenavanbeek-png/anchor-kit that referenced this pull request Jun 27, 2026
@helenahelenavanbeek-png helenahelenavanbeek-png force-pushed the feat/asset-validation branch 2 times, most recently from ad65810 to 354c8d1 Compare June 29, 2026 12:04
…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
@0xNgoo 0xNgoo force-pushed the feat/asset-validation branch from 3f12132 to d27c5e8 Compare July 1, 2026 14:57
@0xNgoo 0xNgoo merged commit e861f17 into 0xNgoo:main Jul 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate each configured asset via AssetSchema in AnchorKitConfigSchema

3 participants