Commit a39d874e authored by yann300's avatar yann300

ensure data is filled

parent bc14b301
...@@ -243,6 +243,7 @@ module.exports = { ...@@ -243,6 +243,7 @@ module.exports = {
outputTypes.push(fnabi.outputs[i].type) outputTypes.push(fnabi.outputs[i].type)
} }
if (!response.length) response = new Uint8Array(32 * fnabi.outputs.length) // ensuring the data is at least filled by 0 cause `AbiCoder` throws if there's not engouh data
// decode data // decode data
var abiCoder = new ethers.utils.AbiCoder() var abiCoder = new ethers.utils.AbiCoder()
var decodedObj = abiCoder.decode(outputTypes, response) var decodedObj = abiCoder.decode(outputTypes, response)
......
...@@ -325,6 +325,8 @@ class TxListener { ...@@ -325,6 +325,8 @@ class TxListener {
_decodeInputParams (data, abi) { _decodeInputParams (data, abi) {
data = ethJSUtil.toBuffer('0x' + data) data = ethJSUtil.toBuffer('0x' + data)
if (!data.length) data = new Uint8Array(32 * abi.inputs.length) // ensuring the data is at least filled by 0 cause `AbiCoder` throws if there's not engouh data
var inputTypes = [] var inputTypes = []
for (var i = 0; i < abi.inputs.length; i++) { for (var i = 0; i < abi.inputs.length; i++) {
inputTypes.push(abi.inputs[i].type) inputTypes.push(abi.inputs[i].type)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment