diff --git a/.changelog/617.bugfix.md b/.changelog/617.bugfix.md new file mode 100644 index 000000000..0095944e8 --- /dev/null +++ b/.changelog/617.bugfix.md @@ -0,0 +1 @@ +Specify search suggestions per layer diff --git a/src/app/components/Search/SearchSuggestionsButtons.tsx b/src/app/components/Search/SearchSuggestionsButtons.tsx index 93fb543e4..49587f19a 100644 --- a/src/app/components/Search/SearchSuggestionsButtons.tsx +++ b/src/app/components/Search/SearchSuggestionsButtons.tsx @@ -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', @@ -28,12 +29,15 @@ export const SuggestionButton = styled(PlainTextButton)({ }) interface Props { + scope: SearchScope | undefined onClickSuggestion: (suggestion: string) => void } -export const SearchSuggestionsButtons: FC = ({ onClickSuggestion }) => { +export const SearchSuggestionsButtons: FC = ({ 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 ( diff --git a/src/app/components/Search/SearchSuggestionsLinks.tsx b/src/app/components/Search/SearchSuggestionsLinks.tsx index 5065c58ab..280c19e5f 100644 --- a/src/app/components/Search/SearchSuggestionsLinks.tsx +++ b/src/app/components/Search/SearchSuggestionsLinks.tsx @@ -8,12 +8,14 @@ import { OptionalBreak } from '../OptionalBreak' import { SearchScope } from '../../../types/searchScope' interface Props { - scope?: SearchScope + scope: SearchScope | undefined } export const SearchSuggestionsLinks: FC = ({ 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 ( = ({ scope, variant, disabled, onFocusChange: o value && value !== valueInSearchParams && ( { setValue(suggestion) }} diff --git a/src/app/components/Search/search-utils.ts b/src/app/components/Search/search-utils.ts index 0a86b690c..2ccfca989 100644 --- a/src/app/components/Search/search-utils.ts +++ b/src/app/components/Search/search-utils.ts @@ -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-nexus/api' -export const searchSuggestionTerms = { - suggestedTransaction: 'b1e68ca814d913064bd6b9460efcb64b4c6d07f3b98fa659beed46164398a830', - suggestedBlock: '1396255', - suggestedAccount: '0xBA504818FdD8D3dBA2Ef8fD9B4F4D5c71aD1d1D3', +type LayerSuggestions = { + suggestedBlock: string + suggestedTransaction: string + suggestedAccount: string +} + +export const searchSuggestionTerms: Record>> = { + 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 = {