Skip to content

Commit

Permalink
Fixed exported ArchivedElection and added missing chainId propert…
Browse files Browse the repository at this point in the history
…y for elections
  • Loading branch information
marcvelmer committed Nov 15, 2023
1 parent ffae80b commit cd6dd94
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/api/election.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ export interface IElectionInfoResponse {
*/
fromArchive: boolean;

/**
* The chain identifier of the election
*/
chainId: string;

/**
* The census of the election
*/
Expand Down
1 change: 1 addition & 0 deletions src/services/election.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export class ElectionService extends Service implements ElectionServicePropertie
maxCensusSize: electionInfo.census.maxCensusSize,
manuallyEnded: electionInfo.manuallyEnded,
fromArchive: electionInfo.fromArchive,
chainId: electionInfo.chainId,
status: electionInfo.status,
voteCount: electionInfo.voteCount,
finalResults: electionInfo.finalResults,
Expand Down
1 change: 1 addition & 0 deletions src/types/election/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './unpublished';
export * from './election';
export * from './published';
export * from './invalid';
export * from './archived';
7 changes: 7 additions & 0 deletions src/types/election/published.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IPublishedElectionParameters extends IElectionParameters {
results: Array<Array<string>>;
manuallyEnded: boolean;
fromArchive: boolean;
chainId: string;
creationTime: string;
metadataURL: string;
raw: object;
Expand All @@ -44,6 +45,7 @@ export class PublishedElection extends Election {
private readonly _finalResults: boolean;
private readonly _manuallyEnded: boolean;
private readonly _fromArchive: boolean;
private readonly _chainId: string;
private readonly _results: Array<Array<string>>;
private readonly _creationTime: Date;
private readonly _metadataURL: string;
Expand Down Expand Up @@ -77,6 +79,7 @@ export class PublishedElection extends Election {
this._results = params.results;
this._manuallyEnded = params.manuallyEnded;
this._fromArchive = params.fromArchive;
this._chainId = params.chainId;
this._creationTime = new Date(params.creationTime);
this._metadataURL = params.metadataURL;
this._raw = params.raw;
Expand Down Expand Up @@ -176,6 +179,10 @@ export class PublishedElection extends Election {
return this._fromArchive;
}

get chainId(): string {
return this._chainId;
}

get creationTime(): Date {
return this._creationTime;
}
Expand Down
1 change: 1 addition & 0 deletions test/integration/election.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe('Election integration tests', () => {
});
expect(publishedElection.manuallyEnded).toBeFalsy();
expect(publishedElection.fromArchive).toBeFalsy();
expect(publishedElection.chainId).toBeDefined();
expect(publishedElection.maxCensusSize).toEqual(1);
});
}, 85000);
Expand Down

0 comments on commit cd6dd94

Please sign in to comment.