Skip to content

Commit 06dc320

Browse files
AnthonyLawWayonb
authored andcommitted
[explorer] fix: improvement blocks listing page
* fix: remove chain info on top right blocks listing page * feat: add inflation data * fix: refactor code * fix: re-arrage block listing table head * feat: new translation * Fix: get inflation from statement receipt * task: fix indent * task: removed unused code * task: update get block list unit test * task: add missing library * task: lint fix import order
1 parent 71fc656 commit 06dc320

File tree

12 files changed

+93
-26
lines changed

12 files changed

+93
-26
lines changed

__tests__/TestHelper.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,21 @@ const TestHelper = {
230230
new Mosaic(new MosaicId('7F2D26E89342D398'), UInt64.fromUint(5))
231231
]
232232
};
233+
},
234+
/**
235+
* Mock inflation statement.
236+
* @param {number} amount reward amount.
237+
* @param {number} height block height.
238+
* @returns {object} inflation statement.
239+
*/
240+
mockInflationStatement: (amount, height) => {
241+
return {
242+
amount: UInt64.fromUint(amount),
243+
height: UInt64.fromUint(height),
244+
mosaicId: new MosaicId('6BED913FA20223F8'),
245+
type: 20803,
246+
version: 1
247+
};
233248
}
234249
};
235250

__tests__/infrastructure/BlockService.spec.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { BlockService, AccountService, NodeService } from '../../src/infrastructure';
21
import Helper from '../../src/helper';
2+
import { BlockService, AccountService, NodeService, ReceiptService } from '../../src/infrastructure';
33
import TestHelper from '../TestHelper';
44
import { restore, stub } from 'sinon';
55

@@ -73,11 +73,13 @@ describe('Block Service', () => {
7373
let getAccounts = {};
7474
let searchBlocks = {};
7575
let getStorageInfo = {};
76+
let searchReceipts = {};
7677

7778
beforeAll(async () => {
7879
getAccounts = stub(AccountService, 'getAccounts');
7980
searchBlocks = stub(BlockService, 'searchBlocks');
8081
getStorageInfo = stub(NodeService, 'getStorageInfo');
82+
searchReceipts = stub(ReceiptService, 'searchReceipts');
8183

8284
getStorageInfo.returns(Promise.resolve({
8385
numBlocks: 100
@@ -102,10 +104,24 @@ describe('Block Service', () => {
102104
})
103105
};
104106

107+
const mockBalanceTransferReceipt = {
108+
data: {
109+
inflationStatement: {
110+
data: mockSearchBlocks.data.map(block => {
111+
// mock reward amount
112+
const amount = block.height * 1000000;
113+
return TestHelper.mockInflationStatement(amount, block.height);
114+
})
115+
}
116+
}
117+
};
118+
105119
getAccounts.returns(Promise.resolve(mockAccounts));
106120

107121
searchBlocks.returns(Promise.resolve(mockSearchBlocks));
108122

123+
searchReceipts.returns(Promise.resolve(mockBalanceTransferReceipt));
124+
109125
// Act:
110126
const blockList = await BlockService.getBlockList(pageInfo);
111127

@@ -115,8 +131,10 @@ describe('Block Service', () => {
115131
expect(blockList.pageSize).toEqual(pageInfo.pageSize);
116132
expect(blockList.data[0].harvester.signer).toEqual(accounts[0].address.plain());
117133
expect(blockList.data).toHaveLength(10);
134+
118135
blockList.data.forEach((block, index) => {
119136
expect(block.age).toEqual(Helper.convertToUTCDate(epochAdjustment + index + 1));
137+
expect(block.blockReward).toEqual(Helper.toNetworkCurrency(block.height * 1000000));
120138
expect(block).toHaveProperty('harvester');
121139
expect(block.harvester).toHaveProperty('signer');
122140
expect(block.harvester).toHaveProperty('linkedAddress');

src/config/i18n/en-us.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,5 +416,6 @@
416416
"recentNamespaces": "Recent Namespaces",
417417
"lastEpoch": "Last Epoch",
418418
"currentEpoch": "Current Epoch",
419-
"value": "Value"
419+
"value": "Value",
420+
"blockReward": "Block Reward"
420421
}

src/config/i18n/es.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,5 +412,6 @@
412412
"recentNamespaces": "Recent Namespaces",
413413
"lastEpoch": "Last Epoch",
414414
"currentEpoch": "Current Epoch",
415-
"value": "Value"
415+
"value": "Value",
416+
"blockReward": "Block Reward"
416417
}

src/config/i18n/ja.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,5 +416,6 @@
416416
"recentNamespaces": "直近ネームスペース",
417417
"lastEpoch": "Last Epoch",
418418
"currentEpoch": "Current Epoch",
419-
"value": ""
419+
"value": "",
420+
"blockReward": "ブロック報酬"
420421
}

src/config/i18n/pt.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,5 +410,6 @@
410410
"recentNamespaces": "Recent Namespaces",
411411
"lastEpoch": "Last Epoch",
412412
"currentEpoch": "Current Epoch",
413-
"value": "Value"
413+
"value": "Value",
414+
"blockReward": "Block Reward"
414415
}

src/config/i18n/ru.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,5 +416,6 @@
416416
"recentNamespaces": "Недавние Пространства имен",
417417
"lastEpoch": "Last Epoch",
418418
"currentEpoch": "Current Epoch",
419-
"value": "Value"
419+
"value": "Value",
420+
"blockReward": "Награда за блок"
420421
}

src/config/i18n/ua.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,5 +412,6 @@
412412
"recentNamespaces": "Recent Namespaces",
413413
"lastEpoch": "Last Epoch",
414414
"currentEpoch": "Current Epoch",
415-
"value": "Value"
415+
"value": "Value",
416+
"blockReward": "Block Reward"
416417
}

src/config/i18n/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,5 +412,6 @@
412412
"recentNamespaces": "Recent Namespaces",
413413
"lastEpoch": "Last Epoch",
414414
"currentEpoch": "Current Epoch",
415-
"value": ""
415+
"value": "",
416+
"blockReward": "Block Reward"
416417
}

src/config/pages/block-list.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,23 @@
1414
"type": "CardTable",
1515
"title": "blocksTitle",
1616
"managerGetter": "block/timeline",
17-
"infoTextGetter": "block/infoText",
1817
"pagination": "server",
1918
"hasFilter": false,
20-
"hasInfoText": true,
19+
"hasInfoText": false,
2120
"fields": [
2221
"height",
23-
"blockType",
2422
"age",
23+
"harvester",
2524
"totalTransactions",
2625
"statements",
27-
"totalFee",
28-
"timestamp",
29-
"harvester"
26+
"blockReward",
27+
"totalFee"
3028
],
3129
"mobileFields": [
3230
"height",
3331
"age",
34-
"transactions",
32+
"totalTransactions",
33+
"blockReward",
3534
"totalFee"
3635
]
3736
}

0 commit comments

Comments
 (0)