@@ -685,12 +685,12 @@ public function getTransactionDetails($hash){
685
685
// transaction is pending if has no blockHash
686
686
$ result ['pending ' ] = true ;
687
687
$ result ['tx ' ] = $ transaction ?: false ;
688
-
689
688
if (isset ($ transaction ['to ' ])) {
690
689
$ token = $ this ->getToken ($ transaction ['to ' ]);
691
690
if ($ token && isset ($ transaction ['input ' ])) {
692
691
$ operation = $ this ->getTokenOperationData ($ transaction ['input ' ], $ token ['decimals ' ]);
693
692
if ($ operation && strtoupper ($ operation ['code ' ]) === '0XA9059CBB ' ) {
693
+ $ result ['token ' ] = $ token ;
694
694
$ result ['operations ' ] = [
695
695
[
696
696
'transactionHash ' => $ transaction ['hash ' ],
@@ -794,14 +794,14 @@ public function getTransactionDetails($hash){
794
794
/**
795
795
* Return operation details
796
796
* @param String $input Transaction input raw data
797
- * @param Int $division
797
+ * @param Int $decimals
798
798
* @return Array|null Operation data
799
799
*/
800
- private function getTokenOperationData ($ input , $ division = 18 ) {
800
+ private function getTokenOperationData ($ input , $ decimals = 18 ) {
801
801
preg_match ('/^(?<code>.{10})(?<from>.{64})(?<value>.{64})(?<rest>.*)?$/ ' , $ input , $ operation );
802
802
if ($ operation ) {
803
803
$ ten = Decimal::create (10 );
804
- $ dec = Decimal::create ($ token [ ' decimals ' ]); ;
804
+ $ dec = Decimal::create ($ decimals) ;
805
805
$ value = Decimal::create (hexdec ($ operation ['value ' ]));
806
806
$ operation ['value ' ] = '' . $ value ->div ($ ten ->pow ($ dec ), 4 );
807
807
0 commit comments