88 CairoEnum ,
99 ParsedStruct ,
1010 Uint256 ,
11- Uint ,
1211} from '../../types' ;
1312import { CairoUint256 } from '../cairoDataTypes/uint256' ;
1413import { CairoUint512 } from '../cairoDataTypes/uint512' ;
@@ -72,80 +71,84 @@ function decodeBaseTypes(
7271
7372 case isTypeUint ( type ) :
7473 switch ( true ) {
75- case CairoUint256 . isAbiType ( type ) :
76- console . log ( 'got 256 uint value' ) ;
74+ case CairoUint256 . isAbiType ( type ) : {
7775 const low = it . next ( ) . value ;
7876 const high = it . next ( ) . value ;
7977
8078 const ret = new CairoUint256 ( low , high ) ;
81- let configConstructor = config ?. [ 'core::integer::u256' ] ;
79+ const configConstructor = config ?. [ 'core::integer::u256' ] ;
8280 if ( configConstructor ) {
8381 return configConstructor ( ret ) ;
8482 }
83+
8584 return ret ;
85+ }
8686
87- case CairoUint512 . isAbiType ( type ) :
87+ case CairoUint512 . isAbiType ( type ) : {
8888 const limb0 = it . next ( ) . value ;
8989 const limb1 = it . next ( ) . value ;
9090 const limb2 = it . next ( ) . value ;
9191 const limb3 = it . next ( ) . value ;
9292
9393 return new CairoUint512 ( limb0 , limb1 , limb2 , limb3 ) . toBigInt ( ) ;
94+ }
9495
95- default :
96+ default : {
9697 temp = it . next ( ) . value ;
9798 const configType = getUintType ( type ) ;
9899 if ( configType ) {
99100 const UintConstructor = config ?. [ configType ] ;
100101 if ( UintConstructor ) {
101102 return UintConstructor ( temp ) ;
102- } else {
103- return BigInt ( temp ) ;
104103 }
104+ return BigInt ( temp ) ;
105105 }
106+ }
106107 }
107108
109+ return BigInt ( temp ) ;
110+
108111 case isTypeEthAddress ( type ) :
109112 temp = it . next ( ) . value ;
110113 return BigInt ( temp ) ;
111114
112- case isTypeContractAddress ( type ) :
115+ case isTypeContractAddress ( type ) : {
113116 temp = it . next ( ) . value ;
114117 temp = toHex ( temp ) ;
115118 const configConstructor = config ?. [ type ] ;
116119 if ( configConstructor ) {
117120 return configConstructor ( temp ) ;
118- } else {
119- return BigInt ( temp ) ;
120121 }
122+ return BigInt ( temp ) ;
123+ }
121124
122125 case isTypeBytes31 ( type ) :
123126 temp = it . next ( ) . value ;
124127 return decodeShortString ( temp ) ;
125128
126- case isTypeSecp256k1Point ( type ) :
129+ case isTypeSecp256k1Point ( type ) : {
127130 const xLow = removeHexPrefix ( it . next ( ) . value ) . padStart ( 32 , '0' ) ;
128131 const xHigh = removeHexPrefix ( it . next ( ) . value ) . padStart ( 32 , '0' ) ;
129132 const yLow = removeHexPrefix ( it . next ( ) . value ) . padStart ( 32 , '0' ) ;
130133 const yHigh = removeHexPrefix ( it . next ( ) . value ) . padStart ( 32 , '0' ) ;
131134 const pubK = BigInt ( addHexPrefix ( xHigh + xLow + yHigh + yLow ) ) ;
132135
133136 return pubK ;
137+ }
134138
135- case isTypeFelt ( type ) :
139+ case isTypeFelt ( type ) : {
136140 temp = String ( it . next ( ) . value ) ;
137- console . log ( 'Original temp = ' , temp ) ;
138141 const configFeltConstructor = config ?. [ 'core::felt252' ] ;
139142 if ( configFeltConstructor ) {
140143 if ( configFeltConstructor === String ) return decodeShortString ( temp ) ;
141- else return configFeltConstructor ( temp ) ;
144+ return configFeltConstructor ( temp ) ;
142145 }
143146
144147 // Default
145148 return BigInt ( temp ) ;
149+ }
146150
147151 default :
148- console . log ( 'went to default block for ' ) ;
149152 temp = it . next ( ) . value ;
150153 return BigInt ( temp ) ;
151154 }
@@ -294,14 +297,12 @@ function decodeCalldataValue(
294297 parsedDataArr . push ( val ) ;
295298 }
296299 }
297- console . log ( 'Returning array: ' , parsedDataArr ) ;
298300 const configConstructor = config ?. [ element . name ] ;
299301 if ( configConstructor ) {
300302 const concatenatedString = parsedDataArr . join ( '' ) ;
301303 return concatenatedString ;
302- } else {
303- return parsedDataArr ;
304304 }
305+ return parsedDataArr ;
305306 }
306307
307308 // base type
@@ -326,9 +327,10 @@ export default function decodeCalldataField(
326327 const { name, type } = input ;
327328
328329 switch ( true ) {
329- case isLen ( name ) :
330+ case isLen ( name ) : {
330331 const temp = calldataIterator . next ( ) . value ;
331332 return BigInt ( temp ) ;
333+ }
332334
333335 case ( structs && type in structs ) || isTypeTuple ( type ) :
334336 return decodeCalldataValue ( calldataIterator , input , structs , enums , config ) ;
@@ -341,8 +343,11 @@ export default function decodeCalldataField(
341343 if ( isCairo1Type ( type ) ) {
342344 return decodeCalldataValue ( calldataIterator , input , structs , enums , config ) ;
343345 }
346+ break ;
344347
345348 default :
346349 return decodeBaseTypes ( type , calldataIterator , config ) ;
347350 }
351+
352+ return null ;
348353}
0 commit comments