-
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.
DAO-385: Implement Upgradable veRIF ERC20 contract with ERC20 Votes (#2)
* remove Lock files * add prettier * add veRIF contract * implement upgradeable veRIF ERC20 contract * update README * RIFTokenTest * deploy DAO * fix sol lint * fix solhint * add a comment * change to deploy-veRif * remove semicolons * rename file
- Loading branch information
1 parent
aa7406a
commit 699b0cb
Showing
18 changed files
with
1,206 additions
and
562 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"arrowParens": "avoid", | ||
"trailingComma": "all", | ||
"printWidth": 110, | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"bracketSpacing": true, | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"singleQuote": false, | ||
"explicitTypes": "always" | ||
} | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
{ | ||
"extends": "solhint:recommended" | ||
"extends": "solhint:recommended", | ||
"rules": { | ||
"no-global-import": "off", | ||
"func-visibility": ["warn", { "ignoreConstructors": true }] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules | ||
contracts/RIFTokenTest.sol | ||
contracts/RIFToken.sol |
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,3 @@ | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.24+commit.e11b9ed9" | ||
} |
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.
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,6 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.4.24; | ||
|
||
import "rif-token-contracts/contracts/RIF/RIFToken.sol"; | ||
|
||
/* File must exist, else test/RIFToken.test.ts will fail */ |
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Compatible with OpenZeppelin Contracts ^5.0.0 | ||
pragma solidity ^0.8.20; | ||
|
||
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20WrapperUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; | ||
|
||
contract VeRIFToken is | ||
Initializable, | ||
ERC20Upgradeable, | ||
ERC20PermitUpgradeable, | ||
ERC20VotesUpgradeable, | ||
ERC20WrapperUpgradeable, | ||
OwnableUpgradeable, | ||
UUPSUpgradeable | ||
{ | ||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize(address rifToken, address initialOwner) public initializer { | ||
__ERC20_init("VeRIFToken", "veRIF"); | ||
__ERC20Permit_init("VeRIFToken"); | ||
__ERC20Votes_init(); | ||
__ERC20Wrapper_init(ERC20Upgradeable(rifToken)); | ||
__Ownable_init(initialOwner); | ||
__UUPSUpgradeable_init(); | ||
} | ||
|
||
// The following functions are overrides required by Solidity. | ||
|
||
//solhint-disable-next-line no-empty-blocks | ||
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} | ||
|
||
function decimals() public view override(ERC20Upgradeable, ERC20WrapperUpgradeable) returns (uint8) { | ||
return super.decimals(); | ||
} | ||
|
||
function _update( | ||
address from, | ||
address to, | ||
uint256 value | ||
) internal override(ERC20Upgradeable, ERC20VotesUpgradeable) { | ||
super._update(from, to, value); | ||
} | ||
|
||
function nonces( | ||
address owner | ||
) public view override(ERC20PermitUpgradeable, NoncesUpgradeable) returns (uint256) { | ||
return super.nonces(owner); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import globals from "globals"; | ||
import tseslint from "typescript-eslint"; | ||
import globals from 'globals' | ||
import tseslint from 'typescript-eslint' | ||
|
||
export default [ | ||
{ | ||
languageOptions: { | ||
languageOptions: { | ||
globals: globals.browser, | ||
}, | ||
}, | ||
...tseslint.configs.recommended, | ||
]; | ||
] |
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 |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import { HardhatUserConfig } from "hardhat/config"; | ||
import "@nomicfoundation/hardhat-toolbox"; | ||
import { HardhatUserConfig } from 'hardhat/config' | ||
import '@nomicfoundation/hardhat-toolbox' | ||
import '@openzeppelin/hardhat-upgrades' | ||
|
||
const config: HardhatUserConfig = { | ||
solidity: { | ||
compilers: [ | ||
{ version: '0.8.24' }, | ||
{ version: '0.4.24' } | ||
] | ||
compilers: [{ version: '0.8.24' }, { version: '0.4.24' }], | ||
}, | ||
}; | ||
} | ||
|
||
export default config; | ||
export default config |
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ethers, upgrades } from 'hardhat' | ||
|
||
export const deployVeRif = async (rifTokenAddress: string, deployerAddress: string) => { | ||
const VeRIFTokenFactory = await ethers.getContractFactory('VeRIFToken') | ||
const veRIFToken = await upgrades.deployProxy(VeRIFTokenFactory, [rifTokenAddress, deployerAddress], { | ||
initializer: 'initialize', | ||
kind: 'uups', | ||
timeout: 0, // wait indefinitely | ||
unsafeAllow: ['internal-function-storage'], | ||
}) | ||
|
||
return await veRIFToken.waitForDeployment() | ||
} |
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,18 @@ | ||
import { ethers } from 'hardhat' | ||
import { deployVeRif } from './deploy-verif' | ||
|
||
const deploy = async () => { | ||
const rifToken = await ethers.deployContract('RIFToken') | ||
const rifAddress = await rifToken.getAddress() | ||
const [deployer] = await ethers.getSigners() | ||
const deployerAddress = await deployer.getAddress() | ||
const veRIFToken = await deployVeRif(rifAddress, deployerAddress) | ||
|
||
console.log(`RIFToken deployed at: ${rifAddress}`) | ||
console.log(`VeRIFToken deployed at: ${await veRIFToken.getAddress()}`) | ||
} | ||
|
||
deploy().catch(err => { | ||
console.log('deployment error: ', err) | ||
process.exit(1) | ||
}) |
Oops, something went wrong.