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

Can not join the dao with a 0x0 address #285

Merged
merged 2 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ You can find more information about the purpose of each access flag at [DAO Regi
Added the following environment variables to your local .env file:

```
# The DAO Owner ETH Address (0x...) in the target network
DAO_OWNER_ADDR=
# The Infura API Key is used to communicate with the Ethereum blockchain
INFURA_KEY=
# The mnemonic that generates you account
Expand Down
6 changes: 4 additions & 2 deletions contracts/core/DaoRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ contract DaoRegistry is MemberGuard, AdapterGuard {
public
hasAccess(this, AclFlag.NEW_MEMBER)
{
require(memberAddress != address(0x0), "invalid member address");

Member storage member = members[memberAddress];
if (!getFlag(member.flags, uint8(MemberFlag.EXISTS))) {
member.flags = setFlag(
Expand Down Expand Up @@ -539,8 +541,8 @@ contract DaoRegistry is MemberGuard, AdapterGuard {
* @param addr The address to look up
*/
function isMember(address addr) public view returns (bool) {
address memberAddr = memberAddressesByDelegatedKey[addr];
return getMemberFlag(memberAddr, MemberFlag.EXISTS);
address memberAddress = memberAddressesByDelegatedKey[addr];
return getMemberFlag(memberAddress, MemberFlag.EXISTS);
}

/**
Expand Down
13 changes: 8 additions & 5 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const truffleImports = require("../utils/TruffleUtil.js");

require("dotenv").config();

module.exports = async (deployer, network) => {
module.exports = async (deployer, network, accounts) => {
let dao;
const deployFunction = truffleImports.deployFunctionFactory(deployer);
if (network === "ganache") {
dao = await deployGanacheDao(deployFunction, network);
dao = await deployGanacheDao(deployFunction, network, accounts);
} else if (network === "rinkeby") {
dao = await deployRinkebyDao(deployFunction, network);
} else if (network === "test" || network === "coverage") {
dao = await deployTestDao(deployFunction, network);
dao = await deployTestDao(deployFunction, network, accounts);
}

if (dao) {
Expand All @@ -38,7 +38,7 @@ module.exports = async (deployer, network) => {
}
};

async function deployTestDao(deployFunction, network) {
async function deployTestDao(deployFunction, network, accounts) {
let { dao } = await deployDao({
...truffleImports,
deployFunction,
Expand All @@ -56,6 +56,7 @@ async function deployTestDao(deployFunction, network) {
couponCreatorAddress: "0x7D8cad0bbD68deb352C33e80fccd4D8e88b4aBb8",
offchainAdmin: "0xedC10CFA90A135C41538325DD57FDB4c7b88faf7",
daoName: process.env.DAO_NAME,
owner: accounts[0],
});
return dao;
}
Expand All @@ -77,12 +78,13 @@ async function deployRinkebyDao(deployFunction, network) {
maxExternalTokens: 100,
couponCreatorAddress: process.env.COUPON_CREATOR_ADDR,
daoName: process.env.DAO_NAME,
owner: process.env.DAO_OWNER_ADDR,
offchainAdmin: "0xedC10CFA90A135C41538325DD57FDB4c7b88faf7",
});
return dao;
}

async function deployGanacheDao(deployFunction, network) {
async function deployGanacheDao(deployFunction, network, accounts) {
let { dao } = await deployDao({
...truffleImports,
deployFunction,
Expand All @@ -99,6 +101,7 @@ async function deployGanacheDao(deployFunction, network) {
maxExternalTokens: 100,
couponCreatorAddress: process.env.COUPON_CREATOR_ADDR,
daoName: process.env.DAO_NAME,
owner: accounts[0],
offchainAdmin: "0xedC10CFA90A135C41538325DD57FDB4c7b88faf7",
});
return dao;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
"version": "1.0.0-rc2",
"description": "A new modular DAO framework, inspired by the Moloch smart contracts",
"main": "truffle-config.js",
"keywords": ["dao", "framework", "smart-contract", "solidity", "modular", "moloch", "ethereum"],
"keywords": [
"dao",
"framework",
"smart-contract",
"solidity",
"modular",
"moloch",
"ethereum"
],
"directories": {
"test": "test"
},
Expand Down
3 changes: 3 additions & 0 deletions test/adapters/distribute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ const {
const { onboardingNewMember } = require("../../utils/TestUtils.js");

const daoOwner = accounts[2];
const daoCreator = accounts[9];

const proposalCounter = proposalIdGenerator().generator;

function getProposalCounter() {
Expand All @@ -63,6 +65,7 @@ describe("Adapter - Distribute", () => {
before("deploy dao", async () => {
const { dao, adapters, extensions } = await deployDefaultDao({
owner: daoOwner,
creator: daoCreator,
});
this.dao = dao;
this.adapters = adapters;
Expand Down
34 changes: 32 additions & 2 deletions test/adapters/onboarding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const {
const { checkBalance, isMember } = require("../../utils/TestUtils.js");

const daoOwner = accounts[0];
const delegatedKey = accounts[9];

const proposalCounter = proposalIdGenerator().generator;

function getProposalCounter() {
Expand All @@ -60,6 +62,7 @@ describe("Adapter - Onboarding", () => {
before("deploy dao", async () => {
const { dao, adapters, extensions } = await deployDefaultDao({
owner: daoOwner,
creator: delegatedKey,
});
this.dao = dao;
this.adapters = adapters;
Expand Down Expand Up @@ -425,15 +428,15 @@ describe("Adapter - Onboarding", () => {
});

it("should be possible to update delegate key and the member continues as an active member", async () => {
const delegateKey = accounts[2];
const delegateKey = accounts[9];
const dao = this.dao;
const bank = this.extensions.bank;
const daoRegistryAdapter = this.adapters.daoRegistryAdapter;

expect(await isMember(bank, daoOwner)).equal(true);
expect(await dao.isMember(delegateKey)).equal(true); // use the dao to check delegatedKeys

const newDelegatedKey = accounts[9];
const newDelegatedKey = accounts[5];
await daoRegistryAdapter.updateDelegateKey(dao.address, newDelegatedKey, {
from: daoOwner,
gasPrice: toBN("0"),
Expand Down Expand Up @@ -518,4 +521,31 @@ describe("Adapter - Onboarding", () => {
"address already taken as delegated key"
);
});

it("should not be possible to onboard a member with a zero address", async () => {
const applicant = "0x0000000000000000000000000000000000000000";
const dao = this.dao;
const onboarding = this.adapters.onboarding;
const voting = this.adapters.voting;

const proposalId = getProposalCounter();
await expectRevert(
onboarding.submitProposal(
dao.address,
proposalId,
applicant,
UNITS,
unitPrice.mul(toBN(3)).add(remaining),
[],
{
from: daoOwner,
gasPrice: toBN("0"),
}
),
"invalid member address."
);

let isMember = await dao.isMember(applicant);
expect(isMember).equal(false);
});
});
8 changes: 8 additions & 0 deletions test/core/registry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,12 @@ describe("Core - Registry", () => {
"adapterId must not be empty"
);
});

it("should not be possible to a zero address be considered a member", async () => {
fforbeck marked this conversation as resolved.
Show resolved Hide resolved
let registry = await DaoRegistry.new();
let isMember = await registry.isMember(
"0x0000000000000000000000000000000000000000"
);
expect(isMember).equal(false);
});
});
Loading