Skip to content

fix(token-registry): convert CIP-26 logo from hex to base64 before re…#751

Open
ghost wants to merge 3 commits into
developfrom
fix/convert-cip-26-logo-from-hex-to-base64
Open

fix(token-registry): convert CIP-26 logo from hex to base64 before re…#751
ghost wants to merge 3 commits into
developfrom
fix/convert-cip-26-logo-from-hex-to-base64

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented May 13, 2026

Fixes: #748

Summary

When the token registry API returns logo data for CIP-26 tokens, the logo.value field contained raw hex-encoded bytes (e.g.89504e470d0a…) instead of the base64-encoded string that the CIP-26 specification and the LogoType.format = "base64" contract both require. This broke logo rendering in every consuming client (wallets,dApps) that treated the value as a base64 image URI.

Changes

Fix — TokenRegistryServiceImpl

  • Added @Slf4j for structured warning logs.

  • Extracted a new private helper encodeLogoValue() that converts a
    hex string to standard base64 using HexFormat and Base64 from
    java.util (no new dependencies).

  • Updated convertToLogoData() to call the helper for CIP-26 logos.
    Edge cases handled:

    Input Behaviour
    Valid hex Converted to base64 ✅
    null value Returns LogoData { format: BASE64, value: null } (unchanged)
    Empty string Returns null logo (field omitted)
    Malformed hex (odd length) Returns null logo + WARN log
    CIP-68 URL Passed through unchanged ✅

Tests — TokenRegistryServiceImplTest

  • Updated shouldConvertCip26LogoToBase64: now passes real hex input
    and asserts the correctly converted base64 output.
  • Updated shouldHandleCaseInsensitiveCipStandards: uses valid hex and
    asserts base64 output.
  • Updated shouldExtractCompleteMetadataWhenFullDataAvailable: helper
    now uses valid hex logo fixture.
  • Added shouldReturnNullLogoForMalformedHex (odd-length hex → null).
  • Added shouldReturnNullLogoForEmptyHexValue (empty string → null).
  • Added shouldNotConvertCip68UrlLogo (CIP-68 URL regression guard).

Behavioral tests

  • network_test_data.yaml: updated logo_value_prefix from"89504e47" (hex PNG magic bytes) to "iVBORw" (base64 PNG prefix) for all CIP-26 tokens on preprod and mainnet.
  • test_token_registry.py: parity test now converts the upstream registry's raw hex value to base64 before comparing with Rosetta's response.
  • network_options_operation_types.json: bumped middleware_version from 2.1.2 to 2.2.0.

@github-actions
Copy link
Copy Markdown
Contributor

❌ Preprod Tests: FAILED

📊 View Detailed Test Report

🔗 Action Run #335

Tests run against preprod network with live blockchain data

@github-actions
Copy link
Copy Markdown
Contributor

❌ Preprod Tests: FAILED

📊 View Detailed Test Report

🔗 Action Run #337

Tests run against preprod network with live blockchain data

@github-actions
Copy link
Copy Markdown
Contributor

✅ Preprod Tests: PASSED

📊 View Detailed Test Report

🔗 Action Run #342

Tests run against preprod network with live blockchain data

@ghost ghost requested review from linconvidal and matiwinnetou May 14, 2026 04:41
@ghost ghost marked this pull request as ready for review May 14, 2026 04:41
@matiwinnetou matiwinnetou modified the milestones: 2.30, 2.3.0 May 27, 2026
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