From 992b877104081b346df345a9c7c96368282e53ef Mon Sep 17 00:00:00 2001 From: Viterbo Date: Tue, 24 Dec 2024 15:39:49 -0300 Subject: [PATCH 1/2] removing a bug --- src/pages/home/HomeInfo.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/HomeInfo.vue b/src/pages/home/HomeInfo.vue index ebebdac2..92f4c2cb 100644 --- a/src/pages/home/HomeInfo.vue +++ b/src/pages/home/HomeInfo.vue @@ -66,7 +66,7 @@ async function fetchLatestBlock() { async function fetchTotalTransactions() { const indexerApi = useChainStore().currentChain.settings.getIndexerApi(); - const response = await indexerApi.get('/v1/transactions?limit=0&next=-1&offset=0&includeAbi=false&includePagination=true&includeTransfers=false&full=false'); + const response = await indexerApi.get('/v1/transactions?limit=1&offset=0&includeAbi=false&includePagination=true&includeTransfers=false&full=false'); transactionsCount.value = response.data.total_count; } From f0db94ecbfd213591b69861ad67badf9dd9064d7 Mon Sep 17 00:00:00 2001 From: Viterbo Date: Tue, 24 Dec 2024 16:21:26 -0300 Subject: [PATCH 2/2] bugfix on search for address --- src/components/AppSearch.vue | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/AppSearch.vue b/src/components/AppSearch.vue index 9d206021..13468a61 100644 --- a/src/components/AppSearch.vue +++ b/src/components/AppSearch.vue @@ -213,12 +213,29 @@ const sortCriteria = (a: SearchResult, b: SearchResult): number => { } }; +const getSearchResultRaw = (result: SearchResultRaw[] | string): SearchResultRaw[] => { + if (typeof result === 'string') { + try { + const obj = JSON.parse(result); + return obj as SearchResultRaw[]; + } catch (e) { + return [{ + type: 'unknown', + address: result, + }] as never as SearchResultRaw[]; + } + } else { + return result as SearchResultRaw[]; + } +}; + + const goToFirstResultNow = (query: string) => { const endpoint = useChainStore().currentChain.settings.getIndexerApiEndpoint(); const url = `${endpoint}/api?module=search&action=search&query=${query}&offset=1`; loading.value = true; axios.get(url).then((response) => { - const result = response.data.result.map((entry: SearchResultRaw) => convertRawToProcessedResult(entry)); + const result = getSearchResultRaw(response.data.result).map((entry: SearchResultRaw) => convertRawToProcessedResult(entry)); loading.value = false; handleResultClick(result[0]); }).catch((error) => { @@ -236,7 +253,7 @@ const fetchResults = (query: string): Observable => { return new Observable((observer) => { loading.value = true; axios.get(url).then((response) => { - const result = response.data.result.map((entry: SearchResultRaw) => convertRawToProcessedResult(entry)); + const result = getSearchResultRaw(response.data.result).map((entry: SearchResultRaw) => convertRawToProcessedResult(entry)); result.sort(sortCriteria); loading.value = false; observer.next(result);