-
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.
Adding AccessManager (and Upgradeability) from OpenZeppelin lib (#84)
* feat(accessManager): adding accessManager contract and adapting contracts * feat(accessManager): a lot * feat(accessManager): submodules * feat(accessManager): submodules * feat(accessManager): submodules * feat(accessManager): submodules * feat(accessManager): submodulesssssssss * feat(AccessMananger) Adding tests and deploy script --------- Co-authored-by: Vincent Rainaud <[email protected]>
- Loading branch information
Showing
26 changed files
with
423 additions
and
359 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,4 @@ | ||
/contracts/.yarn/** linguist-vendored | ||
/contracts/.yarn/releases/* binary | ||
/contracts/.yarn/plugins/**/* binary | ||
/contracts/.pnp.* binary linguist-generated |
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,34 @@ | ||
node_modules | ||
.env | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
broadcast/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env | ||
|
||
# Node modules | ||
!/node_modules | ||
node_modules/* | ||
|
||
# Package lock files | ||
package-lock.json | ||
|
||
# Yarn | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
# System files | ||
.DS_Store |
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,6 +1,9 @@ | ||
[submodule "lib/openzeppelin-contracts"] | ||
path = lib/openzeppelin-contracts | ||
url = https://github.com/openzeppelin/openzeppelin-contracts | ||
[submodule "contracts/lib/forge-std"] | ||
path = contracts/lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "contracts/lib/openzeppelin-contracts-upgradeable"] | ||
path = contracts/lib/openzeppelin-contracts-upgradeable | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable | ||
[submodule "contracts/lib/openzeppelin-contracts"] | ||
path = contracts/lib/openzeppelin-contracts | ||
url = https://github.com/openzeppelin/openzeppelin-contracts | ||
url = https://github.com/OpenZeppelin/openzeppelin-contracts |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,32 @@ | ||
# Network (e.g. MAINNET) | ||
DEPLOYMENT_NETWORK= | ||
|
||
# RPC URL | ||
SEPOLIA_RPC= | ||
MAINNET_RPC= | ||
|
||
# Private keys | ||
PRIVATE_KEY= | ||
ETHERSCAN_API_KEY= | ||
|
||
# ------------------------------ | ||
# ------- SEPOLIA CONFIG ------- | ||
# ------------------------------ | ||
|
||
# Deployer address | ||
DEPLOYER_ADDRESS_SEPOLIA= | ||
|
||
# For AccessManager | ||
ACCESS_MANAGER_ADMIN_SEPOLIA= | ||
ACCESS_MANAGER_ADDRESS_SEPOLIA= | ||
|
||
# ------------------------------ | ||
# ------- MAINNET CONFIG ------- | ||
# ------------------------------ | ||
|
||
# Deployer address | ||
DEPLOYER_ADDRESS_MAINNET= | ||
|
||
# For AccessManager | ||
ACCESS_MANAGER_ADMIN_MAINNET= | ||
ACCESS_MANAGER_ADDRESS_MAINNET= |
This file was deleted.
Oops, something went wrong.
Empty file.
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,4 @@ | ||
lib | ||
node_modules | ||
cache | ||
out |
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,16 @@ | ||
{ | ||
"plugins": ["prettier-plugin-solidity"], | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"parser": "solidity-parse", | ||
"printWidth": 80, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": false | ||
} | ||
} | ||
] | ||
} |
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
Submodule openzeppelin-contracts-upgradeable
added at
26fa13
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,24 @@ | ||
{ | ||
"name": "dex", | ||
"version": "1.0.0", | ||
"description": "Decentralized Exchange", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"files": [ | ||
"src/**/*.sol" | ||
], | ||
"devDependencies": { | ||
"prettier": "3.2.5", | ||
"prettier-plugin-solidity": "1.3.1" | ||
}, | ||
"scripts": { | ||
"prettier": "prettier --write --plugin=prettier-plugin-solidity 'contracts/**/*.sol'", | ||
"lint": "prettier --list-different --plugin=prettier-plugin-solidity 'contracts/**/*.sol'", | ||
"gas-report": "forge test --gas-report", | ||
"deploy-access-manager": "forge script script/00_deployAccessManager.s.sol --rpc-url $RPC_URL --private-key $ACCOUNT_PRIVATE_KEY --broadcast --verify -vvvv", | ||
"deploy-registry": "forge script script/01_deployRegistry.s.sol --rpc-url $RPC_URL --private-key $ACCOUNT_PRIVATE_KEY --broadcast --verify -vvvv" | ||
}, | ||
"dependencies": { | ||
"dotenv": "16.4.5" | ||
} | ||
} |
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 @@ | ||
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ | ||
ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/ | ||
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/ | ||
forge-std/=lib/forge-std/src/ | ||
openzeppelin-contracts/=lib/openzeppelin-contracts/ |
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 | ||
pragma solidity ^0.8.0; | ||
|
||
import "forge-std/Script.sol"; | ||
import "forge-std/console.sol"; | ||
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
import "@openzeppelin/contracts/access/manager/AccessManager.sol"; | ||
|
||
contract AccessManagerDeploymentScript is Script { | ||
address private testRes; | ||
address private initialSuperAdmin; | ||
bool private forTest; | ||
|
||
function run() public { | ||
vm.startBroadcast(); | ||
if (forTest) { | ||
address accessManagerInstance = address(new AccessManager(initialSuperAdmin)); | ||
console.log( | ||
"AccessManager instance deployed at", | ||
accessManagerInstance, | ||
"with super admin", | ||
initialSuperAdmin | ||
); | ||
testRes = accessManagerInstance; | ||
} else { | ||
string memory deploymentNetwork = vm.envString("DEPLOYMENT_NETWORK"); | ||
if (bytes(deploymentNetwork).length == 0) { | ||
revert("DEPLOYMENT_NETWORK is not set in .env file"); | ||
} | ||
|
||
string memory envVar = string.concat("ACCESS_MANAGER_ADMIN_", deploymentNetwork); | ||
if (bytes(vm.envString(envVar)).length == 0) { | ||
revert(string.concat(envVar, " is not set in .env file")); | ||
} | ||
initialSuperAdmin = vm.envAddress(envVar); | ||
|
||
address accessManagerInstance = address(new AccessManager(initialSuperAdmin)); | ||
console.log( | ||
"AccessManager instance deployed at", | ||
accessManagerInstance, | ||
"with super admin", | ||
initialSuperAdmin | ||
); | ||
} | ||
vm.stopBroadcast(); | ||
} | ||
|
||
function deployForTest(address _initialSuperAdmin) public returns (address _testRes) { | ||
forTest = true; | ||
initialSuperAdmin = _initialSuperAdmin; | ||
run(); | ||
_testRes = testRes; | ||
// Reset the variables for the next test | ||
forTest = false; | ||
testRes = address(0); | ||
initialSuperAdmin = address(0); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.