-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/subdomain registrar #98
base: master
Are you sure you want to change the base?
Conversation
86400, | ||
[] | ||
) | ||
).to.be.revertedWith( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's worth making compatible with the NDT rental EIP which went it into final status recently https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4907.md |
c2a5417
to
d014bc9
Compare
d1a9d3e
to
b6b00fc
Compare
|
||
const labelhash = (label) => utils.keccak256(utils.toUtf8Bytes(label)) | ||
const ROOT_NODE = | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ROOT_NODE and EMPTY_BYTES32 are the same so no need to hard code twice. It should rather use const { EMPTY_BYTES32 } = require('../test-utils/constants')
const GRACE_PERIOD = 86400 * 90 | ||
|
||
const EMPTY_BYTES32 = | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use const { EMPTY_BYTES32 } = require('../test-utils/constants')
|
||
const EMPTY_BYTES32 = | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' | ||
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use const { EMPTY_ADDRESS } = require('../test-utils/constants')
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000' | ||
const MAX_EXPIRY = 2n ** 64n - 1n | ||
|
||
function increaseTime(delay) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should put them in test-utils/constants
return ethers.provider.send('evm_increaseTime', [delay]) | ||
} | ||
|
||
function mine() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should put them in test-utils/constants
'PublicResolver', | ||
EnsRegistry.address, | ||
NameWrapper.address, | ||
'0x0000000000000000000000000000000000000000', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use EMPTY_ADDRESS
_checkParent(parentNode, duration); | ||
|
||
if (fee > 0) { | ||
IERC20(token).transferFrom( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we only accept fee in ERC20 token, rather than using ETH with existing price oracle?
expect(fuses).to.equal(CAN_EXTEND_EXPIRY | PARENT_CANNOT_CONTROL) | ||
}) | ||
|
||
it('should not allow subdomains to be registerd over another domain', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean 'should not allow subdomains to be registered twice, or
should not allow subdomains to be registered when already registered? Wasn't quite sure what
over another domain` mean.
|
||
const labelhash = (label) => utils.keccak256(utils.toUtf8Bytes(label)) | ||
const ROOT_NODE = | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reuse from ../test-utils/constants
const ROOT_NODE = | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' | ||
|
||
const EMPTY_BYTES32 = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reuse from ../test-utils/constants
|
||
const EMPTY_BYTES32 = | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' | ||
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reuse from ../test-utils/constants
BaseRegistrar.address, | ||
) | ||
|
||
// setup .xyz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you test .xyz domains?
) | ||
|
||
// setup .xyz | ||
await EnsRegistry.setSubnodeOwner( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same. Do you test .xyz domains?
expect(expiry).to.equal(block.timestamp + duration) | ||
expect(fuses).to.equal(PARENT_CANNOT_CONTROL) | ||
}) | ||
it('should not allow subdomains to be created on unapproved parents', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should't the same test exist on TestForeverSubdomainRegistrar.js
?
) | ||
}) | ||
|
||
it('should allow subdomains to be registered without a fee', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should't the same test exist on TestForeverSubdomainRegistrar.js
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or extract common functions between rental and forever registrar into seperate test, or use shouldBehaveLike*
pattern you used for NameWrapper tests.
expect(fuses).to.equal(PARENT_CANNOT_CONTROL) | ||
}) | ||
|
||
it('should revert if user has insufficient balance of the token', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should't the same test exist on TestForeverSubdomainRegistrar.js
?
).to.be.revertedWith(`ERC20: transfer amount exceeds balance`) | ||
}) | ||
|
||
it('should revert if parent is expired', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should't the same test exist on TestForeverSubdomainRegistrar.js?
expect(await NameWrapper.ownerOf(subNode)).to.equal(account2) | ||
}) | ||
it('should allow subdomains to be renewed', async () => { | ||
const [owner, , expiry] = await NameWrapper.getData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is owner
variable in use?
expect(expiry2.toNumber()).to.equal(expiry.toNumber() + 500) | ||
}) | ||
|
||
it('should allow subdomains to be renewed even with 0 registration fee', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually testing what you want to test? The only difference with the test one above is the duration, not registration fee
expect(expiry2.toNumber()).to.equal(expiry.toNumber() + 86400) | ||
}) | ||
|
||
it('should revert if expiry is greater than parent', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the parent expiry? If 84600
, it would be great to set that into a meaningful variable so that the test is easier to read
// expect(await NameWrapper.ownerOf(subNode)).to.equal(account2) | ||
// expect(await NameWrapper.ownerOf(subNode2)).to.equal(account3) | ||
// expect(await PublicResolver['addr(bytes32)'](subNode)).to.equal(account2) | ||
// expect(await PublicResolver['addr(bytes32)'](subNode2)).to.equal(account3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you either uncomment or delete if not needed?
).to.be.revertedWith(`Unavailable()`) | ||
}) | ||
|
||
it('Names can extend their own expiry', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not possible for RenstalSubdomainRegistrar? If not, there should be a test for that. Otherwise, I am not sure if this test is necessary as it's not extending through subname registrar but rather directly interacting with the name wrapper.
true, | ||
) | ||
await NameWrapper.setApprovalForAll(SubdomainRegistrar.address, true) | ||
await Erc20WithAccount2.approve( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to approve? Assuming you are testing registration without fee as the next one is explicitly testing with fee
true, | ||
) | ||
const fee = (await SubdomainRegistrar.names(node)).registrationFee | ||
const balanceBefore = await Erc20WithAccount2.balanceOf(account2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable is not in use
import {IForeverSubdomainRegistrar} from "./IForeverSubdomainRegistrar.sol"; | ||
import {ISubdomainPricer} from "./pricers/ISubdomainPricer.sol"; | ||
|
||
error ParentNameNotSetup(bytes32 parentNode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no test case to cover this error
|
||
error Unavailable(); | ||
error Unauthorised(bytes32 node); | ||
error NameNotRegistered(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no test case to cover this error
error Unavailable(); | ||
error Unauthorised(bytes32 node); | ||
error NameNotRegistered(); | ||
error InvalidTokenAddress(address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no test case to cover this error
error Unauthorised(bytes32 node); | ||
error NameNotRegistered(); | ||
error InvalidTokenAddress(address); | ||
error NameNotSetup(bytes32 node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no test case to cover this error
error NameNotSetup(bytes32 node); | ||
error DataMissing(); | ||
error ParentExpired(bytes32 node); | ||
error ParentNotWrapped(bytes32 node); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no test case to cover this error
} | ||
} | ||
|
||
function _checkParent(bytes32 parentNode, uint64 duration) internal view { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think test coverage exists for these cases
- parent name is not wrapped -> Error
- parent is NOT .eth (DNS, subname)
- parent expiry is in grace period
- parent expiry does not exist (subname?)
Subdomain registrar using the new wrapper expiry.