From 81aa4a4004e57e730e11d0fd457e8c55417229f0 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Mon, 27 Aug 2018 10:57:52 -0300 Subject: [PATCH] small logic fix --- contracts/registry/ENSSubdomainRegistry.sol | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/contracts/registry/ENSSubdomainRegistry.sol b/contracts/registry/ENSSubdomainRegistry.sol index 56dd1ee..83ba8f3 100644 --- a/contracts/registry/ENSSubdomainRegistry.sol +++ b/contracts/registry/ENSSubdomainRegistry.sol @@ -25,6 +25,7 @@ contract ENSSubdomainRegistry is Controlled { event FundsOwner(bytes32 indexed subdomainhash, address fundsOwner); event DomainPrice(bytes32 indexed namehash, uint256 price); event DomainMoved(bytes32 indexed namehash, address newRegistry); + event SlashedSubdomain(bytes32 namehash, address reporter); enum NodeState { Free, Owned, Moved } struct Domain { @@ -194,15 +195,15 @@ contract ENSSubdomainRegistry is Controlled { bytes32 userHash = keccak256(_subdomain); bytes32 subdomainHash = keccak256(abi.encodePacked(_domainHash, userHash)); - require(accounts[subdomainHash].creationTime == 0, "Username not registered."); + require(accounts[subdomainHash].creationTime > 0, "Username not registered."); uint256 offendingChar = uint256(_subdomain[_offendingPos]); - require(offendingChar >= _rangeStart && offendingChar <= _rangeEnd, "Invalid range."); + require(_rangeStart < offendingChar && _rangeEnd > offendingChar, "Invalid range."); require( MerkleProof.verifyProof( _proof, unallowedCharactersMerkleRoot, - keccak256(abi.encodePacked(_rangeStart, _rangeEnd)) + keccak256(abi.encodePacked(keccak256(abi.encodePacked(_rangeStart, _rangeEnd)))) ), "Invalid Proof." ); @@ -213,7 +214,10 @@ contract ENSSubdomainRegistry is Controlled { uint256 amountToTransfer = accounts[subdomainHash].tokenBalance; delete accounts[subdomainHash]; - require(token.transfer(msg.sender, amountToTransfer), "Error in transfer."); + if(amountToTransfer > 0){ + require(token.transfer(msg.sender, amountToTransfer), "Error in transfer."); + } + emit SlashedSubdomain(subdomainHash, msg.sender); } /**