From f668841ab940bccfb0352872d711da4f31fd8fe1 Mon Sep 17 00:00:00 2001 From: Mohammed Ryaan Date: Thu, 21 May 2026 16:58:31 +0530 Subject: [PATCH] fix(abstract-eth): update abi encoding for zama tx TICKET: CHALO-472 --- modules/abstract-eth/src/lib/zamaUtils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/abstract-eth/src/lib/zamaUtils.ts b/modules/abstract-eth/src/lib/zamaUtils.ts index 40deec0a58..30055d4e56 100644 --- a/modules/abstract-eth/src/lib/zamaUtils.ts +++ b/modules/abstract-eth/src/lib/zamaUtils.ts @@ -1,5 +1,6 @@ import { addHexPrefix, toBuffer } from 'ethereumjs-util'; import EthereumAbi from 'ethereumjs-abi'; +import { ethers } from 'ethers'; // --------------------------------------------------------------------------- // Constants @@ -96,8 +97,14 @@ export function buildMulticallDelegationCalldata( }); // Encode outer multicall(bytes[]) + // ethereumjs-abi v0.6.x has a bug where it omits the per-element offset table + // for bytes[], producing malformed calldata that on-chain ABI decoders reject. + // Use ethers AbiCoder which correctly emits the head offset words. const outerMethod = EthereumAbi.methodID('multicall', [...aclMulticallTypes]); - const outerArgs = EthereumAbi.rawEncode([...aclMulticallTypes], [innerCalls]); + const outerArgs = Buffer.from( + new ethers.utils.AbiCoder().encode([...aclMulticallTypes], [innerCalls]).slice(2), + 'hex' + ); return addHexPrefix(Buffer.concat([outerMethod, outerArgs]).toString('hex')); }