Skip to content

Commit

Permalink
Fix for showing dupe for account and objects (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-white authored Aug 18, 2023
1 parent 8de057e commit d8cfcd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/api/hooks/useGetSearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from "../../pages/utils";
import {getAddressFromName} from "./useGetANS";
import {sendToGTM} from "./useGoogleTagManager";
import {objectCoreAddress} from "../../constants";

export type SearchResult = {
label: string;
Expand Down Expand Up @@ -90,11 +91,19 @@ export default function useGetSearchResults(input: string) {
{address: searchText},
state.network_value,
)
.then((): SearchResult => {
return {
label: `Object ${searchText}`,
to: `/object/${searchText}`,
};
.then((resources): SearchResult | undefined => {
let hasObjectCore = false;
resources.forEach((resource) => {
if (resource.type === objectCoreAddress) {
hasObjectCore = true;
}
});
if (hasObjectCore) {
return {
label: `Object ${searchText}`,
to: `/object/${searchText}`,
};
}
})
.catch(() => {
return null;
Expand Down
5 changes: 5 additions & 0 deletions src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,8 @@ export const WHILTELISTED_TESTNET_DELEGATION_NODES = import.meta.env
.REACT_APP_WHILTELISTED_TESTNET_DELEGATION_NODES
? import.meta.env.REACT_APP_WHILTELISTED_TESTNET_DELEGATION_NODES.split(",")
: null;

/**
* Core Address
*/
export const objectCoreAddress = "0x1::object::ObjectCore";

0 comments on commit d8cfcd6

Please sign in to comment.