add status contact code to register method

This commit is contained in:
Barry Gitarts 2018-06-07 15:24:10 -04:00
parent 2d15531ab0
commit ef4ff22ed5
2 changed files with 44 additions and 3 deletions

View File

@ -69,13 +69,15 @@ contract ENSSubdomainRegistry is Controlled {
* @param _account optional address to set at public resolver
* @param _pubkeyA optional pubkey part A to set at public resolver
* @param _pubkeyB optional pubkey part B to set at public resolver
* @param _statusAccount optional contact code to set at text in public resolver
*/
function register(
bytes32 _userHash,
bytes32 _domainHash,
address _account,
bytes32 _pubkeyA,
bytes32 _pubkeyB
bytes32 _pubkeyB,
string _statusAccount
)
external
returns(bytes32 subdomainHash)
@ -100,6 +102,9 @@ contract ENSSubdomainRegistry is Controlled {
if (resolvePubkey) {
resolver.setPubkey(subdomainHash, _pubkeyA, _pubkeyB);
}
if (bytes(_statusAccount).length != 0) {
resolver.setText(subdomainHash, "statusAccount", _statusAccount);
}
ens.setOwner(subdomainHash, msg.sender);
}else {
//transfer ownship of subdone to registrant

View File

@ -112,6 +112,7 @@ contract('ENSSubdomainRegistry', function () {
domains.free.namehash,
utils.zeroAddress,
utils.zeroBytes32,
utils.zeroBytes32,
utils.zeroBytes32
).send({from: registrant});
@ -136,6 +137,7 @@ contract('ENSSubdomainRegistry', function () {
domains.free.namehash,
registrant,
utils.zeroBytes32,
utils.zeroBytes32,
utils.zeroBytes32
).send({from: registrant});
@ -152,6 +154,33 @@ contract('ENSSubdomainRegistry', function () {
assert.equal(result[1], utils.zeroBytes32, "Unexpected resolved pubkey[1]");
});
it('should register free status contact code only resolver-defined subdomain', async () => {
let registrant = accountsArr[2];
let subdomain = 'bob2';
let usernameHash = namehash.hash(subdomain + '.' + domains.free.name);
let contactCode = '0x04dbb31252d9bddb4e4d362c7b9c80cba74732280737af97971f42ccbdc716f3f3efb1db366880e52d09b1bfd59842e833f3004088892b7d14b9ce9e957cea9a82';
let result = await ENSSubdomainRegistry.methods.register(
web3Utils.sha3(subdomain),
domains.free.namehash,
registrant,
utils.zeroBytes32,
utils.zeroBytes32,
contactCode
).send({from: registrant});
result = await ens.methods.owner(usernameHash).call()
assert.equal(result, registrant, "Owner not set");
result = await ens.methods.resolver(usernameHash).call()
assert.equal(result, PublicResolver.address, "PublicResolver not set");
result = await PublicResolver.methods.text(usernameHash, "statusAccount").call()
assert.equal(result, contactCode, "Resolved contact code not set");
result = await PublicResolver.methods.pubkey(usernameHash).call()
assert.equal(result[0], utils.zeroBytes32, "Unexpected resolved pubkey[0]");
assert.equal(result[1], utils.zeroBytes32, "Unexpected resolved pubkey[1]");
});
it('should register free pubkey only resolver-defined subdomain', async () => {
let subdomain = 'carlos';
let registrant = accountsArr[3];
@ -162,7 +191,8 @@ contract('ENSSubdomainRegistry', function () {
domains.free.namehash,
utils.zeroAddress,
pubkey[0],
pubkey[1]
pubkey[1],
utils.zeroBytes32
).send({from: registrant});
//TODO: check events
@ -190,7 +220,8 @@ contract('ENSSubdomainRegistry', function () {
domains.free.namehash,
registrant,
pubkey[0],
pubkey[1]
pubkey[1],
utils.zeroBytes32
).send({from: registrant});
//TODO: check events
@ -216,6 +247,7 @@ contract('ENSSubdomainRegistry', function () {
domains.free.namehash,
utils.zeroAddress,
utils.zeroBytes32,
utils.zeroBytes32,
utils.zeroBytes32
).send({from: registrant});
let releaseDelay = await ENSSubdomainRegistry.methods.releaseDelay().call();
@ -257,6 +289,7 @@ contract('ENSSubdomainRegistry', function () {
domains.paid.namehash,
utils.zeroAddress,
utils.zeroBytes32,
utils.zeroBytes32,
utils.zeroBytes32
).send({from: registrant});
@ -290,6 +323,7 @@ contract('ENSSubdomainRegistry', function () {
domains.paid.namehash,
utils.zeroAddress,
utils.zeroBytes32,
utils.zeroBytes32,
utils.zeroBytes32
).send({from: registrant});
@ -330,6 +364,7 @@ contract('ENSSubdomainRegistry', function () {
domains.paid.namehash,
utils.zeroAddress,
utils.zeroBytes32,
utils.zeroBytes32,
utils.zeroBytes32
).send({from: registrant});
await ens.methods.setOwner(usernameHash, newOwner).send({from: registrant});
@ -371,6 +406,7 @@ contract('ENSSubdomainRegistry', function () {
domains.paid.namehash,
utils.zeroAddress,
utils.zeroBytes32,
utils.zeroBytes32,
utils.zeroBytes32
).send({from: registrant});
await ens.methods.setOwner(usernameHash, newOwner).send({from: registrant});