Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
Update Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonLewis committed Sep 25, 2023
1 parent fa942df commit 3841683
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions KIPs/kip-149.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ interface IBaseRegistry {
function getActiveAddr(string memory name) external returns (address);
/// @dev Returns all system contracts registered as name.
function getAllContracts(string memory name) external view returns (Record[] memory);
function getAllRecords(string memory name) external view returns (Record[] memory);
/// @dev Returns all names of registered system contracts.
function getAllContractNames() external view returns (string[] memory);
function getAllNames() external view returns (string[] memory);
/// @dev Returns owner of contract.
function owner() external view returns (address);
Expand Down Expand Up @@ -228,31 +228,32 @@ bytes32 public constant STAKING_TRACKER_KEY = keccak256(abi.encodePacked("Stakin
* @dev Returns the address of contract if active at current block including pre-deployed system contract.
* @param name Name of the system contract.
*/
function getActiveContract(string memory name) public view override returns (address) {
bytes32 key = keccak256(abi.encodePacked(name));
function getActiveAddr(string memory name) public view override returns (address) {
address addr = super.getActiveAddr(name);
if (addr != address(0)) {
return addr;
}
uint256 activation;
bytes32 key = keccak256(abi.encodePacked(name));
uint256 length = records[name].length;
uint256 activation;
if (length > 0) {
activation = records[name][length - 1].activation;
}
address addr = super.getActiveAddr(name);
if (addr != address(0)) {
return addr;
// It means it was deprecated by registering zero address.
bool isActivated = activation != 0 && activation <= block.number;
if (key == ADDRESS_BOOK_KEY) {
return isActivated ? addr : ADDRESS_BOOK;
} else if (key == VOTING_KEY) {
return isActivated ? addr : VOTING;
} else if (key == TREASURY_REBALANCE_KEY) {
return isActivated ? addr : TREASURY_REBALANCE;
} else if (key == STAKING_TRACKER_KEY) {
return isActivated ? addr : STAKING_TRACKER;
} else {
if (key == ADDRESS_BOOK_KEY) {
return activation != 0 && activation <= block.number ? address(0) : ADDRESS_BOOK;
} else if (key == VOTING_KEY) {
return activation != 0 && activation <= block.number ? address(0) : VOTING;
} else if (key == TREASURY_REBALANCE_KEY) {
return activation != 0 && activation <= block.number ? address(0) : TREASURY_REBALANCE;
} else if (key == STAKING_TRACKER_KEY) {
return activation != 0 && activation <= block.number ? address(0) : STAKING_TRACKER;
} else {
return addr;
}
return addr;
}
}
```
Expand Down

0 comments on commit 3841683

Please sign in to comment.