Skip to content

Disallow unsupported FIO assets #5664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025
Merged

Disallow unsupported FIO assets #5664

merged 1 commit into from
Jul 18, 2025

Conversation

Jon-edge
Copy link
Collaborator

@Jon-edge Jon-edge commented Jul 18, 2025

This change doesn't cover all situations, but at least prevents new FIO actions from using unsupported assets.

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

cursor[bot]

This comment was marked as outdated.

* Validate if an Edge asset can be converted to FIO codes using the whitelist
* TODO: Integrate into the rest of FIO functionality
*/
export const validateFioAsset = (
Copy link
Contributor

Choose a reason for hiding this comment

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

This should move to fioConstants.ts, and should use the same logic of const fioAssets = infoServerData.rollup?.fioAssets ?? FIO_ASSET_MAP. That way it still works if the info server is down. The info server data is supposed to be supplemental to stuff baked in the app.

Indeed, the logic could just be added to tokenIdToFioCode, which would be edited to return | undefined. Then we know any place we might send and Edge currency to Fio-land it's actually something Fio supports.

If that's a big change, then just moving this to the right file would be enough for the merge.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah it was intentionally separated because moving to the existing fio<>asset utils had a lot of fallout

@Jon-edge Jon-edge force-pushed the jon/fix/fio-token-map branch from 1c32f15 to ece3fcd Compare July 18, 2025 01:05
@Jon-edge Jon-edge enabled auto-merge July 18, 2025 01:05
cursor[bot]

This comment was marked as outdated.

@Jon-edge Jon-edge disabled auto-merge July 18, 2025 01:08
This change doesn't cover all situations, but at least prevents new FIO actions from using unsupported assets.
@Jon-edge Jon-edge force-pushed the jon/fix/fio-token-map branch from ece3fcd to 48ec0ad Compare July 18, 2025 01:08
@Jon-edge Jon-edge enabled auto-merge July 18, 2025 01:08
@Jon-edge Jon-edge disabled auto-merge July 18, 2025 01:08
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Inconsistent Token Validation Functions

The new validateFioAsset function is inconsistent with the existing tokenIdToFioCode function. validateFioAsset only checks fioAsset.tokenCodes?.[tokenId] for tokens, returning isValid: false if not explicitly mapped. However, tokenIdToFioCode includes a fallback to currencyConfig.allTokens[tokenId]?.currencyCode for tokens not in the special mapping. This makes validateFioAsset more restrictive, especially since the updated FIO_ASSET_MAP has fewer explicit tokenCodes. Consequently, validateFioAsset may reject tokens that tokenIdToFioCode can successfully convert, leading to inconsistent behavior (e.g., valid tokens being filtered out in the UI).

src/constants/FioConstants.ts#L186-L231

*/
export const validateFioAsset = (
currencyConfig: EdgeCurrencyConfig,
tokenId: EdgeTokenId
): FioValidationResult => {
const fioAssets = infoServerData.rollup?.fioAssets ?? FIO_ASSET_MAP
const { pluginId } = currencyConfig.currencyInfo
// Check if this plugin is supported
const fioAsset = fioAssets[pluginId]
if (fioAsset == null) {
return {
isValid: false,
error: `${currencyConfig.currencyInfo.displayName} is not supported by FIO Protocol`
}
}
const fioChainCode = fioAsset.chainCode
// For native assets (tokenId is null)
if (tokenId == null) {
return {
isValid: true,
fioChainCode,
fioTokenCode: fioChainCode
}
}
// For tokens, check if the token is in the whitelist
const fioTokenCode = fioAsset.tokenCodes?.[tokenId]
if (fioTokenCode == null) {
const tokenInfo = currencyConfig.allTokens[tokenId]
const tokenName =
tokenInfo?.displayName ?? tokenInfo?.currencyCode ?? tokenId
return {
isValid: false,
error: `${tokenName} is not supported by FIO Protocol`
}
}
return {
isValid: true,
fioChainCode,
fioTokenCode
}
}

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@Jon-edge Jon-edge merged commit 97dd71e into develop Jul 18, 2025
3 checks passed
@Jon-edge Jon-edge deleted the jon/fix/fio-token-map branch July 18, 2025 01:58
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.

2 participants