Skip to content

Commit

Permalink
Merge pull request #1159 from alleslabs/fix/invalid-search
Browse files Browse the repository at this point in the history
fix: invalid search proposal and pool
  • Loading branch information
songwongtp authored Sep 20, 2024
2 parents dda393f + 38fe3ce commit ee113a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#1159](https://github.com/alleslabs/celatone-frontend/pull/1159) Fix search showing invalid proposal and pool id
- [#1150](https://github.com/alleslabs/celatone-frontend/pull/1150) Fix camel case on message

## v1.9.0
Expand Down
20 changes: 11 additions & 9 deletions src/lib/services/searchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
splitModulePath,
} from "lib/utils";

import { useBlockData } from "./block";
import { useBlockData, useBlockDataLcd } from "./block";
import { useEvmCodesByAddress } from "./evm";
import { useModuleByAddressLcd } from "./move/module";
import { useAddressByIcnsNameLcd, useIcnsNamesByAddressLcd } from "./name";
Expand Down Expand Up @@ -232,11 +232,13 @@ export const useSearchHandler = (
Number(debouncedKeyword),
isPosDecimal(debouncedKeyword) && isFullTier
);
const { foundBlock, isFetching: blockFetching } = useMemo(() => {
if (isPosDecimal(debouncedKeyword) && !isFullTier)
return { foundBlock: true, isFetching: false };
return { foundBlock: blockApi.data, isFetching: blockApi.isFetching };
}, [blockApi.data, blockApi.isFetching, debouncedKeyword, isFullTier]);
const blockLcd = useBlockDataLcd(
Number(debouncedKeyword),
isPosDecimal(debouncedKeyword) && !isFullTier
);
const { data: blockData, isFetching: blockFetching } = isFullTier
? blockApi
: blockLcd;

/// /////////////////////////////////////////////////////
// Proposal
Expand Down Expand Up @@ -417,13 +419,13 @@ export const useSearchHandler = (
type: "EVM Transaction Hash",
});

if (foundBlock)
if (blockData)
results.push({
value: debouncedKeyword,
type: "Block",
});

if (proposalData)
if (proposalData?.info)
results.push({
value: debouncedKeyword,
type: "Proposal ID",
Expand All @@ -435,7 +437,7 @@ export const useSearchHandler = (
type: "Validator Address",
});

if (poolData)
if (poolData?.info)
results.push({
value: debouncedKeyword,
type: "Pool ID",
Expand Down

0 comments on commit ee113a1

Please sign in to comment.