Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #307 from ensdomains/upgrade/truffle
Browse files Browse the repository at this point in the history
upgrade/truffle
  • Loading branch information
Dean Eigenmann authored Dec 27, 2018
2 parents 9a6c49a + 0419298 commit 192a0c1
Show file tree
Hide file tree
Showing 21 changed files with 346 additions and 266 deletions.
6 changes: 3 additions & 3 deletions contracts/DNSResolver.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

contract DNSResolver {
address public owner;
Expand All @@ -13,11 +13,11 @@ contract DNSResolver {
owner = msg.sender;
}

function setDnsrr(bytes32 node, bytes data) public owner_only {
function setDnsrr(bytes32 node, bytes memory data) public owner_only {
zones[node] = data;
}

function dnsrr(bytes32 node) public view returns (bytes) {
function dnsrr(bytes32 node) public view returns (bytes memory) {
return zones[node];
}

Expand Down
20 changes: 10 additions & 10 deletions contracts/Deed.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
pragma solidity ^0.4.24;
pragma solidity >=0.4.24;

interface Deed {

function setOwner(address newOwner) public;
function setRegistrar(address newRegistrar) public;
function setBalance(uint newValue, bool throwOnFailure) public;
function closeDeed(uint refundRatio) public;
function destroyDeed() public;
function setOwner(address payable newOwner) external;
function setRegistrar(address newRegistrar) external;
function setBalance(uint newValue, bool throwOnFailure) external;
function closeDeed(uint refundRatio) external;
function destroyDeed() external;

function owner() public view returns (address);
function previousOwner() public view returns (address);
function value() public view returns (uint);
function creationDate() public view returns (uint);
function owner() external view returns (address);
function previousOwner() external view returns (address);
function value() external view returns (uint);
function creationDate() external view returns (uint);

}
86 changes: 45 additions & 41 deletions contracts/DeedImplementation.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "./Deed.sol";

Expand All @@ -8,22 +8,22 @@ import "./Deed.sol";
*/
contract DeedImplementation is Deed {

address constant burn = 0xdead;
address payable constant burn = address(0xdead);

address public registrar;
address public owner;
address public previousOwner;
address payable private _owner;
address private _previousOwner;
address private _registrar;

uint public creationDate;
uint public value;
uint private _creationDate;
uint private _value;

bool active;

event OwnerChanged(address newOwner);
event DeedClosed();

modifier onlyRegistrar {
require(msg.sender == registrar);
require(msg.sender == _registrar);
_;
}

Expand All @@ -32,72 +32,76 @@ contract DeedImplementation is Deed {
_;
}

constructor(address _owner) public payable {
owner = _owner;
registrar = msg.sender;
creationDate = now;
constructor(address payable initialOwner) public payable {
_owner = initialOwner;
_registrar = msg.sender;
_creationDate = now;
active = true;
value = msg.value;
_value = msg.value;
}

function setOwner(address newOwner) public onlyRegistrar {
require(newOwner != 0);
previousOwner = owner; // This allows contracts to check who sent them the ownership
owner = newOwner;
function setOwner(address payable newOwner) external onlyRegistrar {
require(newOwner != address(0x0));
_previousOwner = _owner; // This allows contracts to check who sent them the ownership
_owner = newOwner;
emit OwnerChanged(newOwner);
}

function setRegistrar(address newRegistrar) public onlyRegistrar {
registrar = newRegistrar;
function setRegistrar(address newRegistrar) external onlyRegistrar {
_registrar = newRegistrar;
}

function setBalance(uint newValue, bool throwOnFailure) public onlyRegistrar onlyActive {
function setBalance(uint newValue, bool throwOnFailure) external onlyRegistrar onlyActive {
// Check if it has enough balance to set the value
require(value >= newValue);
value = newValue;
require(_value >= newValue);
_value = newValue;
// Send the difference to the owner
require(owner.send(address(this).balance - newValue) || !throwOnFailure);
require(_owner.send(address(this).balance - newValue) || !throwOnFailure);
}

/**
* @dev Close a deed and refund a specified fraction of the bid value
*
* @param refundRatio The amount*1/1000 to refund
*/
function closeDeed(uint refundRatio) public onlyRegistrar onlyActive {
function closeDeed(uint refundRatio) external onlyRegistrar onlyActive {
active = false;
require(burn.send(((1000 - refundRatio) * address(this).balance)/1000));
emit DeedClosed();
destroyDeed();
_destroyDeed();
}

/**
* @dev Close a deed and refund a specified fraction of the bid value
*/
function destroyDeed() public {
require(!active);
function destroyDeed() external {
_destroyDeed();
}

// Instead of selfdestruct(owner), invoke owner fallback function to allow
// owner to log an event if desired; but owner should also be aware that
// its fallback function can also be invoked by setBalance
if (owner.send(address(this).balance)) {
selfdestruct(burn);
}
function owner() external view returns (address) {
return _owner;
}

function owner() public view returns (address) {
return owner;
function previousOwner() external view returns (address) {
return _previousOwner;
}

function previousOwner() public view returns (address) {
return previousOwner;
function value() external view returns (uint) {
return _value;
}

function value() public view returns (uint) {
return value;
function creationDate() external view returns (uint) {
_creationDate;
}

function creationDate() public view returns (uint) {
return creationDate;
function _destroyDeed() internal {
require(!active);

// Instead of selfdestruct(owner), invoke owner fallback function to allow
// owner to log an event if desired; but owner should also be aware that
// its fallback function can also be invoked by setBalance
if (_owner.send(address(this).balance)) {
selfdestruct(burn);
}
}
}
6 changes: 3 additions & 3 deletions contracts/DefaultReverseResolver.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "./ReverseRegistrar.sol";

Expand Down Expand Up @@ -31,7 +31,7 @@ contract DefaultReverseResolver is Resolver {

// Assign ownership of the reverse record to our deployer
ReverseRegistrar registrar = ReverseRegistrar(ens.owner(ADDR_REVERSE_NODE));
if (address(registrar) != 0) {
if (address(registrar) != address(0x0)) {
registrar.claim(msg.sender);
}
}
Expand All @@ -41,7 +41,7 @@ contract DefaultReverseResolver is Resolver {
* @param node The node to update.
* @param _name The name to set.
*/
function setName(bytes32 node, string _name) public owner_only(node) {
function setName(bytes32 node, string memory _name) public owner_only(node) {
name[node] = _name;
}
}
16 changes: 8 additions & 8 deletions contracts/ENS.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity >=0.4.24;

interface ENS {

Expand All @@ -15,12 +15,12 @@ interface ENS {
event NewTTL(bytes32 indexed node, uint64 ttl);


function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public;
function setResolver(bytes32 node, address resolver) public;
function setOwner(bytes32 node, address owner) public;
function setTTL(bytes32 node, uint64 ttl) public;
function owner(bytes32 node) public view returns (address);
function resolver(bytes32 node) public view returns (address);
function ttl(bytes32 node) public view returns (uint64);
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external;
function setResolver(bytes32 node, address resolver) external;
function setOwner(bytes32 node, address owner) external;
function setTTL(bytes32 node, uint64 ttl) external;
function owner(bytes32 node) external view returns (address);
function resolver(bytes32 node) external view returns (address);
function ttl(bytes32 node) external view returns (uint64);

}
16 changes: 8 additions & 8 deletions contracts/ENSRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "./ENS.sol";

Expand Down Expand Up @@ -32,7 +32,7 @@ contract ENSRegistry is ENS {
* @param node The node to transfer ownership of.
* @param owner The address of the new owner.
*/
function setOwner(bytes32 node, address owner) public only_owner(node) {
function setOwner(bytes32 node, address owner) external only_owner(node) {
emit Transfer(node, owner);
records[node].owner = owner;
}
Expand All @@ -43,7 +43,7 @@ contract ENSRegistry is ENS {
* @param label The hash of the label specifying the subnode.
* @param owner The address of the new owner.
*/
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) public only_owner(node) {
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external only_owner(node) {
bytes32 subnode = keccak256(abi.encodePacked(node, label));
emit NewOwner(node, label, owner);
records[subnode].owner = owner;
Expand All @@ -54,7 +54,7 @@ contract ENSRegistry is ENS {
* @param node The node to update.
* @param resolver The address of the resolver.
*/
function setResolver(bytes32 node, address resolver) public only_owner(node) {
function setResolver(bytes32 node, address resolver) external only_owner(node) {
emit NewResolver(node, resolver);
records[node].resolver = resolver;
}
Expand All @@ -64,7 +64,7 @@ contract ENSRegistry is ENS {
* @param node The node to update.
* @param ttl The TTL in seconds.
*/
function setTTL(bytes32 node, uint64 ttl) public only_owner(node) {
function setTTL(bytes32 node, uint64 ttl) external only_owner(node) {
emit NewTTL(node, ttl);
records[node].ttl = ttl;
}
Expand All @@ -74,7 +74,7 @@ contract ENSRegistry is ENS {
* @param node The specified node.
* @return address of the owner.
*/
function owner(bytes32 node) public view returns (address) {
function owner(bytes32 node) external view returns (address) {
return records[node].owner;
}

Expand All @@ -83,7 +83,7 @@ contract ENSRegistry is ENS {
* @param node The specified node.
* @return address of the resolver.
*/
function resolver(bytes32 node) public view returns (address) {
function resolver(bytes32 node) external view returns (address) {
return records[node].resolver;
}

Expand All @@ -92,7 +92,7 @@ contract ENSRegistry is ENS {
* @param node The specified node.
* @return ttl of the node.
*/
function ttl(bytes32 node) public view returns (uint64) {
function ttl(bytes32 node) external view returns (uint64) {
return records[node].ttl;
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/FIFSRegistrar.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "./ENS.sol";

Expand All @@ -11,7 +11,7 @@ contract FIFSRegistrar {

modifier only_owner(bytes32 label) {
address currentOwner = ens.owner(keccak256(abi.encodePacked(rootNode, label)));
require(currentOwner == 0 || currentOwner == msg.sender);
require(currentOwner == address(0x0) || currentOwner == msg.sender);
_;
}

Expand Down
Loading

0 comments on commit 192a0c1

Please sign in to comment.