diff --git a/src/lib/components/search-bar/components/result.svelte b/src/lib/components/search-bar/components/result.svelte
index 7e8802bba..256754304 100644
--- a/src/lib/components/search-bar/components/result.svelte
+++ b/src/lib/components/search-bar/components/result.svelte
@@ -73,7 +73,7 @@
{@html pickLabel(item)}
-{:else if item.type === 'ens'}
+{:else if item.type === 'address'}
diff --git a/src/lib/components/search-bar/search.ts b/src/lib/components/search-bar/search.ts
index 0b9f19364..7a6ac65b8 100644
--- a/src/lib/components/search-bar/search.ts
+++ b/src/lib/components/search-bar/search.ts
@@ -6,6 +6,7 @@ import ensStore from '$lib/stores/ens/ens.store';
import mapFilterUndefined from '$lib/utils/map-filter-undefined';
import { BASE_URL } from '$lib/utils/base-url';
import network from '$lib/stores/wallet/network';
+import { isAddress } from 'ethers';
const client = new MeiliSearch({
host: `${BASE_URL}/api/search`,
@@ -52,8 +53,7 @@ async function getEnsResult(q: string): Promise {
if (lookup) {
return {
- type: 'ens',
- name: q,
+ type: 'address',
address: lookup,
};
}
@@ -64,6 +64,17 @@ async function getEnsResult(q: string): Promise {
return undefined;
}
+function getAddressResult(q: string): Result | undefined {
+ if (isAddress(q)) {
+ return {
+ type: 'address',
+ address: q,
+ };
+ }
+
+ return undefined;
+}
+
export async function search(q: string): Promise {
const commonOptions: Partial = {
attributesToHighlight: ['name'],
@@ -91,10 +102,11 @@ export async function search(q: string): Promise {
const parsedHits: Result[] = resultsSchema.parse(hits);
- const [gitUrlResult, ensResult] = await Promise.all([
+ const [gitUrlResult, ensResult, addressResult] = await Promise.all([
getGitUrlResults(q, parsedHits),
getEnsResult(q),
+ getAddressResult(q),
]);
- return mapFilterUndefined([ensResult, gitUrlResult, ...parsedHits], (v) => v);
+ return mapFilterUndefined([addressResult, ensResult, gitUrlResult, ...parsedHits], (v) => v);
}