@@ -3,46 +3,45 @@ import { formatTime, formatAssetAmount } from './util'
33
44export default ( assetTxs , chain_stats , asset , t ) => {
55
6- //Calculated AssetTx
7- let calculatedAssetTx = [ ]
8-
9- if ( assetTxs != null ) {
6+ const getCalculatedAssetTx = ( ) => {
107 // Supply Starts at Zero
118 let supply = 0
129 // Sort AssetTxs by block_time and Calculate Supply Change / Total Supply
1310 assetTxs . sort ( ( a , b ) => ( a . status . block_time > b . status . block_time ) ? 1 : ( ( b . status . block_time > a . status . block_time ) ? - 1 : 0 ) )
14- assetTxs . map ( tx => {
11+ let calAssetTx = assetTxs . map ( tx => {
1512 let calTxObj = { }
1613 calTxObj . txid = tx . txid
1714 calTxObj . block_height = tx . status . block_height
1815 calTxObj . block_time = formatTime ( tx . status . block_time )
19-
16+
2017 // Find all Issuance and add them to Supply
2118 tx . vin . map ( vinTx => {
2219 if ( "issuance" in vinTx ) {
23- calTxObj . supplyChange = chain_stats . has_blinded_issuances ? t `Confidential` : formatAssetAmount ( ( "+ " + vinTx . issuance . assetamount ) , asset . precision , t )
20+ calTxObj . supplyChange = chain_stats . has_blinded_issuances ? t `Confidential` : `+ ${ formatAssetAmount ( ( vinTx . issuance . assetamount ) , asset . precision , t ) . text } `
2421 calTxObj . totalSupply = chain_stats . has_blinded_issuances ? t `Confidential` : formatAssetAmount ( ( supply + vinTx . issuance . assetamount ) , asset . precision , t )
2522 supply = ( supply + vinTx . issuance . assetamount )
2623 }
2724 } )
28-
25+
2926 // Find all Burn Transactions and Remove them from Supply
3027 tx . vout . map ( voutTx => {
3128 if ( voutTx . scriptpubkey_type === "op_return" ) {
3229 if ( voutTx . value > 0 ) {
33- calTxObj . supplyChange = chain_stats . has_blinded_issuances ? t `Confidential` : formatAssetAmount ( ( "- " + voutTx . value ) , asset . precision , t )
30+ calTxObj . supplyChange = chain_stats . has_blinded_issuances ? t `Confidential` : `- ${ formatAssetAmount ( ( voutTx . value ) , asset . precision , t ) . text } `
3431 calTxObj . totalSupply = chain_stats . has_blinded_issuances ? t `Confidential` : formatAssetAmount ( ( supply - voutTx . value ) , asset . precision , t )
3532 supply = ( supply - voutTx . value )
3633 }
3734 }
3835 } )
39- calculatedAssetTx . push ( calTxObj )
36+ return calTxObj
4037 } )
38+
39+ // Reverse Calculated AssetTx to Display Newest to Older
40+ return calAssetTx . reverse ( )
4141 }
42- // Reverse Calculated AssetTx to Display Newest to Older
43- calculatedAssetTx . reverse ( )
44-
45-
42+
43+ let calculatedAssetTx = assetTxs === null ? "" : getCalculatedAssetTx ( )
44+
4645
4746 return (
4847 < div >
0 commit comments