feat: add Tron chain support to lintent.org#49
Conversation
New files: - tronExecution.ts: open escrow, approve tokens, get block timestamp - tronSolver.ts: fill outputs, claim, validate proofs, read state - chainType.ts: isTronChain / isEvmChain helpers - tronlink.ts: TronLink connection utilities - WalletStatus.svelte: wallet status component - tronSupport.test.ts: unit tests for chain type utilities Bug fixes: - solver.ts: use eth_getBlockByNumber instead of eth_getBlockByHash (blockByHash is unreliable on many public RPCs); add Tron-aware fill timestamp path for EVM->Tron outputs Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- config.ts: add Tron chain config, TRON_MAINNET_INPUT/OUTPUT_SETTLER - app.d.ts: add TronWeb type declarations - state.svelte.ts: add TronLink account tracking, accountForChain() - intentFactory.ts: use intent.inputSettler (not store.inputSettler) to correctly save TRON_MAINNET_INPUT_SETTLER for Tron source intents - flowProgress.ts: add Tron branch in isInputChainFinalised() - intentExecution.ts: route Tron source intents to openTronEscrowIntent - ConnectWallet.svelte: show TronLink connect option - FillIntent.svelte: Tron-aware isFilled() via readTronFillRecord - ReceiveMessage.svelte: Tron-aware receipt/timestamp in isValidated() - Finalise.svelte: handle Tron source chain claim - IssueIntent.svelte: handle Tron input token approval/open - +page.svelte: guard account() for disconnected TronLink - FlowStepTracker.svelte: display Tron chain steps - intent.ts: containerToIntent dispatches to Tron intent type - vite.config.ts: add TronLink global polyfill Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Switches from local file: reference to the published npm package. 0.1.2 fixes Polymer oracle resolution for Tron->EVM intents (output.oracle now resolves from the input chain, not the output chain). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
tronExecution.ts was missing getTronBlockTimestamp (needed by solver.ts and ReceiveMessage.svelte for Tron fill timestamp lookups). Also fixes orderToTronTuple to convert user and inputOracle to Tron base58 format — TronLink encodes address-typed fields incorrectly when given 0x hex. app.d.ts: add TronWeb.trx.getBlock type declaration. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR performs a major architectural migration from a local intent library and chain-name-based configuration to ChangesIntent Library Migration & Configuration
Svelte Components & UI
🎯 4 (Complex) | ⏱️ ~75 minutes
✨ Finishing Touches🧪 Generate unit tests (beta)
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🚀 Preview deployed! Worker: |
…-lintentorg # Conflicts: # src/lib/config.ts
|
🚀 Preview deployed! Worker: |
getClient() throws for Tron chainId (not in clientsById), causing getOrderProgressChecks to always return all-false for any Tron-involved order. Add Tron-specific branches in isOutputFilled, isOutputValidatedOnChain, and isInputChainFinalised using TronWeb helpers instead of viem. Add readTronIsOutputFilled and getTronTransactionFrom to tronSolver.ts, and declare getTransaction on the TronWeb.trx type stub in app.d.ts. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed! Worker: |
readTronOrderStatus hits TronGrid (api.trongrid.io) without an API key and gets 429 on the first call. The catch handler previously discarded the error leaving claimedByChain[chainId] as undefined, which rendered the greyed "Finalise" placeholder instead of the active "Claim" button. - Cache the Tron orderStatus call via getOrFetchRpc (30s TTL) to avoid hammering TronGrid on repeated polls - On any error, set claimedByChain[chainId] = false so the button falls through to the active Claim path instead of staying in the loading state Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed! Worker: |
Add 15s error backoff to rpcCache so 429 failures don't immediately retry and create a thundering herd. Also use 2min/3min TTLs for Tron balance/allowance checks instead of 30s/60s to reduce request frequency against api.trongrid.io's rate-limited public endpoint. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
|
||
| const cache = new Map<string, CacheEntry<unknown>>(); | ||
| const inflight = new Map<string, Promise<unknown>>(); | ||
| const errorBackoff = new Map<string, number>(); // key -> backoff expiry timestamp |
There was a problem hiding this comment.
Module-level Map errorBackoff stores per-RPC backoff state across requests; consider scoping it to an explicit cache service or making its lifetime/request-scope explicit to avoid unintended cross-request state.
Details
✨ AI Reasoning
A new in-memory Map named errorBackoff is defined at module scope and used to track per-RPC backoff state. Module-scope Maps persist for the lifetime of the process and can unintentionally retain request-specific or caller-specific state across requests, leading to data leakage and cross-request interference. This was introduced in the recent changes and increases global caching beyond the existing cache and inflight maps.
🔧 How do I fix it?
Avoid storing request-specific data in module-level variables. Use request-scoped variables or explicitly mark shared caches as intentional.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
|
🚀 Preview deployed! Worker: |
|
🚀 Preview deployed! Worker: |
Summary
tronSolver.tsandtronExecution.tsfor Tron-specific order handling, along withtronlink.tsutilities and chain-type helpers@lifi/intentto 0.1.2as anycasts, adds new unit and e2e tests (Tron support, wallet client switching, recipient field, order validation)Test plan
bun test— all unit tests pass including new Tron testsescrow-standard-blackbox,escrow-standard-live)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Chores