Skip to content

Commit

Permalink
wrapped up a version for auditing
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbeny committed Mar 4, 2024
1 parent c6f504e commit 3147593
Show file tree
Hide file tree
Showing 42 changed files with 4,744 additions and 20,184 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ packages/subgraph/tests/.latest.json
packages/subgraph/tests/helpers/extended-schema.ts

packages/contracts/deployments/
packages/contracts/dao-initial-data.json
packages/contracts/dao-initial-data*.json

.vscode
2 changes: 1 addition & 1 deletion packages/contracts-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xinfin/osx-daofin-contracts-ethers",
"version": "0.10.7",
"version": "0.10.10",
"description": "The Aragon OSx contract definitions for ethers.js",
"main": "dist/bundle-cjs.js",
"module": "dist/bundle-esm.js",
Expand Down
18,905 changes: 1,677 additions & 17,228 deletions packages/contracts/.openzeppelin/unknown-51.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions packages/contracts/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"code-complexity": ["error", 8],
"code-complexity": ["error", 11],
"compiler-version": ["error", ">=0.8.4"],
"func-visibility": ["error", {"ignoreConstructors": true}],
"max-line-length": ["error", 120],
"named-parameters-mapping": "warn",
"no-console": "off",
"not-rely-on-time": "off",
"prettier/prettier": [
Expand Down
73 changes: 40 additions & 33 deletions packages/contracts/deploy/03_create_dao/01_create_dao.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import DaoData from '../../dao-initial-data.json';
import DaoData from '../../dao-initial-data-internal-demo.json';
import {DaofinPluginSetupParams} from '../../plugin-settings';
import {ADDRESS_ZERO} from '../../test/unit-testing/daofin-common';
import {XDCValidator__factory} from '../../typechain';
import {
JudiciaryCommittee,
MasterNodeCommittee,
Expand All @@ -19,12 +18,7 @@ import {
activeContractsList,
} from '@xinfin/osx-ethers';
import {PermissionIds} from '@xinfin/osx-sdk-client';
import {
bytesToHex,
decodeRatio,
encodeRatio,
hexToBytes,
} from '@xinfin/osx-sdk-common';
import {hexToBytes} from '@xinfin/osx-sdk-common';
import {BigNumber, BigNumberish} from 'ethers';
import {id, parseEther, toUtf8Bytes} from 'ethers/lib/utils';
import {DeployFunction} from 'hardhat-deploy/types';
Expand Down Expand Up @@ -109,8 +103,43 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
],
],
[
Math.floor(new Date().getTime() / 1000) + 60 * 1000 * 60,
Math.floor(new Date().getTime() / 1000) + 60 * 1000 * 80,
// 1st
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 3
),
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 5
),
// 2nd
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 5
),
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 7
),
// 3rd
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 7
),
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 9
),
// 3rd
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 9
),
// 4th
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 11
),
// 5th
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 13
),
// 6th
BigNumber.from(
Math.floor(new Date().getTime() / 1000) + 60 * 60 * 24 * 15
),
],
daoParams.judiciaryList,
parseEther('1'),
Expand Down Expand Up @@ -190,7 +219,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const tx = await daoFactoryInstance.connect(deployer).createDao(
{
subdomain: daoParams.daoEnsSubDomain,
subdomain: `${daoParams.daoEnsSubDomain}-${Date.now()}`,
metadata: toUtf8Bytes(metadataUri),
daoURI: '',
trustedForwarder: ADDRESS_ZERO,
Expand Down Expand Up @@ -237,28 +266,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
log => pspInterface.parseLog(log).args[1]
),
});
console.log(network);

if (network === 'apothem' || network === 'anvil') {
const validatorContract = XDCValidator__factory.connect(
XDCMasterNodeTestingAddress,
deployer
);

for (let i = 0; i < daoParams.dummyMasterNodeAddresses.length; i++) {
const address = daoParams.dummyMasterNodeAddresses[i];
console.log({address});

const isExist = await validatorContract.isCandidate(address);
console.log('XDCValidatorMock', `${address} : ${isExist}`);

if (isExist) return;
const tx = await validatorContract.addCandidate(address);
console.log('XDCValidatorMock', `${address} : ${tx.hash}`);

await tx.wait();
}
}
};

export default func;
Expand Down
49 changes: 49 additions & 0 deletions packages/contracts/deploy/04_testing_configs/01_add_master_node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import DaoData from '../../dao-initial-data-internal-demo.json';
import {DaofinPluginSetupParams} from '../../plugin-settings';
import {XDCValidator__factory} from '../../typechain';
import {BigNumberish} from 'ethers';
import {ethers} from 'hardhat';
import {DeployFunction} from 'hardhat-deploy/types';
import {HardhatRuntimeEnvironment} from 'hardhat/types';

export type DaofinPluginInstall = {
globalSettings: {
xdcValidator: string;
amounts: BigNumberish[];
};
committeeSettings: any[];
electionPeriods: BigNumberish[];
};
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log('Adding MasterNodes...');

const [deployer] = await hre.ethers.getSigners();

Check failure on line 20 in packages/contracts/deploy/04_testing_configs/01_add_master_node.ts

View workflow job for this annotation

GitHub Actions / tests

'deployer' is assigned a value but never used. Allowed unused vars must match /_/u
const network = process.env.NETWORK_NAME
? process.env.NETWORK_NAME
: hre.network.name;

const {METADATA, XDCMasterNodeTestingAddress} = DaofinPluginSetupParams;

Check failure on line 25 in packages/contracts/deploy/04_testing_configs/01_add_master_node.ts

View workflow job for this annotation

GitHub Actions / tests

'METADATA' is assigned a value but never used. Allowed unused vars must match /_/u

Check failure on line 25 in packages/contracts/deploy/04_testing_configs/01_add_master_node.ts

View workflow job for this annotation

GitHub Actions / tests

'XDCMasterNodeTestingAddress' is assigned a value but never used. Allowed unused vars must match /_/u
// @ts-ignore

Check failure on line 26 in packages/contracts/deploy/04_testing_configs/01_add_master_node.ts

View workflow job for this annotation

GitHub Actions / tests

Do not use "@ts-ignore" because it alters compilation errors
const daoParams = DaoData[network];

if (network === 'apothem' || network === 'anvil') {
const validatorContract = await ethers.getContractAt(
'XDCValidator',
daoParams['xdcValidatorAddress']
);
for (const address of daoParams['dummyMasterNodeAddresses']) {
const isExist = await validatorContract.isCandidate(address);

if (!isExist) {
const tx = await validatorContract.addCandidate(address);
console.log('XDCValidatorMock', `${address} : ${tx.hash}`);
await tx.wait();
} else {
console.log(`${address}`);
}
}
}
};

export default func;
func.tags = [];
6 changes: 6 additions & 0 deletions packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ const config: HardhatUserConfig = {
outDir: 'typechain',
target: 'ethers-v5',
},
contractSizer: {
alphaSort: true,
disambiguatePaths: false,
runOnCompile: true,
strict: true,
},
};

export default config;
2 changes: 1 addition & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@xinfin/osx-daofin-contracts",
"license": "AGPL-3.0-or-later",
"description": "",
"version": "0.10.7",
"version": "0.10.10",
"author": {
"name": "aragon",
"url": "https://github.com/aragon"
Expand Down
90 changes: 79 additions & 11 deletions packages/contracts/plugin-info.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,107 @@
{
"apothem": {
"repo": "beny-plugin-repo-beta-3000",
"address": "0x502C8B0Fd2ea16b7D4ECf1D4E9aD7d51Ce0Dd251",
"repo": "beny-plugin-repo-v1-beta-8888-2",
"address": "0x92F00d4D70E61f6df55F3A14E30ACF6309B86Ed0",
"args": [],
"blockNumberOfDeployment": 58952824,
"blockNumberOfDeployment": 60143430,
"releases": {
"1": {
"builds": {
"1": {
"setup": {
"name": "DaofinPluginSetup",
"address": "0x275416d9E7464D7341127Ef96ad51513e4ce554d",
"address": "0x096e66a3Baba882Bad0EEc677fF48549BD06a920",
"args": [],
"blockNumberOfDeployment": 58952826
"blockNumberOfDeployment": 58995345
},
"implementation": {
"name": "DaofinPlugin",
"address": "0x5478f3FbAde40A17d4B9f51fDe5db4793E39902d",
"address": "0xf116205602d3602De2c7F4A3cE8F9D9E6d8C3B84",
"args": [],
"blockNumberOfDeployment": 58952826
"blockNumberOfDeployment": 58995345
},
"helpers": [],
"buildMetadataURI": "ipfs://QmW1gUZqJo5mTfQUfDwVSWa4meZeb7z14APpG9vK5puoCS",
"blockNumberOfPublication": 58952830
"blockNumberOfPublication": 58995349
},
"2": {
"setup": {
"name": "DaofinPluginSetup",
"address": "0x655c2D2f612CEBc6f465741993D5d14D502d32d2",
"args": [],
"blockNumberOfDeployment": 59216153
},
"implementation": {
"name": "DaofinPlugin",
"address": "0x60d2496e3Df3dD6AC69C3FAe2177AfeF6cd2c7db",
"args": [],
"blockNumberOfDeployment": 59216153
},
"helpers": [],
"buildMetadataURI": "ipfs://QmW1gUZqJo5mTfQUfDwVSWa4meZeb7z14APpG9vK5puoCS",
"blockNumberOfPublication": 59216156
},
"3": {
"setup": {
"name": "DaofinPluginSetup",
"address": "0xA4C64a712573c696F08F061da44617fD042044e1",
"args": [],
"blockNumberOfDeployment": 59445709
},
"implementation": {
"name": "DaofinPlugin",
"address": "0x82F2e0190084E4ca59f32db512c7D9d290b90a30",
"args": [],
"blockNumberOfDeployment": 59445709
},
"helpers": [],
"buildMetadataURI": "ipfs://QmW1gUZqJo5mTfQUfDwVSWa4meZeb7z14APpG9vK5puoCS",
"blockNumberOfPublication": 59445736
},
"4": {
"setup": {
"name": "DaofinPluginSetup",
"address": "0x3120617c04d2b077135b3378e42dFA0d6E68cA5c",
"args": [],
"blockNumberOfDeployment": 59445935
},
"implementation": {
"name": "DaofinPlugin",
"address": "0xa9C762EA75c302dfBf9F98b6Cc234f02CD920Cbe",
"args": [],
"blockNumberOfDeployment": 59445935
},
"helpers": [],
"buildMetadataURI": "ipfs://QmW1gUZqJo5mTfQUfDwVSWa4meZeb7z14APpG9vK5puoCS",
"blockNumberOfPublication": 59445940
},
"5": {
"setup": {
"name": "DaofinPluginSetup",
"address": "0x3120617c04d2b077135b3378e42dFA0d6E68cA5c",
"args": [],
"blockNumberOfDeployment": 59445935
},
"implementation": {
"name": "DaofinPlugin",
"address": "0xa9C762EA75c302dfBf9F98b6Cc234f02CD920Cbe",
"args": [],
"blockNumberOfDeployment": 59445935
},
"helpers": [],
"buildMetadataURI": "ipfs://QmW1gUZqJo5mTfQUfDwVSWa4meZeb7z14APpG9vK5puoCS",
"blockNumberOfPublication": 59446411
}
},
"releaseMetadataURI": "ipfs://QmbJWAESqCsf4RFCqEY7jecCashj8usXiyDNfKtZCwwzGb"
}
}
},
"anvil": {
"repo": "beny-plugin-repo-1003",
"address": "0x75A6BC1bD4A578864F9b45A7935245D22F8d393A",
"repo": "daofin-plugin-1709551555640",
"address": "0x92F00d4D70E61f6df55F3A14E30ACF6309B86Ed0",
"args": [],
"blockNumberOfDeployment": 54098625,
"blockNumberOfDeployment": 58995357,
"releases": {
"1": {
"builds": {
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/plugin-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import daofinBuildMetadata from './src/build-metadata.json';
import daofinReleaseMetadata from './src/release-metadata.json';

export const DaofinPluginSetupParams: PluginSetupParams = {
PLUGIN_REPO_ENS_NAME: 'beny-plugin-repo-beta-3000',
PLUGIN_REPO_ENS_NAME: `daofin-plugin-${Date.now()}`,
PLUGIN_CONTRACT_NAME: 'DaofinPlugin',
PLUGIN_SETUP_CONTRACT_NAME: 'DaofinPluginSetup',
VERSION: {
release: 1, // Increment this number ONLY if breaking/incompatible changes were made. Updates between releases are NOT possible.
build: 1, // Increment this number if non-breaking/compatible changes were made. Updates to newer builds are possible.
build: 5, // Increment this number if non-breaking/compatible changes were made. Updates to newer builds are possible.
},
METADATA: {
build: daofinBuildMetadata,
Expand Down
Loading

0 comments on commit 3147593

Please sign in to comment.