Skip to content

Latest commit

 

History

History
176 lines (111 loc) · 4.19 KB

File metadata and controls

176 lines (111 loc) · 4.19 KB

Whitelist

1. Summary

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.

2. Important links

{% embed url="https://github.com/PWNFinance/pwn_safe/blob/main/src/Whitelist.sol" %} GitHub {% endembed %}

{% file src="../../../../.gitbook/assets/Whitelist.json" %} JSON ABI {% endfile %}

3. Contract details

  • Whitelist.sol is written in Solidity version 0.8.15
  • This contract inherits the Ownable contract

Features

  • Keeps a whitelist of approved assets
  • Keeps a whitelist of approved libraries for delegate calls

Functions

canBeTokenized

Overview

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:

  • addressassetAddress - Address of the asset or asset collection to check

Implementation

function canBeTokenized(address assetAddress) external view returns (bool) {
    if (!useWhitelist)
        return true;

    return isWhitelisted[assetAddress];
}
setUseWhitelist

Overview

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 the useWhitelist flag

Implementation

function setUseWhitelist(bool _useWhitelist) external onlyOwner {
	useWhitelist = _useWhitelist;
}
setIsWhitelisted

Overview

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:

  • addressassetAddress - Address of the asset being modified
  • bool_isWhitelisted - Boolean determining the addition or removal from the whitelist

Implementation

function setIsWhitelisted(
	address assetAddress,
	bool _isWhitelisted
) public onlyOwner {
	isWhitelisted[assetAddress] = _isWhitelisted;
}
setIsWhitelistedBatch

Overview

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[] calldataassetAddresses - Array of addresses being modified
  • bool_isWhitelisted - Boolean determining the addition or removal from the whitelist

Implementation

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:

  • addresslibAddress - Address of the library being modified
  • bool_isWhitelisted - Boolean determining the addition or removal from the whitelist

Implementation

function setIsWhitelistedLib(address libAddress, bool _isWhitelisted) public onlyOwner {
    isWhitelistedLib[libAddress] = _isWhitelisted;
}

Events

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 indexedassetAddress - Address of the whitelisted asset
  • boolindexedisWhitelisted - True if the asset was whitelisted and false if the asset was removed from the whitelist