Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

Commit

Permalink
fix: 🐛 add improvements requested by VW
Browse files Browse the repository at this point in the history
  • Loading branch information
shuffledex committed Oct 25, 2019
1 parent c4b9017 commit fab0d35
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions examples/advancedPLCRVoting.ts
Expand Up @@ -34,7 +34,7 @@ export const advancedPLCRVotingCheckpoint = async (polymathAPI: PolymathAPI, tic
investors: [myAddress],
canSendAfter: [new Date()],
canReceiveAfter: [new Date()],
expiryTime: [new Date(2021, 10)],
expiryTime: [new Date(2030, 10)],
};
await addInvestorsToWhitelist(polymathAPI, ticker, kycInvestorMultiData);

Expand All @@ -60,7 +60,7 @@ export const advancedPLCRVotingCheckpoint = async (polymathAPI: PolymathAPI, tic
startTime: new Date(),
commitDuration: 20,
revealDuration: 20,
proposalTitles: ['Propostal Title Example'],
proposalTitles: ['Proposal Title Example'],
proposalDetails: 'Proposal Details',
choices: ['Choice one', 'Choice two'],
choicesCounts: 2,
Expand Down
Expand Up @@ -648,7 +648,7 @@ describe('AdvancedPLCRVotingCheckpointWrapper', () => {
when(mockedBallotsMethod.callAsync()).thenResolve(expectedBallotsResult);

const mockedParams = {
name: 'nee ballot',
name: 'new ballot',
startTime: new Date(2019, 10),
commitDuration: 80000,
revealDuration: 3000,
Expand Down Expand Up @@ -1353,13 +1353,13 @@ describe('AdvancedPLCRVotingCheckpointWrapper', () => {
),
).thenResolve(expectedIsVoterAllowedResult);

// pending ballots
// Pending ballots
const expectedPendingBallotsResult = [[new BigNumber(1), new BigNumber(2)], [new BigNumber(3), new BigNumber(4)]];
const mockedPendingBallotsMethod = mock(MockedCallMethod);
when(mockedContract.pendingBallots).thenReturn(instance(mockedPendingBallotsMethod));
when(mockedPendingBallotsMethod.callAsync(mockedParams.txData.from)).thenResolve(expectedPendingBallotsResult);

// get ballot details
// Get ballot details
const expectedBallotDetailsResult = [
'ballot name',
new BigNumber(1000),
Expand Down
Expand Up @@ -184,8 +184,8 @@ interface GetAdvancedPLCRVotingCheckpointLogsAsyncParams extends GetLogs {
/**
* @param name Name of the ballot (Should be unique)
* @param startTime startTime of the ballot
* @param commitDuration Unix time period till the voters commit there vote
* @param revealDuration Unix time period till the voters reveal there vote starts when commit duration ends
* @param commitDuration Unix time period till the voters commit their vote
* @param revealDuration Unix time period till the voters reveal their vote starts when commit duration ends
*/
export interface BallotParams extends TxParams {
name: string;
Expand Down Expand Up @@ -228,11 +228,9 @@ export interface CreateCumulativeBallotParams extends BallotParams {
}

/**
* @param choicesCounts No. of choices (If it is 0 then it means NAY/YAY ballot type is choosen).
* @param checkpointId Valid checkpoint Id
*/
export interface CreateCustomCumulativeBallotParams extends CreateCumulativeBallotParams {
choicesCounts: number[];
checkpointId: number;
}

Expand Down Expand Up @@ -546,14 +544,16 @@ export default abstract class AdvancedPLCRVotingCheckpointCommon extends ModuleC

/**
* Used to get the current stage of the ballot
* @return ballot state
*/
public getCurrentBallotStage = async (params: BallotIdParams): Promise<BallotStage> => {
const result = await (await this.contract).getCurrentBallotStage.callAsync(numberToBigNumber(params.ballotId));
return parseBallotStageValue(result);
};

/**
* Get the voting power for an voter in terms of the token
* Get the voting power for a voter in terms of the token
* @return voting power
*/
public getVoteTokenCount = async (params: VoteTokenCountParams): Promise<number> => {
const result = await (await this.contract).getVoteTokenCount.callAsync(
Expand All @@ -565,6 +565,7 @@ export default abstract class AdvancedPLCRVotingCheckpointCommon extends ModuleC

/**
* Queries the result of a given ballot
* @return ballot result
*/
public getBallotResults = async (params: BallotIdParams): Promise<BallotResult> => {
const result = await (await this.contract).getBallotResults.callAsync(numberToBigNumber(params.ballotId));
Expand All @@ -576,7 +577,8 @@ export default abstract class AdvancedPLCRVotingCheckpointCommon extends ModuleC
};

/**
* Get the details of the ballot
* Get the details of the ballot
* @return ballot details
*/
public getBallotDetails = async (params: BallotIdParams): Promise<BallotDetails> => {
const result = await (await this.contract).getBallotDetails.callAsync(numberToBigNumber(params.ballotId));
Expand Down Expand Up @@ -961,7 +963,7 @@ export default abstract class AdvancedPLCRVotingCheckpointCommon extends ModuleC
};

/**
* Allows the token issuer to scrapped down a ballot
* Allows the token issuer to cancel a ballot
*/
public cancelBallot = async (params: CancelBallotParams): Promise<PolyResponse> => {
assert.assert(
Expand Down Expand Up @@ -1142,7 +1144,7 @@ export default abstract class AdvancedPLCRVotingCheckpointCommon extends ModuleC

private checkIndexOutOfBound = async (ballotId: number) => {
const allBallots: Ballot[] = await this.getAllBallots();
assert.assert(allBallots.length > ballotId, ErrorCode.InvalidData, 'Index out of bound');
assert.assert(allBallots.length > ballotId, ErrorCode.InvalidData, 'Index out of bounds');
};

private checkValidStage = async (ballot: BallotIdParams, stage: BallotStage) => {
Expand Down

0 comments on commit fab0d35

Please sign in to comment.