PWN Hub
1. Summary
The PWNHub.sol contract stores tags for each contract in the protocol and therefore defines what contracts are a valid part of the protocol.
2. Important links
3. Contract details
- PWNHub.sol is written in Solidity version 0.8.16
Features
- Stores tags
- Sets tags
- Provides view functions to read tags
Inherited contracts, implemented Interfaces and ERCs
Functions
setTag
Overview
An owner of the PWN Hub can add and remove tag to/from different address. This way new contracts to the protocol are added and old ones are deprecated.
This function takes three arguments supplied by the owner:
address
_address
- Address to which a tag is setbytes32
tag
- Tag that is set to the addressbool
_hasTag
- Boolean determining if the tag will be added or removed
Implementation
function setTag(address _address, bytes32 tag, bool _hasTag) public onlyOwner {
tags[_address][tag] = _hasTag;
emit TagSet(_address, tag, _hasTag);
}
setTags
Overview
This function allows performing setTag
on multiple addresses and tags at the same time. Only the addition or removal of tags can be done in one call.
This function takes three arguments supplied by the owner:
address[] memory
_addresses
- Addresses to which a corresponding tag is setbytes32[] memory
tags
- Tags that are set to the corresponding addressesbool
_hasTag
- Boolean determining if the tags will be added or removed
Implementation
function setTags(address[] memory _addresses, bytes32[] memory _tags, bool _hasTag) external onlyOwner {
if (_addresses.length != _tags.length)
revert InvalidInputData();
uint256 length = _tags.length;
for (uint256 i; i < length;) {
setTag(_addresses[i], _tags[i], _hasTag);
unchecked { ++i; }
}
}
View Functions
hasTag
Overview
This function checks if an address has a supplied tag set and returns a boolean.
This function takes two arguments supplied by the caller:
address
_address
- Address to checkbytes32
tag
- Tag to check
Implementation
function hasTag(address _address, bytes32 tag) external view returns (bool) {
return tags[_address][tag];
}
Events
The PWN Hub contract defines one event and no custom errors.
event TagSet(address indexed _address, bytes32 indexed tag, bool hasTag);
TagSet
TagSet event is emitted when a tag is set for an address.
This event has three parameters:
address indexed
_address
- Address the tag is set tobytes32 indexed
tag
- Tag that has been set to the addressbool
hasTag
- Boolean determining if the tag has been set or unset