@@ -27,40 +27,25 @@ export const calculateTokenValue = (
2727 fullValue = true
2828) : string => {
2929 try {
30- console . log ( 'calculateTokenValue - Input:' , { tokenTx, txType, tokenId, fullValue } )
31-
3230 if ( txType === TokenType . ERC_20 || txType === TokenType . EVM_Internal ) {
33- console . log ( 'calculateTokenValue - ERC20/EVM_Internal branch' )
34- console . log ( 'calculateTokenValue - contractInfo:' , tokenTx . contractInfo )
35- console . log ( 'calculateTokenValue - tokenValue:' , tokenTx . tokenValue )
36-
3731 const decimalsValue = tokenTx . contractInfo . decimals && ! isNaN ( parseInt ( tokenTx . contractInfo . decimals ) )
3832 ? parseInt ( tokenTx . contractInfo . decimals )
3933 : 18
40-
41- console . log ( 'calculateTokenValue - decimalsValue:' , decimalsValue )
4234
43- if ( tokenTx . tokenValue === '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' ) {
44- console . log ( 'calculateTokenValue - unlimited value detected' )
45- return 'unlimited'
46- }
47-
48- console . log ( 'calculateTokenValue - attempting formatUnits with:' , tokenTx . tokenValue , decimalsValue )
49- const formatted = formatUnits ( tokenTx . tokenValue , decimalsValue )
50- console . log ( 'calculateTokenValue - formatUnits result:' , formatted )
51-
52- return fullValue ? formatted : roundTokenValue ( formatted )
35+ return tokenTx . tokenValue === '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
36+ ? 'unlimited'
37+ : fullValue
38+ ? formatUnits ( tokenTx . tokenValue , decimalsValue )
39+ : roundTokenValue ( formatUnits ( tokenTx . tokenValue , decimalsValue ) )
5340
5441 // : round(web3.utils.fromWei(tokenTx.tokenValue, "ether"));
5542 } else if ( txType === TokenType . ERC_721 ) {
56- console . log ( 'calculateTokenValue - ERC721 branch' )
5743 return tokenTx . tokenEvent === 'Approval For All'
5844 ? tokenTx . tokenValue === '0x0000000000000000000000000000000000000000000000000000000000000001'
5945 ? 'True'
6046 : 'False'
6147 : shortTokenValue ( web3 . utils . hexToNumberString ( tokenTx . tokenValue ) )
6248 } else if ( txType === TokenType . ERC_1155 ) {
63- console . log ( 'calculateTokenValue - ERC1155 branch' )
6449 return tokenTx . tokenEvent === 'Approval For All'
6550 ? tokenTx . tokenValue === '0x0000000000000000000000000000000000000000000000000000000000000001'
6651 ? 'True'
@@ -71,11 +56,7 @@ export const calculateTokenValue = (
7156 ? shortTokenValue ( web3 . utils . hexToNumberString ( tokenTx . tokenValue . substring ( 0 , 66 ) ) )
7257 : shortTokenValue ( web3 . utils . hexToNumberString ( '0x' + tokenTx . tokenValue . substring ( 66 , 130 ) ) )
7358 }
74-
75- console . log ( 'calculateTokenValue - No matching token type, txType:' , txType )
7659 } catch ( e ) {
77- console . error ( 'calculateTokenValue - Error caught:' , e )
78- console . error ( 'calculateTokenValue - Error stack:' , e . stack )
7960 return 'error in calculating tokenValue'
8061 }
8162 return 'error in calculating tokenValue'
0 commit comments