Skip to content

Commit

Permalink
Merge pull request #366 from pshenmic/feat/versions-from-dapi
Browse files Browse the repository at this point in the history
Status versions from DAPI
  • Loading branch information
owl352 authored Dec 18, 2024
2 parents 236e8e2 + 18e8b78 commit a480964
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 53 deletions.
56 changes: 48 additions & 8 deletions packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,55 @@ HTTP /status
hash: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF",
timestamp: "2024-06-06T21:50:20.949Z"
}
"epoch": {
"number": 3640,
"firstBlockHeight": 72534,
"firstCoreBlockHeight": 1160707,
"startTime": 1734457229495,
"feeMultiplier": 1,
"endTime": 1734460829495
},
"transactionsCount": 25912,
"totalCredits": 7288089799960610,
"totalCollectedFeesDay": 12733263640,
"transfersCount": 1849,
"dataContractsCount": 630,
"documentsCount": 15384,
"identitiesCount": 712,
"network": "dash-testnet-51",
"api": {
"version": "1.0.7",
"block": {
"height": 72555,
"hash": "EDA1CDF601224CD3ED168D35B4699DE2796F774B526103C64D371EF3AAFD8274",
"timestamp": "2024-12-17T17:57:08.758Z"
}
},
"tenderdash": {
"version": "1.4.0",
"block": {
"height": 72555,
"hash": "EDA1CDF601224CD3ED168D35B4699DE2796F774B526103C64D371EF3AAFD8274",
"timestamp": "2024-12-17T17:57:08.758Z"
}
},
"versions": {
"software": {
"dapi": "1.5.1",
"drive": "1.6.2",
"tenderdash": "1.4.0"
},
tenderdash: {
version: "0.14.0-dev.6",
block: {
height: 20154,
hash: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF",
timestamp: "2024-06-06T21:53:27.947Z"
}
}
"protocol": {
"tenderdash": {
"p2p": 10,
"block": 14
},
"drive": {
"latest": 6,
"current": 6
}
}
}
}
```
---
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"lint": "standard ."
},
"dependencies": {
"@dashevo/wasm-dpp": "github:owl352/wasm-dpp",
"@dashevo/dapi-client": "github:owl352/dapi-client",
"@dashevo/dashd-rpc": "19.0.0",
"@dashevo/wasm-dpp": "github:owl352/wasm-dpp",
"@fastify/cors": "^8.3.0",
"@scure/base": "^1.1.5",
"bs58": "^6.0.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/DAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class DAPI {
}
})
}

async getStatus () {
return this.dapi.platform.getStatus()
}
}

module.exports = DAPI
22 changes: 20 additions & 2 deletions packages/api/src/controllers/MainController.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ class MainController {
}

getStatus = async (request, response) => {
const [blocks, stats, tdStatus, epochsInfo, totalCredits, totalCollectedFeesDay] = (await Promise.allSettled([
const [blocks, stats, status, tdStatus, epochsInfo, totalCredits, totalCollectedFeesDay] = (await Promise.allSettled([
this.blocksDAO.getBlocks(1, 1, 'desc'),
this.blocksDAO.getStats(),
this.dapi.getStatus(),
TenderdashRPC.getStatus(),
this.dapi.getEpochsInfo(1),
this.dapi.getTotalCredits(),
Expand Down Expand Up @@ -56,12 +57,29 @@ class MainController {
}
},
tenderdash: {
version: tdStatus?.version ?? null,
version: status?.version?.software.tenderdash ?? null,
block: {
height: tdStatus?.highestBlock?.height ?? null,
hash: tdStatus?.highestBlock?.hash ?? null,
timestamp: tdStatus?.highestBlock?.timestamp ?? null
}
},
versions: {
software: {
dapi: status?.version?.software.dapi ?? null,
drive: status?.version?.software.drive ?? null,
tenderdash: status?.version?.software.tenderdash ?? null
},
protocol: {
tenderdash: {
p2p: status?.version?.protocol.tenderdash?.p2p ?? null,
block: status?.version?.protocol.tenderdash?.block ?? null
},
drive: {
latest: status?.version?.protocol.drive?.latest ?? null,
current: status?.version?.protocol.drive?.current ?? null
}
}
}
})
}
Expand Down
42 changes: 41 additions & 1 deletion packages/api/test/integration/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ describe('Other routes', () => {

mock.method(DAPI.prototype, 'getIdentityKeys', async () => null)

mock.method(DAPI.prototype, 'getStatus', async () => null)

mock.method(tenderdashRpc, 'getBlockByHeight', async () => ({
block: {
header: {
Expand Down Expand Up @@ -384,8 +386,29 @@ describe('Other routes', () => {
timestamp: new Date().toISOString()
}
}
const mockDapiStatus = {
version: {
software: {
dapi: '1.5.1',
drive: '1.6.2',
tenderdash: '1.4.0'
},
protocol: {
tenderdash: {
p2p: 10,
block: 14
},
drive: {
latest: 6,
current: 6
}
}
}
}

mock.reset()
mock.method(DAPI.prototype, 'getTotalCredits', async () => 0)
mock.method(DAPI.prototype, 'getStatus', async () => mockDapiStatus)
mock.method(DAPI.prototype, 'getEpochsInfo', async () => [{
number: 0,
firstBlockHeight: 0,
Expand Down Expand Up @@ -433,12 +456,29 @@ describe('Other routes', () => {
}
},
tenderdash: {
version: mockTDStatus?.version ?? null,
version: mockDapiStatus.version.software.tenderdash ?? null,
block: {
height: mockTDStatus?.highestBlock?.height,
hash: mockTDStatus?.highestBlock?.hash,
timestamp: mockTDStatus?.highestBlock?.timestamp
}
},
versions: {
software: {
dapi: mockDapiStatus.version.software.dapi ?? null,
drive: mockDapiStatus.version.software.drive ?? null,
tenderdash: mockDapiStatus.version.software.tenderdash ?? null
},
protocol: {
tenderdash: {
p2p: mockDapiStatus.version.protocol.tenderdash.p2p ?? null,
block: mockDapiStatus.version.protocol.tenderdash.block ?? null
},
drive: {
latest: mockDapiStatus.version.protocol.drive.latest ?? null,
current: mockDapiStatus.version.protocol.drive.current ?? null
}
}
}
}

Expand Down
56 changes: 48 additions & 8 deletions packages/frontend/src/app/api/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,55 @@ HTTP /status
hash: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF",
timestamp: "2024-06-06T21:50:20.949Z"
}
"epoch": {
"number": 3640,
"firstBlockHeight": 72534,
"firstCoreBlockHeight": 1160707,
"startTime": 1734457229495,
"feeMultiplier": 1,
"endTime": 1734460829495
},
"transactionsCount": 25912,
"totalCredits": 7288089799960610,
"totalCollectedFeesDay": 12733263640,
"transfersCount": 1849,
"dataContractsCount": 630,
"documentsCount": 15384,
"identitiesCount": 712,
"network": "dash-testnet-51",
"api": {
"version": "1.0.7",
"block": {
"height": 72555,
"hash": "EDA1CDF601224CD3ED168D35B4699DE2796F774B526103C64D371EF3AAFD8274",
"timestamp": "2024-12-17T17:57:08.758Z"
}
},
"tenderdash": {
"version": "1.4.0",
"block": {
"height": 72555,
"hash": "EDA1CDF601224CD3ED168D35B4699DE2796F774B526103C64D371EF3AAFD8274",
"timestamp": "2024-12-17T17:57:08.758Z"
}
},
"versions": {
"software": {
"dapi": "1.5.1",
"drive": "1.6.2",
"tenderdash": "1.4.0"
},
tenderdash: {
version: "0.14.0-dev.6",
block: {
height: 20154,
hash: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF",
timestamp: "2024-06-06T21:53:27.947Z"
}
}
"protocol": {
"tenderdash": {
"p2p": 10,
"block": 14
},
"drive": {
"latest": 6,
"current": 6
}
}
}
}
```
---
Expand Down
Loading

0 comments on commit a480964

Please sign in to comment.