Skip to content

Commit

Permalink
Merge pull request #98 from kaleido-io/v1.1-refactors
Browse files Browse the repository at this point in the history
changes to support FF version 1.0
  • Loading branch information
shorsher authored Aug 17, 2022
2 parents 6de657f + 7c7a352 commit 0b57d3c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions server/src/controllers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class CommonController {
@OpenAPI({ summary: 'List verifiers (such as Ethereum keys) for all organizations in network' })
async verifiers(): Promise<Verifier[]> {
const orgs = await firefly.getOrganizations();
const verifiers = await firefly.getVerifiers('default');
const defaultVerifiers = await firefly.getVerifiers('default');
const legacyVerifiers = await firefly.getVerifiers('ff_system');
const verifiers = defaultVerifiers.concat(legacyVerifiers);

const result: Verifier[] = [];
for (const v of verifiers) {
const o = orgs.find((o) => o.id === v.identity);
Expand Down Expand Up @@ -87,8 +90,15 @@ export class CommonController {
@OpenAPI({ summary: 'Look up FireFly status' })
async ffStatus(): Promise<FFStatus> {
const status = await firefly.getStatus();
return {
multiparty: status.multiparty.enabled,
};
if ("multiparty" in status) {
return {
multiparty: status.multiparty.enabled,
};
} else {
// Assume multiparty mode if `multiparty` key is missing from status
return {
multiparty: true
}
}
}
}
4 changes: 4 additions & 0 deletions server/test/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('Common Operations', () => {

mockFireFly.getOrganizations.mockResolvedValueOnce(orgs);
mockFireFly.getVerifiers.mockResolvedValueOnce(verifiers);
mockFireFly.getVerifiers.mockResolvedValueOnce([]);

await request(server)
.get('/api/common/verifiers')
Expand All @@ -70,5 +71,8 @@ describe('Common Operations', () => {

expect(mockFireFly.getOrganizations).toHaveBeenCalledWith();
expect(mockFireFly.getVerifiers).toHaveBeenCalledWith('default');

expect(mockFireFly.getOrganizations).toHaveBeenCalledWith();
expect(mockFireFly.getVerifiers).toHaveBeenCalledWith('ff_system');
});
});

0 comments on commit 0b57d3c

Please sign in to comment.