This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
coder decodeParams with empty string leads to BigNumber error #231
Labels
Bug
Addressing a bug
Comments
@debris i'm not 100% sure about this but the following code could fix it, can you take a look: SolidityType.prototype.formatOutput = function (param, arrayType) {
if (arrayType) {
// let's assume, that we solidity will never return long arrays :P
var result = [];
var paramSlice = param.dynamicPart().slice(0, 64);
var length = (paramSlice !== '') ? new BigNumber(paramSlice, 16) : 0; // <<---
for (var i = 0; i < length * 64; i += 64) {
result.push(this._outputFormatter(new SolidityParam(param.dynamicPart().substr(i + 64, 64))));
}
return result;
}
return this._outputFormatter(param);
}; |
this error probably occurred, cause empty array was not properly formatted by geth/cpp/python. There is a test for it here. I've checked how empty array is being returned in latest geth (0.9.39) and it's working as expected. |
This was referenced Jan 12, 2022
This was referenced Mar 7, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
using web3.js 0.5.0 via atmospherejs.com
when an eth_call returns 0x, SolidityFunction.unpackOutput slices it into "" which gets passed to decodeParams and an eventual error. Here's the trace:
The text was updated successfully, but these errors were encountered: