fix(hyperliquid-composer): validate evmExtraWeiDecimals before requestEvmContract#1940
fix(hyperliquid-composer): validate evmExtraWeiDecimals before requestEvmContract#1940imfeng wants to merge 2 commits intoLayerZero-Labs:mainfrom
Conversation
…n EVM connection process - Added retrieval of ERC20 ABI and on-chain decimals to validate weiDiff. - Introduced user prompt to confirm using on-chain derived weiDiff if discrepancies are found. - Updated writeUpdatedCoreSpotDeployment to ensure weiDiff is set before proceeding.
PR SummaryMedium Risk Overview Updates the confirmation prompt to explicitly display the Written by Cursor Bugbot for commit cea8e56. This will update automatically on new commits. Configure here. |
…maintain weiDiff integrity - Wrapped the on-chain decimals retrieval in a try-catch block to handle potential errors gracefully. - Added logging to warn when on-chain decimals fetching fails, ensuring the process continues with the stored weiDiff value.
Motivation
request-evm-contractreadstxData.weiDifffrom the local deployment JSON and submits it asevmExtraWeiDecimalswithout any validation. If the deployment file is stale, manually edited, or generated by an older CLI version, the wrong value gets submitted. Oncefinalize-evm-contractis called, this value is permanently locked on-chain.This has already caused real-world damage: token index 1825 on Hyperliquid testnet was permanently locked with
evm_extra_wei_decimals=0instead of the correct value11(ERC20 decimals(18) - weiDecimals(7)). The token had to be abandoned and redeployed.Additionally,
writeUpdatedCoreSpotDeploymentsilently falls back to0whenweiDiffisnull/undefined, masking configuration errors.Changes
1. On-chain cross-validation in
requestEvmContract(link-evm-core.ts)Before submitting, the CLI now:
decimals()from the ERC20 contract on-chainonChainDecimals - coreSpot.weiDecimalstxData.weiDiffdoes not match, warns the user with full details and prompts to use the on-chain derived valuefinalize-evm-contractalso uses it2. Display
evmExtraWeiDecimalsin confirmation prompt (link-evm-core.ts)The confirmation prompt now shows the exact
evmExtraWeiDecimalsvalue being submitted and warns that it becomes irreversible after finalization:3. Remove silent fallback to 0 (
parser.ts)writeUpdatedCoreSpotDeploymentpreviously usedtxData.weiDiff ?? 0, silently writingevm_extra_wei_decimals: 0whenweiDiffwas missing. This is now replaced with an explicit error:Files Changed
packages/hyperliquid-composer/src/commands/link-evm-core.tspackages/hyperliquid-composer/src/io/parser.ts?? 0fallback with explicit null-check error