forked from ensdomains/ens-contracts
-
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 ensdomains#42 from ensdomains/namewrapper
Add namewrapper to ens-contracts
- Loading branch information
Showing
28 changed files
with
7,868 additions
and
2,287 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
PRIVATE_KEY= | ||
ETHERSCAN_API_KEY= | ||
INFURA_API_KEY= | ||
METADATA_ADDRESS= | ||
WRAPPER_ADDRESS= | ||
RESOLVER_ADDRESS= |
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,21 @@ | ||
module.exports = { | ||
env: { | ||
mocha: true, | ||
}, | ||
plugins: ["babel"], | ||
rules: { | ||
"import/extensions": [ | ||
"error", | ||
"ignorePackages", | ||
{ | ||
js: "never", | ||
ts: "never", | ||
}, | ||
], | ||
"import/prefer-default-export": "off", | ||
"prefer-destructuring": "off", | ||
"prefer-template": "off", | ||
"no-console": "off", | ||
"func-names": "off", | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
node_modules | ||
artifacts | ||
cache | ||
gasreport-* | ||
.env | ||
*.DS_Store | ||
node_modules | ||
build | ||
|
||
#Hardhat files | ||
cache | ||
artifacts |
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,9 @@ | ||
{ | ||
"extends": "solium:all", | ||
"rules": { | ||
"indentation": ["error", 4], | ||
"quotes": ["error", "double"], | ||
"arg-overflow": "off", | ||
"blank-lines": "off" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -18,4 +18,3 @@ script: | |
|
||
notifications: | ||
email: 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,51 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.4; | ||
|
||
library BytesUtils { | ||
/* | ||
* @dev Returns the keccak-256 hash of a byte range. | ||
* @param self The byte string to hash. | ||
* @param offset The position to start hashing at. | ||
* @param len The number of bytes to hash. | ||
* @return The hash of the byte range. | ||
*/ | ||
function keccak(bytes memory self, uint offset, uint len) internal pure returns (bytes32 ret) { | ||
require(offset + len <= self.length); | ||
assembly { | ||
ret := keccak256(add(add(self, 32), offset), len) | ||
} | ||
} | ||
|
||
/** | ||
* @dev Returns the ENS namehash of a DNS-encoded name. | ||
* @param self The DNS-encoded name to hash. | ||
* @param offset The offset at which to start hashing. | ||
* @return The namehash of the name. | ||
*/ | ||
function namehash(bytes memory self, uint offset) internal pure returns(bytes32) { | ||
(bytes32 labelhash, uint newOffset) = readLabel(self, offset); | ||
if(labelhash == bytes32(0)) { | ||
require(offset == self.length - 1, "namehash: Junk at end of name"); | ||
return bytes32(0); | ||
} | ||
return keccak256(abi.encodePacked(namehash(self, newOffset), labelhash)); | ||
} | ||
|
||
/** | ||
* @dev Returns the keccak-256 hash of a DNS-encoded label, and the offset to the start of the next label. | ||
* @param self The byte string to read a label from. | ||
* @param idx The index to read a label at. | ||
* @return labelhash The hash of the label at the specified index, or 0 if it is the last label. | ||
* @return newIdx The index of the start of the next label. | ||
*/ | ||
function readLabel(bytes memory self, uint256 idx) internal pure returns (bytes32 labelhash, uint newIdx) { | ||
require(idx < self.length, "readLabel: Index out of bounds"); | ||
uint len = uint(uint8(self[idx])); | ||
if(len > 0) { | ||
labelhash = keccak(self, idx + 1, len); | ||
} else { | ||
labelhash = bytes32(0); | ||
} | ||
newIdx = idx + len + 1; | ||
} | ||
} |
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,20 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.4; | ||
|
||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract Controllable is Ownable { | ||
mapping(address=>bool) public controllers; | ||
|
||
event ControllerChanged(address indexed controller, bool active); | ||
|
||
function setController(address controller, bool active) onlyOwner() public { | ||
controllers[controller] = active; | ||
emit ControllerChanged(controller, active); | ||
} | ||
|
||
modifier onlyController() { | ||
require(controllers[msg.sender], "Controllable: Caller is not a controller"); | ||
_; | ||
} | ||
} |
Oops, something went wrong.