-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 9a2730d
Showing
31 changed files
with
9,455 additions
and
0 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,3 @@ | ||
ETH_KEY=<Private-Key> | ||
ETHERSCAN_KEY=<Etherscan-Api-Key> | ||
POLYGONSCAN_KEY=<Polygonscan-Api-Key> |
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 @@ | ||
node_modules | ||
artifacts | ||
cache | ||
coverage |
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,21 @@ | ||
module.exports = { | ||
env: { | ||
browser: false, | ||
es2021: true, | ||
mocha: true, | ||
node: true, | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
extends: [ | ||
'standard', | ||
'plugin:prettier/recommended', | ||
'plugin:node/recommended', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
}, | ||
rules: { | ||
'node/no-unsupported-features/es-syntax': ['error', {ignores: ['modules']}], | ||
}, | ||
}; |
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,11 @@ | ||
node_modules | ||
.env | ||
coverage | ||
coverage.json | ||
typechain | ||
typechain-types | ||
|
||
#Hardhat files | ||
cache | ||
artifacts | ||
|
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,2 @@ | ||
auto-install-peers = true | ||
strict-peer-dependencies = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
artifacts | ||
cache | ||
coverage* | ||
gasReporterOutput.json | ||
Releases.md |
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,7 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"rules": { | ||
"compiler-version": ["error", "^0.8.0"], | ||
"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 |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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.17" | ||
} |
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 @@ | ||
# Sample Hardhat Project | ||
|
||
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract. | ||
|
||
Try running some of the following tasks: | ||
|
||
```shell | ||
npx hardhat help | ||
npx hardhat test | ||
REPORT_GAS=true npx hardhat test | ||
npx hardhat node | ||
npx hardhat run scripts/deploy.ts | ||
``` |
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,59 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.17; | ||
|
||
import {PluginUUPSUpgradeable, IDAO} from "@aragon/osx/core/plugin/PluginUUPSUpgradeable.sol"; | ||
import {ITemplate} from "./interfaces/ITemplate.sol"; | ||
|
||
/// @title TEMPLATE_PLUGIN | ||
/// @author DAO Box - 2023 | ||
/// @notice A plugin that <does something>. | ||
/// @dev This contract is a template for a plugin | ||
contract TemplatePlugin is ITemplate, PluginUUPSUpgradeable { | ||
/// @notice The ID of the permission required to call the `sensative` function. | ||
bytes32 public constant SOME_PERMISSION_ID = keccak256("SOME_PERMISSION"); | ||
|
||
/// @notice The number that does something important. | ||
uint256 private someNumber; | ||
|
||
/// @notice The [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface ID of the contract. | ||
bytes4 internal constant TEMPLATE_PLUGIN_INTERFACE_ID = | ||
this.initialize.selector ^ this.getSomeNumber.selector; | ||
|
||
/// @notice Initializes the component. | ||
/// @dev This method is required to support [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822). | ||
/// @param _dao The IDAO interface of the associated DAO. | ||
/// @param _someNumber A number that does something important | ||
function initialize(IDAO _dao, uint256 _someNumber) external initializer { | ||
__PluginUUPSUpgradeable_init(_dao); | ||
someNumber = _someNumber; | ||
} | ||
|
||
/// @notice Checks if this or the parent contract supports an interface by its ID. | ||
/// @param _interfaceId The ID of the interface. | ||
/// @return Returns `true` if the interface is supported. | ||
function supportsInterface( | ||
bytes4 _interfaceId | ||
) public view virtual override returns (bool) { | ||
return | ||
_interfaceId == TEMPLATE_PLUGIN_INTERFACE_ID || | ||
super.supportsInterface(_interfaceId); | ||
} | ||
|
||
/// @notice Gets the number that does something important. | ||
/// @return Returns the number that does something important. | ||
function getSomeNumber() external view returns (uint256) { | ||
return someNumber; | ||
} | ||
|
||
/// @notice Does something that requires a permission | ||
function execute( | ||
IDAO.Action[] calldata _actions | ||
) external auth(SOME_PERMISSION_ID) { | ||
revert("Not implemented."); | ||
} | ||
|
||
/// @dev This empty reserved space is put in place to allow future versions to add new | ||
/// variables without shifting down storage in the inheritance chain. | ||
/// https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps | ||
uint256[49] private __gap; | ||
} |
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,123 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.17; | ||
|
||
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; | ||
import {Address} from "@openzeppelin/contracts/utils/Address.sol"; | ||
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; | ||
import {PluginSetup, IPluginSetup} from "@aragon/osx/framework/plugin/setup/PluginSetup.sol"; | ||
|
||
import {IDAO} from "@aragon/osx/core/dao/IDAO.sol"; | ||
import {DAO} from "@aragon/osx/core/dao/DAO.sol"; | ||
import {PermissionLib} from "@aragon/osx/core/permission/PermissionLib.sol"; | ||
|
||
import {TemplatePlugin} from "./TemplatePlugin.sol"; | ||
|
||
/// @title TemplatePluginSetup | ||
/// @author DAO BOX | ||
/// @notice The setup contract of the `TemplatePlugin` contract. | ||
contract TemplateSetup is PluginSetup { | ||
using Address for address; | ||
using Clones for address; | ||
using ERC165Checker for address; | ||
|
||
/// @notice The address of the `TemplatePlugin` base contract. | ||
TemplatePlugin private immutable templatePlugin; | ||
|
||
/// @notice The error thrown when the helpers array length is not x. | ||
error WrongHelpersArrayLength(uint length); | ||
|
||
/// @notice The contract constructor, that deployes the bases. | ||
constructor() { | ||
templatePlugin = new TemplatePlugin(); | ||
} | ||
|
||
/// @inheritdoc IPluginSetup | ||
function prepareInstallation( | ||
address _dao, | ||
bytes calldata _data | ||
) | ||
external | ||
returns (address plugin, PreparedSetupData memory preparedSetupData) | ||
{ | ||
// Decode `_data` to extract the params needed for deploying and initializing `TemplatePlugin` plugin, | ||
// and the required helpers | ||
uint256 someNumber = abi.decode(_data, (uint256)); | ||
|
||
// Prepare and deploy plugin proxy. | ||
plugin = createERC1967Proxy( | ||
address(templatePlugin), | ||
abi.encodeWithSelector( | ||
TemplatePlugin.initialize.selector, | ||
_dao, | ||
someNumber | ||
) | ||
); | ||
|
||
// Prepare permissions | ||
PermissionLib.MultiTargetPermission[] | ||
memory permissions = new PermissionLib.MultiTargetPermission[](2); | ||
|
||
// Set plugin permissions to be granted. | ||
// Grant the list of prmissions of the plugin to the DAO. | ||
permissions[0] = PermissionLib.MultiTargetPermission( | ||
PermissionLib.Operation.Grant, | ||
plugin, | ||
_dao, | ||
PermissionLib.NO_CONDITION, | ||
templatePlugin.SOME_PERMISSION_ID() | ||
); | ||
|
||
// Grant `EXECUTE_PERMISSION` of the DAO to the plugin. | ||
permissions[1] = PermissionLib.MultiTargetPermission( | ||
PermissionLib.Operation.Grant, | ||
_dao, | ||
plugin, | ||
PermissionLib.NO_CONDITION, | ||
DAO(payable(_dao)).EXECUTE_PERMISSION_ID() | ||
); | ||
|
||
preparedSetupData.permissions = permissions; | ||
} | ||
|
||
/// @inheritdoc IPluginSetup | ||
function prepareUninstallation( | ||
address _dao, | ||
SetupPayload calldata _payload | ||
) | ||
external | ||
view | ||
returns (PermissionLib.MultiTargetPermission[] memory permissions) | ||
{ | ||
// Prepare permissions. | ||
uint256 helperLength = _payload.currentHelpers.length; | ||
if (helperLength != 0) { | ||
revert WrongHelpersArrayLength({length: helperLength}); | ||
} | ||
|
||
permissions = new PermissionLib.MultiTargetPermission[](2); | ||
|
||
// Set plugin permissions to be Revoked. | ||
// Grant the list of prmissions of the plugin to the DAO. | ||
permissions[0] = PermissionLib.MultiTargetPermission( | ||
PermissionLib.Operation.Revoke, | ||
_payload.plugin, | ||
_dao, | ||
PermissionLib.NO_CONDITION, | ||
templatePlugin.SOME_PERMISSION_ID() | ||
); | ||
|
||
// Revoke `EXECUTE_PERMISSION` of the DAO to the plugin. | ||
permissions[1] = PermissionLib.MultiTargetPermission( | ||
PermissionLib.Operation.Revoke, | ||
_dao, | ||
_payload.plugin, | ||
PermissionLib.NO_CONDITION, | ||
DAO(payable(_dao)).EXECUTE_PERMISSION_ID() | ||
); | ||
} | ||
|
||
/// @inheritdoc IPluginSetup | ||
function implementation() external view virtual override returns (address) { | ||
return address(templatePlugin); | ||
} | ||
} |
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,15 @@ | ||
{ | ||
"ui": "", | ||
"change": "", | ||
"pluginSetupABI": { | ||
"prepareInstallation": [ | ||
"" | ||
], | ||
"prepareUpdate": [ | ||
"" | ||
], | ||
"prepareUninstallation": [ | ||
"" | ||
] | ||
} | ||
} |
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,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
/// @title ITemplate | ||
/// @dev This interface defines the methods that must be implemented by a template in a smart contract system. | ||
/// @author DAO Box | ||
interface ITemplate { | ||
/// @dev Returns a uint256 value. | ||
/// @return The uint256 value returned by the plugin. | ||
function getSomeNumber() external view returns (uint256); | ||
} |
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,5 @@ | ||
{ | ||
"name": "TEMPLATE_PLUGIN", | ||
"description": "", | ||
"images": {} | ||
} |
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 @@ | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
|
||
const func: DeployFunction = async function ({ | ||
deployments, | ||
getNamedAccounts, | ||
}: HardhatRuntimeEnvironment) { | ||
const { deploy } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
|
||
console.log(`\n10: Creating TEMPLATE_SETUP.`); | ||
await deploy("TEMPLATE_SETUP", { | ||
from: deployer, | ||
log: true, | ||
}); | ||
}; | ||
|
||
export default func; | ||
func.tags = ["CreateTEMPLATE_SETUP"]; |
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,33 @@ | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { newPluginRepo } from "./helpers"; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployments, getNamedAccounts, ethers, network } = hre; | ||
const { get } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
const signer = await ethers.getSigner(deployer); | ||
const { address: setupAddress } = await get("Template"); | ||
|
||
const networkName = network.name === "local" ? "mainnet" : network.name; | ||
|
||
const buildMetadataCid = ""; | ||
const releaseMetadataCid =""; | ||
|
||
console.warn( | ||
`\n20: Creating Template repo \nPlease make sure pluginRepo is not created more than once with the same subdomain.` | ||
); | ||
|
||
await newPluginRepo({ | ||
subdomain: "Template", | ||
setupAddress, | ||
deployer, | ||
networkName, | ||
signer, | ||
buildMetadataCid, | ||
releaseMetadataCid, | ||
}); | ||
}; | ||
|
||
export default func; | ||
func.tags = ["CreateTemplateRepo"]; |
Oops, something went wrong.