Skip to content

Commit

Permalink
Specify search suggestions per layer
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Jun 30, 2023
1 parent 71c6643 commit d439bac
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions .changelog/617.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Specify search suggestions per layer
8 changes: 6 additions & 2 deletions src/app/components/Search/SearchSuggestionsButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import RepeatIcon from '@mui/icons-material/Repeat'
import AccountBalanceWalletIcon from '@mui/icons-material/AccountBalanceWallet'
import { searchSuggestionTerms } from './search-utils'
import { OptionalBreak } from '../OptionalBreak'
import { SearchScope } from '../../../types/searchScope'

const PlainTextButton = styled(Button)({
fontSize: 'inherit',
Expand All @@ -28,12 +29,15 @@ export const SuggestionButton = styled(PlainTextButton)({
})

interface Props {
scope: SearchScope | undefined
onClickSuggestion: (suggestion: string) => void
}

export const SearchSuggestionsButtons: FC<Props> = ({ onClickSuggestion }) => {
export const SearchSuggestionsButtons: FC<Props> = ({ scope, onClickSuggestion }) => {
const { t } = useTranslation()
const { suggestedBlock, suggestedTransaction, suggestedAccount } = searchSuggestionTerms
const { suggestedBlock, suggestedTransaction, suggestedAccount } =
(scope?.network && scope?.layer && searchSuggestionTerms[scope.network][scope.layer]) ??
searchSuggestionTerms['mainnet']['sapphire']!

return (
<span>
Expand Down
6 changes: 4 additions & 2 deletions src/app/components/Search/SearchSuggestionsLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { OptionalBreak } from '../OptionalBreak'
import { SearchScope } from '../../../types/searchScope'

interface Props {
scope?: SearchScope
scope: SearchScope | undefined
}

export const SearchSuggestionsLinks: FC<Props> = ({ scope }) => {
const { t } = useTranslation()
const { suggestedBlock, suggestedTransaction, suggestedAccount } = searchSuggestionTerms
const { suggestedBlock, suggestedTransaction, suggestedAccount } =
(scope?.network && scope?.layer && searchSuggestionTerms[scope.network][scope.layer]) ??
searchSuggestionTerms['mainnet']['sapphire']!

return (
<Trans
Expand Down
1 change: 1 addition & 0 deletions src/app/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const SearchCmp: FC<SearchProps> = ({ scope, variant, disabled, onFocusChange: o
value &&
value !== valueInSearchParams && (
<SearchSuggestionsButtons
scope={scope}
onClickSuggestion={suggestion => {
setValue(suggestion)
}}
Expand Down
31 changes: 27 additions & 4 deletions src/app/components/Search/search-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,34 @@ import {
import { Network } from '../../../types/network'
import { RouteUtils } from '../../utils/route-utils'
import { AppError, AppErrors } from '../../../types/errors'
import { Layer } from '../../../oasis-indexer/api'

export const searchSuggestionTerms = {
suggestedTransaction: 'b1e68ca814d913064bd6b9460efcb64b4c6d07f3b98fa659beed46164398a830',
suggestedBlock: '1396255',
suggestedAccount: '0xBA504818FdD8D3dBA2Ef8fD9B4F4D5c71aD1d1D3',
type LayerSuggestions = {
suggestedBlock: string
suggestedTransaction: string
suggestedAccount: string
}

export const searchSuggestionTerms: Record<Network, Partial<Record<Layer, LayerSuggestions>>> = {
mainnet: {
emerald: {
suggestedBlock: '4260',
suggestedTransaction: '0x2f461f83745e1fa1177138aa815e210e1c69305db8065af9015b2e490a5033f1',
suggestedAccount: '0x0266562AB0aE2a80C14373029a70F73A9A3dB9d3',
},
sapphire: {
suggestedBlock: '4260',
suggestedTransaction: '0x5900415a3fbb39325d5dfe145d1eccd1586a2afe12a204de34ecac0c808ac3f7',
suggestedAccount: '0x90adE3B7065fa715c7a150313877dF1d33e777D5',
},
},
testnet: {
sapphire: {
suggestedBlock: '4260',
suggestedTransaction: '0xd9b5c08be1cb74229abedd9b3e1afb8b43228085a6abf72993db415959ab6b35',
suggestedAccount: '0xfA3AC9f65C9D75EE3978ab76c6a1105f03156204',
},
},
}

export const validateAndNormalize = {
Expand Down

0 comments on commit d439bac

Please sign in to comment.