Skip to content

Commit 1f29297

Browse files
authored
feat: add property for gRPC web proxy endpoint to NodeDetails view (#2047)
Signed-off-by: Simon Viénot <simon.vienot@icloud.com>
1 parent 40c4bbf commit 1f29297

File tree

6 files changed

+58
-14
lines changed

6 files changed

+58
-14
lines changed

src/components/values/Endpoints.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,23 @@
66

77
<template>
88

9-
<div v-if="props.endpoints && props.endpoints.length">
9+
<!-- If domain_name is provided: -->
10+
<!-- www.example.com:50211 (34.94.106.61) -->
11+
<!-- otherwise: -->
12+
<!-- 34.94.106.61:50211 -->
13+
14+
<div v-if="props.endpoints && props.endpoints.length > 0">
1015
<div v-for="s in props.endpoints" :key="s.ip_address_v4" class="h-is-monospace">
11-
<span v-if="s.ip_address_v4">{{ s.ip_address_v4 }}</span>
12-
<span v-if="s.ip_address_v4 && s.port != null" class="h-is-low-contrast">{{ ':' + s.port }}</span>
16+
<template v-if="s.domain_name.length > 0">
17+
<span>{{ s.domain_name }}</span>
18+
<span v-if="s.port > 0" class="h-is-low-contrast">{{ ':' + s.port }}</span>
19+
<span v-if="s.ip_address_v4.length > 0" class="ml-1">{{ `(${s.ip_address_v4})` }}</span>
20+
</template>
21+
<template v-else-if="s.ip_address_v4.length > 0">
22+
<span>{{ s.ip_address_v4 }}</span>
23+
<span v-if="s.port > 0" class="h-is-low-contrast">{{ ':' + s.port }}</span>
24+
</template>
25+
<template v-else/>
1326
</div>
1427
</div>
1528

src/pages/NodeDetails.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
<Endpoints :endpoints="node?.service_endpoints"></Endpoints>
6767
</template>
6868
</Property>
69+
<Property id="grpcEndpoint">
70+
<template #name>gRPC Web Proxy Endpoint</template>
71+
<template #value>
72+
<Endpoints :endpoints="node?.grpc_proxy_endpoint ? [node.grpc_proxy_endpoint] : []"></Endpoints>
73+
</template>
74+
</Property>
6975
<Property id="adminKey">
7076
<template #name>Admin Key</template>
7177
<template #value>

src/schemas/MirrorNodeSchemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,11 @@ export interface NetworkNode {
774774
stake_rewarded: number | null // The sum (balance + staked) for all accounts staked to the node that are not declining rewards at the beginning of the staking period
775775
staking_period: TimestampRange | null
776776
reward_rate_start: number | null
777+
grpc_proxy_endpoint: ServiceEndPoint
777778
}
778779

779780
export interface ServiceEndPoint {
781+
domain_name: string
780782
ip_address_v4: string
781783
port: number
782784
}

tests/unit/Mocks.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,6 +3619,11 @@ export const SAMPLE_NETWORK_NODES = {
36193619
"decline_reward": null,
36203620
"description": "Hosted by Hedera | East Coast, USA",
36213621
"file_id": "0.0.102",
3622+
"grpc_proxy_endpoint": {
3623+
"domain_name": "www.example.com",
3624+
"ip_address_v4": "34.94.106.6",
3625+
"port": 42
3626+
},
36223627
"memo": "0.0.3",
36233628
"node_id": 0,
36243629
"node_account_id": "0.0.3",
@@ -3627,24 +3632,29 @@ export const SAMPLE_NETWORK_NODES = {
36273632
"reward_rate_start": 2740,
36283633
"service_endpoints": [
36293634
{
3635+
"domain_name": "www.example.com",
36303636
"ip_address_v4": "3.211.248.172",
36313637
"port": 50211
36323638
},
36333639
{
3634-
"ip_address_v4": "3.211.248.172",
3640+
"domain_name": "www.example.com",
3641+
"ip_address_v4": "",
36353642
"port": 50212
36363643
},
36373644
{
3645+
"domain_name": "www.example.com",
36383646
"ip_address_v4": "35.231.208.148",
36393647
"port": 0
36403648
},
36413649
{
3650+
"domain_name": "",
36423651
"ip_address_v4": "35.231.208.148",
36433652
"port": 50211
36443653
},
36453654
{
3655+
"domain_name": "",
36463656
"ip_address_v4": "35.231.208.148",
3647-
"port": 50212
3657+
"port": 0
36483658
},
36493659
],
36503660
"timestamp": {
@@ -3670,10 +3680,13 @@ export const SAMPLE_NETWORK_NODES = {
36703680
"reward_rate_start": 5479,
36713681
"service_endpoints": [
36723682
{
3683+
"domain_name": "",
36733684
"ip_address_v4": "3.133.213.146",
36743685
"port": 50211
36753686
},
36763687
{
3688+
"domain_name": "",
3689+
"ip_address_v4": "",
36773690
"port": 50212
36783691
}
36793692
],
@@ -3704,11 +3717,14 @@ export const SAMPLE_NETWORK_NODES = {
37043717
"reward_rate_start": 8219,
37053718
"service_endpoints": [
37063719
{
3720+
"domain_name": "",
37073721
"ip_address_v4": "3.133.213.146",
37083722
"port": 50211
37093723
},
37103724
{
3711-
"ip_address_v4": "3.133.213.147"
3725+
"domain_name": "",
3726+
"ip_address_v4": "3.133.213.147",
3727+
"port": 0
37123728
}
37133729
],
37143730
"timestamp": {

tests/unit/node/NodeDetails.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ describe("NodeDetails.vue", () => {
8484
expect(wrapper.get("#rangeFromValue").text()).toBe("4:10:06.0411 PMJun 6, 2022, UTC")
8585
expect(wrapper.get("#rangeToValue").text()).toBe("None")
8686
expect(wrapper.get("#nodeCertHashValue").text()).toBe("0xd316b5ef57b76daf37e3bebbe3b69e6f67b669ce1dd1ed75e5c69a69bf75f36d376f475f7b571d79a6f8e37e37f1f736f3d69b73c6daf1ae9a7dff3775be5fd5bdf7e34e3a75af3c73Copy")
87-
expect(wrapper.get("#serviceEndpointsValue").text()).toBe("3.211.248.172:502113.211.248.172:5021235.231.208.148:035.231.208.148:5021135.231.208.148:50212")
87+
expect(wrapper.get("#serviceEndpointsValue").text()).toBe(
88+
"www.example.com:50211(3.211.248.172)" +
89+
"www.example.com:50212" +
90+
"www.example.com(35.231.208.148)" +
91+
"35.231.208.148:50211" +
92+
"35.231.208.148")
93+
expect(wrapper.get("#grpcEndpointValue").text()).toBe("www.example.com:42(34.94.106.6)")
8894

8995
expect(wrapper.get("#yearlyRate").text()).toBe("LAST PERIOD REWARD RATE 1%APPROX ANNUAL EQUIVALENT")
9096
expect(wrapper.get("#consensusStake").text()).toBe("STAKE FOR CONSENSUS 6,000,000HBAR25.00% of total")

tests/unit/values/Endpoints.spec.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe("Endpoint.vue", () => {
3030
await flushPromises()
3131
})
3232

33-
it("should not output an endpoint where the address is undefined", async () => {
33+
it("should not output an endpoint when both domain_name and address are undefined", async () => {
3434
const wrapper = mount(Endpoints, {
3535
props: {
3636
endpoints: SAMPLE_NETWORK_NODES.nodes[1].service_endpoints as Array<ServiceEndPoint>
@@ -43,7 +43,7 @@ describe("Endpoint.vue", () => {
4343
await flushPromises()
4444
})
4545

46-
it("should output an endpoint address alone when port is undefined", async () => {
46+
it("should output endpoint address without port when port is 0", async () => {
4747
const wrapper = mount(Endpoints, {
4848
props: {
4949
endpoints: SAMPLE_NETWORK_NODES.nodes[2].service_endpoints as Array<ServiceEndPoint>
@@ -58,19 +58,20 @@ describe("Endpoint.vue", () => {
5858
await flushPromises()
5959
})
6060

61-
it("should ouput <address>:<port> for all 5 endpoints", async () => {
61+
it("should ouput all variants of endpoint", async () => {
6262
const wrapper = mount(Endpoints, {
6363
props: {
6464
endpoints: SAMPLE_NETWORK_NODES.nodes[0].service_endpoints as Array<ServiceEndPoint>
6565
}
6666
});
6767
await flushPromises()
6868
expect(wrapper.text()).toBe(
69-
"3.211.248.172:50211" +
70-
"3.211.248.172:50212" +
71-
"35.231.208.148:0" +
69+
"www.example.com:50211(3.211.248.172)" +
70+
"www.example.com:50212" +
71+
"www.example.com(35.231.208.148)" +
7272
"35.231.208.148:50211" +
73-
"35.231.208.148:50212")
73+
"35.231.208.148"
74+
)
7475

7576
wrapper.unmount()
7677
await flushPromises()

0 commit comments

Comments
 (0)