8
8
9
9
namespace Merkeleon \Coder ;
10
10
11
+ use Illuminate \Support \Arr ;
11
12
use Merkeleon \Coder \Exceptions \CoderException ;
12
13
use Web3 \
13
14
{
@@ -42,9 +43,9 @@ public function __construct(string $connection, string $contractAddress)
42
43
public function decodeLog (array $ log ): array
43
44
{
44
45
$ 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 );
48
49
49
50
if (empty ($ topics ) || is_null ($ data ))
50
51
{
@@ -59,7 +60,7 @@ public function decodeLog(array $log): array
59
60
60
61
if ($ topicId && isset ($ eventInputs [$ topicId ]))
61
62
{
62
- $ inputs = array_get ($ eventInputs [$ topicId ], 'inputs ' );
63
+ $ inputs = Arr:: get ($ eventInputs [$ topicId ], 'inputs ' );
63
64
$ parsedEvent = $ this ->decodeEvent ($ inputs , $ topics , $ data );
64
65
$ parsedEvent ['eventName ' ] = $ eventInputs [$ topicId ]['name ' ];
65
66
}
@@ -91,12 +92,12 @@ public function decodeLogs(array $logs): array
91
92
*/
92
93
private function encodeEventSignature (array $ event )
93
94
{
94
- $ rawSignature = array_get ($ event , 'name ' ) . '( ' ;
95
+ $ rawSignature = Arr:: get ($ event , 'name ' ) . '( ' ;
95
96
$ types = [];
96
97
97
- foreach (array_get ($ event , 'inputs ' , []) as $ i => $ input )
98
+ foreach (Arr:: get ($ event , 'inputs ' , []) as $ i => $ input )
98
99
{
99
- $ types [$ i ] = array_get ($ input , 'type ' );
100
+ $ types [$ i ] = Arr:: get ($ input , 'type ' );
100
101
}
101
102
102
103
$ rawSignature .= join (', ' , $ types ) . ') ' ;
@@ -115,8 +116,8 @@ private function decodeEvent(array $inputs, array $topics, string $data): array
115
116
$ result = [];
116
117
foreach ($ inputs as $ i => $ input )
117
118
{
118
- $ type = array_get ($ input , 'type ' );
119
- $ name = array_get ($ input , 'name ' );
119
+ $ type = Arr:: get ($ input , 'type ' );
120
+ $ name = Arr:: get ($ input , 'name ' );
120
121
121
122
if ($ type === 'address ' )
122
123
{
@@ -147,7 +148,7 @@ public function getBalance(string $holderAddress): string
147
148
148
149
return ;
149
150
}
150
- $ response = array_first ($ result )->toString ();
151
+ $ response = Arr:: first ($ result )->toString ();
151
152
});
152
153
153
154
return $ response ;
@@ -169,7 +170,7 @@ public function getAllowance(string $ownerAddress, string $spenderAddress): stri
169
170
return ;
170
171
}
171
172
172
- $ response = array_first ($ result )->toString ();
173
+ $ response = Arr:: first ($ result )->toString ();
173
174
});
174
175
175
176
return $ response ;
@@ -209,9 +210,9 @@ private function encodeFunctionSignature(string $method)
209
210
$ rawSignature = $ method . '( ' ;
210
211
$ types = [];
211
212
212
- foreach (array_get ($ function , 'inputs ' , []) as $ i => $ input )
213
+ foreach (Arr:: get ($ function , 'inputs ' , []) as $ i => $ input )
213
214
{
214
- $ types [$ i ] = array_get ($ input , 'type ' );
215
+ $ types [$ i ] = Arr:: get ($ input , 'type ' );
215
216
}
216
217
217
218
$ rawSignature .= join (', ' , $ types ) . ') ' ;
0 commit comments