Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
5ad62a7e
Commit
5ad62a7e
authored
Apr 09, 2021
by
smartcontracts
Committed by
GitHub
Apr 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: Minor cleanup to address manager (#372)
Co-authored-by:
Maurelian
<
maurelian@protonmail.ch
>
parent
b42fe20c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
6 deletions
+28
-6
Lib_AddressManager.sol
...mistic-ethereum/libraries/resolver/Lib_AddressManager.sol
+28
-6
No files found.
packages/contracts/contracts/optimistic-ethereum/libraries/resolver/Lib_AddressManager.sol
View file @
5ad62a7e
...
@@ -18,9 +18,10 @@ contract Lib_AddressManager is Ownable {
...
@@ -18,9 +18,10 @@ contract Lib_AddressManager is Ownable {
address _newAddress
address _newAddress
);
);
/*******************************************
* Contract Variables: Internal Accounting *
/*************
*******************************************/
* Variables *
*************/
mapping (bytes32 => address) private addresses;
mapping (bytes32 => address) private addresses;
...
@@ -29,6 +30,11 @@ contract Lib_AddressManager is Ownable {
...
@@ -29,6 +30,11 @@ contract Lib_AddressManager is Ownable {
* Public Functions *
* Public Functions *
********************/
********************/
/**
* Changes the address associated with a particular name.
* @param _name String name to associate an address with.
* @param _address Address to associate with the name.
*/
function setAddress(
function setAddress(
string memory _name,
string memory _name,
address _address
address _address
...
@@ -36,16 +42,27 @@ contract Lib_AddressManager is Ownable {
...
@@ -36,16 +42,27 @@ contract Lib_AddressManager is Ownable {
public
public
onlyOwner
onlyOwner
{
{
emit AddressSet(_name, _address);
addresses[_getNameHash(_name)] = _address;
addresses[_getNameHash(_name)] = _address;
emit AddressSet(
_name,
_address
);
}
}
/**
* Retrieves the address associated with a given name.
* @param _name Name to retrieve an address for.
* @return Address associated with the given name.
*/
function getAddress(
function getAddress(
string memory _name
string memory _name
)
)
public
public
view
view
returns (address)
returns (
address
)
{
{
return addresses[_getNameHash(_name)];
return addresses[_getNameHash(_name)];
}
}
...
@@ -55,13 +72,18 @@ contract Lib_AddressManager is Ownable {
...
@@ -55,13 +72,18 @@ contract Lib_AddressManager is Ownable {
* Internal Functions *
* Internal Functions *
**********************/
**********************/
/**
* Computes the hash of a name.
* @param _name Name to compute a hash for.
* @return Hash of the given name.
*/
function _getNameHash(
function _getNameHash(
string memory _name
string memory _name
)
)
internal
internal
pure
pure
returns (
returns (
bytes32
_hash
bytes32
)
)
{
{
return keccak256(abi.encodePacked(_name));
return keccak256(abi.encodePacked(_name));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment