This contract is used by the ATR Module and is responsible for managing a whitelist of assets which are permitted to have their transfer rights tokenized.
{% embed url="https://github.com/PWNFinance/pwn_safe/blob/main/src/Whitelist.sol" %} GitHub {% endembed %}
{% file src="../../../../.gitbook/assets/Whitelist.json" %} JSON ABI {% endfile %}
- Whitelist.sol is written in Solidity version 0.8.15
- This contract inherits the Ownable contract
- Keeps a whitelist of approved assets
- Keeps a whitelist of approved libraries for delegate calls
canBeTokenized
A getter function to see if a certain asset or asset collection is whitelisted to be tokenised. The function returns a boolean.
This function takes one argument supplied by the caller:
address
assetAddress
- Address of the asset or asset collection to check
function canBeTokenized(address assetAddress) external view returns (bool) {
if (!useWhitelist)
return true;
return isWhitelisted[assetAddress];
}
setUseWhitelist
A setter function to turn the whitelist on and off. It can be called only by the owner.
This function takes one argument supplied by the owner:
bool
_useWhitelist
- A boolean to update theuseWhitelist
flag
function setUseWhitelist(bool _useWhitelist) external onlyOwner {
useWhitelist = _useWhitelist;
}
setIsWhitelisted
A setter function to add or remove an address from the whitelist. It can be called only by the owner.
This function takes two arguments supplied by the owner:
address
assetAddress
- Address of the asset being modifiedbool
_isWhitelisted
- Boolean determining the addition or removal from the whitelist
function setIsWhitelisted(
address assetAddress,
bool _isWhitelisted
) public onlyOwner {
isWhitelisted[assetAddress] = _isWhitelisted;
}
setIsWhitelistedBatch
A setter function to add or remove multiple addresses from the whitelist. It can be called only by the owner.
This function takes two arguments supplied by the caller:
address[] calldata
assetAddresses
- Array of addresses being modifiedbool
_isWhitelisted
- Boolean determining the addition or removal from the whitelist
function setIsWhitelistedBatch(
address[] calldata assetAddresses,
bool _isWhitelisted
) external onlyWhitelistManager {
uint256 length = assetAddresses.length;
for (uint256 i; i < length; ) {
setIsWhitelisted(assetAddresses[i], _isWhitelisted);
unchecked {
++i;
}
}
}
setIsWhitelistedLib
Overview
A setter function to add or remove a library address from the whitelist. It can be called only by the owner.
This function takes two arguments supplied by the owner:
address
libAddress
- Address of the library being modifiedbool
_isWhitelisted
- Boolean determining the addition or removal from the whitelist
Implementation
function setIsWhitelistedLib(address libAddress, bool _isWhitelisted) public onlyOwner {
isWhitelistedLib[libAddress] = _isWhitelisted;
}
The Whitelist contract defines one event and no custom errors.
event AssetWhitelisted(address indexed assetAddress, bool indexed isWhitelisted);
AssetWhitelisted
AssetWhitelisted event is emitted when an asset address is whitelisted or removed from the whitelist.
This event has two parameters:
address indexed
assetAddress
- Address of the whitelisted assetbool
indexed
isWhitelisted
- True if the asset was whitelisted and false if the asset was removed from the whitelist