File tree Expand file tree Collapse file tree
modules/abstract-eth/src/lib Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { addHexPrefix , toBuffer } from 'ethereumjs-util' ;
22import EthereumAbi from 'ethereumjs-abi' ;
3+ import { ethers } from 'ethers' ;
34
45// ---------------------------------------------------------------------------
56// Constants
@@ -96,8 +97,14 @@ export function buildMulticallDelegationCalldata(
9697 } ) ;
9798
9899 // Encode outer multicall(bytes[])
100+ // ethereumjs-abi v0.6.x has a bug where it omits the per-element offset table
101+ // for bytes[], producing malformed calldata that on-chain ABI decoders reject.
102+ // Use ethers AbiCoder which correctly emits the head offset words.
99103 const outerMethod = EthereumAbi . methodID ( 'multicall' , [ ...aclMulticallTypes ] ) ;
100- const outerArgs = EthereumAbi . rawEncode ( [ ...aclMulticallTypes ] , [ innerCalls ] ) ;
104+ const outerArgs = Buffer . from (
105+ new ethers . utils . AbiCoder ( ) . encode ( [ ...aclMulticallTypes ] , [ innerCalls ] ) . slice ( 2 ) ,
106+ 'hex'
107+ ) ;
101108 return addHexPrefix ( Buffer . concat ( [ outerMethod , outerArgs ] ) . toString ( 'hex' ) ) ;
102109}
103110
You can’t perform that action at this time.
0 commit comments