Skip to content
This repository was archived by the owner on Dec 18, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions contract-hardhat/contracts/FeatureRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import "./ReclaimTokens.sol";
import "./interfaces/IFeatureRegistry.sol";

/**
* @title Registry for managing polymath feature switches
*/
contract FeatureRegistry is IFeatureRegistry, ReclaimTokens {
mapping(bytes32 => bool) public featureStatus;

/**
* @notice Get the status of a feature
* @param _nameKey is the key for the feature status mapping
* @return bool
*/
function getFeatureStatus(string calldata _nameKey) external view returns(bool) {
bytes32 key = keccak256(bytes(_nameKey));
return featureStatus[key];
}

/**
* @notice change a feature status
* @dev feature status is set to false by default
* @param _nameKey is the key for the feature status mapping
* @param _newStatus is the new feature status
*/
function setFeatureStatus(string calldata _nameKey, bool _newStatus) external onlyOwner {
bytes32 key = keccak256(bytes(_nameKey));
require(featureStatus[key] != _newStatus, "Status unchanged");
emit ChangeFeatureStatus(_nameKey, _newStatus);
featureStatus[key] = _newStatus;
}

}
488 changes: 488 additions & 0 deletions contract-hardhat/contracts/ModuleRegistry.sol

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions contract-hardhat/contracts/Pausable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

/**
* @title Utility contract to allow pausing and unpausing of certain functions
*/
contract Pausable {
event Pause(address account);
event Unpause(address account);

bool public paused = false;

/**
* @notice Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused, "Contract is paused");
_;
}

/**
* @notice Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused, "Contract is not paused");
_;
}

/**
* @notice Called by the owner to pause, triggers stopped state
*/
function _pause() internal whenNotPaused {
paused = true;
/*solium-disable-next-line security/no-block-members*/
emit Pause(msg.sender);
}

/**
* @notice Called by the owner to unpause, returns to normal state
*/
function _unpause() internal whenPaused {
paused = false;
/*solium-disable-next-line security/no-block-members*/
emit Unpause(msg.sender);
}

}
35 changes: 35 additions & 0 deletions contract-hardhat/contracts/PolymathRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import "./ReclaimTokens.sol";
import "./interfaces/IPolymathRegistry.sol";

/**
* @title Core functionality for registry upgradability
*/
contract PolymathRegistry is ReclaimTokens, IPolymathRegistry {
mapping(bytes32 => address) public storedAddresses;

/**
* @notice Gets the contract address
* @param _nameKey is the key for the contract address mapping
* address
*/
function getAddress(string calldata _nameKey) external view returns(address) {
bytes32 key = keccak256(bytes(_nameKey));
require(storedAddresses[key] != address(0), "Invalid key");
return storedAddresses[key];
}

/**
* @notice Changes the contract address
* @param _nameKey is the key for the contract address mapping
* @param _newAddress is the new contract address
*/
function changeAddress(string calldata _nameKey, address _newAddress) external onlyOwner {
bytes32 key = keccak256(bytes(_nameKey));
emit ChangeAddress(_nameKey, storedAddresses[key], _newAddress);
storedAddresses[key] = _newAddress;
}

}
23 changes: 23 additions & 0 deletions contract-hardhat/contracts/ReclaimTokens.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;

import "./libraries/Ownable.sol";
import "./libraries/token/ERC20/IERC20.sol";

/**
* @title Utility contract to allow owner to retreive any ERC20 sent to the contract
*/
abstract contract ReclaimTokens is Ownable {
constructor() Ownable() {}

/**
* @notice Reclaim all ERC20Basic compatible tokens
* @param _tokenContract The address of the token contract
*/
function reclaimERC20(address _tokenContract) external onlyOwner {
require(_tokenContract != address(0), "Invalid address");
IERC20 token = IERC20(_tokenContract);
uint256 balance = token.balanceOf(address(this));
require(token.transfer(owner(), balance), "Transfer failed");
}
}
Loading