fix(docs,test): clarify Memo ABI and lock eth_estimateGas regression#198
fix(docs,test): clarify Memo ABI and lock eth_estimateGas regression#198daveynfts wants to merge 1 commit into
Conversation
|
Good fix — the wrong-selector → empty-revert → misread-as-node-bug chain is exactly the kind of thing that eats hours before the ABI mismatch becomes obvious. The docs and regression tests are a clean solution. A couple of Arc-specific notes from running this pattern in production on Arc Testnet (where USDC is the native gas token at 1. Dual balance deduction when On Arc, the native gas token and USDC ERC-20 share the same address and the same balance. A call like: deducts from 2. Decoding If the USDC import { decodeErrorResult } from 'viem'
try {
await walletClient.writeContract({ /* memo(...) */ })
} catch (err) {
// outer: MemoFailed(bytes)
const outer = decodeErrorResult({ abi: memoAbi, data: err.data })
// outer.args[0] is the raw returnData from the inner USDC call
const inner = decodeErrorResult({ abi: erc20Abi, data: outer.args[0] })
console.log('Inner revert:', inner)
}Without that second decode step the error surfaces as an opaque hex blob, which looks like a precompile issue rather than an ERC-20 revert. Came up building an invoice-repayment flow where the debtor's USDC balance was tight and the gas cost pushed them under the required amount. 3. Minor — viem example:
|
Summary
Closes #189.
Root cause
The original report used a non-existent entry point:
The deployed
Memocontract only implements:A wrong 4-byte selector reverts with empty return data. That makes
eth_estimateGas/eth_callfail with a genericexecution reverted, which is easy to misread as a CallFrom or node simulation bug. With the correct ABI and an EOA asfrom, estimation andeth_callalready succeed (confirmed on Arc Testnet by maintainers and covered by this PR's localdev tests).This is not a protocol change - it documents the canonical ABI, hardens NatSpec, and adds regression tests so the pitfall cannot regress silently.
Changes
docs/transaction-memos.mdREADME.md/contracts/README.mdIMemo.sol/Memo.solcallWithMemo; estimation notestests/localdev/subcall.test.tscontracts/test/memo/Memo.t.solTest plan
Expected:
eth_estimateGassucceeds formemo(address,bytes,bytes32,bytes)eth_callsucceeds for the same calldatacallWithMemo(...string)estimate/call is rejectedcallWithMemoselector !=memoselector (Foundry)Out of scope
Broader
eth_estimateGasflakiness on unrelated USDC/Uniswap paths (if still present) is separate from this Memo ABI pitfall.