- Added MINTER_ROLE constant to manage minting permissions. - Updated mint function to restrict access to addresses with MINTER_ROLE, enhancing security and compliance. - Granted MINTER_ROLE to the initial owner during contract deployment.
90 lines
3.1 KiB
Solidity
90 lines
3.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import "@openzeppelin/contracts/access/AccessControl.sol";
|
|
|
|
contract StablecoinReferenceRegistry is AccessControl {
|
|
bytes32 public constant STABLECOIN_REGISTRAR_ROLE = keccak256("STABLECOIN_REGISTRAR");
|
|
|
|
enum StablecoinStatus { ACTIVE, SUSPENDED, REVOKED }
|
|
|
|
struct StablecoinEntry {
|
|
string tokenSymbol;
|
|
address tokenAddress;
|
|
string issuerOrBridge;
|
|
string legalClaimType;
|
|
string redemptionPath;
|
|
string reserveDisclosureRef;
|
|
uint8 riskTier;
|
|
address pauseAuthority;
|
|
StablecoinStatus status;
|
|
bool exists;
|
|
}
|
|
|
|
mapping(address => StablecoinEntry) private _byAddress;
|
|
address[] private _addressList;
|
|
|
|
event StablecoinRegistered(
|
|
address indexed tokenAddress,
|
|
string tokenSymbol,
|
|
StablecoinStatus status
|
|
);
|
|
event StablecoinStatusUpdated(address indexed tokenAddress, StablecoinStatus status);
|
|
|
|
constructor(address admin) {
|
|
_grantRole(DEFAULT_ADMIN_ROLE, admin);
|
|
_grantRole(STABLECOIN_REGISTRAR_ROLE, admin);
|
|
}
|
|
|
|
function register(
|
|
address tokenAddress,
|
|
string calldata tokenSymbol,
|
|
string calldata issuerOrBridge,
|
|
string calldata legalClaimType,
|
|
string calldata redemptionPath,
|
|
string calldata reserveDisclosureRef,
|
|
uint8 riskTier,
|
|
address pauseAuthority
|
|
) external onlyRole(STABLECOIN_REGISTRAR_ROLE) {
|
|
require(tokenAddress != address(0), "DBIS: zero address");
|
|
require(!_byAddress[tokenAddress].exists, "DBIS: already registered");
|
|
_byAddress[tokenAddress] = StablecoinEntry({
|
|
tokenSymbol: tokenSymbol,
|
|
tokenAddress: tokenAddress,
|
|
issuerOrBridge: issuerOrBridge,
|
|
legalClaimType: legalClaimType,
|
|
redemptionPath: redemptionPath,
|
|
reserveDisclosureRef: reserveDisclosureRef,
|
|
riskTier: riskTier,
|
|
pauseAuthority: pauseAuthority,
|
|
status: StablecoinStatus.ACTIVE,
|
|
exists: true
|
|
});
|
|
_addressList.push(tokenAddress);
|
|
emit StablecoinRegistered(tokenAddress, tokenSymbol, StablecoinStatus.ACTIVE);
|
|
}
|
|
|
|
function setStatus(address tokenAddress, StablecoinStatus status) external onlyRole(STABLECOIN_REGISTRAR_ROLE) {
|
|
require(_byAddress[tokenAddress].exists, "DBIS: not registered");
|
|
_byAddress[tokenAddress].status = status;
|
|
emit StablecoinStatusUpdated(tokenAddress, status);
|
|
}
|
|
|
|
function getEntry(address tokenAddress) external view returns (StablecoinEntry memory) {
|
|
return _byAddress[tokenAddress];
|
|
}
|
|
|
|
function isActive(address tokenAddress) external view returns (bool) {
|
|
return _byAddress[tokenAddress].exists && _byAddress[tokenAddress].status == StablecoinStatus.ACTIVE;
|
|
}
|
|
|
|
function getRegisteredCount() external view returns (uint256) {
|
|
return _addressList.length;
|
|
}
|
|
|
|
function getRegisteredAt(uint256 index) external view returns (address) {
|
|
require(index < _addressList.length, "DBIS: index");
|
|
return _addressList[index];
|
|
}
|
|
}
|