Skip to content

Commit

Permalink
Add @openzeppelin/contracts dependency
Browse files Browse the repository at this point in the history
Use ERC20 contracts and libraries to interact with staking token in
staking contract.
  • Loading branch information
r-czajkowski committed Oct 30, 2023
1 parent 5362d0c commit 048313b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
12 changes: 8 additions & 4 deletions core/contracts/staking/TokenStaking.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.9;
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/// @title TokenStaking
/// @notice A token staking contract for a specified standard ERC20 token. A
/// holder of the specified token can stake its tokens to this contract
/// and recover the stake after undelegation period is over.
contract TokenStaking {
// TODO: use IERC20 contract as type
address internal immutable token;
using SafeERC20 for IERC20;

IERC20 internal immutable token;

constructor(address _token) {
constructor(IERC20 _token) {
require(
address(_token) != address(0),
"Token can not be the zero address"
Expand Down
2 changes: 1 addition & 1 deletion core/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.17",
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
Expand Down
3 changes: 3 additions & 0 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,8 @@
"ts-node": ">=8.0.0",
"typechain": "^8.1.0",
"typescript": ">=4.5.0"
},
"dependencies": {
"@openzeppelin/contracts": "^5.0.0"
}
}
5 changes: 5 additions & 0 deletions core/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,11 @@
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-waffle/-/hardhat-waffle-2.0.6.tgz#d11cb063a5f61a77806053e54009c40ddee49a54"
integrity sha512-+Wz0hwmJGSI17B+BhU/qFRZ1l6/xMW82QGXE/Gi+WTmwgJrQefuBs1lIf7hzQ1hLk6hpkvb/zwcNkpVKRYTQYg==

"@openzeppelin/contracts@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.0.tgz#ee0e4b4564f101a5c4ee398cd4d73c0bd92b289c"
integrity sha512-bv2sdS6LKqVVMLI5+zqnNrNU/CA+6z6CmwFXm/MzmOPBRSO5reEJN7z0Gbzvs0/bv/MZZXNklubpwy3v2+azsw==

"@openzeppelin/defender-admin-client@^1.48.0":
version "1.49.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-admin-client/-/defender-admin-client-1.49.0.tgz#ed07318ccba10ac8a8a33cf594fc18b7ab5889f9"
Expand Down

0 comments on commit 048313b

Please sign in to comment.