Skip to content

Commit

Permalink
FET-1573 expiry subname not working
Browse files Browse the repository at this point in the history
  • Loading branch information
SagiSan committed Sep 23, 2024
1 parent 2a84283 commit 5d73c07
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 49 deletions.
66 changes: 35 additions & 31 deletions packages/ensjs/deploy/00_register_concurrently.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,30 @@ const DURATION = 31556000
* }[]}
*/

const sameExpiryNames = Array.from({ length: 20 }, (_, index) => ({
const sameExpiryNames = Array.from({ length: 21 }, (_, index) => ({
label: `same-expiry-legacy-name-${index}`,
type: 'legacy',
namedOwner: 'owner4',
reverseRecord: true,
duration: DURATION,
}))

const expiryNames = Array.from({ length: 20 }, (_, index) => ({
label: `wrapped-name-${index}`,
type: 'wrapped',
const expiryNames = Array.from({ length: 42 }, (_, index) => ({
label:
index < 21 ? `expiry-subname-${index}` : `no-expiry-subname-${index - 21}`,
namedOwner: 'owner4',

// reverseRecord: true,
expiry: DURATION + index + 1,
// duration: 31556000 + index + 1,
type: 'wrapped',
expiry: index < 21 ? 36000 * (index + 1) : 0,
subnameFuses: encodeFuses({
input: {
parent: {
named: ['PARENT_CANNOT_CONTROL'],
},
child: {
named: ['CANNOT_UNWRAP'],
},
},
}),
}))

const names = [
Expand Down Expand Up @@ -80,29 +88,25 @@ const names = [
},
}),
reverseRecord: true,
duration: DURATION,
duration: DURATION * 3,
subnames: [
{
label: 'subname-1',
namedOwner: 'owner4',
type: 'wrapped',
subnameFuses: encodeFuses({
input: {
parent: {
named: ['PARENT_CANNOT_CONTROL'],
},
child: {
named: ['CANNOT_UNWRAP'],
},
},
}),
},
// { label: 'subname-2', namedOwner: 'owner4' },
// { label: 'test', namedOwner: 'owner4' },
// { label: 'legacy', namedOwner: 'owner4' },
// { label: 'xyz', namedOwner: 'owner4', expiry: 3600 },
// { label: 'addr', namedOwner: 'owner4' },
// ...expiryNames,
// {
// label: 'subname-1',
// namedOwner: 'owner4',
// type: 'wrapped',
// expiry: Math.floor(Date.now() / 1000),
// subnameFuses: encodeFuses({
// input: {
// parent: {
// named: ['PARENT_CANNOT_CONTROL'],
// },
// child: {
// named: ['CANNOT_UNWRAP'],
// },
// },
// }),
// },
...expiryNames,
],
},
]
Expand Down Expand Up @@ -190,7 +194,7 @@ const func = async function (hre) {
label,
namedOwner,
namedAddr,
duration
duration,
})
else
return wrappedNameGenerator.register({
Expand Down
56 changes: 38 additions & 18 deletions packages/ensjs/src/functions/subgraph/getNamesForAddress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,29 @@ const legacyNamesList = Array.from(
{ length: 20 },
(_, i) => `same-expiry-legacy-name-${i}.eth`,
)
const subnamesList = Array.from(
{ length: 42 },
(_, i) =>
`${i > 20 ? 'no-' : ''}expiry-subname-${i}.concurrent-wrapped-name.eth`,
)

const user4 = '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65'
let expiry: bigint

describe.only('validate data', () => {
it.each([
...legacyNamesList,
'concurrent-wrapped-name.eth',
'subname-1.concurrent-wrapped-name.eth',
...subnamesList,
// 'concurrent-wrapped-name.eth',
// 'subname-1.concurrent-wrapped-name.eth',
])('%s', async (name) => {
console.log(name)
const ownerData = await getOwner(publicClient, { name })
const owner = ownerData?.registrant ?? ownerData?.owner
expect(owner).toEqual(user4)
const expiryData = await getExpiry(publicClient, { name })
const expiryValue = expiryData?.expiry?.value || 0n

console.log('expiryData', expiryData)
if (!expiry) expiry = expiryValue
const wrapperData = await getWrapperData(publicClient, { name })

Expand All @@ -47,7 +54,7 @@ describe.only('validate data', () => {
ownerData?.ownershipLevel === 'nameWrapper'
? wrappedExpiryValue
: expiryValue

// console.log(expectedExpiry)
expect(expectedExpiry).toEqual(expiry)
})
})
Expand All @@ -73,20 +80,27 @@ it('has registration date on .eth names', async () => {
}
}
})
it('test', async () => {

// this is my test
it.only('test', async () => {
let fullResult = await getNamesForAddress(publicClient, {
address: accounts[4],
orderBy: 'expiryDate',
orderDirection: 'asc',
pageSize: 20,
})
console.log(
fullResult.map((name) => ({
name: name?.name,
expiry: name?.expiryDate?.value,
})),
)
// console.log(
// fullResult.map((name) => ({
// name: name?.name,
// expiry: name?.expiryDate?.value,
// })),
// )
console.log(fullResult.length)
if (!fullResult.length) throw new Error('No names found')
for (let i = 0; i < 20; i += 1) {
console.log(fullResult[i].name)
// expect(fullResult[i].name).toContain('same-expiry')
}
const previousPage = fullResult
fullResult = await getNamesForAddress(publicClient, {
address: accounts[4],
Expand All @@ -95,14 +109,20 @@ it('test', async () => {
pageSize: 20,
previousPage,
})
console.log(
fullResult.map((name) => ({
name: name?.name,
expiry: name?.expiryDate?.value,
})),
)
expect(fullResult).toEqual(fullResult)
for (let i = 0; i < 20; i += 1) {
console.log(fullResult[i].name)
// expect(fullResult[i].name).toContain('same-expiry')
}
// console.log(
// fullResult.map((name) => ({
// name: name?.name,
// expiry: name?.expiryDate?.value,
// })),
// )
// console.log(fullResult)
// expect(fullResult).toEqual(fullResult)
})
// end

// describe('filter', () => {
// it('filters by owner', async () => {
Expand Down

0 comments on commit 5d73c07

Please sign in to comment.