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

chore: upgrades sol version to 8.4.0 #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions contracts/AbstractRNS.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.4;

contract AbstractRNS {
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 setOwner(bytes32 node, address ownerAddress) public;
function setSubnodeOwner(bytes32 node, bytes32 label, address ownerAddress) public;
function setResolver(bytes32 node, address resolverAddress) public;
function setTTL(bytes32 node, uint64 ttlValue) public;
abstract contract AbstractRNS {
function owner(bytes32 node) public view virtual returns (address);

function resolver(bytes32 node) public view virtual returns (address);

function ttl(bytes32 node) public view virtual returns (uint64);

function setOwner(bytes32 node, address ownerAddress) public virtual;

function setSubnodeOwner(
bytes32 node,
bytes32 label,
address ownerAddress
) public virtual;

function setResolver(bytes32 node, address resolverAddress) public virtual;

function setTTL(bytes32 node, uint64 ttlValue) public virtual;

// Logged when the owner of a node assigns a new owner to a subnode.
event NewOwner(bytes32 indexed node, bytes32 indexed label, address ownerAddress);
event NewOwner(
bytes32 indexed node,
bytes32 indexed label,
address ownerAddress
);

// Logged when the owner of a node transfers ownership to a new account.
event Transfer(bytes32 indexed node, address ownerAddress);
Expand Down
8 changes: 4 additions & 4 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.4;

contract Migrations {
address public owner;
uint public last_completed_migration;
uint256 public last_completed_migration;

constructor() public {
constructor() {
owner = msg.sender;
}

modifier restricted() {
if (msg.sender == owner) _;
}

function setCompleted(uint completed) public restricted {
function setCompleted(uint256 completed) public restricted {
last_completed_migration = completed;
}

Expand Down
38 changes: 27 additions & 11 deletions contracts/RNS.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pragma solidity ^0.5.0;
pragma solidity ^0.8.4;

import './AbstractRNS.sol';
import "./AbstractRNS.sol";

/// @title RNS Registry
contract RNS is AbstractRNS {
Expand All @@ -10,44 +10,48 @@ contract RNS is AbstractRNS {
uint64 ttl;
}

mapping(bytes32=>Record) records;
mapping(bytes32 => Record) records;

modifier only_owner(bytes32 node) {
require(records[node].owner == msg.sender);
_;
}

constructor() public {
constructor() {
records[bytes32(0)].owner = msg.sender;
}

/// @notice Returns the current owner of a domain.
/// @param node namehash of the domain.
/// @return The owner of the domain.
function owner(bytes32 node) public view returns (address) {
function owner(bytes32 node) public view override returns (address) {
return records[node].owner;
}

/// @notice Returns the current resolver of a domain.
/// @param node namehash of the domain.
/// @return The resolver of the domain.
function resolver(bytes32 node) public view returns (address) {
function resolver(bytes32 node) public view override returns (address) {
return records[node].resolver;
}

/// @notice Returns the time to live of a domain and any records
/// associated with it.
/// @param node namehash of the domain.
/// @return The ttl of the domain.
function ttl(bytes32 node) public view returns (uint64) {
function ttl(bytes32 node) public view override returns (uint64) {
return records[node].ttl;
}

/// @notice Transfers ownership of a domain.
/// @dev Only owner of the node.
/// @param node namehash of the domain to transfer ownership of.
/// @param ownerAddress The new owner.
function setOwner(bytes32 node, address ownerAddress) public only_owner(node) {
function setOwner(bytes32 node, address ownerAddress)
public
override
only_owner(node)
{
emit Transfer(node, ownerAddress);
records[node].owner = ownerAddress;
}
Expand All @@ -57,7 +61,11 @@ contract RNS is AbstractRNS {
/// @param node namehash of the parent domain.
/// @param label keccak256 of the label specifying the subnode.
/// @param ownerAddress The new owner.
function setSubnodeOwner(bytes32 node, bytes32 label, address ownerAddress) public only_owner(node) {
function setSubnodeOwner(
bytes32 node,
bytes32 label,
address ownerAddress
) public override only_owner(node) {
bytes32 subnode = keccak256(abi.encodePacked(node, label));
emit NewOwner(node, label, ownerAddress);
records[subnode].owner = ownerAddress;
Expand All @@ -70,7 +78,11 @@ contract RNS is AbstractRNS {
/// @dev Only owner of the node.
/// @param node namehash of the domain to set the resolver of.
/// @param resolverAddress The new resolver.
function setResolver(bytes32 node, address resolverAddress) public only_owner(node) {
function setResolver(bytes32 node, address resolverAddress)
public
override
only_owner(node)
{
emit NewResolver(node, resolverAddress);
records[node].resolver = resolverAddress;
}
Expand All @@ -79,7 +91,11 @@ contract RNS is AbstractRNS {
/// @dev Only owner of the node.
/// @param node namehash of the domain to set the ttl of.
/// @param ttlValue The new ttl.
function setTTL(bytes32 node, uint64 ttlValue) public only_owner(node) {
function setTTL(bytes32 node, uint64 ttlValue)
public
override
only_owner(node)
{
emit NewTTL(node, ttlValue);
records[node].ttl = ttlValue;
}
Expand Down
Loading