Skip to content

Commit

Permalink
Fix action
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolmin committed Dec 4, 2023
1 parent 87756b2 commit 49dc76c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
4 changes: 3 additions & 1 deletion lib/api/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@ export const RESOURCES = {
api_v2_key: {
path: '/api/v2/key',
},
universal_profile: {},
universal_profile: {
path: '',
},

// API V1
csv_export_txs: {
Expand Down
5 changes: 3 additions & 2 deletions lib/api/useUniversalProfileApiFetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { SearchResultUniversalProfile } from '../../types/api/search';
import type { SearchResultAddressOrContractOrUniversalProfile } from '../../types/api/search';
import type { UniversalProfileProxyResponse } from '../../types/api/universalProfile';

import type { Params as FetchParams } from 'lib/hooks/useFetch';
Expand All @@ -19,12 +19,13 @@ export default function useUniversalProfileApiFetch() {
) => {
try {
const { hits } = await algoliaIndex.search(queryParams);
return hits.map<SearchResultUniversalProfile>((hit) => {
return hits.map<SearchResultAddressOrContractOrUniversalProfile>((hit) => {
const hitAsUp = hit as unknown as UniversalProfileProxyResponse;
return {
type: 'universal_profile',
name: hitAsUp.hasProfileName ? hitAsUp.LSP3Profile.name : null,
address: hit.objectID,
is_smart_contract_verified: false,
};
});
} catch (error) {
Expand Down
9 changes: 1 addition & 8 deletions types/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,12 @@ export interface SearchResultTx {
url?: string; // not used by the frontend, we build the url ourselves
}

export interface SearchResultUniversalProfile {
type: 'universal_profile';
name: string | null;
address: string;
}

export type SearchResultItem =
SearchResultToken |
SearchResultAddressOrContractOrUniversalProfile |
SearchResultBlock |
SearchResultTx |
SearchResultLabel |
SearchResultUniversalProfile;
SearchResultLabel

export interface SearchResult {
items: Array<SearchResultItem>;
Expand Down
2 changes: 2 additions & 0 deletions ui/address/contract/ContractSourceCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ const ContractSourceCode = ({ address, implementationAddress }: Props) => {
) : null;

const copyToClipboard = activeContractData?.length === 1 ?
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<CopyToClipboard text={ activeContractData[0].source_code } isLoading={ isLoading } ml={{ base: 'auto', lg: diagramLink ? '0' : 'auto' }}/> :
null;

Expand Down
5 changes: 3 additions & 2 deletions ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { scroller, Element } from 'react-scroll';

import type { SearchResultItem } from 'types/api/search';

import type { ResourceError } from 'lib/api/resources';
import useIsMobile from 'lib/hooks/useIsMobile';
import useMarketplaceApps from 'ui/marketplace/useMarketplaceApps';
import TextAd from 'ui/shared/ad/TextAd';
Expand All @@ -18,7 +17,7 @@ import SearchBarSuggestApp from './SearchBarSuggestApp';
import SearchBarSuggestItem from './SearchBarSuggestItem';

interface Props {
query: UseQueryResult<Array<SearchResultItem>, ResourceError<unknown>>;
query: UseQueryResult<Array<SearchResultItem>, Error>;
searchTerm: string;
onItemClick: (event: React.MouseEvent<HTMLAnchorElement>) => void;
containerId: string;
Expand Down Expand Up @@ -142,6 +141,8 @@ const SearchBarSuggest = ({ query, searchTerm, onItemClick, containerId }: Props
{ cat.title }
</Text>
{ cat.id !== 'app' && itemsGroups[cat.id]?.map((item, index) =>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<SearchBarSuggestItem key={ index } data={ item } isMobile={ isMobile } searchTerm={ searchTerm } onClick={ onItemClick }/>,
) }
{ cat.id === 'app' && itemsGroups[cat.id]?.map((item, index) =>
Expand Down

0 comments on commit 49dc76c

Please sign in to comment.