diff --git a/packages/ensjs/deploy/00_register_concurrently.cjs b/packages/ensjs/deploy/00_register_concurrently.cjs index 87c6571c..5dcda2b4 100644 --- a/packages/ensjs/deploy/00_register_concurrently.cjs +++ b/packages/ensjs/deploy/00_register_concurrently.cjs @@ -10,6 +10,9 @@ const { makeNameGenerator: makeLegacyNameGenerator, } = require('../utils/legacyNameGenerator.cjs') const { makeNonceManager } = require('../utils/nonceManager.cjs') +const { encodeFuses } = require('../dist/cjs/utils/fuses') + +const DURATION = 31556000 /** * @type {{ @@ -35,15 +38,16 @@ const sameExpiryNames = Array.from({ length: 20 }, (_, index) => ({ type: 'legacy', namedOwner: 'owner4', reverseRecord: true, - duration: 3600, + duration: DURATION, })) const expiryNames = Array.from({ length: 20 }, (_, index) => ({ label: `wrapped-name-${index}`, - // type: 'wrapped', + type: 'wrapped', namedOwner: 'owner4', + // reverseRecord: true, - expiry: 31556000 + index + 1, + expiry: DURATION + index + 1, // duration: 31556000 + index + 1, })) @@ -68,15 +72,37 @@ const names = [ label: 'concurrent-wrapped-name', type: 'wrapped', namedOwner: 'owner4', + fuses: encodeFuses({ + input: { + child: { + named: ['CANNOT_UNWRAP'], + }, + }, + }), reverseRecord: true, + duration: DURATION, subnames: [ - // { label: 'subname-1', namedOwner: 'owner4', duration: 36000 }, + { + 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, + // ...expiryNames, ], }, ] @@ -128,7 +154,6 @@ const func = async function (hre) { }) }, ), - await network.provider.send('evm_mine'), ) network.provider.send('evm_mine') @@ -165,6 +190,7 @@ const func = async function (hre) { label, namedOwner, namedAddr, + duration }) else return wrappedNameGenerator.register({ diff --git a/packages/ensjs/src/functions/subgraph/getNamesForAddress.test.ts b/packages/ensjs/src/functions/subgraph/getNamesForAddress.test.ts index 60a4aaa5..20243299 100644 --- a/packages/ensjs/src/functions/subgraph/getNamesForAddress.test.ts +++ b/packages/ensjs/src/functions/subgraph/getNamesForAddress.test.ts @@ -3,10 +3,13 @@ import type { Address } from 'viem' import { beforeAll, describe, expect, it } from 'vitest' import { publicClient, walletClient } from '../../test/addTestContracts.js' -import { EMPTY_ADDRESS } from '../../utils/consts.js' +import { GRACE_PERIOD_SECONDS } from '../../utils/consts.js' import getNamesForAddress, { type NameWithRelation, } from './getNamesForAddress.js' +import getOwner from '../public/getOwner.js' +import getExpiry from '../public/getExpiry.js' +import getWrapperData from '../public/getWrapperData.js' let accounts: Address[] @@ -14,6 +17,41 @@ beforeAll(async () => { accounts = await walletClient.getAddresses() }) +const legacyNamesList = Array.from( + { length: 20 }, + (_, i) => `same-expiry-legacy-name-${i}.eth`, +) + +const user4 = '0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65' +let expiry: bigint + +describe.only('validate data', () => { + it.each([ + ...legacyNamesList, + 'concurrent-wrapped-name.eth', + 'subname-1.concurrent-wrapped-name.eth', + ])('%s', async (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 + + if (!expiry) expiry = expiryValue + const wrapperData = await getWrapperData(publicClient, { name }) + + // expiry value from wrapper datat includes grace period + const wrappedExpiryValue = + (wrapperData?.expiry?.value || 0n) - BigInt(GRACE_PERIOD_SECONDS) + const expectedExpiry = + ownerData?.ownershipLevel === 'nameWrapper' + ? wrappedExpiryValue + : expiryValue + + expect(expectedExpiry).toEqual(expiry) + }) +}) + it('returns with default values', async () => { const result = await getNamesForAddress(publicClient, { address: accounts[1],