-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change the owner, add creator immutable state, update test
- Loading branch information
1 parent
5c7df17
commit 121f327
Showing
6 changed files
with
281 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
/** | ||
* @title MockRegistry | ||
* @dev Simulates a registry implementation for testing | ||
*/ | ||
contract MockRegistry { | ||
mapping(address => bool) public registeredAddresses; | ||
address public admin; | ||
uint256 public constant version = 1; | ||
|
||
// ### Events | ||
event AddressRegistered(address indexed account); | ||
event AddressUnregistered(address indexed account); | ||
event AdminChanged(address indexed oldAdmin, address indexed newAdmin); | ||
|
||
constructor() { | ||
admin = msg.sender; | ||
} | ||
|
||
function register(address account) external { | ||
require(!registeredAddresses[account], "Address already registered"); | ||
registeredAddresses[account] = true; | ||
emit AddressRegistered(account); | ||
} | ||
|
||
function unregister(address account) external { | ||
require(registeredAddresses[account], "Address not registered"); | ||
registeredAddresses[account] = false; | ||
emit AddressUnregistered(account); | ||
} | ||
|
||
function isRegistered(address account) external view returns (bool) { | ||
return registeredAddresses[account]; | ||
} | ||
|
||
function changeAdmin(address newAdmin) external { | ||
require(msg.sender == admin, "Only admin can change admin"); | ||
require(newAdmin != address(0), "New admin cannot be zero address"); | ||
emit AdminChanged(admin, newAdmin); | ||
admin = newAdmin; | ||
} | ||
|
||
function getRegistryVersion() public pure virtual returns (uint256) { | ||
return version; | ||
} | ||
|
||
function initialize(address _admin) external { | ||
require(admin == address(0), "Already initialized"); | ||
admin = _admin; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import {MockRegistry} from './MockRegistry.sol'; | ||
|
||
contract MockRegistryV2 is MockRegistry { | ||
function getRegistryVersion() public pure override returns (uint256) { | ||
return 2; | ||
} | ||
} |
Oops, something went wrong.