Skip to content

Commit

Permalink
fix daoCreator (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkent600 authored Dec 1, 2018
1 parent 9b258aa commit fc98124
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 23 deletions.
15 changes: 0 additions & 15 deletions lib/contractWrapperBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,6 @@ export abstract class ContractWrapperBase implements IContractWrapper {
throw new Error("getParameters has not been not implemented by the contract wrapper");
}

/**
* Given an avatar address, returns the schemes parameters hash
* @param avatarAddress
*/
public async getSchemeParametersHash(avatarAddress: Address): Promise<Hash> {
const controllerService = new ControllerService(avatarAddress);
const controller = await controllerService.getController();
return controller.getSchemeParameters(this.address, avatarAddress);
}

/**
* Given a hash, returns the associated parameters as an array, ordered by the order
* in which the parameters appear in the contract's Parameters struct.
Expand Down Expand Up @@ -197,11 +187,6 @@ export abstract class ContractWrapperBase implements IContractWrapper {
return new ArcTransactionDataResult<Hash>(txResult.tx, this.contract, parametersHash);
}

protected async _getSchemeParameters(avatarAddress: Address): Promise<any> {
const paramsHash = await this.getSchemeParametersHash(avatarAddress);
return this.getParameters(paramsHash);
}

protected _getParametersHash(...params: Array<any>): Promise<Hash> {
return this.contract.getParametersHash(...params);
}
Expand Down
6 changes: 5 additions & 1 deletion lib/wrappers/daoCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export class DaoCreatorWrapper extends ContractWrapperBase {
to: contractAddress,
}, callback)))()
.then((result: string): boolean => {
return result === "0x0";
/**
* odd thing that in some environments this is returned as 0x0 (like the automated tests) and
* others as 0x (like in more than one observed application context)
*/
return (result === "0x0") || (result === "0x");
})
.catch((): boolean => {
return false;
Expand Down
9 changes: 5 additions & 4 deletions lib/wrappers/tokenCapGC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ export class TokenCapGCWrapper extends ContractWrapperBase {
cap);
}

public async getParameters(paramsHash: Hash): Promise<any> {
public async getParameters(paramsHash: Hash): Promise<GetTokenCapGcParamsResult> {
const params = await this.getParametersArray(paramsHash);
return {
cap: params[1],
token: params[0],
};
}

public async getSchemeParametersHash(avatarAddress: Address): Promise<Hash> {
public async getRegisteredParametersHash(avatarAddress: Address): Promise<Hash> {
const controllerService = new ControllerService(avatarAddress);
const controller = await controllerService.getController();
return controller.getGlobalConstraintParameters(this.address, avatarAddress);
}

public async getSchemeParameters(avatarAddress: Address): Promise<GetTokenCapGcParamsResult> {
return this._getSchemeParameters(avatarAddress);
public async getRegisteredParameters(avatarAddress: Address): Promise<GetTokenCapGcParamsResult> {
const paramsHash = await this.getRegisteredParametersHash(avatarAddress);
return this.getParameters(paramsHash);
}
}

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.93",
"version": "0.0.0-alpha.94",
"description": "A JavaScript library for interacting with @daostack/arc ethereum smart contracts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions test/globalConstraintRegistrar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ describe("GlobalConstraintRegistrar", () => {

const tokenWrapper = await WrapperService.factories.TokenCapGC.at(tokenCapGC.address) as TokenCapGCWrapper;

const paramsHash = await tokenWrapper.getSchemeParametersHash(dao.avatar.address);
const paramsHash = await tokenWrapper.getRegisteredParametersHash(dao.avatar.address);

assert.equal(paramsHash, tokenCapGCParamsHash);

const params = await tokenWrapper.getSchemeParameters(dao.avatar.address);
const params = await tokenWrapper.getRegisteredParameters(dao.avatar.address);

assert.equal(params.cap.toString(), tokenCapParams.cap);
assert.equal(params.token, tokenCapParams.token);
Expand Down

0 comments on commit fc98124

Please sign in to comment.