This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from rnsdomains/v2
New resolver
- Loading branch information
Showing
22 changed files
with
5,621 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
pragma solidity ^0.5.0; | ||
|
||
import "@ensdomains/resolver/contracts/profiles/AddrResolver.sol"; | ||
|
||
// Source: https://github.com/ensdomains/resolvers/blob/9c3ed5377501d77738089c81c2a0b141878048f9/contracts/profiles/AddrResolver.sol | ||
contract RSKAddrResolver is AddrResolver { | ||
uint constant private COIN_TYPE_RSK = 137; | ||
|
||
/** | ||
* Sets the address associated with an RNS node. | ||
* @param node The node to update. | ||
* @param a The address to set. | ||
*/ | ||
function setAddr(bytes32 node, address a) external authorised(node) { | ||
bytes memory b = addressToBytes(a); | ||
emit AddressChanged(node, COIN_TYPE_RSK, b); | ||
emit AddrChanged(node, a); | ||
_addresses[node][COIN_TYPE_RSK] = b; | ||
} | ||
|
||
/** | ||
* Returns the address associated with an RNS node. | ||
* @param node The RNS node to query. | ||
* @return The associated address. | ||
*/ | ||
function addr(bytes32 node) public view returns (address payable) { | ||
bytes memory a = addr(node, COIN_TYPE_RSK); | ||
if (a.length == 0) { | ||
return address(0); | ||
} | ||
return bytesToAddress(a); | ||
} | ||
|
||
/** | ||
* Sets the coin address associated with an RNS node . | ||
* @param node The node to update. | ||
* @param coinType slip0044 coin type. | ||
* @param a The address to set. | ||
*/ | ||
function setAddr(bytes32 node, uint coinType, bytes memory a) public authorised(node) { | ||
emit AddressChanged(node, coinType, a); | ||
if(coinType == COIN_TYPE_RSK) { | ||
emit AddrChanged(node, bytesToAddress(a)); | ||
} | ||
_addresses[node][coinType] = a; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
pragma solidity ^0.5.0; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "@rsksmart/rns-registry/contracts/AbstractRNS.sol"; | ||
import "@openzeppelin/upgrades/contracts/Initializable.sol"; | ||
import "./RSKAddrResolver.sol"; | ||
import "@ensdomains/resolver/contracts/profiles/ContentHashResolver.sol"; | ||
import "@ensdomains/resolver/contracts/profiles/ABIResolver.sol"; | ||
import "@ensdomains/resolver/contracts/profiles/PubkeyResolver.sol"; | ||
import "@ensdomains/resolver/contracts/profiles/TextResolver.sol"; | ||
import "@ensdomains/resolver/contracts/profiles/InterfaceResolver.sol"; | ||
|
||
/** | ||
* @title ResolverV1 | ||
* @dev A public resolver implementation. This implementation can | ||
* be as an openzeppelin/upgrades v2.8 proxy contract implementation. | ||
* Source: https://github.com/ensdomains/resolvers/blob/9c3ed5377501d77738089c81c2a0b141878048f9/contracts/PublicResolver.sol | ||
*/ | ||
contract ResolverV1 is Initializable, RSKAddrResolver, ContentHashResolver, ABIResolver, PubkeyResolver, TextResolver, InterfaceResolver { | ||
AbstractRNS public rns; | ||
|
||
/** | ||
* A mapping of authorisations. An address that is authorised for a name | ||
* may make any changes to the name that the owner could, but may not update | ||
* the set of authorisations. | ||
* (node, owner, caller) => isAuthorised | ||
*/ | ||
mapping(bytes32=>mapping(address=>mapping(address=>bool))) public authorisations; | ||
|
||
event AuthorisationChanged(bytes32 indexed node, address indexed owner, address indexed target, bool isAuthorised); | ||
|
||
/** | ||
* @notice Initializes the contract. | ||
* @dev Replace the usage of a constructor. | ||
* @param _rns the RNS Registry address. | ||
*/ | ||
function initialize(AbstractRNS _rns) initializer external { | ||
rns = _rns; | ||
} | ||
|
||
/** | ||
* @dev Sets or clears an authorisation. | ||
* Authorisations are specific to the caller. Any account can set an authorisation | ||
* for any name, but the authorisation that is checked will be that of the | ||
* current owner of a name. Thus, transferring a name effectively clears any | ||
* existing authorisations, and new authorisations can be set in advance of | ||
* an ownership transfer if desired. | ||
* | ||
* @param node The name to change the authorisation on. | ||
* @param target The address that is to be authorised or deauthorised. | ||
* @param isAuthorised True if the address should be authorised, or false if it should be deauthorised. | ||
*/ | ||
function setAuthorisation(bytes32 node, address target, bool isAuthorised) external { | ||
authorisations[node][msg.sender][target] = isAuthorised; | ||
emit AuthorisationChanged(node, msg.sender, target, isAuthorised); | ||
} | ||
|
||
function isAuthorised(bytes32 node) internal view returns(bool) { | ||
address owner = rns.owner(node); | ||
return owner == msg.sender || authorisations[node][owner][msg.sender]; | ||
} | ||
|
||
function multicall(bytes[] calldata data) external returns(bytes[] memory results) { | ||
results = new bytes[](data.length); | ||
for(uint i = 0; i < data.length; i++) { | ||
(bool success, bytes memory result) = address(this).delegatecall(data[i]); | ||
require(success); | ||
results[i] = result; | ||
} | ||
return results; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
pragma solidity ^0.5.0; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "../ResolverV1.sol"; | ||
import "@openzeppelin/contracts/introspection/IERC165.sol"; | ||
|
||
contract DummyVersion is ResolverV1 { | ||
uint public v; | ||
|
||
event Log(); | ||
|
||
function initialize() public { | ||
emit Log(); | ||
} | ||
|
||
function setV(uint _v) public { | ||
v = _v; | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceID) public pure returns(bool) { | ||
return interfaceID == this.setV.selector || super.supportsInterface(interfaceID); | ||
} | ||
} | ||
|
||
contract TruthyERC165 is IERC165 { | ||
function supportsInterface(bytes4 /*interfaceId*/) external view returns (bool) { | ||
return true; | ||
} | ||
} | ||
|
||
contract FalsyERC165 is IERC165 { | ||
function supportsInterface(bytes4 /*interfaceId*/) external view returns (bool) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pragma solidity ^0.5.0; | ||
|
||
import "@openzeppelin/upgrades/contracts/upgradeability/ProxyFactory.sol"; | ||
import "@openzeppelin/upgrades/contracts/upgradeability/ProxyAdmin.sol"; | ||
|
||
contract Dummy { | ||
constructor() internal { | ||
revert("This contract is used to import dependencies. Do not use."); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.