Skip to content

Commit

Permalink
chore: temporarily lock nfd resolution to mainnet (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell authored Oct 9, 2024
1 parent 4351b46 commit 77a33ec
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/features/search/data/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import { isTransactionId } from '@/utils/is-transaction-id'
import { isInteger } from '@/utils/is-integer'
import { syncedRoundAtom } from '@/features/blocks/data'
import { createApplicationSummaryAtom } from '@/features/applications/data/application-summary'
import { useSelectedNetwork } from '@/features/network/data'
import { mainnetId, useSelectedNetwork } from '@/features/network/data'
import { getTransactionResultAtom } from '@/features/transactions/data'
import { isNFD } from '@/features/nfd/data/is-nfd'
import { getNfdResultAtom } from '@/features/nfd/data/nfd-result'
import { NfdResult } from '@/features/nfd/data/types'

const handle404 = (e: Error) => {
if (is404(e)) {
Expand All @@ -43,15 +44,20 @@ const createSearchAtoms = (store: JotaiStore, selectedNetwork: string) => {
const results: SearchResult[] = []

if (isAddress(term)) {
const nfdAtom = getNfdResultAtom({ address: term })
const nfd = await get(nfdAtom)
let nfd: NfdResult | null = null

if (selectedNetwork === mainnetId) {
const nfdAtom = getNfdResultAtom({ address: term })
nfd = await get(nfdAtom)
}

results.push({
type: SearchResultType.Account,
id: term,
label: `${ellipseAddress(term)}${nfd ? ` (${nfd.name})` : ''}`,
url: Urls.Explore.Account.ByAddress.build({ address: term, networkId: selectedNetwork }),
})
} else if (isNFD(term)) {
} else if (selectedNetwork === mainnetId && isNFD(term)) {
const nfdAtom = getNfdResultAtom({ nfd: term })
const nfd = await get(nfdAtom)
if (nfd && isAddress(nfd.depositAccount)) {
Expand Down

0 comments on commit 77a33ec

Please sign in to comment.