From c6fe465a5063ce612c0677420d3132e27966fafa Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Sat, 2 Dec 2023 22:26:20 +0530 Subject: [PATCH] fix: Ignore expired ENS domains on space creation (#4424) --- src/composables/useEns.ts | 8 ++++++-- src/helpers/queries.ts | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/composables/useEns.ts b/src/composables/useEns.ts index 7e17648f32f..4b045b05dd0 100644 --- a/src/composables/useEns.ts +++ b/src/composables/useEns.ts @@ -25,8 +25,12 @@ export function useEns() { const domains = response.account?.domains || []; const wrappedDomains = response.account?.wrappedDomains || []; - const allDomains = [...domains, ...wrappedDomains]; - + let allDomains = [...domains, ...wrappedDomains]; + // Filter out expired domains + const now = (Date.now() / 1000).toFixed(0); + allDomains = allDomains.filter( + domain => !domain.expiryDate || domain.expiryDate > now + ); ownedEnsDomains.value = await fetchAllDomainData(allDomains); }; diff --git a/src/helpers/queries.ts b/src/helpers/queries.ts index 17be5f908e3..0c1a93369aa 100644 --- a/src/helpers/queries.ts +++ b/src/helpers/queries.ts @@ -202,9 +202,11 @@ export const ENS_DOMAINS_BY_ACCOUNT_QUERY = gql` account(id: $id) { domains { name + expiryDate } wrappedDomains { name + expiryDate } } }