-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
2,124 additions
and
23 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
abi-bindings/go/staking/ERC20TokenStakingManager/ERC20TokenStakingManager.go
Large diffs are not rendered by default.
Oops, something went wrong.
2,060 changes: 2,060 additions & 0 deletions
2,060
abi-bindings/go/staking/ERC20TokenStakingManager/ERC20TokenStakingManager.go.orig
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,9 @@ import { | |
ERC20Burnable, | ||
ERC20 | ||
} from "@openzeppelin/[email protected]/token/ERC20/extensions/ERC20Burnable.sol"; | ||
import {IERC20Mintable} from "../staking/interfaces/IERC20Mintable.sol"; | ||
|
||
contract ExampleERC20 is ERC20Burnable { | ||
contract ExampleERC20 is ERC20Burnable, IERC20Mintable { | ||
string private constant _TOKEN_NAME = "Mock Token"; | ||
string private constant _TOKEN_SYMBOL = "EXMP"; | ||
|
||
|
@@ -30,4 +31,8 @@ contract ExampleERC20 is ERC20Burnable { | |
|
||
_mint(msg.sender, amount); | ||
} | ||
|
||
function mint(address account, uint256 amount) external { | ||
_mint(account, amount); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ pragma solidity 0.8.25; | |
import {IERC20TokenStakingManager} from "./interfaces/IERC20TokenStakingManager.sol"; | ||
import {Initializable} from | ||
"@openzeppelin/[email protected]/proxy/utils/Initializable.sol"; | ||
import {IERC20} from "@openzeppelin/[email protected]/token/ERC20/IERC20.sol"; | ||
import {IERC20Mintable} from "./interfaces/IERC20Mintable.sol"; | ||
import {SafeERC20TransferFrom} from "@utilities/SafeERC20TransferFrom.sol"; | ||
import {SafeERC20} from "@openzeppelin/[email protected]/token/ERC20/utils/SafeERC20.sol"; | ||
import {ICMInitializable} from "../utilities/ICMInitializable.sol"; | ||
|
@@ -20,13 +20,13 @@ contract ERC20TokenStakingManager is | |
PoSValidatorManager, | ||
IERC20TokenStakingManager | ||
{ | ||
using SafeERC20 for IERC20; | ||
using SafeERC20TransferFrom for IERC20; | ||
using SafeERC20 for IERC20Mintable; | ||
using SafeERC20TransferFrom for IERC20Mintable; | ||
|
||
// solhint-disable private-vars-leading-underscore | ||
/// @custom:storage-location erc7201:avalanche-icm.storage.ERC20TokenStakingManager | ||
struct ERC20TokenStakingManagerStorage { | ||
IERC20 _token; | ||
IERC20Mintable _token; | ||
uint8 _tokenDecimals; | ||
} | ||
// solhint-enable private-vars-leading-underscore | ||
|
@@ -62,22 +62,25 @@ contract ERC20TokenStakingManager is | |
*/ | ||
function initialize( | ||
PoSValidatorManagerSettings calldata settings, | ||
IERC20 token | ||
IERC20Mintable token | ||
) external reinitializer(2) { | ||
__ERC20TokenStakingManager_init(settings, token); | ||
} | ||
|
||
// solhint-disable func-name-mixedcase | ||
function __ERC20TokenStakingManager_init( | ||
PoSValidatorManagerSettings calldata settings, | ||
IERC20 token | ||
IERC20Mintable token | ||
) internal onlyInitializing { | ||
__POS_Validator_Manager_init(settings); | ||
__ERC20TokenStakingManager_init_unchained(token); | ||
} | ||
|
||
// solhint-disable func-name-mixedcase | ||
function __ERC20TokenStakingManager_init_unchained(IERC20 token) internal onlyInitializing { | ||
function __ERC20TokenStakingManager_init_unchained(IERC20Mintable token) | ||
internal | ||
onlyInitializing | ||
{ | ||
ERC20TokenStakingManagerStorage storage $ = _getERC20StakingManagerStorage(); | ||
require(address(token) != address(0), "ERC20TokenStakingManager: zero token address"); | ||
$._token = token; | ||
|
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,12 @@ | ||
// (c) 2024, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
// SPDX-License-Identifier: Ecosystem | ||
|
||
pragma solidity 0.8.25; | ||
|
||
import {IERC20} from "@openzeppelin/[email protected]/token/ERC20/IERC20.sol"; | ||
|
||
interface IERC20Mintable is IERC20 { | ||
function mint(address account, uint256 amount) external; | ||
} |
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 |
---|---|---|
|
@@ -12,16 +12,16 @@ import {PoSValidatorManagerSettings} from "../interfaces/IPoSValidatorManager.so | |
import {IRewardCalculator} from "../interfaces/IRewardCalculator.sol"; | ||
import {ICMInitializable} from "../../utilities/ICMInitializable.sol"; | ||
import {ExampleERC20} from "@mocks/ExampleERC20.sol"; | ||
import {IERC20} from "@openzeppelin/[email protected]/token/ERC20/IERC20.sol"; | ||
import {IERC20Mintable} from "../interfaces/IERC20Mintable.sol"; | ||
import {SafeERC20} from "@openzeppelin/[email protected]/token/ERC20/utils/SafeERC20.sol"; | ||
|
||
// TODO: Remove this once all unit tests implemented | ||
// solhint-disable no-empty-blocks | ||
contract ERC20TokenStakingManagerTest is PoSValidatorManagerTest { | ||
using SafeERC20 for IERC20; | ||
using SafeERC20 for IERC20Mintable; | ||
|
||
ERC20TokenStakingManager public app; | ||
IERC20 public token; | ||
IERC20Mintable public token; | ||
|
||
function setUp() public virtual { | ||
// Construct the object under test | ||
|