From 5082e7240bd13e2fd376ccfe9eddf43fb2c653a7 Mon Sep 17 00:00:00 2001 From: Nadia Date: Mon, 23 Dec 2024 09:31:44 +0200 Subject: [PATCH] error search --- .../componentDescription/WidgetConfig.js | 57 +++++++------------ app/views/binance/network/nft.html.erb | 8 +-- app/views/ethereum/network/nft.html.erb | 8 +-- .../ethereum_streaming/network/nft.html.erb | 8 +-- 4 files changed, 34 insertions(+), 47 deletions(-) diff --git a/app/javascript/component/componentDescription/WidgetConfig.js b/app/javascript/component/componentDescription/WidgetConfig.js index 7d9cc9ec..02da2bd4 100644 --- a/app/javascript/component/componentDescription/WidgetConfig.js +++ b/app/javascript/component/componentDescription/WidgetConfig.js @@ -12,7 +12,6 @@ export default class WidgetConfig { icon: 'eth.svg', innovation: true, blockProducerName: 'Validator', - }, { tag: 'bsc', @@ -26,7 +25,6 @@ export default class WidgetConfig { start: Date.parse('2020-08-29'), innovation: true, blockProducerName: 'Validator', - }, { tag: 'arbitrum', @@ -42,43 +40,32 @@ export default class WidgetConfig { }, ]; } + + static getBlockchainMap() { + return this.getBlockchainInfo().reduce((map, blockchain) => { + map[blockchain.chainId] = blockchain; + return map; + }, {}); + } + + static getProperty(chainId, property) { + const blockchain = this.getBlockchainMap()[chainId]; + return blockchain ? blockchain[property] : null; + } + static getNetwork(chainId) { - const blockchainsInfo = this.getBlockchainInfo(); - let network; - blockchainsInfo.forEach(element => { - if (element.chainId === chainId) { - network = element.network; - } - }); - return network; + return this.getProperty(chainId, 'network'); } + static getCurrency(chainId) { - const blockchainsInfo = this.getBlockchainInfo(); - let currency; - blockchainsInfo.forEach(element => { - if (element.chainId === chainId) { - currency = element.currency; - } - }); - return currency; + return this.getProperty(chainId, 'currency'); } + static getBlockProducerName(chainId) { - const blockchainsInfo = this.getBlockchainInfo(); - let blockProducerName; - blockchainsInfo.forEach(element => { - if (element.chainId === chainId) { - blockProducerName = element.blockProducerName; - } - }); - return blockProducerName; - } static getName(chainId) { - const blockchainsInfo = this.getBlockchainInfo(); - let name; - blockchainsInfo.forEach(element => { - if (element.chainId === chainId) { - name = element.name; - } - }); - return name; + return this.getProperty(chainId, 'blockProducerName'); + } + + static getName(chainId) { + return this.getProperty(chainId, 'name'); } } diff --git a/app/views/binance/network/nft.html.erb b/app/views/binance/network/nft.html.erb index 78157ca5..88990bb2 100644 --- a/app/views/binance/network/nft.html.erb +++ b/app/views/binance/network/nft.html.erb @@ -67,7 +67,7 @@ return { topElement: response => response.EVM.Transfers, chainId: response => response.EVM.Transfers[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId) || 'network'}`, id: 'TopTransferNFT', columns: [ { @@ -104,7 +104,7 @@ return { topElement: response => response.EVM.Transfers, chainId: response => response.EVM.Transfers[0]?.ChainId, - title: response => `Top transferred NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId)}`, + title: response => `Top transferred NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId) || 'network'}`, id: 'NFTTransfersByDatePie', columns: [ { @@ -156,7 +156,7 @@ return { topElement: response => response.EVM.DEXTrades, chainId: response => response.EVM.DEXTrades[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId) || 'network'}`, id: 'TopTradedNFTTokens', columns: [ { @@ -199,7 +199,7 @@ return { topElement: response => response.EVM.DEXTrades, chainId: response => response.EVM.DEXTrades[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId) || 'network'}`, id: 'TopTradedNFTTokensPie', columns: [ { diff --git a/app/views/ethereum/network/nft.html.erb b/app/views/ethereum/network/nft.html.erb index b0d4552c..e06ed5b3 100644 --- a/app/views/ethereum/network/nft.html.erb +++ b/app/views/ethereum/network/nft.html.erb @@ -68,7 +68,7 @@ return { topElement: response => response.EVM.Transfers, chainId: response => response.EVM.Transfers[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId) || 'network'}`, id: 'TopTransferNFT', columns: [ { @@ -105,7 +105,7 @@ return { topElement: response => response.EVM.Transfers, chainId: response => response.EVM.Transfers[0]?.ChainId, - title: response => `Top transferred NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId)}`, + title: response => `Top transferred NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId) || 'network'}`, id: 'NFTTransfersByDatePie', columns: [ { @@ -157,7 +157,7 @@ return { topElement: response => response.EVM.DEXTrades, chainId: response => response.EVM.DEXTrades[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId) || 'network'}`, id: 'TopTradedNFTTokens', columns: [ { @@ -200,7 +200,7 @@ return { topElement: response => response.EVM.DEXTrades, chainId: response => response.EVM.DEXTrades[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId) || 'network'}`, id: 'TopTradedNFTTokensPie', columns: [ { diff --git a/app/views/ethereum_streaming/network/nft.html.erb b/app/views/ethereum_streaming/network/nft.html.erb index d460625b..ff6e8a17 100644 --- a/app/views/ethereum_streaming/network/nft.html.erb +++ b/app/views/ethereum_streaming/network/nft.html.erb @@ -67,7 +67,7 @@ return { topElement: response => response.EVM.Transfers, chainId: response => response.EVM.Transfers[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId) || 'network' }`, id: 'TopTransferNFT', columns: [ { @@ -104,7 +104,7 @@ return { topElement: response => response.EVM.Transfers, chainId: response => response.EVM.Transfers[0]?.ChainId, - title: response => `Top transferred NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId)}`, + title: response => `Top transferred NFT tokens in ${WidgetConfig.getName(response.EVM.Transfers[0]?.ChainId) || 'network'}`, id: 'NFTTransfersByDatePie', columns: [ { @@ -156,7 +156,7 @@ return { topElement: response => response.EVM.DEXTrades, chainId: response => response.EVM.DEXTrades[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId) || 'network'}`, id: 'TopTradedNFTTokens', columns: [ { @@ -199,7 +199,7 @@ return { topElement: response => response.EVM.DEXTrades, chainId: response => response.EVM.DEXTrades[0]?.ChainId, - title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId)}`, + title: response => `Top traded NFT tokens in ${WidgetConfig.getName(response.EVM.DEXTrades[0]?.ChainId) || 'network'}`, id: 'TopTradedNFTTokensPie', columns: [ {