-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #707 from ava-labs/acp-99-reference-impl-multi-con…
…tract Refactor validator manager into multiple contracts
- Loading branch information
Showing
29 changed files
with
2,684 additions
and
4,768 deletions.
There are no files selected for viewing
541 changes: 541 additions & 0 deletions
541
abi-bindings/go/OwnableUpgradeable/OwnableUpgradeable.go
Large diffs are not rendered by default.
Oops, something went wrong.
1,726 changes: 137 additions & 1,589 deletions
1,726
abi-bindings/go/validator-manager/ERC20TokenStakingManager/ERC20TokenStakingManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
1,726 changes: 137 additions & 1,589 deletions
1,726
abi-bindings/go/validator-manager/NativeTokenStakingManager/NativeTokenStakingManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
883 changes: 468 additions & 415 deletions
883
...oAValidatorManager/PoAValidatorManager.go → ...ager/ValidatorManager/ValidatorManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
566 changes: 304 additions & 262 deletions
566
...SValidatorManager/IPoSValidatorManager.go → ...rfaces/IStakingManager/IStakingManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
|
||
pragma solidity 0.8.25; | ||
|
||
import {PoSValidatorManager} from "./PoSValidatorManager.sol"; | ||
import {PoSValidatorManagerSettings} from "./interfaces/IPoSValidatorManager.sol"; | ||
import {StakingManager} from "./StakingManager.sol"; | ||
import {StakingManagerSettings} from "./interfaces/IStakingManager.sol"; | ||
import {IERC20TokenStakingManager, PChainOwner} from "./interfaces/IERC20TokenStakingManager.sol"; | ||
import {IERC20Mintable} from "./interfaces/IERC20Mintable.sol"; | ||
import {ICMInitializable} from "@utilities/ICMInitializable.sol"; | ||
|
@@ -20,11 +20,7 @@ import {SafeERC20} from "@openzeppelin/[email protected]/token/ERC20/utils/SafeERC | |
* | ||
* @custom:security-contact https://github.com/ava-labs/icm-contracts/blob/main/SECURITY.md | ||
*/ | ||
contract ERC20TokenStakingManager is | ||
Initializable, | ||
PoSValidatorManager, | ||
IERC20TokenStakingManager | ||
{ | ||
contract ERC20TokenStakingManager is Initializable, StakingManager, IERC20TokenStakingManager { | ||
using SafeERC20 for IERC20Mintable; | ||
using SafeERC20TransferFrom for IERC20Mintable; | ||
|
||
|
@@ -67,18 +63,18 @@ contract ERC20TokenStakingManager is | |
* @param token The ERC20 token to be staked | ||
*/ | ||
function initialize( | ||
PoSValidatorManagerSettings calldata settings, | ||
StakingManagerSettings calldata settings, | ||
IERC20Mintable token | ||
) external reinitializer(2) { | ||
__ERC20TokenStakingManager_init(settings, token); | ||
} | ||
|
||
// solhint-disable-next-line func-name-mixedcase | ||
function __ERC20TokenStakingManager_init( | ||
PoSValidatorManagerSettings calldata settings, | ||
StakingManagerSettings calldata settings, | ||
IERC20Mintable token | ||
) internal onlyInitializing { | ||
__POS_Validator_Manager_init(settings); | ||
__StakingManager_init(settings); | ||
__ERC20TokenStakingManager_init_unchained(token); | ||
} | ||
|
||
|
@@ -137,23 +133,23 @@ contract ERC20TokenStakingManager is | |
} | ||
|
||
/** | ||
* @notice See {PoSValidatorManager-_lock} | ||
* @notice See {StakingManager-_lock} | ||
* Note: Must be guarded with reentrancy guard for safe transfer from. | ||
*/ | ||
function _lock(uint256 value) internal virtual override returns (uint256) { | ||
return _getERC20StakingManagerStorage()._token.safeTransferFrom(value); | ||
} | ||
|
||
/** | ||
* @notice See {PoSValidatorManager-_unlock} | ||
* @notice See {StakingManager-_unlock} | ||
* Note: Must be guarded with reentrancy guard for safe transfer. | ||
*/ | ||
function _unlock(address to, uint256 value) internal virtual override { | ||
_getERC20StakingManagerStorage()._token.safeTransfer(to, value); | ||
} | ||
|
||
/** | ||
* @notice See {PoSValidatorManager-_reward} | ||
* @notice See {StakingManager-_reward} | ||
*/ | ||
function _reward(address account, uint256 amount) internal virtual override { | ||
ERC20TokenStakingManagerStorage storage $ = _getERC20StakingManagerStorage(); | ||
|
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.