Skip to content

Commit f668841

Browse files
fix(abstract-eth): update abi encoding for zama tx
TICKET: CHALO-472
1 parent 5995969 commit f668841

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

modules/abstract-eth/src/lib/zamaUtils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { addHexPrefix, toBuffer } from 'ethereumjs-util';
22
import 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

0 commit comments

Comments
 (0)