Skip to content

Commit

Permalink
feat: update hardhat toolbox for ethers v6 (#119)
Browse files Browse the repository at this point in the history
Signed-off-by: Jawad Tariq <[email protected]>
Co-authored-by: Jawad Tariq <[email protected]>
  • Loading branch information
sebastiendan and JDawg287 committed Jan 8, 2024
1 parent e6bf967 commit 79a4924
Show file tree
Hide file tree
Showing 24 changed files with 4,206 additions and 5,797 deletions.
2 changes: 1 addition & 1 deletion contracts/topos-core/AdminMultisigBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ contract AdminMultisigBase is EternalStorage {
}

function _getAdmin(uint256 adminEpoch, uint256 index) internal view returns (address) {
return getAddress(_getAdminKey(adminEpoch, index));
return getAddressStorage(_getAdminKey(adminEpoch, index));
}

function _getAdminCount(uint256 adminEpoch) internal view returns (uint256) {
Expand Down
4 changes: 3 additions & 1 deletion contracts/topos-core/EternalStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ contract EternalStorage {
return _stringStorage[key];
}

function getAddress(bytes32 key) public view returns (address) {
// Renamed getAddress to getAddressStorage to prevent overriding ethers v6
// getAddress BaseContract method
function getAddressStorage(bytes32 key) public view returns (address) {
return _addressStorage[key];
}

Expand Down
14 changes: 7 additions & 7 deletions contracts/topos-core/SubnetRegistrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ contract SubnetRegistrator is Initializable, Ownable {
/// @notice Subnet removal event
event SubnetRemoved(SubnetId subnetId);

/// @notice Contract initializer
/// @dev Can only be called once
/// @param admin address of the admin
function initialize(address admin) public initializer {
_transferOwnership(admin);
}

/// @notice Check if the subnet is already registered
/// @param subnetId FROST public key of a subnet
function subnetExists(SubnetId subnetId) external view returns (bool) {
Expand All @@ -49,13 +56,6 @@ contract SubnetRegistrator is Initializable, Ownable {
return SubnetId.wrap(subnetSet.keyAtIndex(index));
}

/// @notice Contract initializer
/// @dev Can only be called once
/// @param admin address of the admin
function initialize(address admin) public initializer {
_transferOwnership(admin);
}

/// @notice Register a new subnet
/// @param chainId subnet network ID
/// @param currencySymbol currencySymbol for a subnet currency
Expand Down
24 changes: 12 additions & 12 deletions contracts/topos-core/ToposCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable {
_disableInitializers();
}

/// @notice Contract initializer
/// @dev Can only be called once
/// @param adminAddresses list of admins
/// @param newAdminThreshold number of admins required to approve a call
function initialize(address[] memory adminAddresses, uint256 newAdminThreshold) public initializer {
// NOTE: Admin epoch is incremented to easily invalidate current admin-related state.
uint256 newAdminEpoch = _adminEpoch() + uint256(1);
_setAdminEpoch(newAdminEpoch);
_setAdmins(newAdminEpoch, adminAddresses, newAdminThreshold);
}

/// @notice Sets the subnet ID
/// @param _networkSubnetId The subnet ID of the subnet this contract is to be deployed on
function setNetworkSubnetId(SubnetId _networkSubnetId) external onlyAdmin {
Expand Down Expand Up @@ -125,17 +136,6 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable {
}
}

/// @notice Contract initializer
/// @dev Can only be called once
/// @param adminAddresses list of admins
/// @param newAdminThreshold number of admins required to approve a call
function initialize(address[] memory adminAddresses, uint256 newAdminThreshold) public initializer {
// NOTE: Admin epoch is incremented to easily invalidate current admin-related state.
uint256 newAdminEpoch = _adminEpoch() + uint256(1);
_setAdminEpoch(newAdminEpoch);
_setAdmins(newAdminEpoch, adminAddresses, newAdminThreshold);
}

/// @notice Checks if a certificate exists on the ToposCore contract
/// @param certId The Certificate ID
function certificateExists(CertificateId certId) public view returns (bool) {
Expand Down Expand Up @@ -172,7 +172,7 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable {

/// @notice Get the ToposCore implmentation address
function implementation() public view override returns (address) {
return getAddress(KEY_IMPLEMENTATION);
return getAddressStorage(KEY_IMPLEMENTATION);
}

/// @notice Get the certificate for the provided certificate ID
Expand Down
2 changes: 1 addition & 1 deletion contracts/topos-core/ToposCoreProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contract ToposCoreProxy is EternalStorage {

// solhint-disable-next-line no-complex-fallback
fallback() external payable {
address implementation = getAddress(KEY_IMPLEMENTATION);
address implementation = getAddressStorage(KEY_IMPLEMENTATION);

// solhint-disable-next-line no-inline-assembly
assembly {
Expand Down
Loading

0 comments on commit 79a4924

Please sign in to comment.