From 3e9e301e8e2338d76980a0fd196d53a59b09b9a0 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Mon, 18 May 2020 11:16:38 -0700 Subject: [PATCH 1/2] Debug mosaic: no bitwidth correction --- packages/web3-eth-abi/src/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/web3-eth-abi/src/index.js b/packages/web3-eth-abi/src/index.js index 382b461d2d4..19655876654 100644 --- a/packages/web3-eth-abi/src/index.js +++ b/packages/web3-eth-abi/src/index.js @@ -118,22 +118,22 @@ ABICoder.prototype.encodeParameters = function (types, params) { // Handle some formatting of params for backwards compatability with Ethers V4 const formatParam = (type, param) => { - if (type.match(paramTypeBytesArray) || type.match(paramTypeNumberArray)) { + if (type.match(paramTypeBytesArray)) { return param.map(p => formatParam(type.replace('[]', ''), p)) } // Format correct width for u?int[0-9]* - let match = type.match(paramTypeNumber); + /*let match = type.match(paramTypeNumber); if (match) { let size = parseInt(match[2] || "256"); if (size / 8 < param.length) { // pad to correct bit width param = utils.leftPad(param, size); } - } + }*/ // Format correct length for bytes[0-9]+ - match = type.match(paramTypeBytes); + let match = type.match(paramTypeBytes); if (match) { if (Buffer.isBuffer(param)) { param = utils.toHex(param); @@ -151,9 +151,9 @@ ABICoder.prototype.encodeParameters = function (types, params) { param = utils.rightPad(param, size * 2) } } - + // format odd-length bytes to even-length - if (param.length % 2 === 1) { + if (param.length % 2 === 1) { param = '0x0' + param.substring(2) } } From f5e1c14af527bc79a612a460b1e4a4077a637c61 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Mon, 18 May 2020 11:53:57 -0700 Subject: [PATCH 2/2] Revert all changes --- packages/web3-eth-abi/src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/web3-eth-abi/src/index.js b/packages/web3-eth-abi/src/index.js index 19655876654..90dce3f5e54 100644 --- a/packages/web3-eth-abi/src/index.js +++ b/packages/web3-eth-abi/src/index.js @@ -118,22 +118,22 @@ ABICoder.prototype.encodeParameters = function (types, params) { // Handle some formatting of params for backwards compatability with Ethers V4 const formatParam = (type, param) => { - if (type.match(paramTypeBytesArray)) { + if (type.match(paramTypeBytesArray) || type.match(paramTypeNumberArray)) { return param.map(p => formatParam(type.replace('[]', ''), p)) } // Format correct width for u?int[0-9]* - /*let match = type.match(paramTypeNumber); + let match = type.match(paramTypeNumber); if (match) { let size = parseInt(match[2] || "256"); if (size / 8 < param.length) { // pad to correct bit width param = utils.leftPad(param, size); } - }*/ + } // Format correct length for bytes[0-9]+ - let match = type.match(paramTypeBytes); + match = type.match(paramTypeBytes); if (match) { if (Buffer.isBuffer(param)) { param = utils.toHex(param);