Skip to content

fix: normalize tokenStandard to uppercase in getAssetItemType#1964

Open
qsysvcore wants to merge 1 commit intoProjectOpenSea:mainfrom
qsysvcore:fix/token-standard-case-sensitivity
Open

fix: normalize tokenStandard to uppercase in getAssetItemType#1964
qsysvcore wants to merge 1 commit intoProjectOpenSea:mainfrom
qsysvcore:fix/token-standard-case-sensitivity

Conversation

@qsysvcore
Copy link
Copy Markdown

Problem

The getAssetItemType function in src/utils/protocol.ts uses a switch statement with uppercase token standard strings ("ERC20", "ERC721", "ERC1155"), but doesn't normalize the input. When the API returns token standards in lowercase or mixed case (e.g., "erc721", "Erc721"), the function incorrectly throws "Unknown schema name" error.

Fix

Added tokenStandard.toUpperCase() normalization at the beginning of the function to ensure case-insensitive matching.

Why this is safe

  • The change is minimal (1 line added)
  • It makes the function more robust against API responses with different casing
  • Aligns with existing patterns in the codebase (e.g., src/sdk/orders.ts uses toUpperCase() when calling this function)
  • No breaking changes - all existing valid inputs continue to work
  • The TokenStandard type already defines the values in uppercase, so this ensures runtime values match the type definitions

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.

1 participant