Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Utils/AbiEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,21 @@ private function encodeTuple($value, array $param): array
{
$dynamic = false;
$preparedParams = [];
// TODO: it currently relies on the ABI component arrays to have a string index but our DARK20 ABI doesn't seem to have that
// https://app.clickup.com/t/86dx0at7u
foreach ($param['components'] as $index => $component) {
$key = is_array($value) ? $index : $component['name'];
foreach ($param['components'] as $component) {
if (! isset($component['name'])) {
throw new Exception('Tuple component missing name');
}

$key = $component['name'];
if (! isset($value[$key])) {
throw new Exception('Tuple value missing component: '.$component['name']);
}

$preparedParam = $this->prepareParam($component, $value[$key]);
if ($preparedParam['dynamic']) {
$dynamic = true;
}

$preparedParams[] = $preparedParam;
}
if ($dynamic) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Utils/AbiEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ function testPrivateMethod(string $methodName, &$object): ReflectionMethod
'name' => 'text',
'type' => 'tuple',
'components' => [
'recipient' => [
'name' => 'from',
[
'name' => 'recipient',
'type' => 'string',
],
],
Expand Down
Loading