├── README.md └── winop.js /README.md: -------------------------------------------------------------------------------- 1 | # windope -------------------------------------------------------------------------------- /winop.js: -------------------------------------------------------------------------------- 1 | if (txs.length) { 2 | for (const tx of Object.values(txs)) { 3 | const date = new Date(timestampToDate(tx.created)) 4 | uniqueDays.add(date.toDateString()) 5 | uniqueWeeks.add(date.getFullYear() + '-' + date.getWeek()) 6 | uniqueMonths.add(date.getFullYear() + '-' + date.getMonth()) 7 | uniqueSource.add(tx.srcChainKey) 8 | uniqueDestination.add(tx.dstChainKey) 9 | uniqueContracts.add(tx.dstUaAddress) 10 | 11 | if (tx.srcUaProtocol) { 12 | if (!protocols[tx.srcUaProtocol.id]) { 13 | protocols[tx.srcUaProtocol.id] = 1 14 | } else { 15 | protocols[tx.srcUaProtocol.id]++ 16 | } 17 | 18 | if (badProtocols.includes(tx.srcUaProtocol.id)) { 19 | badProtocolsCount++ 20 | } 21 | } 22 | 23 | if (!sources[tx.srcChainKey]) { 24 | sources[tx.srcChainKey] = 1 25 | } else { 26 | sources[tx.srcChainKey]++ 27 | } 28 | 29 | if (!destinations[tx.dstChainKey]) { 30 | destinations[tx.dstChainKey] = 1 31 | } else { 32 | destinations[tx.dstChainKey]++ 33 | } 34 | } 35 | 36 | data.first_tx = new Date(timestampToDate(txs[txs.length - 1].created)) 37 | data.last_tx = new Date(timestampToDate(txs[0].created)) 38 | data.source_chain_count = uniqueSource.size 39 | data.dest_chain_count = uniqueDestination.size 40 | data.contracts = uniqueContracts.size 41 | data.days = uniqueDays.size 42 | data.weeks = uniqueWeeks.size 43 | data.months = uniqueMonths.size 44 | data.badProtocolsCount = badProtocolsCount 45 | data.sources = sources 46 | data.destinations = destinations 47 | data.protocols = protocols 48 | } 49 | } 50 | --------------------------------------------------------------------------------