Skip to content

Commit

Permalink
fix: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrescimbeni committed Jun 20, 2022
2 parents 229f9ca + ac3eca0 commit be1532a
Show file tree
Hide file tree
Showing 35 changed files with 1,773 additions and 1,316 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"no-undef": "off",
"eol-last": 2,
"eqeqeq": "error",
"indent": ["error", 2],
"indent": ["error", 2, { "SwitchCase": 1 }],
"block-spacing": ["error", "always"],
"comma-spacing": "error",
"brace-style": "error",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ This hardhat task runs on the selected network, it receives the name of the cont

Example for ERC20Token:

`yarn hardhat create2 --network arbitrumTestnet --contract ERC20Token --salt 2 --initializer "DXGovTestToken,DXGTT,0xC4B60a931929d3ed0AC423F9Ea80e5962726dA73,100000000000000000000000"`
`yarn hardhat create2 --network arbitrumTestnet --contract ERC20Token --salt 2 --initializer "DXGovTestToken,DXGTT,0xC4B60a931929d3ed0AC423F9Ea80e5962726dA73,1000000000000000000000000"`

## Sourcify

Expand Down
1 change: 1 addition & 0 deletions contracts/erc20guild/implementations/GuardedERC20Guild.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ contract GuardedERC20Guild is ERC20GuildUpgradeable, OwnableUpgradeable {
uint256 _lockTime,
address _permissionRegistry
) public virtual override initializer {
__Ownable_init();
super.initialize(
_token,
_proposalTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ contract SnapshotERC20Guild is ERC20GuildUpgradeable {
// @dev Lock tokens in the guild to be used as voting power
// @param tokenAmount The amount of tokens to be locked
function lockTokens(uint256 tokenAmount) external virtual override {
require(tokenAmount > 0, "SnapshotERC20Guild: Tokens to lock should be higher than 0");
if (tokensLocked[msg.sender].amount == 0) totalMembers = totalMembers.add(1);
_updateAccountSnapshot(msg.sender);
_updateTotalSupplySnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ contract SnapshotRepERC20Guild is ERC20GuildUpgradeable, OwnableUpgradeable {
uint256 _lockTime,
address _permissionRegistry
) public override initializer {
__Ownable_init();
super.initialize(
_token,
_proposalTime,
Expand Down
2 changes: 1 addition & 1 deletion contracts/erc20guild/utils/GuildRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract GuildRegistry is Ownable {
uint256 guildIndexToDelete = guildsByAddress[guildAddress];
address guildAddressToMove = guilds[guilds.length - 1];
guilds[guildIndexToDelete] = guildAddressToMove;
guildsByAddress[guildAddress] = guildIndexToDelete;
guildsByAddress[guildAddressToMove] = guildIndexToDelete;
guilds.pop();
index.decrement();
emit RemoveGuild(guildAddress);
Expand Down
8 changes: 7 additions & 1 deletion contracts/test/ERC20Mock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";

// mock class using ERC20
contract ERC20Mock is ERC20, ERC20Detailed {
constructor(address initialAccount, uint256 initialBalance) public ERC20Detailed("DXD", "DXdao", 18) {
constructor(
address initialAccount,
uint256 initialBalance,
string memory symbol,
string memory name,
uint8 decimals
) public ERC20Detailed(symbol, name, decimals) {
_mint(initialAccount, initialBalance);
}
}
123 changes: 51 additions & 72 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,53 @@ require("hardhat-dependency-compiler");
require("hardhat-contract-sizer");

require("./scripts/create2");
require("./scripts/deploy-dxvote");
require("./scripts/deploy-dxvote-develop");
require("./scripts/actions-dxdao-contracts");
require("./scripts/deploy-dxdao-contracts");
require("./scripts/deploymentTemplates/dxvote-develop");
require("./scripts/deploymentTemplates/guilds-goerli");

const moment = require("moment");

// MNEMONIC KEY = "dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao"
// # Account #0: 0x79706c8e413cdaee9e63f282507287b9ea9c0928 (10000 ETH)
// # Private Key: 0xe408e147b1335674887c1ac7dc3c45de9762aa824cf6255fd8bd61fecf15f021
// #
// # Account #1: 0xc73480525e9d1198d448ece4a01daea851f72a9d (10000 ETH)
// # Private Key: 0x6c8a6a9a7dbad13d6b41089648ae4b7971116611e4acd8f052c478dd8c62673e
// #
// # Account #2: 0x3f943f38b2fbe1ee5daf0516cecfe4e0f8734351 (10000 ETH)
// # Private Key: 0x0054b824c2083e7db09f36edb2ab24eb31f8276fa6cd62e30b42e3a185b37179
// #
// # Account #3: 0xaf1a6415202453d79b84d8a9d055b8f9141f696b (10000 ETH)
// # Private Key: 0x3688ff0d0a95dd8b90bc68739505b488ff4908291eeb36380a94227d22653ce3
// #
// # Account #4: 0x02803e2cdff171d1910d178dac948c711937bd3f (10000 ETH)
// # Private Key: 0x530caa05cf058253ed14a2e6ccc5dcb952f09c7bcdcfb4be37e572e85dcafd1e
// #
// # Account #5: 0x797c62953ef866a1ece855c4033cc5dc3c11290b (10000 ETH)
// # Private Key: 0x88ae5259286213d051e99da743d79be5d69dc75ee317bc887f5996ff004b83a6
// #
// # Account #6: 0x016f70459e4ba98e0d60a5f5855e117e8ff39cae (10000 ETH)
// # Private Key: 0x68f5bc4b52a67b3d800d0d8832ae3b89067a3bbee68c66544147e312d996d994
// #
// # Account #7: 0x073f4fdc12f805b8d98e58551fc10d0a71bbc7db (10000 ETH)
// # Private Key: 0x9adc9dfdce8383a1634716bf7a2e317a145f37a176a7b42538ace5ac20e223a1
// #
// # Account #8: 0x6829556f30899d70403947590ffe8900e8c0d0d7 (10000 ETH)
// # Private Key: 0x13436bc37e24487c2f1739d1ce6b8271a8465fee93aa3685ce543e56a50e1692
// #
// # Account #9: 0x2b410bcb3b8096164fa8c6a06220a66bfb77058d (10000 ETH)
// # Private Key: 0x4fe097bbfe75d9531d253b7f917f89dcee6664d832e40a8d82d717602dfeeb6c
// #
// # Account #10: 0x309f75c54a57937a7a0c6eb9b36eb1dbca82407e (10000 ETH)
// # Private Key: 0xb10da35e4abe181d1143aa28a7da6c5f303660b954cf283accfeba2dfb56ab51
// #
// # Account #11: 0xec9d2d34ad6acda19ab8afe71595051b206e3e4d (10000 ETH)
// # Private Key: 0xfdf0c66289fafea1803c64522d073d6cc9ec71ba76e945a7c207f1f5ebb8e3b1
// #
// # Account #12: 0x40c23c536bad1fe206ce911114f2c70309a7e487 (10000 ETH)
// # Private Key: 0x97c63b257e8f86e05ae5a7bbb025b02d179b8d00fb9fbcdbfcdf04dcf9173cf2
// #
// # Account #13: 0x28d254f2ddb522c43a21d338e337fd8d2f820db2 (10000 ETH)
// # Private Key: 0xcdef57c095755d77bbbb327a187e67039c62fe39425e29b3646d334f54d28808
// #
// # Account #14: 0xaf7386ce842cc0cffef91361059b0ca9ae48d6a0 (10000 ETH)
// # Private Key: 0x4739bf3390cd5be10d0f58d2c1e887a186b544af563fa62717a6c324b36fed59
// #
// # Account #15: 0x46c18451aaead6a2cb888b5bd6193c0f2c402329 (10000 ETH)
// # Private Key: 0xc6b5889c8fbd0f3304ddd53b85f056a32b8338f99e5b8877ecb1d1c5543c8d6a
// #
// # Account #16: 0xc707c8143a6e1274ae7f637946f685870925261f (10000 ETH)
// # Private Key: 0x4b00e0c8e17e88d588b204121594f14d20d1abe50e280d599ff39d6b35c44533
// #
// # Account #17: 0x5b14a88dbbb04abcb6e5bf6384491be8d939cf57 (10000 ETH)
// # Private Key: 0x18eecce45e3211ce6ce967f66c404798e36e8298b4b5222ebf597b841ebd868a
// #
// # Account #18: 0x92d356240dda25d050aa441690b92b2fa0011b84 (10000 ETH)
// # Private Key: 0xe53525f97971b006e14820a8a7b74f8aae375b6635735d89b4db2e4cbdf0e8e0
// #
// # Account #19: 0x5a485c203d9537095a6be2acc5a7ad83805d301d (10000 ETH)
// # Private Key: 0xb86f3287c11a77c7317c2484be2bd386816876ead8ceaf86971b7b7c1afbb12b

const INFURA_PROJECT_ID = process.env.KEY_INFURA_API_KEY;
const MNEMONIC =
process.env.KEY_MNEMONIC ||
"dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao dxdao";
const MNEMONIC_KEY =
"cream core pear sure dinner indoor citizen divorce sudden captain subject remember";

// # Accounts
// # ========
// # Account #0: 0x9578e973bba0cc33bdbc93c7f77bb3fe6d47d68a (10000 ETH)
// # Private Key #0: 0x2edaf5755c340d57c68ab5c084a0afd867caafcbcf556838f404468e2ad0ea94

// # Account #1: 0xc5b20ade9c9cd5e0cc087c62b26b815a4bc1881f (10000 ETH)
// # Private Key #1: 0x40126ad770c1ff59937436ddab2872193c01d5353213d297fdb0ea2c13b5981e

// # Account #2: 0xaf8eb8c3a5d9d900aa0b98e3df0bcc17d3c5f698 (10000 ETH)
// # Private Key #2: 0x4db6b61624bd4a9bf87ff59e7fca0991b02ff605664a3ad97dc237c84ba0e013

// # Account #3: 0x84eeb305da0a4309a696d43de9f79f04e66eb4f8 (10000 ETH)
// # Private Key #3: 0x6d8b1b46346a00fec52fd0e2edba75592e8814b11aec5815ec0f6b882e072131

// # Account #4: 0x1b929bdde0fb3b7b759696f23d6cac0963d326e6 (10000 ETH)
// # Private Key #4: 0x19ea21f217094f12da6bab83fe697f902caea0dcf5a2914d7c000b73938f7d85

// # Account #5: 0xd507743abcdb265f5fcef125e3f6cf7250cfe9da (10000 ETH)
// # Private Key #5: 0x6a944885ff4551fd546c59a2322a967af9906f596f60ecd110505c278f464f6e

// # Account #6: 0x9af7a0d34fcf09a735ddaa03adc825398a6557ae (10000 ETH)
// # Private Key #6: 0x4299ee99407089bfc51e829734c0f6c1b366f515d5ddb5ece4f880a2f8fd430c

// # Account #7: 0x2154cdc3632db21a2635819afa450f2dda08aebd (10000 ETH)
// # Private Key #7: 0x0e7ee7881e497062427ed392d310f09ca993fa964040c751cc383c10f55efc7c

// # Account #8: 0x73c8825893ba6b197f883f60a20b4926c0f32a2c (10000 ETH)
// # Private Key #8: 0xd84954f2cea66fd01a872496f25ddb86db79ee81366609fbcff8087c9739b63a

// # Account #9: 0x73d2888f96bc0eb530490ca5342d0c274d95654d (10000 ETH)
// # Private Key #9: 0xd20a2f6a6656d291ca4c4e6121b479db81b3b281e64707ff4a068acf549dc03c

// # Account #10: 0xf8a3681248934f1139be67e0c22a6af450eb9d7c (10000 ETH)
// # Private Key #10: 0x8188d555d06262bfa3a343fa809b59b6368f02aa5a1ac5a3d2cb24e18e2b556e

const INFURA_PROJECT_ID = "5730f284ad6741b183c921ebb0509880";
const MNEMONIC = process.env.KEY_MNEMONIC || MNEMONIC_KEY;
const ETHERSCAN_API_KEY = process.env.KEY_ETHERSCAN;

const hardharNetworks = process.env.CI
Expand Down Expand Up @@ -115,20 +92,22 @@ const hardharNetworks = process.env.CI
mainnet: {
url: `https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}`,
accounts: { mnemonic: MNEMONIC },
chainId: 1,
gasLimit: 9000000,
gasPrice: 100000000000, // 100 gwei
timeout: 60000,
},
rinkeby: {
url: `https://rinkeby.infura.io/v3/${INFURA_PROJECT_ID}`,
goerli: {
url: `https://goerli.infura.io/v3/${INFURA_PROJECT_ID}`,
accounts: { mnemonic: MNEMONIC },
gasLimit: 10000000,
gasPrice: 1000000000, // 1 gwei
timeout: 60000,
chainId: 5,
gasMultiplier: 10,
timeout: 600000, // 10 minutes
},
xdai: {
url: "https://rpc.xdaichain.com/",
accounts: { mnemonic: MNEMONIC },
chainId: 100,
gasLimit: 17000000,
gasPrice: 2000000000, // 2 gwei
timeout: 60000,
Expand Down
17 changes: 17 additions & 0 deletions scripts/actions-dxdao-contracts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable no-case-declarations */
require("@nomiclabs/hardhat-web3");

const { doActions } = require("./utils/do-actions");

task("actions-dxdao-contracts", "Execute actions on dxdao-contracts")
.addParam("actions", "The actions json array in string format")
.addParam(
"networkContracts",
"The networkContracts json object in string format"
)
.setAction(async ({ actions, networkContracts }) => {
// Do actions
await doActions(JSON.parse(actions), JSON.parse(networkContracts));

return;
});
79 changes: 79 additions & 0 deletions scripts/deploy-dxdao-contracts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* eslint-disable no-case-declarations */
require("@nomiclabs/hardhat-web3");

const moment = require("moment");

const { deployTokens } = require("./utils/deploy-tokens");
const {
deployPermissionRegistry,
} = require("./utils/deploy-permissionRegistry");
const { deployGuildRegistry } = require("./utils/deploy-guildRegistry");
const { deployDao } = require("./utils/deploy-dao");
const { deployGuilds } = require("./utils/deploy-guilds");
const { doActions } = require("./utils/do-actions");

task("deploy-dxdao-contracts", "Deploy dxdao-contracts")
.addParam("deployconfig", "The deploy config json in string format")
.setAction(async ({ deployconfig }) => {
// Set networkContracts object that will store the contracts deployed
let networkContracts = {
fromBlock: (await web3.eth.getBlock("latest")).number,
avatar: null,
reputation: null,
token: null,
controller: null,
permissionRegistry: null,
schemes: {},
utils: {},
votingMachines: {},
addresses: {},
};

// Parse string json config to json object
const deploymentConfig = JSON.parse(deployconfig);

if (deploymentConfig.tokens) {
networkContracts = Object.assign(
await deployTokens(deploymentConfig.tokens, networkContracts),
networkContracts
);
}

if (deploymentConfig.permissionRegistry) {
networkContracts = Object.assign(
await deployPermissionRegistry(
deploymentConfig.permissionRegistry,
networkContracts
),
networkContracts
);
}

if (deploymentConfig.dao) {
networkContracts = Object.assign(
await deployDao(deploymentConfig.dao, networkContracts),
networkContracts
);
}

if (deploymentConfig.guildRegistry) {
networkContracts = Object.assign(
await deployGuildRegistry(
deploymentConfig.guildRegistry,
networkContracts
),
networkContracts
);
}

if (deploymentConfig.guilds) {
networkContracts = Object.assign(
await deployGuilds(deploymentConfig.guilds, networkContracts),
networkContracts
);
}

console.log("Contracts deployed:", networkContracts);

return networkContracts;
});
Loading

0 comments on commit be1532a

Please sign in to comment.