Open bjutkoski opened 9 months ago
i am encountering the same issue now
I have same issue while reading tuple data output
I have modified Ethabi class decodeParameters function as given below and its working fine:
public function decodeParameters($types, $param) { if (!is_string($param)) { throw new InvalidArgumentException('The param must be string.'); }
// change json to array
$outputTypes = [];
if ($types instanceof stdClass && isset($types->outputs)) {
$types = Utils::jsonToArray($types, 2);
}
if (is_array($types) && isset($types['outputs'])) {
$outputTypes = $types;
$types = [];
if(!empty($outputTypes['outputs'][0]['components']))
{
foreach ($outputTypes['outputs'][0]['components'] as $component) {
$types[] = $component['type'];
}
}
else{
foreach ($outputTypes['outputs'] as $output) {
if (isset($output['type'])) {
$types[] = $output['type'];
}
}
}
}
$typesLength = count($types);
$abiTypes = $this->parseAbiTypes($types);
// decode with tuple type
$results = [];
$decodeResults = $this->types['tuple']->decode(Utils::stripZero($param), 0, [ 'coders' => $abiTypes ]);
for ($i = 0; $i < $typesLength; $i++) {
if(!empty($outputTypes['outputs'][0]['components']))
{
if (isset($outputTypes['outputs'][0]['components'][$i]['name']) && empty($outputTypes['outputs'][0]['components'][$i]['name']) === false) {
$results[$outputTypes['outputs'][0]['components'][$i]['name']] = $decodeResults[$i];
} else {
$results[$i] = $decodeResults[$i];
}
}
else{
if (isset($outputTypes['outputs'][$i]['name']) && empty($outputTypes['outputs'][$i]['name']) === false) {
$results[$outputTypes['outputs'][$i]['name']] = $decodeResults[$i];
} else {
$results[$i] = $decodeResults[$i];
}
}
}
return $results;
}
I have same issue while reading tuple data output
I have modified Ethabi class decodeParameters function as given below and its working fine:
public function decodeParameters($types, $param) { if (!is_string($param)) { throw new InvalidArgumentException('The param must be string.'); }
// change json to array
$outputTypes = [];
if ($types instanceof stdClass && isset($types->outputs)) {
$types = Utils::jsonToArray($types, 2);
}
if (is_array($types) && isset($types['outputs'])) {
$outputTypes = $types;
$types = [];
if(!empty($outputTypes['outputs'][0]['components']))
{
foreach ($outputTypes['outputs'][0]['components'] as $component) {
$types[] = $component['type'];
}
}
else{
foreach ($outputTypes['outputs'] as $output) {
if (isset($output['type'])) {
$types[] = $output['type'];
}
}
}
}
$typesLength = count($types);
$abiTypes = $this->parseAbiTypes($types);
// decode with tuple type
$results = [];
$decodeResults = $this->types['tuple']->decode(Utils::stripZero($param), 0, [ 'coders' => $abiTypes ]);
for ($i = 0; $i < $typesLength; $i++) {
if(!empty($outputTypes['outputs'][0]['components']))
{
if (isset($outputTypes['outputs'][0]['components'][$i]['name']) && empty($outputTypes['outputs'][0]['components'][$i]['name']) === false) {
$results[$outputTypes['outputs'][0]['components'][$i]['name']] = $decodeResults[$i];
} else {
$results[$i] = $decodeResults[$i];
}
}
else{
if (isset($outputTypes['outputs'][$i]['name']) && empty($outputTypes['outputs'][$i]['name']) === false) {
$results[$outputTypes['outputs'][$i]['name']] = $decodeResults[$i];
} else {
$results[$i] = $decodeResults[$i];
}
}
}
return $results;
}
I have same issue while reading tuple data output
I have modified Ethabi class decodeParameters function as given below and its working fine:
public function decodeParameters($types, $param) { if (!is_string($param)) { throw new InvalidArgumentException('The param must be string.'); }
// change json to array $outputTypes = []; if ($types instanceof stdClass && isset($types->outputs)) { $types = Utils::jsonToArray($types, 2); } if (is_array($types) && isset($types['outputs'])) { $outputTypes = $types; $types = []; if(!empty($outputTypes['outputs'][0]['components'])) { foreach ($outputTypes['outputs'][0]['components'] as $component) { $types[] = $component['type']; } } else{ foreach ($outputTypes['outputs'] as $output) { if (isset($output['type'])) { $types[] = $output['type']; } } } } $typesLength = count($types); $abiTypes = $this->parseAbiTypes($types); // decode with tuple type $results = []; $decodeResults = $this->types['tuple']->decode(Utils::stripZero($param), 0, [ 'coders' => $abiTypes ]); for ($i = 0; $i < $typesLength; $i++) { if(!empty($outputTypes['outputs'][0]['components'])) { if (isset($outputTypes['outputs'][0]['components'][$i]['name']) && empty($outputTypes['outputs'][0]['components'][$i]['name']) === false) { $results[$outputTypes['outputs'][0]['components'][$i]['name']] = $decodeResults[$i]; } else { $results[$i] = $decodeResults[$i]; } } else{ if (isset($outputTypes['outputs'][$i]['name']) && empty($outputTypes['outputs'][$i]['name']) === false) { $results[$outputTypes['outputs'][$i]['name']] = $decodeResults[$i]; } else { $results[$i] = $decodeResults[$i]; } } } return $results; }
I'm having this error
Undefined array key "coders"
when methods has tuple[] or tuple as input/output/web3p/web3.php/src/Contracts/Types/Tuple.php:116
input as tuple[]
tuple as output