Skip to content

Commit

Permalink
Make it upgradable (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-fruitful authored Mar 15, 2024
1 parent df693a8 commit f0b3a08
Show file tree
Hide file tree
Showing 30 changed files with 1,630 additions and 129 deletions.
3 changes: 3 additions & 0 deletions .gemforge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.json
*.sol
*.log
11 changes: 8 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ jobs:
node-version: 20
cache: "yarn"

- name: Configure Git Safe Directory
run: git config --global --add safe.directory ${{ github.workspace }}

- name: Install NPM packages
run: yarn install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Install solc
run: svm install 0.8.20 && svm use 0.8.20

Expand All @@ -47,7 +53,6 @@ jobs:
id: test

- name: Upload coverage report to Coveralls
uses: coverallsapp/github-action@v2
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/diamond-2-hardhat"]
path = lib/diamond-2-hardhat
url = https://github.com/mudgen/diamond-2-hardhat
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/Vectorized/solady
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.formatOnSave": true,
"solidity.formatter": "forge",
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
}
}
142 changes: 142 additions & 0 deletions gemforge.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/**
* GemForge configuration file.
*
* For detailed instructions please see the documentation at https://gemforge.xyz/configuration/
*/
module.exports = {
// Configuration file version
version: 2,
// Compiler configuration
solc: {
// SPDX License - to be inserted in all generated .sol files
license: 'MIT',
// Solidity compiler version - to be inserted in all generated .sol files
version: '0.8.21',
},
// commands to execute
commands: {
// the build command
build: 'forge build',
},
paths: {
// contract built artifacts folder
artifacts: 'out',
// source files
src: {
// file patterns to include in facet parsing
facets: [
// include all .sol files in the facets directory ending "Facet"
'src/facets/*Facet.sol'
],
},
// folders for gemforge-generated files
generated: {
// output folder for generated .sol files
solidity: 'src/generated',
// output folder for support scripts and files
support: '.gemforge',
// deployments JSON file
deployments: 'gemforge.deployments.json',
},
// library source code
lib: {
// diamond library
diamond: 'lib/diamond-2-hardhat',
}
},
// artifacts configuration
artifacts: {
// artifact format - "foundry" or "hardhat"
format: 'foundry',
},
// generator options
generator: {
// proxy interface options
proxyInterface: {
// imports to include in the generated IDiamondProxy interface
imports: [],
},
},
// diamond configuration
diamond: {
// Whether to include public methods when generating the IDiamondProxy interface. Default is to only include external methods.
publicMethods: false,
// Names of core facet contracts - these will not be modified/removed once deployed.
// This default list is based on the diamond-2-hardhat library.
// NOTE: WE RECOMMEND NOT CHANGING ANY OF THESE EXISTING NAMES UNLESS YOU KNOW WHAT YOU ARE DOING.
coreFacets: [
'OwnershipFacet',
'DiamondCutFacet',
'DiamondLoupeFacet',
],
},
// lifecycle hooks
hooks: {
// shell command to execute before build
preBuild: '',
// shell command to execute after build
postBuild: '',
// shell command to execute before deploy
preDeploy: '',
// shell command to execute after deploy
postDeploy: '',
},
// Wallets to use for deployment
wallets: {
// Wallet named "wallet1"
wallet1: {
// Wallet type - mnemonic
type: 'mnemonic',
// Wallet config
config: {
// Mnemonic phrase
words: 'test test test test test test test test test test test junk',
// 0-based index of the account to use
index: 0,
}
},
wallet2: {
// Wallet type - mnemonic
type: 'mnemonic',
// Wallet config
config: {
// Mnemonic phrase
words: () => process.env.MNEMONIC,
// 0-based index of the account to use
index: 0,
},
},
},
// Networks/chains
networks: {
// Local network
local: {
// RPC endpoint URL
rpcUrl: 'http://localhost:8545',
},
// Sepolia test network
sepolia: {
// RPC endpoint URL
rpcUrl: () => process.env.SEPOLIA_RPC_URL,
}
},
// Targets to deploy
targets: {
local: {
// Network to deploy to
network: 'local',
// Wallet to use for deployment
wallet: 'wallet1',
// Initialization function arguments
initArgs: [],
},
testnet: {
// Network to deploy to
network: 'sepolia',
// Wallet to use for deployment
wallet: 'wallet2',
// Initialization function arguments
initArgs: [],
}
}
}
1 change: 1 addition & 0 deletions lib/diamond-2-hardhat
Submodule diamond-2-hardhat added at c455af
1 change: 1 addition & 0 deletions lib/solady
Submodule solady added at ec85d4
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"type": "module",
"scripts": {
"prepare": "forge install && husky",
"build": "forge build",
"build": "gemforge build",
"test": "forge test",
"test-coverage": "forge coverage --report lcov",
"devnet": "anvil",
"commitlint": "commitlint --edit",
"deploy": "./script/gemforge/deploy.js",
"query": "gemforge query",
"deploy-local": "forge script scripts/Deploy.s.sol --rpc-url http://localhost:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --broadcast",
"deploy-public": "export $(cat .env | grep -v \\# | xargs) && forge script scripts/Deploy.s.sol --chain-id $CHAIN_ID --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast"
},
Expand All @@ -21,6 +23,7 @@
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"gemforge": "^2.7.0",
"husky": "^9.0.11"
}
}
8 changes: 8 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
forge-std/=lib/forge-std/src/
openzeppelin/=lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
diamond-2-hardhat/=lib/diamond-2-hardhat/contracts/
ds-test/=lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/
openzeppelin-contracts/=lib/openzeppelin-contracts/
solady/=lib/solady/src/
35 changes: 0 additions & 35 deletions scripts/Deploy.s.sol

This file was deleted.

61 changes: 0 additions & 61 deletions src/NaymToken.sol

This file was deleted.

24 changes: 24 additions & 0 deletions src/facets/ACLFacet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { LibACL } from "../libs/LibACL.sol";
import { Modifiers } from "../shared/Modifiers.sol";

/**
* @title Access Control List
* @notice Use it to authorize various actions on the contracts
* @dev Use it to (un)assign or check role membership
*/
contract ACLFacet is Modifiers {
function setSystemAdmin(address _newSystemAdmin) external onlySysAdmin {
LibACL._setSystemAdmin(_newSystemAdmin);
}

function setMinter(address _newMinter) external onlySysAdmin {
LibACL._setMinter(_newMinter);
}

function removeSysAdmin(address _removeSystemAdmin) external onlySysAdmin {
LibACL._removeSystemAdmin(_removeSystemAdmin);
}
}
Loading

0 comments on commit f0b3a08

Please sign in to comment.