Skip to content

Commit

Permalink
fix: rm past expired ens
Browse files Browse the repository at this point in the history
  • Loading branch information
0xsign committed Oct 5, 2023
1 parent f6ad112 commit d874464
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/ens.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { toStartOfDay, unixFromDate } from '@lib/fmt'
import type { TUnixTimestamp } from '@lib/type'
import { GraphQLClient } from 'graphql-request'

export const DOMAINS_QUERY = `
query getDomains($address: String!) {
query getDomains($address: String!, $expiryDateGte: Int!) {
account(id: $address) {
registrations(
orderBy:expiryDate, orderDirection:asc,
where:{ expiryDate_gte: $expiryDateGte }
) {
expiryDate
registrationDate
Expand Down Expand Up @@ -61,7 +63,10 @@ const client = new GraphQLClient(endpoint, {
})

export async function getENSRegistrations(address: `0x${string}`) {
const response = (await client.request(DOMAINS_QUERY, { address: address.toLowerCase() })) as DomainsResponse
const response = (await client.request(DOMAINS_QUERY, {
address: address.toLowerCase(),
expiryDateGte: unixFromDate(toStartOfDay(new Date())),
})) as DomainsResponse

const registrations: ENSRegistration[] = (response?.account?.registrations || []).map((registration) => ({
domainName: registration.domain.name,
Expand Down

0 comments on commit d874464

Please sign in to comment.