Skip to content

Commit 9533a27

Browse files
committed
PR feedbacks
1 parent 81c561f commit 9533a27

File tree

7 files changed

+19
-104
lines changed

7 files changed

+19
-104
lines changed

src/infrastructure/BlockHttp.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { Address } from '../model/account/Address';
2121
import { PublicAccount } from '../model/account/PublicAccount';
2222
import { BlockInfo } from '../model/blockchain/BlockInfo';
2323
import { BlockType } from '../model/blockchain/BlockType';
24-
import { ImportanceBlockFooter } from '../model/blockchain/ImportanceBlockFooter';
2524
import { MerklePathItem } from '../model/blockchain/MerklePathItem';
2625
import { MerkleProofInfo } from '../model/blockchain/MerkleProofInfo';
2726
import { NemesisImportanceBlockInfo } from '../model/blockchain/NemesisImportanceBlockInfo';
@@ -125,21 +124,12 @@ export class BlockHttp extends Http implements BlockRepository {
125124
return normalBlock;
126125
} else if ([BlockType.ImportanceBlock.valueOf(), BlockType.NemesisBlock.valueOf()].includes(blockType)) {
127126
const importanceBlockInfoDto = dto.block as ImportanceBlockDTO;
128-
const importanceBlockFooter = new ImportanceBlockFooter(
129-
importanceBlockInfoDto.votingEligibleAccountsCount,
130-
UInt64.fromNumericString(importanceBlockInfoDto.harvestingEligibleAccountsCount),
131-
UInt64.fromNumericString(importanceBlockInfoDto.totalVotingBalance),
132-
importanceBlockInfoDto.previousImportanceBlockHash,
133-
);
134-
return Object.assign(
135-
{
136-
__proto__: Object.getPrototypeOf(normalBlock),
137-
},
138-
normalBlock,
139-
{
140-
importanceBlockFooter,
141-
},
142-
) as NemesisImportanceBlockInfo;
127+
return DtoMapping.assign(normalBlock, {
128+
votingEligibleAccountsCount: importanceBlockInfoDto.votingEligibleAccountsCount,
129+
harvestingEligibleAccountsCount: UInt64.fromNumericString(importanceBlockInfoDto.harvestingEligibleAccountsCount),
130+
totalVotingBalance: UInt64.fromNumericString(importanceBlockInfoDto.totalVotingBalance),
131+
previousImportanceBlockHash: importanceBlockInfoDto.previousImportanceBlockHash,
132+
}) as NemesisImportanceBlockInfo;
143133
} else {
144134
throw new Error(`Block type: ${blockType} invalid.`);
145135
}

src/model/blockchain/ImportanceBlockFooter.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/model/blockchain/NemesisImportanceBlockInfo.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { ImportanceBlockFooter } from './ImportanceBlockFooter';
17+
import { UInt64 } from '../UInt64';
1818
import { NormalBlockInfo } from './NomalBlockInfo';
1919

20-
export type NemesisImportanceBlockInfo = NormalBlockInfo & { importanceBlockFooter: ImportanceBlockFooter };
20+
export type NemesisImportanceBlockInfo = NormalBlockInfo & {
21+
votingEligibleAccountsCount: number;
22+
harvestingEligibleAccountsCount: UInt64;
23+
totalVotingBalance: UInt64;
24+
previousImportanceBlockHash: string;
25+
};

src/model/blockchain/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export * from './BlockInfo';
44
export * from './BlockType';
55
export * from './ChainInfo';
66
export * from './FinalizedBlock';
7-
export * from './ImportanceBlockFooter';
87
export * from './MerklePathItem';
98
export * from './MerklePosition';
109
export * from './MerkleProofInfo';

test/infrastructure/BlockHttp.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ describe('BlockHttp', () => {
127127
expect(blockInfo.totalFee.toString()).to.be.equals(blockInfoDto.meta.totalFee);
128128

129129
if (isImportance) {
130-
expect((blockInfo as NemesisImportanceBlockInfo).importanceBlockFooter.harvestingEligibleAccountsCount.toString()).to.be.equals(
130+
expect((blockInfo as NemesisImportanceBlockInfo).harvestingEligibleAccountsCount.toString()).to.be.equals(
131131
(importanceBlockInfoDto.block as ImportanceBlockDTO).harvestingEligibleAccountsCount,
132132
);
133-
expect((blockInfo as NemesisImportanceBlockInfo).importanceBlockFooter.previousImportanceBlockHash).to.be.equals(
133+
expect((blockInfo as NemesisImportanceBlockInfo).previousImportanceBlockHash).to.be.equals(
134134
(importanceBlockInfoDto.block as ImportanceBlockDTO).previousImportanceBlockHash,
135135
);
136-
expect((blockInfo as NemesisImportanceBlockInfo).importanceBlockFooter.totalVotingBalance.toString()).to.be.equals(
136+
expect((blockInfo as NemesisImportanceBlockInfo).totalVotingBalance.toString()).to.be.equals(
137137
(importanceBlockInfoDto.block as ImportanceBlockDTO).totalVotingBalance,
138138
);
139-
expect((blockInfo as NemesisImportanceBlockInfo).importanceBlockFooter.votingEligibleAccountsCount).to.be.equals(
139+
expect((blockInfo as NemesisImportanceBlockInfo).votingEligibleAccountsCount).to.be.equals(
140140
(importanceBlockInfoDto.block as ImportanceBlockDTO).votingEligibleAccountsCount,
141141
);
142142
}

test/model/blockchain/BlockInfo.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { deepEqual } from 'assert';
1818
import { expect } from 'chai';
19+
import { BlockType } from '../../../src';
1920
import { Address } from '../../../src/model/account/Address';
2021
import { PublicAccount } from '../../../src/model/account/PublicAccount';
2122
import { NormalBlockInfo } from '../../../src/model/blockchain/NomalBlockInfo';
@@ -43,7 +44,7 @@ describe('BlockInfo', () => {
4344
signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF',
4445
beneficiaryAddress: '7826D27E1D0A26CA4E316F901E23E55C8711DB20DF5C49B5',
4546
timestamp: new UInt64([0, 0]),
46-
type: 33091,
47+
type: BlockType.NormalBlock,
4748
version: 1,
4849
network: 144,
4950
},

test/model/blockchain/ImportanceBlockFooter.spec.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)