Skip to content

Commit

Permalink
Make nemesis/importance block optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rg911 committed Dec 1, 2020
1 parent df02dc0 commit 189945d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/infrastructure/BlockHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ export class BlockHttp extends Http implements BlockRepository {
const importanceBlockInfoDto = dto.block as ImportanceBlockDTO;
return DtoMapping.assign(normalBlock, {
votingEligibleAccountsCount: importanceBlockInfoDto.votingEligibleAccountsCount,
harvestingEligibleAccountsCount: UInt64.fromNumericString(importanceBlockInfoDto.harvestingEligibleAccountsCount),
totalVotingBalance: UInt64.fromNumericString(importanceBlockInfoDto.totalVotingBalance),
harvestingEligibleAccountsCount: importanceBlockInfoDto.harvestingEligibleAccountsCount
? UInt64.fromNumericString(importanceBlockInfoDto.harvestingEligibleAccountsCount)
: undefined,
totalVotingBalance: importanceBlockInfoDto.totalVotingBalance
? UInt64.fromNumericString(importanceBlockInfoDto.totalVotingBalance)
: undefined,
previousImportanceBlockHash: importanceBlockInfoDto.previousImportanceBlockHash,
}) as NemesisImportanceBlockInfo;
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/model/blockchain/NemesisImportanceBlockInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { UInt64 } from '../UInt64';
import { NormalBlockInfo } from './NomalBlockInfo';

export type NemesisImportanceBlockInfo = NormalBlockInfo & {
votingEligibleAccountsCount: number;
harvestingEligibleAccountsCount: UInt64;
totalVotingBalance: UInt64;
previousImportanceBlockHash: string;
votingEligibleAccountsCount?: number;
harvestingEligibleAccountsCount?: UInt64;
totalVotingBalance?: UInt64;
previousImportanceBlockHash?: string;
};
4 changes: 2 additions & 2 deletions test/infrastructure/BlockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ describe('BlockHttp', () => {
expect(blockInfo.totalFee.toString()).to.be.equals(blockInfoDto.meta.totalFee);

if (isImportance) {
expect((blockInfo as NemesisImportanceBlockInfo).harvestingEligibleAccountsCount.toString()).to.be.equals(
expect((blockInfo as NemesisImportanceBlockInfo).harvestingEligibleAccountsCount!.toString()).to.be.equals(
(importanceBlockInfoDto.block as ImportanceBlockDTO).harvestingEligibleAccountsCount,
);
expect((blockInfo as NemesisImportanceBlockInfo).previousImportanceBlockHash).to.be.equals(
(importanceBlockInfoDto.block as ImportanceBlockDTO).previousImportanceBlockHash,
);
expect((blockInfo as NemesisImportanceBlockInfo).totalVotingBalance.toString()).to.be.equals(
expect((blockInfo as NemesisImportanceBlockInfo).totalVotingBalance!.toString()).to.be.equals(
(importanceBlockInfoDto.block as ImportanceBlockDTO).totalVotingBalance,
);
expect((blockInfo as NemesisImportanceBlockInfo).votingEligibleAccountsCount).to.be.equals(
Expand Down

0 comments on commit 189945d

Please sign in to comment.