-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathCrossChainNameServiceLookup.sol
47 lines (38 loc) · 1.49 KB
/
CrossChainNameServiceLookup.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import {OwnerIsCreator} from "@chainlink/contracts-ccip/src/v0.8/shared/access/OwnerIsCreator.sol";
/**
* THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
* THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE.
* DO NOT USE THIS CODE IN PRODUCTION.
*/
contract CrossChainNameServiceLookup is OwnerIsCreator {
mapping(string => address) public lookup;
address internal s_crossChainNameService;
event Registered(string indexed _name, address indexed _address);
error Unauthorized();
error AlreadyTaken();
modifier onlyCrossChainNameService() {
if (msg.sender != s_crossChainNameService) revert Unauthorized();
_;
}
/**
* @notice Sets the address of the Cross Chain Name Service entity
* This entity is either CrossChainNameServiceRegister or CrossChainNameServiceReceiver contract,
* depends on the chain this lookup contract lives
* @param crossChainNameService - address of the Cross Chain Name Service entity - Register or Receiver
* @dev Only Owner can call
*/
function setCrossChainNameServiceAddress(
address crossChainNameService
) external onlyOwner {
s_crossChainNameService = crossChainNameService;
}
function register(
string memory _name,
address _address
) external onlyCrossChainNameService {
if (lookup[_name] != address(0)) revert AlreadyTaken();
lookup[_name] = _address;
}
}