Skip to content

Commit

Permalink
fix: update display contract search result
Browse files Browse the repository at this point in the history
  • Loading branch information
Tien Nam Dao committed Nov 25, 2022
1 parent 527d894 commit ca05294
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/Search/ResultView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ellipseBetweenText, LinkMaker } from 'utils/helper'
import styles from './style.module.scss'

export interface SearchResultViewItem {
type: 'Address' | 'Block' | 'Transaction' | 'Validator' | 'Token'
type: 'Address' | 'Block' | 'Transaction' | 'Validator' | 'Token' | 'Contract'
time?: string
status?: string
value: string | number
Expand Down
15 changes: 14 additions & 1 deletion components/Search/SearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function SearchResult({ status, data }: SearchResultProps) {
return []
}

const { blocks, addresses, transactions, validators, tokens } = data?.result
const { blocks, addresses, transactions, validators, tokens, contracts } = data?.result
const items: SearchResultViewItem[] = []
if (blocks && blocks.length > 0) {
for (let item of blocks) {
Expand Down Expand Up @@ -45,6 +45,19 @@ export default function SearchResult({ status, data }: SearchResultProps) {
}
}
}
if (contracts && contracts.length > 0) {
for (let item of contracts) {
if (!items.find((i: SearchResultViewItem) => item.addressHash === i.key)) {
items.push({
time: item.insertedAt,
type: 'Contract',
key: item.addressHash,
value: `${item.name} | ${item.addressHash}`,
linkValue: item.addressHash
})
}
}
}
if (transactions && transactions.length > 0) {
for (let item of transactions) {
if (!items.find((i: SearchResultViewItem) => (item.evmHash || item.cosmosHash) === i.key)) {
Expand Down
1 change: 1 addition & 0 deletions project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface SearchItemResponse {
validators: ValidatorData[]
addresses: AddressSearchResponse[]
tokens: TokenSearchResponse[]
contracts: ContractSearchResponse[]
}
}

Expand Down
6 changes: 6 additions & 0 deletions types/address.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,9 @@ interface VerifyStatusResponse {
result: string
status: string
}

interface ContractSearchResponse {
addressHash: string
insertedAt: string
name: string
}

0 comments on commit ca05294

Please sign in to comment.