Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepo support #294

Merged
merged 21 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b1dc1a8
feat: Move typechain configs to contracts repo.
mprasanjith Nov 17, 2022
bb57ce1
fix: merge
dcrescimbeni Dec 7, 2022
1c3c57c
ci: added deployment scripts for 1.5 contracts
dcrescimbeni Dec 8, 2022
57b9e34
feat: Support monorepo.
mprasanjith Dec 12, 2022
e27e6b7
Merge branch 'feature/monorepo-setup' of github.com:DXgovernance/dxda…
mprasanjith Dec 12, 2022
8ccbd18
Merge branch 'feature/dxgov-guild-deployments' into feature/monorepo-…
MiltonTulli Dec 19, 2022
4c06e7e
fixes to implement subgraph in monorepo
MiltonTulli Dec 22, 2022
0d3cdbd
Merge branch 'v2.0' into feature/monorepo-setup-w-create2
MiltonTulli Jan 6, 2023
832746d
Fix eslint errors & format
MiltonTulli Jan 6, 2023
d910459
Fix deployment modules
MiltonTulli Jan 9, 2023
32b7eb3
Fix eslint warnings
MiltonTulli Jan 9, 2023
d2acc33
fix: replaced DXDVotingMachine references and initial params
dcrescimbeni Jan 9, 2023
47282c5
fix: deleted unwanted change
dcrescimbeni Jan 9, 2023
59ffded
Merge pull request #297 from dcrescimbeni/fix/dao-deploy-script-fixes
dcrescimbeni Jan 10, 2023
4e5e82a
Format & lint files
MiltonTulli Jan 16, 2023
f5f67f3
fix(deployGuild): moved mint action after the guild initialization
dcrescimbeni Jan 30, 2023
6e8dd67
feat: added localhost guild
dcrescimbeni Jan 30, 2023
0478089
fix: syncs blockchain time with current time
dcrescimbeni Jan 30, 2023
4c4f875
Merge pull request #306 from dcrescimbeni/dev/localhost-guild
dcrescimbeni Jan 30, 2023
1d67e91
Remove bytecodes update
MiltonTulli Feb 3, 2023
45b6602
Merge commit '1d67e913' into feature/monorepo-setup-w-create2
MiltonTulli Feb 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ tags
.log/
yarn-error.log
venv/
contracts/hardhat-dependency-compiler
contracts/hardhat-dependency-compiler
types
.turbo
bytecodes
3 changes: 1 addition & 2 deletions contracts/utils/PermissionRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ contract PermissionRegistry is OwnableUpgradeable {
uint256 currentBalance = IERC20(erc20Limits[from][i].token).balanceOf(from);
if (currentBalance < erc20Limits[from][i].initialValueOnBlock) {
require(
erc20Limits[from][i].initialValueOnBlock.sub(currentBalance) <=
erc20Limits[from][i].valueAllowed,
erc20Limits[from][i].initialValueOnBlock.sub(currentBalance) <= erc20Limits[from][i].valueAllowed,
"PermissionRegistry: Value limit reached"
);
}
Expand Down
12 changes: 12 additions & 0 deletions deploy/advanceTime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { time } = require("@openzeppelin/test-helpers");
const moment = require("moment");

// Sync the blockchain time to the current time
module.exports = async () => {
const target = Math.floor(moment.now() / 1000);
console.log(`Increasing blockchain timestamp to ${target}`);
await time.increaseTo(target);
};

module.exports.tags = ["AdvanceTime"];

37 changes: 37 additions & 0 deletions deploy/avatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const deploySalt = process.env.DEPLOY_SALT;

const DAOAvatar = await hre.artifacts.require("DAOAvatar");

const daoAvatarDeploy = await deploy("DAOAvatar", {
name: "DAOAvatar",
from: deployer,
args: [],
deterministicDeployment: deploySalt,
});

const daoAvatar = await DAOAvatar.at(daoAvatarDeploy.address);

const controllerDeployed = await deployments.get("DAOController");

await daoAvatar.initialize(controllerDeployed.address);

if (process.env.ETHERSCAN_API_KEY && hre.network.name !== "hardhat") {
try {
await hre.run("verify:verify", {
address: daoAvatar.address,
constructorArguments: [],
});
} catch (error) {
console.error("Error verifying contract", error);
}
}

console.log(`DAOAvatar address ${daoAvatar.address}`);
};

module.exports.tags = ["DAOAvatar"];
module.exports.dependencies = ["Controller"];

100 changes: 100 additions & 0 deletions deploy/avatarScheme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const deploySalt = process.env.DEPLOY_SALT;

const AvatarScheme = await hre.artifacts.require("AvatarScheme");

const avatarSchemeDeploy = await deploy("AvatarScheme", {
name: "AvatarScheme",
from: deployer,
args: [],
deterministicDeployment: deploySalt,
});

const avatarScheme = await AvatarScheme.at(avatarSchemeDeploy.address);

const avatarDeployed = await deployments.get("DAOAvatar");
const dxdVotingMachineDeployed = await deployments.get("VotingMachine");
const controllerDeployed = await deployments.get("DAOController");
const permissionRegistryDeployed = await deployments.get(
"PermissionRegistry"
);

try {
await avatarScheme.initialize(
avatarDeployed.address,
dxdVotingMachineDeployed.address,
controllerDeployed.address,
permissionRegistryDeployed.address,
"Master Wallet",
5
);
} catch (e) {
console.warn("Avatar scheme is already deployed.");
}

const Controller = await hre.artifacts.require("DAOController");
const controller = await Controller.at(controllerDeployed.address);
const DXDVotingMachine = await hre.artifacts.require("VotingMachine");
const dxdVotingMachine = await DXDVotingMachine.at(
dxdVotingMachineDeployed.address
);

const defaultParameters = {
queuedVoteRequiredPercentage: 5000,
queuedVotePeriodLimit: 60,
boostedVotePeriodLimit: 60,
preBoostedVotePeriodLimit: 10,
thresholdConst: 2000,
quietEndingPeriod: 10,
daoBounty: web3.utils.toWei("0.1"),
boostedVoteRequiredPercentage: 100,
};

const defaultParametersArray = [
defaultParameters.queuedVoteRequiredPercentage,
defaultParameters.queuedVotePeriodLimit,
defaultParameters.boostedVotePeriodLimit,
defaultParameters.preBoostedVotePeriodLimit,
defaultParameters.thresholdConst,
defaultParameters.quietEndingPeriod,
defaultParameters.daoBounty,
defaultParameters.boostedVoteRequiredPercentage,
];

await dxdVotingMachine.setParameters(defaultParametersArray);
const defaultParamsHash = await dxdVotingMachine.getParametersHash(
defaultParametersArray
);

await controller.registerScheme(
avatarScheme.address,
defaultParamsHash,
false,
true,
true
);

if (process.env.ETHERSCAN_API_KEY && hre.network.name !== "hardhat") {
try {
await hre.run("verify:verify", {
address: avatarScheme.address,
constructorArguments: [],
});
} catch (error) {
console.error("Error verifying contract", error);
}
}

console.log(`AvatarScheme address ${avatarScheme.address}`);
};

module.exports.tags = ["AvatarScheme"];
module.exports.dependencies = [
"DAOAvatar",
"VotingMachine",
"Controller",
"PermissionRegistry",
];

4 changes: 3 additions & 1 deletion deploy/carrotGuild.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const moment = require("moment");
import { deploySnapshotRepGuild } from "./deployGuild";
const {
deploySnapshotRepGuild,
} = require("../scripts/deployUtils/deployGuild");

const config = {
GUILD_ID: "CarrotGuild",
Expand Down
77 changes: 77 additions & 0 deletions deploy/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const deploySalt = process.env.DEPLOY_SALT;

const Controller = await hre.artifacts.require("DAOController");
const DAOReputation = await hre.artifacts.require("DAOReputation");

const controllerDeploy = await deploy("DAOController", {
name: "Controller",
from: deployer,
args: [],
deterministicDeployment: deploySalt,
});

const controller = await Controller.at(controllerDeploy.address);

const dxdVotingMachineDeployed = await deployments.get("VotingMachine");
const daoReputationDeployed = await deployments.get("DAOReputation");
const daoReputation = await DAOReputation.at(daoReputationDeployed.address);
await daoReputation.transferOwnership(controller.address);

const DXDVotingMachine = await hre.artifacts.require("VotingMachine");
const dxdVotingMachine = await DXDVotingMachine.at(
dxdVotingMachineDeployed.address
);

const defaultParameters = {
queuedVoteRequiredPercentage: 5000,
queuedVotePeriodLimit: 60,
boostedVotePeriodLimit: 60,
preBoostedVotePeriodLimit: 10,
thresholdConst: 2000,
quietEndingPeriod: 10,
daoBounty: web3.utils.toWei("0.1"),
boostedVoteRequiredPercentage: 100,
};

const defaultParametersArray = [
defaultParameters.queuedVoteRequiredPercentage,
defaultParameters.queuedVotePeriodLimit,
defaultParameters.boostedVotePeriodLimit,
defaultParameters.preBoostedVotePeriodLimit,
defaultParameters.thresholdConst,
defaultParameters.quietEndingPeriod,
defaultParameters.daoBounty,
defaultParameters.boostedVoteRequiredPercentage,
];

await dxdVotingMachine.setParameters(defaultParametersArray);
const defaultParamsHash = await dxdVotingMachine.getParametersHash(
defaultParametersArray
);

await controller.initialize(
deployer,
daoReputationDeployed.address,
defaultParamsHash
);

if (process.env.ETHERSCAN_API_KEY && hre.network.name !== "hardhat") {
try {
await hre.run("verify:verify", {
address: controller.address,
constructorArguments: [],
});
} catch (error) {
console.error("Error verifying contract", error);
}
}

console.log(`Controller address ${controller.address}`);
};

module.exports.tags = ["Controller"];
module.exports.dependencies = ["DAOReputation", "VotingMachine"];

79 changes: 79 additions & 0 deletions deploy/daoProposals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy } = deployments;
const { deployer, tokenHolder } = await getNamedAccounts();

function testCallFrom(address, number = 1) {
return new web3.eth.Contract(ActionMock.abi).methods
.test(address, number)
.encodeABI();
}

const SOME_HASH =
"0x1000000000000000000000000000000000000000000000000000000000000000";
const TEST_TITLE = "Awesome Proposal Title";

const ActionMock = await hre.artifacts.require("ActionMock");
const actionMockDeployed = await deploy("ActionMock", {
name: "ActionMock",
from: deployer,
args: [],
});
const actionMock = await ActionMock.at(actionMockDeployed.address);

const Controller = await hre.artifacts.require("DAOController");
const controllerDeployed = await deployments.get("DAOController");
const controller = await Controller.at(controllerDeployed.address);

const avatarDeployed = await deployments.get("DAOAvatar");

const AvatarScheme = await hre.artifacts.require("AvatarScheme");
const avatarSchemeDeployed = await deployments.get("AvatarScheme");
const avatarScheme = await AvatarScheme.at(avatarSchemeDeployed.address);

const PermissionRegistry = await hre.artifacts.require("PermissionRegistry");
const permissionRegistryDeployed = await deployments.get(
"PermissionRegistry"
);
const permissionRegistry = await PermissionRegistry.at(
permissionRegistryDeployed.address
);
await permissionRegistry.setETHPermission(
avatarSchemeDeployed.address,
actionMockDeployed.address,
web3.eth.abi.encodeFunctionSignature("test(address,uint256)"),
0,
true
);

const callData = testCallFrom(avatarDeployed.address);
const callDataMintRep = await controller.contract.methods
.mintReputation(10, tokenHolder)
.encodeABI();

await avatarScheme.proposeCalls(
[actionMock.address, controllerDeployed.address],
[callData, callDataMintRep],
[0, 0],
2,
TEST_TITLE,
SOME_HASH
);
// const proposalId = await helpers.getValueFromLogs(tx, "_proposalId");
// await org.votingMachine.vote(proposalId, constants.YES_OPTION, 0, {
// from: accounts[2],
// });
// const organizationProposal = await avatarScheme.getProposal(proposalId);
// assert.equal(
// organizationProposal.state,
// constants.WALLET_SCHEME_PROPOSAL_STATES.passed
// );
};

module.exports.tags = ["DAOProposals"];
module.exports.dependencies = [
"AvatarScheme",
"DAOAvatar",
"Controller",
"PermissionRegistry",
];

2 changes: 1 addition & 1 deletion deploy/dxdToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
const dxdTokenDeploy = await deploy("ERC20Mock", {
name: "DXDToken",
from: deployer,
args: [tokenHolder, hre.web3.utils.toWei("1000"), "DXD", "DXD Token", 18],
args: ["DXD token", "DXD", hre.web3.utils.toWei("1000"), tokenHolder],
deterministicDeployment: deploySalt,
});

Expand Down
4 changes: 3 additions & 1 deletion deploy/dxgovGuild.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const moment = require("moment");
import { deploySnapshotRepGuild } from "./deployGuild";
const {
deploySnapshotRepGuild,
} = require("../scripts/deployUtils/deployGuild");

const config = {
GUILD_ID: "DXgovGuild",
Expand Down
38 changes: 38 additions & 0 deletions deploy/localhostGuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const moment = require("moment");
const {
deploySnapshotRepGuild,
} = require("../scripts/deployUtils/deployGuild");

const config = {
GUILD_ID: "LocalhostGuild",
TOKEN_ID: "LocalhostRepToken",
TOKEN_NAME: "Localhost Reputation Token",
TOKEN_SYMBOL: "LOC",
guildConfig: {
proposalTime: moment.duration(10, "minutes").asSeconds(),
timeForExecution: moment.duration(7, "days").asSeconds(),
votingPowerPercentageForProposalExecution: 2000, // 20% voting power for proposal execution
votingPowerPercentageForProposalCreation: 200, // 2% voting power for proposal creation
name: "Localhost Guild", // guild name
voteGas: "0", // vote gas
maxGasPrice: "0", // max gas price
maxActiveProposals: 20, // max active proposals
lockTime: moment.duration(15, "minutes").asSeconds(), // lock time, not used but should be higher than proposal time
},
initialRepHolders: [
// default testing accounts #0, #1, #2
{ address: "0x9578e973bba0cc33bdbc93c7f77bb3fe6d47d68a", amount: "34" },
{ address: "0xc5b20ade9c9cd5e0cc087c62b26b815a4bc1881f", amount: "33" },
{ address: "0xaf8eb8c3a5d9d900aa0b98e3df0bcc17d3c5f698", amount: "33" },
],
deployExtraSalt: "localhost",
};

module.exports = hre => deploySnapshotRepGuild(config)(hre);
module.exports.dependencies = [
"Create2Deployer",
"PermissionRegistry",
"GuildRegistry",
];
module.exports.tags = [config.GUILD_ID];
module.exports.config = config;
Loading