[sc-150250]: add native token name support to CoinInfo structure and related functions - #4831
Conversation
Summary by OctaneNew ContractsNo new contracts were added. Updated Contracts
🔗 Commit Hash: 56969a5 |
|
This PR touches persistence-sensitive files: Post a comment with one of:
Each token must be accompanied by >=60 chars of reasoning. The reasoning must be fresh — posted or edited at or after the HEAD commit. Why audit evidence is required for Pass / Mitigated: humans don't reliably ask the right BC question on every PR. AI being in the loop is the whole point of this gate. The bot does not judge whether your reasoning is correct — reviewers do, like any other code review. Things worth thinking about: could a previous version have written data this PR's new check would now reject? Was there a partial migration ("regenerate on next user action") that may not have completed for all users? Does this format live in iCloud / Google Drive backup, exported files, or sync payloads? See Changed files (2)
Copy this audit prompt into Claude Code on this branch (or run the
|
There was a problem hiding this comment.
Pull request overview
This PR extends Trust Wallet Core’s coin metadata model by introducing a nativeTokenName field, exposing it via a new public C API (TWCoinTypeConfigurationGetNativeTokenName), and propagating the field through registry data, code generation (legacy + codegen-v2), and generated coin-type tests. This enables distinguishing a chain/coin display name from the chain’s native token name (notably for L2s using ETH).
Changes:
- Added
nativeTokenNameto the internalCoinInfostructure and exposed it viaTWCoinTypeConfigurationGetNativeTokenName. - Updated registry + code generators (Ruby + codegen-v2) to populate
nativeTokenNamewith override + fallback (nativeTokenName → displayName → name). - Updated interface and per-coin chain tests to validate
nativeTokenNamevalues.
Reviewed changes
Copilot reviewed 176 out of 177 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/interface/TWCoinTypeTests.cpp | Adds interface-level tests for native token name defaulting/override. |
| tests/chains/ZkSyncV2/TWCoinTypeTests.cpp | Asserts native token name for zkSync Era. |
| tests/chains/ZkLinkNova/TWCoinTypeTests.cpp | Asserts native token name for zkLink Nova. |
| tests/chains/Zilliqa/TWCoinTypeTests.cpp | Asserts native token name for Zilliqa. |
| tests/chains/ZetaEVM/TWCoinTypeTests.cpp | Asserts native token name for Zeta EVM. |
| tests/chains/ZenEON/TWCoinTypeTests.cpp | Asserts native token name for Zen EON. |
| tests/chains/Zen/TWCoinTypeTests.cpp | Asserts native token name for Zen (Horizen). |
| tests/chains/Zelcash/TWCoinTypeTests.cpp | Asserts native token name for Flux (Zelcash). |
| tests/chains/Zcash/TWCoinTypeTests.cpp | Asserts native token name for Zcash. |
| tests/chains/XRP/TWCoinTypeTests.cpp | Asserts native token name for XRP. |
| tests/chains/xDai/TWCoinTypeTests.cpp | Asserts native token name for xDai/Gnosis Chain. |
| tests/chains/WAX/TWCoinTypeTests.cpp | Asserts native token name for WAX. |
| tests/chains/Waves/TWCoinTypeTests.cpp | Asserts native token name for Waves. |
| tests/chains/Wanchain/TWCoinTypeTests.cpp | Asserts native token name for Wanchain. |
| tests/chains/Viction/TWCoinTypeTests.cpp | Asserts native token name for Viction. |
| tests/chains/Viacoin/TWCoinTypeTests.cpp | Asserts native token name for Viacoin. |
| tests/chains/Verge/TWCoinTypeTests.cpp | Asserts native token name for Verge. |
| tests/chains/VeChain/TWCoinTypeTests.cpp | Asserts native token name for VeChain. |
| tests/chains/Tron/TWCoinTypeTests.cpp | Asserts native token name for Tron. |
| tests/chains/ThunderToken/TWCoinTypeTests.cpp | Asserts native token name for ThunderCore. |
| tests/chains/ThetaFuel/TWCoinTypeTests.cpp | Asserts native token name for Theta Fuel. |
| tests/chains/Theta/TWCoinTypeTests.cpp | Asserts native token name for Theta. |
| tests/chains/TheOpenNetwork/TWCoinTypeTests.cpp | Asserts native token name for TON (“Gram”). |
| tests/chains/Tezos/TWCoinTypeTests.cpp | Asserts native token name for Tezos. |
| tests/chains/TBinance/TWCoinTypeTests.cpp | Asserts native token name for Binance testnet coin type. |
| tests/chains/Syscoin/TWCoinTypeTests.cpp | Asserts native token name for Syscoin. |
| tests/chains/Sui/TWCoinTypeTests.cpp | Asserts native token name for Sui. |
| tests/chains/Stratis/TWCoinTypeTests.cpp | Asserts native token name for Stratis. |
| tests/chains/Stellar/TWCoinTypeTests.cpp | Asserts native token name for Stellar. |
| tests/chains/Sonic/TWCoinTypeTests.cpp | Asserts native token name for Sonic. |
| tests/chains/Solana/TWCoinTypeTests.cpp | Asserts native token name for Solana. |
| tests/chains/SmartBitcoinCash/TWCoinTypeTests.cpp | Asserts native token name for SmartBCH. |
| tests/chains/SeiEVM/TWCoinTypeTests.cpp | Asserts native token name for Sei EVM. |
| tests/chains/Scroll/TWCoinTypeTests.cpp | Asserts native token name for Scroll (Ethereum). |
| tests/chains/Rootstock/TWCoinTypeTests.cpp | Asserts native token name for Rootstock. |
| tests/chains/Ronin/TWCoinTypeTests.cpp | Asserts native token name for Ronin. |
| tests/chains/RobinhoodChain/TWCoinTypeTests.cpp | Asserts native token name for Robinhood Chain (Ethereum). |
| tests/chains/Ravencoin/TWCoinTypeTests.cpp | Asserts native token name for Ravencoin. |
| tests/chains/Qtum/TWCoinTypeTests.cpp | Asserts native token name for Qtum. |
| tests/chains/Polymesh/TWCoinTypeTests.cpp | Asserts native token name for Polymesh. |
| tests/chains/PolygonZkEvm/TWCoinTypeTests.cpp | Asserts native token name for Polygon zkEVM (Ethereum). |
| tests/chains/Polygon/TWCoinTypeTests.cpp | Asserts native token name for Polygon. |
| tests/chains/Polkadot/TWCoinTypeTests.cpp | Asserts native token name for Polkadot. |
| tests/chains/POANetwork/TWCoinTypeTests.cpp | Asserts native token name for POA Network. |
| tests/chains/Plasma/TWCoinTypeTests.cpp | Asserts native token name for Plasma. |
| tests/chains/Pivx/TWCoinTypeTests.cpp | Asserts native token name for Pivx. |
| tests/chains/Pactus/CoinTypeTests.cpp | Asserts native token name for Pactus. |
| tests/chains/Optimism/TWCoinTypeTests.cpp | Asserts native token name for Optimism (Ethereum). |
| tests/chains/OpBNBtestnet/TWCoinTypeTests.cpp | Asserts native token name for OpBNB testnet (BNB). |
| tests/chains/Ontology/TWCoinTypeTests.cpp | Asserts native token name for Ontology. |
| tests/chains/OKXChain/TWCoinTypeTests.cpp | Asserts native token name for OKX Chain. |
| tests/chains/Oasis/TWCoinTypeTests.cpp | Asserts native token name for Oasis. |
| tests/chains/NULS/TWCoinTypeTests.cpp | Asserts native token name for NULS. |
| tests/chains/Nimiq/TWCoinTypeTests.cpp | Asserts native token name for Nimiq. |
| tests/chains/Nervos/TWCoinTypeTests.cpp | Asserts native token name for Nervos (“Nervos Network”). |
| tests/chains/Neon/TWCoinTypeTests.cpp | Asserts native token name for Neon. |
| tests/chains/NEO/TWCoinTypeTests.cpp | Asserts native token name for NEO. |
| tests/chains/Nebulas/TWCoinTypeTests.cpp | Asserts native token name for Nebulas. |
| tests/chains/Nebl/TWCoinTypeTests.cpp | Asserts native token name for Nebl (“Neblio”). |
| tests/chains/NEAR/TWCoinTypeTests.cpp | Asserts native token name for NEAR. |
| tests/chains/NativeZetaChain/TWCoinTypeTests.cpp | Asserts native token name for NativeZetaChain (“ZetaChain”). |
| tests/chains/Nano/TWCoinTypeTests.cpp | Asserts native token name for Nano. |
| tests/chains/MultiversX/TWCoinTypeTests.cpp | Asserts native token name for MultiversX. |
| tests/chains/Moonriver/TWCoinTypeTests.cpp | Asserts native token name for Moonriver. |
| tests/chains/Moonbeam/TWCoinTypeTests.cpp | Asserts native token name for Moonbeam. |
| tests/chains/Monad/TWCoinTypeTests.cpp | Asserts native token name for Monad. |
| tests/chains/Monacoin/TWCoinTypeTests.cpp | Asserts native token name for Monacoin. |
| tests/chains/Metis/TWCoinTypeTests.cpp | Asserts native token name for Metis. |
| tests/chains/Meter/TWCoinTypeTests.cpp | Asserts native token name for Meter. |
| tests/chains/Merlin/TWCoinTypeTests.cpp | Asserts native token name for Merlin. |
| tests/chains/MegaETH/TWCoinTypeTests.cpp | Asserts native token name for MegaETH. |
| tests/chains/Mantle/TWCoinTypeTests.cpp | Asserts native token name for Mantle. |
| tests/chains/MantaPacific/TWCoinTypeTests.cpp | Asserts native token name for Manta Pacific (Ethereum). |
| tests/chains/Litecoin/TWCoinTypeTests.cpp | Asserts native token name for Litecoin. |
| tests/chains/Linea/TWCoinTypeTests.cpp | Asserts native token name for Linea (Ethereum). |
| tests/chains/Lightlink/TWCoinTypeTests.cpp | Asserts native token name for Lightlink Phoenix. |
| tests/chains/Kusama/TWCoinTypeTests.cpp | Asserts native token name for Kusama. |
| tests/chains/KuCoinCommunityChain/TWCoinTypeTests.cpp | Asserts native token name for KCC (“KuCoin Token”). |
| tests/chains/Komodo/TWCoinTypeTests.cpp | Asserts native token name for Komodo. |
| tests/chains/Klaytn/TWCoinTypeTests.cpp | Asserts native token name for Kaia. |
| tests/chains/Kin/TWCoinTypeTests.cpp | Asserts native token name for Kin. |
| tests/chains/KavaEvm/TWCoinTypeTests.cpp | Asserts native token name for KavaEvm (“Kava”). |
| tests/chains/IoTeX/TWCoinTypeTests.cpp | Asserts native token name for IoTeX. |
| tests/chains/IOST/TWCoinTypeTests.cpp | Asserts native token name for IOST. |
| tests/chains/InternetComputer/TWCoinTypeTests.cpp | Asserts native token name for Internet Computer. |
| tests/chains/ICON/TWCoinTypeTests.cpp | Asserts native token name for ICON. |
| tests/chains/HyperEVM/TWCoinTypeTests.cpp | Asserts native token name for HyperEVM (“Hyperliquid”). |
| tests/chains/Hedera/TWCoinTypeTests.cpp | Asserts native token name for Hedera. |
| tests/chains/Harmony/TWCoinTypeTests.cpp | Asserts native token name for Harmony. |
| tests/chains/Groestlcoin/TWCoinTypeTests.cpp | Asserts native token name for Groestlcoin. |
| tests/chains/Greenfield/TWCoinTypeTests.cpp | Asserts native token name for Greenfield (BNB). |
| tests/chains/GoChain/TWCoinTypeTests.cpp | Asserts native token name for GoChain. |
| tests/chains/Firo/TWCoinTypeTests.cpp | Asserts native token name for Firo. |
| tests/chains/FIO/TWCoinTypeTests.cpp | Asserts native token name for FIO. |
| tests/chains/Filecoin/TWCoinTypeTests.cpp | Asserts native token name for Filecoin. |
| tests/chains/Fantom/TWCoinTypeTests.cpp | Asserts native token name for Fantom. |
| tests/chains/Evmos/TWCoinTypeTests.cpp | Asserts native token name for Evmos. |
| tests/chains/Everscale/TWCoinTypeTests.cpp | Asserts native token name for Everscale. |
| tests/chains/EthereumClassic/TWCoinTypeTests.cpp | Asserts native token name for Ethereum Classic. |
| tests/chains/Ethereum/TWCoinTypeTests.cpp | Asserts native token name for Ethereum. |
| tests/chains/EOS/TWCoinTypeTests.cpp | Asserts native token name for EOS. |
| tests/chains/ECO/TWCoinTypeTests.cpp | Asserts native token name for Huobi ECO Chain. |
| tests/chains/ECash/TWCoinTypeTests.cpp | Asserts native token name for eCash. |
| tests/chains/Dydx/TWCoinTypeTests.cpp | Asserts native token name for dYdX. |
| tests/chains/Dogecoin/TWCoinTypeTests.cpp | Asserts native token name for Dogecoin. |
| tests/chains/DigiByte/TWCoinTypeTests.cpp | Asserts native token name for DigiByte. |
| tests/chains/Decred/TWCoinTypeTests.cpp | Asserts native token name for Decred. |
| tests/chains/Dash/TWCoinTypeTests.cpp | Asserts native token name for Dash. |
| tests/chains/Cronos/TWCoinTypeTests.cpp | Asserts native token name for Cronos Chain. |
| tests/chains/Cosmos/Umee/TWCoinTypeTests.cpp | Asserts native token name for Umee. |
| tests/chains/Cosmos/TWCoinTypeTests.cpp | Asserts native token name for Cosmos Hub (“Cosmos”). |
| tests/chains/Cosmos/Tia/TWCoinTypeTests.cpp | Asserts native token name for Celestia. |
| tests/chains/Cosmos/THORChain/TWCoinTypeTests.cpp | Asserts native token name for THORChain. |
| tests/chains/Cosmos/TerraV2/TWCoinTypeTests.cpp | Asserts native token name for Terra v2. |
| tests/chains/Cosmos/Terra/TWCoinTypeTests.cpp | Asserts native token name for Terra Classic. |
| tests/chains/Cosmos/Stride/TWCoinTypeTests.cpp | Asserts native token name for Stride. |
| tests/chains/Cosmos/Sommelier/TWCoinTypeTests.cpp | Asserts native token name for Sommelier. |
| tests/chains/Cosmos/Sei/TWCoinTypeTests.cpp | Asserts native token name for Sei. |
| tests/chains/Cosmos/Secret/TWCoinTypeTests.cpp | Asserts native token name for Secret Network. |
| tests/chains/Cosmos/Quasar/TWCoinTypeTests.cpp | Asserts native token name for Quasar. |
| tests/chains/Cosmos/Persistence/TWCoinTypeTests.cpp | Asserts native token name for Persistence. |
| tests/chains/Cosmos/Osmosis/TWCoinTypeTests.cpp | Asserts native token name for Osmosis. |
| tests/chains/Cosmos/Noble/TWCoinTypeTests.cpp | Asserts native token name for Noble. |
| tests/chains/Cosmos/Neutron/TWCoinTypeTests.cpp | Asserts native token name for Neutron. |
| tests/chains/Cosmos/NativeInjective/TWCoinTypeTests.cpp | Asserts native token name for Native Injective (“Injective”). |
| tests/chains/Cosmos/NativeEvmos/TWCoinTypeTests.cpp | Asserts native token name for Native Evmos (“Evmos”). |
| tests/chains/Cosmos/NativeCanto/TWCoinTypeTests.cpp | Asserts native token name for Native Canto (“Canto”). |
| tests/chains/Cosmos/Mars/TWCoinTypeTests.cpp | Asserts native token name for Mars Hub. |
| tests/chains/Cosmos/Kujira/TWCoinTypeTests.cpp | Asserts native token name for Kujira. |
| tests/chains/Cosmos/Kava/TWCoinTypeTests.cpp | Asserts native token name for Kava. |
| tests/chains/Cosmos/Juno/TWCoinTypeTests.cpp | Asserts native token name for Juno. |
| tests/chains/Cosmos/FetchAI/TWCoinTypeTests.cpp | Asserts native token name for FetchAI (“Fetch.ai”). |
| tests/chains/Cosmos/CryptoOrg/TWCoinTypeTests.cpp | Asserts native token name for Crypto.org (“Cronos”). |
| tests/chains/Cosmos/Crescent/TWCoinTypeTests.cpp | Asserts native token name for Crescent. |
| tests/chains/Cosmos/Coreum/TWCoinTypeTests.cpp | Asserts native token name for Coreum. |
| tests/chains/Cosmos/Comdex/TWCoinTypeTests.cpp | Asserts native token name for Comdex. |
| tests/chains/Cosmos/Bluzelle/TWCoinTypeTests.cpp | Asserts native token name for Bluzelle. |
| tests/chains/Cosmos/BandChain/TWCoinTypeTests.cpp | Asserts native token name for BandChain (“Band Protocol”). |
| tests/chains/Cosmos/Axelar/TWCoinTypeTests.cpp | Asserts native token name for Axelar. |
| tests/chains/Cosmos/Akash/TWCoinTypeTests.cpp | Asserts native token name for Akash. |
| tests/chains/Cosmos/Agoric/TWCoinTypeTests.cpp | Asserts native token name for Agoric. |
| tests/chains/ConfluxeSpace/TWCoinTypeTests.cpp | Asserts native token name for Conflux eSpace (“Conflux”). |
| tests/chains/Celo/TWCoinTypeTests.cpp | Asserts native token name for Celo. |
| tests/chains/Cardano/TWCoinTypeTests.cpp | Asserts native token name for Cardano. |
| tests/chains/Callisto/TWCoinTypeTests.cpp | Asserts native token name for Callisto (“Callisto Network”). |
| tests/chains/BounceBit/TWCoinTypeTests.cpp | Asserts native token name for BounceBit. |
| tests/chains/Boba/TWCoinTypeTests.cpp | Asserts native token name for Boba. |
| tests/chains/Blast/TWCoinTypeTests.cpp | Asserts native token name for Blast (Ethereum). |
| tests/chains/BitcoinGold/TWCoinTypeTests.cpp | Asserts native token name for Bitcoin Gold. |
| tests/chains/BitcoinDiamond/TWCoinTypeTests.cpp | Asserts native token name for Bitcoin Diamond. |
| tests/chains/BitcoinCash/TWCoinTypeTests.cpp | Asserts native token name for Bitcoin Cash. |
| tests/chains/Bitcoin/TWCoinTypeTests.cpp | Asserts native token name for Bitcoin. |
| tests/chains/BinanceSmartChain/TWCoinTypeTests.cpp | Asserts native token name for BNB Smart Chain + legacy (BNB). |
| tests/chains/Binance/TWCoinTypeTests.cpp | Asserts native token name for BNB Beacon Chain (BNB). |
| tests/chains/Base/TWCoinTypeTests.cpp | Asserts native token name for Base (Ethereum). |
| tests/chains/Avalanche/TWCoinTypeTests.cpp | Asserts native token name for Avalanche C-Chain (“Avalanche”). |
| tests/chains/Aurora/TWCoinTypeTests.cpp | Asserts native token name for Aurora (Ethereum). |
| tests/chains/ArbitrumNova/TWCoinTypeTests.cpp | Asserts native token name for Arbitrum Nova (Ethereum). |
| tests/chains/Arbitrum/TWCoinTypeTests.cpp | Asserts native token name for Arbitrum (Ethereum). |
| tests/chains/Aptos/TWCoinTypeTests.cpp | Asserts native token name for Aptos. |
| tests/chains/Algorand/TWCoinTypeTests.cpp | Asserts native token name for Algorand. |
| tests/chains/Aion/TWCoinTypeTests.cpp | Asserts native token name for Aion. |
| tests/chains/Aeternity/TWCoinTypeTests.cpp | Asserts native token name for Aeternity. |
| tests/chains/AcalaEVM/TWCoinTypeTests.cpp | Asserts native token name for Acala EVM (“Acala”). |
| tests/chains/Acala/TWCoinTypeTests.cpp | Asserts native token name for Acala. |
| src/Coin.h | Extends CoinInfo with nativeTokenName. |
| src/Coin.cpp | Adds TWCoinTypeConfigurationGetNativeTokenName implementation. |
| registry.json | Adds nativeTokenName entries for many coins. |
| include/TrustWalletCore/TWCoinTypeConfiguration.h | Adds public C API declaration + docs for native token name. |
| codegen/lib/templates/TWCoinTypeTests.cpp.erb | Updates legacy test template to validate native token name. |
| codegen/lib/templates/CoinInfoData.cpp.erb | Updates legacy coin info template to emit native token name field. |
| codegen/lib/coin_test_gen.rb | Adds Ruby helper for nativeTokenName fallback generation. |
| codegen/bin/coins | Adds Ruby helper for nativeTokenName fallback generation. |
| codegen-v2/src/registry.rs | Extends CoinItem with nativeTokenName registry field. |
| codegen-v2/src/codegen/template_generator.rs | Adds {NATIVE_TOKEN_NAME} substitution with fallback chain. |
| codegen-v2/src/codegen/cpp/templates/TWCoinTypeTests.cpp | Updates codegen-v2 C++ tests template to assert native token name. |
| codegen-v2/manifest/TWCoinTypeConfiguration.yaml | Exposes TWCoinTypeConfigurationGetNativeTokenName in the API manifest for bindings/codegen. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Binary size comparison➡️ aarch64-apple-ios: - 14.31 MB
+ 14.31 MB +2 KB➡️ aarch64-apple-ios-sim: - 14.31 MB
+ 14.31 MB +2 KB➡️ aarch64-linux-android: - 18.73 MB
+ 18.73 MB +1 KB➡️ armv7-linux-androideabi: - 16.17 MB
+ 16.17 MB +1 KB➡️ wasm32-unknown-emscripten: - 13.66 MB
+ 13.66 MB +1 KB |
|
[bc-check: Pass] BC-risk audit — feat/native-token-name → master @ 56969a5 — 2026-07-27T08:47:25ZVerdict: SAFE This PR adds a new optional |
Overview
Detailed findings
|
|
❌ The last analysis has failed. |
This pull request adds support for a new
nativeTokenNamefield for coins, updates the registry data to include this field for many coins, and updates the code generation and tests to use and validate this field. This makes it possible to distinguish the native token name from the coin or chain name, which is especially useful for chains that use the same token (like Ethereum-based L2s).Registry and Data Model Updates:
nativeTokenNamefield to the coin registry data model (CoinItemincodegen-v2/src/registry.rs) and populated this field for many coins inregistry.json.API and Functionality:
TWCoinTypeConfigurationGetNativeTokenNamein the manifest and header files to retrieve the native token name for a coin.Code Generation and Templates:
nativeTokenNamefield, and to fall back to display name or name if not specified. This affects C++ code generation and test templates.Tests:
These changes ensure that the native token name is consistently available and validated across the codebase and registry.