Skip to content

Commit

Permalink
getSubnames - check that registry owner is namewrapper before adding …
Browse files Browse the repository at this point in the history
…wrapped values
  • Loading branch information
storywithoutend committed Jul 10, 2023
1 parent dda9516 commit 7661e3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions packages/ensjs/src/functions/getSubnames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Params = {
}

const largeQuery = async (
{ gqlInstance }: ENSArgs<'gqlInstance'>,
{ gqlInstance, contracts }: ENSArgs<'gqlInstance' | 'contracts'>,
{
name,
pageSize = 10,
Expand All @@ -62,6 +62,9 @@ const largeQuery = async (
search = '',
}: Params,
) => {
const nameWrapper = await contracts?.getNameWrapper()
const nameWrapperAddress = nameWrapper?.address.toLowerCase()

const { client } = gqlInstance

const lastSubname = lastSubnames?.[lastSubnames.length - 1]
Expand Down Expand Up @@ -165,7 +168,8 @@ const largeQuery = async (
type: 'domain',
} as Subname

if (wrappedDomain) {
// If the subname is wrapped, we need to verfiy that it is wrapped by checking the registry owner
if (wrappedDomain && obj.owner === nameWrapperAddress) {
obj.type = 'wrappedDomain'
const expiryDateAsDate =
wrappedDomain.expiryDate && wrappedDomain.expiryDate !== '0'
Expand Down Expand Up @@ -194,7 +198,7 @@ const largeQuery = async (
}

const getSubnames = (
injected: ENSArgs<'gqlInstance'>,
injected: ENSArgs<'gqlInstance' | 'contracts'>,
functionArgs: Params,
): Promise<ReturnData> => {
return largeQuery(injected, functionArgs)
Expand Down
2 changes: 1 addition & 1 deletion packages/ensjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export class ENS {

public getSubnames = this.generateFunction<FunctionTypes['getSubnames']>(
'initialGetters',
['gqlInstance'],
['gqlInstance', 'contracts'],
'getSubnames',
)

Expand Down

0 comments on commit 7661e3c

Please sign in to comment.