Skip to content

Commit 9d60600

Browse files
authored
fix Arr:: helpers
1 parent e239260 commit 9d60600

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/Coder.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Merkeleon\Coder;
1010

11+
use Illuminate\Support\Arr;
1112
use Merkeleon\Coder\Exceptions\CoderException;
1213
use Web3\
1314
{
@@ -42,9 +43,9 @@ public function __construct(string $connection, string $contractAddress)
4243
public function decodeLog(array $log): array
4344
{
4445
$eventInputs = [];
45-
$data = array_get($log, 'data');
46-
$topics = array_slice(array_get($log, 'topics', []), 1);
47-
$topicId = substr(array_first(array_get($log, 'topics', [])), 2);
46+
$data = Arr::get($log, 'data');
47+
$topics = array_slice(Arr::get($log, 'topics', []), 1);
48+
$topicId = substr(Arr::first(Arr::get($log, 'topics', [])), 2);
4849

4950
if (empty($topics) || is_null($data))
5051
{
@@ -59,7 +60,7 @@ public function decodeLog(array $log): array
5960

6061
if ($topicId && isset($eventInputs[$topicId]))
6162
{
62-
$inputs = array_get($eventInputs[$topicId], 'inputs');
63+
$inputs = Arr::get($eventInputs[$topicId], 'inputs');
6364
$parsedEvent = $this->decodeEvent($inputs, $topics, $data);
6465
$parsedEvent['eventName'] = $eventInputs[$topicId]['name'];
6566
}
@@ -91,12 +92,12 @@ public function decodeLogs(array $logs): array
9192
*/
9293
private function encodeEventSignature(array $event)
9394
{
94-
$rawSignature = array_get($event, 'name') . '(';
95+
$rawSignature = Arr::get($event, 'name') . '(';
9596
$types = [];
9697

97-
foreach (array_get($event, 'inputs', []) as $i => $input)
98+
foreach (Arr::get($event, 'inputs', []) as $i => $input)
9899
{
99-
$types[$i] = array_get($input, 'type');
100+
$types[$i] = Arr::get($input, 'type');
100101
}
101102

102103
$rawSignature .= join(',', $types) . ')';
@@ -115,8 +116,8 @@ private function decodeEvent(array $inputs, array $topics, string $data): array
115116
$result = [];
116117
foreach ($inputs as $i => $input)
117118
{
118-
$type = array_get($input, 'type');
119-
$name = array_get($input, 'name');
119+
$type = Arr::get($input, 'type');
120+
$name = Arr::get($input, 'name');
120121

121122
if ($type === 'address')
122123
{
@@ -147,7 +148,7 @@ public function getBalance(string $holderAddress): string
147148

148149
return;
149150
}
150-
$response = array_first($result)->toString();
151+
$response = Arr::first($result)->toString();
151152
});
152153

153154
return $response;
@@ -169,7 +170,7 @@ public function getAllowance(string $ownerAddress, string $spenderAddress): stri
169170
return;
170171
}
171172

172-
$response = array_first($result)->toString();
173+
$response = Arr::first($result)->toString();
173174
});
174175

175176
return $response;
@@ -209,9 +210,9 @@ private function encodeFunctionSignature(string $method)
209210
$rawSignature = $method . '(';
210211
$types = [];
211212

212-
foreach (array_get($function, 'inputs', []) as $i => $input)
213+
foreach (Arr::get($function, 'inputs', []) as $i => $input)
213214
{
214-
$types[$i] = array_get($input, 'type');
215+
$types[$i] = Arr::get($input, 'type');
215216
}
216217

217218
$rawSignature .= join(',', $types) . ')';

0 commit comments

Comments
 (0)