Skip to content

feat(coins): Add TRON and TRC20 support#316

Merged
CharlVS merged 3 commits intodevfrom
codex/tron-support
Mar 18, 2026
Merged

feat(coins): Add TRON and TRC20 support#316
CharlVS merged 3 commits intodevfrom
codex/tron-support

Conversation

@CharlVS
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS commented Mar 18, 2026

Summary

  • add first-class TRX and TRC20 protocol support in komodo_defi_types
  • reuse the ETH activation namespace for TRON while sending TRON-specific activation params and parsing TRON fee/details correctly
  • add TRON/TRC20 coverage in activation strategies, withdraw serialization, fee parsing, legacy activation response parsing, and targeted tests

Details

  • add dedicated TrxProtocol and Trc20Protocol classes and protocol-type resolution that prefers protocol.type over the legacy top-level type
  • add CoinSubClass.trx and CoinSubClass.trc20, update parent-child handling, and keep TRON out of EVM-specific capability buckets
  • add TrxWithTokensActivationParams and Trc20ActivationParams, generalize ERC20 request surfaces to accept TRC20 protocol payloads, and support withdraw.expiration_seconds
  • add FeeInfoTron plus UI display support and preserve native TRX balances when parsing the docs-style legacy eth_addresses_infos / erc20_addresses_infos response shape
  • fix batch-activation capability detection so TRX parent activation correctly covers child token activation

Validation

  • flutter test in packages/komodo_defi_types
  • flutter test in packages/komodo_defi_rpc_methods
  • flutter test test/activation/tron_activation_strategy_test.dart in packages/komodo_defi_sdk
  • flutter build web in /Users/charl/Code/UTXO/gleec-wallet-dev/sdk/packages/komodo_defi_sdk/example
  • flutter build web in /Users/charl/Code/UTXO/gleec-wallet-dev

@CharlVS CharlVS changed the title Add TRON and TRC20 support feat(coins): Add TRON and TRC20 support Mar 18, 2026
@CharlVS
Copy link
Copy Markdown
Collaborator Author

CharlVS commented Mar 18, 2026

@codex

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

Visit the preview URL for this PR (updated for commit a93a934):

https://komodo-playground--pr316-codex-tron-support-mrwh0zpn.web.app

(expires Wed, 25 Mar 2026 15:06:08 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2bfedd77fdea45b25ba7c784416e81f177aa5c47

Copy link
Copy Markdown
Collaborator Author

@CharlVS CharlVS left a comment

Choose a reason for hiding this comment

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

I did a pass on this against the existing SDK/types conventions and the main thing I would fix before merge is the legacy wallet-balance fallback.

  1. In packages/komodo_defi_rpc_methods/lib/src/rpc_methods/eth/enable_eth_with_tokens.dart, WalletBalance.fromLegacyAddressInfos() / WalletAddress.fromLegacyJson() only reconstruct balances from balances. The repo fixtures in playground/assets/komodo_defi.postman_collection.json also contain legacy erc20_addresses_infos entries that have only tickers and no balances (for example the BNB/MATIC responses). With the new fallback path, those enabled zero-balance tokens would disappear from the synthesized wallet_balance instead of being preserved as activated assets. Since this PR explicitly aims to preserve the docs-style legacy response shape, I think this should synthesize zero balances from tickers too, and add a regression test for that case.

  2. The new protocol.type precedence looks right for TRON, but it now changes parsing semantics across shared codepaths: AssetId.parse, ProtocolClass.fromJson, and the protocol constructors. The current regression coverage is TRX/TRC20-specific. I would add a couple non-TRON cases here as well so we know we did not accidentally change parsing behavior for existing configs while fixing the TRON shape.

  3. In packages/komodo_defi_sdk/lib/src/activation/protocol_strategies/eth_task_activation_strategy.dart, activation progress still reports node count via protocol.requiredServers.electrum?.length ?? 0. For TRX/EVM-style configs that means the progress metadata/UI will report 0 nodes even when nodes is populated. Not merge-blocking, but worth cleaning up while this path is open.

Aside from those points, the overall layering and strategy reuse are aligned with the existing repo structure.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad37ab2fef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/komodo_defi_types/lib/src/transactions/fee_info.dart
@CharlVS CharlVS merged commit cd5b45d into dev Mar 18, 2026
2 of 4 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a93a93452c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

required ActivationParams activationParams,
required String platform,
required String contractAddress,
String protocolType = 'ERC20',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Default TRC20 custom activations to the TRC20 protocol

For callers who use client.rpc.erc20.enableCustomErc20Token(...) directly to add a custom TRC20 asset, this helper still defaults protocolType to ERC20. Unless they discover and override the extra string manually, the request serializes "protocol": {"type": "ERC20"} even when the rest of the payload is TRON-specific, so the new TRC20 support only works through CustomErc20ActivationStrategy and not through the public RPC namespace.

Useful? React with 👍 / 👎.

Comment on lines +26 to +28
JsonMap toRpcParams() => super.toRpcParams().deepMerge({
'nodes': nodes.map((e) => e.toJson()).toList(),
'priv_key_policy': privKeyPolicy?.toJson(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Serialize a concrete priv_key_policy for custom TRC20 params

The new custom-TRC20 flow reaches Trc20ActivationParams.fromJsonConfig(...) without ever setting privKeyPolicy, and this serializer then overwrites the base default with "priv_key_policy": null. That means custom TRC20 activation requests can carry an invalid tagged-union value instead of the documented ContextPrivKey object, which is likely to make the headline custom-token path fail against stricter KDF builds.

Useful? React with 👍 / 👎.

CharlVS added a commit that referenced this pull request Apr 1, 2026
* feat(sdk): add TRON and TRC20 support

* chore(sdk): remove generated whitespace

* fix(sdk): align config parsing and KDF compatibility
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