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

use AbsoluteVote for schemes in the createGenesisDao script #348

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
47 changes: 32 additions & 15 deletions lib/scripts/createGenesisDao.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Web3 } from "web3";
import { AvatarService } from "../avatarService";
import { DefaultSchemePermissions, SchemePermissions } from "../commonTypes";
import { Address } from "../commonTypes";
import { Utils } from "../utils";
Expand Down Expand Up @@ -51,12 +52,11 @@ export class GenesisDaoCreator {
*/
public async forge(foundersConfigurationLocation: string): Promise<ForgedDaoInfo> {

const live = this.network === "live";
/**
* Genesis DAO parameters
*/
const orgName = live ? "Genesis Alpha" : "Genesis Alpha";
const tokenName = live ? "Genesis Alpha" : "Genesis Alpha";
const orgName = "Genesis Test";
const tokenName = "Genesis Test";
const tokenSymbol = "GDT";

/**
Expand Down Expand Up @@ -113,8 +113,8 @@ export class GenesisDaoCreator {
while (!avatarInst) {

await Avatar.at(txForgeOrg.logs[0].args._avatar)
.then((address: Address) => {
avatarInst = address;
.then((contract: any) => {
avatarInst = contract;
})
/* tslint:disable-next-line:no-empty */
.catch(() => {
Expand Down Expand Up @@ -149,6 +149,7 @@ export class GenesisDaoCreator {
const GlobalConstraintRegistrar = await Utils.requireContract("GlobalConstraintRegistrar");
const SchemeRegistrar = await Utils.requireContract("SchemeRegistrar");
const UpgradeScheme = await Utils.requireContract("UpgradeScheme");
const AbsoluteVote = await Utils.requireContract("AbsoluteVote");
const GenesisProtocol = await Utils.requireContract("GenesisProtocol");

/**
Expand All @@ -169,11 +170,27 @@ export class GenesisDaoCreator {
const upgradeSchemeInst = await UpgradeScheme.deployed();
const globalConstraintRegistrarInst = await GlobalConstraintRegistrar.deployed();
const contributionRewardInst = await ContributionReward.deployed();
const absoluteVoteInst = await AbsoluteVote.deployed();
const avatarService = new AvatarService(forgedDaoInfo.avatarAddress);
const daoReputationAddress = await avatarService.getNativeReputationAddress();

const absoluteVoteParamsHash = await absoluteVoteInst.getParametersHash(
daoReputationAddress,
50,
true
);

await absoluteVoteInst.setParameters(
daoReputationAddress,
50,
true
);

/**
* Set/get the GenesisProtocol voting parameters that will be used as defaults
* for the schemes' voting machine as we add the schemes to the Genesis DAO, below.
*/
const genesisProtocolParams = await genesisProtocolInst.getParametersHash(
const genesisProtocolParamsHash = await genesisProtocolInst.getParametersHash(
[
defaultVotingMachineParams.preBoostedVoteRequiredPercentage,
defaultVotingMachineParams.preBoostedVotePeriodLimit,
Expand Down Expand Up @@ -215,17 +232,17 @@ export class GenesisDaoCreator {
* Set/get the Genesis DAO's scheme parameters, using the GenesisProtocol voting machine
* parameters that we just obtained above.
*/
await schemeRegistrarInst.setParameters(genesisProtocolParams, genesisProtocolParams, genesisProtocolInst.address);
const schemeRegisterParams = await schemeRegistrarInst.getParametersHash(genesisProtocolParams, genesisProtocolParams, genesisProtocolInst.address);
await schemeRegistrarInst.setParameters(absoluteVoteParamsHash, absoluteVoteParamsHash, absoluteVoteInst.address);
const schemeRegisterParams = await schemeRegistrarInst.getParametersHash(absoluteVoteParamsHash, absoluteVoteParamsHash, absoluteVoteInst.address);

await globalConstraintRegistrarInst.setParameters(genesisProtocolParams, genesisProtocolInst.address);
const schemeGCRegisterParams = await globalConstraintRegistrarInst.getParametersHash(genesisProtocolParams, genesisProtocolInst.address);
await globalConstraintRegistrarInst.setParameters(absoluteVoteParamsHash, absoluteVoteInst.address);
const schemeGCRegisterParams = await globalConstraintRegistrarInst.getParametersHash(absoluteVoteParamsHash, absoluteVoteInst.address);

await upgradeSchemeInst.setParameters(genesisProtocolParams, genesisProtocolInst.address);
const schemeUpgradeParams = await upgradeSchemeInst.getParametersHash(genesisProtocolParams, genesisProtocolInst.address);
await upgradeSchemeInst.setParameters(absoluteVoteParamsHash, absoluteVoteInst.address);
const schemeUpgradeParams = await upgradeSchemeInst.getParametersHash(absoluteVoteParamsHash, absoluteVoteInst.address);

await contributionRewardInst.setParameters(orgNativeTokenFee, genesisProtocolParams, genesisProtocolInst.address);
const contributionRewardParams = await contributionRewardInst.getParametersHash(orgNativeTokenFee, genesisProtocolParams, genesisProtocolInst.address);
await contributionRewardInst.setParameters(orgNativeTokenFee, genesisProtocolParamsHash, genesisProtocolInst.address);
const contributionRewardParams = await contributionRewardInst.getParametersHash(orgNativeTokenFee, genesisProtocolParamsHash, genesisProtocolInst.address);

/**
* Register the schemes with the Genesis DAO
Expand All @@ -242,7 +259,7 @@ export class GenesisDaoCreator {
schemeGCRegisterParams,
schemeUpgradeParams,
contributionRewardParams,
genesisProtocolParams];
genesisProtocolParamsHash];

const permissionArray = [
schemeRegistrarPermissions,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/arc.js",
"version": "0.0.0-alpha.81",
"version": "0.0.0-alpha.82",
"description": "A JavaScript library for interacting with @daostack/arc ethereum smart contracts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down