Skip to content

Commit

Permalink
Add subname expiry test
Browse files Browse the repository at this point in the history
  • Loading branch information
sugh01 committed Dec 12, 2023
1 parent f6a0802 commit 7777318
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 248 deletions.
4 changes: 3 additions & 1 deletion packages/ensjs/src/test/usage/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { RegistrationParameters } from '../../utils/registerHelpers.js'

// const accounts = await walletClient.getAddresses()
// type accountType = typeof accounts[0]
export const commitAndRegisterName = async (params: RegistrationParameters, account: any) => {
export const commitAndRegisterName = async (params: RegistrationParameters, account: any): Promise<string> => {

Check failure on line 12 in packages/ensjs/src/test/usage/helper.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `params:·RegistrationParameters,·account:·any` with `⏎··params:·RegistrationParameters,⏎··account:·any,⏎`
const commitTx = await commitName(walletClient, {

Check failure on line 13 in packages/ensjs/src/test/usage/helper.ts

View workflow job for this annotation

GitHub Actions / Lint

Replace `····` with `··`
...params,

Check failure on line 14 in packages/ensjs/src/test/usage/helper.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
account: account,

Check failure on line 15 in packages/ensjs/src/test/usage/helper.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
Expand All @@ -36,4 +36,6 @@ export const commitAndRegisterName = async (params: RegistrationParameters, acco
expect(tx).toBeTruthy()
const receipt = await waitForTransaction(tx)
expect(receipt.status).toBe('success')

return tx
}
50 changes: 1 addition & 49 deletions packages/ensjs/src/test/usage/ownership.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { labelhash, type Address, type Hex } from 'viem'
import { getChainContractAddress } from '../../contracts/getChainContractAddress.js'
import { nameWrapperOwnerOfSnippet } from '../../contracts/nameWrapper.js'
import { type Address, type Hex } from 'viem'
import {
publicClient,
testClient,
waitForTransaction,
walletClient,
} from '../../test/addTestContracts.js'
import { namehash } from '../../utils/normalise.js'
import type { RegistrationParameters } from '../../utils/registerHelpers.js'
import { baseRegistrarNameExpiresSnippet } from '../../contracts/baseRegistrar.js'
import setAddressRecord from '../../functions/wallet/setAddressRecord.js'
import getResolver from '../../functions/public/getResolver.js'
import getOwner from '../../functions/public/getOwner.js'
import unwrapName from '../../functions/wallet/unwrapName.js'
import transferName from '../../functions/wallet/transferName.js'
import createSubname from '../../functions/wallet/createSubname.js'
import { registrySetApprovalForAllSnippet } from '../../contracts/registry.js'
import { encodeAbi } from '../../utils/index.js'
import setRecords from '../../functions/wallet/setRecords.js'
import { commitAndRegisterName } from './helper.js'
Expand All @@ -40,49 +35,6 @@ afterEach(async () => {

const secret = `0x${'a'.repeat(64)}` as Hex

const getNameWrapperOwner = async (name: string) => {
return publicClient.readContract({
abi: nameWrapperOwnerOfSnippet,
functionName: 'ownerOf',
address: getChainContractAddress({
client: publicClient,
contract: 'ensNameWrapper',
}),
args: [BigInt(namehash(name))],
})
}

const getExpiry = async (name: string) => {
return publicClient.readContract({
abi: baseRegistrarNameExpiresSnippet,
functionName: 'nameExpires',
address: getChainContractAddress({
client: publicClient,
contract: 'ensBaseRegistrarImplementation',
}),
args: [BigInt(labelhash(name.split('.')[0]))],
})
}

const approve = async (address: Address) => {
return walletClient.writeContract({
abi: registrySetApprovalForAllSnippet,
address: getChainContractAddress({
client: walletClient,
contract: 'ensRegistry',
}),
functionName: 'setApprovalForAll',
args: [
getChainContractAddress({
client: walletClient,
contract: 'ensNameWrapper',
}),
true,
],
account: address,
})
}

const dummyABI = [
{
type: 'function',
Expand Down
Loading

0 comments on commit 7777318

Please sign in to comment.