Skip to content

Commit 8d12a6d

Browse files
authored
Merge pull request #82 from iotaledger/feat/update-milestone-routes
Feat: Update milestone routes
2 parents b0ed9a3 + 2c25279 commit 8d12a6d

File tree

12 files changed

+131
-100
lines changed

12 files changed

+131
-100
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"license": "MIT",
1111
"dependencies": {
12-
"@iota/iota.js": "^1.9.0-stardust.9",
12+
"@iota/iota.js": "^1.9.0-stardust.11",
1313
"classnames": "^2.3.1",
1414
"humanize-duration": "^3.25.2",
1515
"moment": "^2.29.1",

src/app/components/tangle/MilestonePayload.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ class MilestonePayload extends Component<MilestonePayloadProps, MilestonePayload
5252
)}
5353
</div>
5454
<div className="card--label">
55-
Last Milestone Id
55+
Previous Milestone Id
5656
</div>
5757
<div className="card--value">
58-
{this.props.payload.lastMilestoneId}
58+
{this.props.payload.previousMilestoneId}
5959
</div>
6060
{this.props.payload.parentMessageIds?.map((parent, idx) => (
6161
<React.Fragment key={idx}>

src/app/routes/Explorer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Peers extends AsyncComponent<RouteComponentProps, ExplorerState> {
6464

6565
this.setState({
6666
milestones: nonNull
67-
.map(m => ({ index: m.index, messageId: m.messageID }))
67+
.map(m => ({ index: m.index, milestoneId: m.milestoneId }))
6868
.sort((m1, m2) => m2.index - m1.index)
6969
.slice(0, 10)
7070
});
@@ -147,9 +147,9 @@ class Peers extends AsyncComponent<RouteComponentProps, ExplorerState> {
147147
<div key={idx} className="milestones-panel--milestone">
148148
<div className="index">{ms.index}</div>
149149
<Link
150-
to={`/explorer/message/${ms.messageId}`}
150+
to={`/explorer/milestone/${ms.index}`}
151151
>
152-
{ms.messageId}
152+
{ms.milestoneId}
153153
</Link>
154154
</div>
155155
))}

src/app/routes/ExplorerState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface ExplorerState {
1818
* The milestones.
1919
*/
2020
milestones: {
21+
milestoneId: string;
2122
index: number;
22-
messageId: string;
2323
}[];
2424
}

src/app/routes/Search.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class Search extends AsyncComponent<RouteComponentProps<SearchRouteProps>, Searc
163163
objParam = response.output.messageId;
164164
} else if (response.milestone) {
165165
objType = "milestone";
166+
objParam = response.milestone.index.toString();
166167
}
167168
if (objType) {
168169
redirect = `/explorer/${objType}/${objParam}`;

src/app/routes/explorer/Milestone.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { messageIdFromMilestonePayload } from "@iota/iota.js";
12
import React, { ReactNode } from "react";
23
import { Link, RouteComponentProps } from "react-router-dom";
34
import { ReactComponent as ChevronLeftIcon } from "../../../assets/chevron-left.svg";
@@ -76,16 +77,16 @@ class Milestone extends AsyncComponent<RouteComponentProps<MilestoneRouteProps>,
7677
<div className="card--value card--value__mono row">
7778
<span className="margin-r-t">
7879
<Link
79-
to={`/explorer/message/${this.state.milestone?.messageId}`}
80+
to={`/explorer/message/${this.state.messageId}`}
8081
className="info-box--title linked"
8182
>
82-
{this.state.milestone?.messageId}
83+
{this.state.messageId}
8384
</Link>
8485

8586
</span>
8687
<MessageButton
8788
onClick={() => ClipboardHelper.copy(
88-
this.state.milestone?.messageId
89+
this.state.messageId
8990
)}
9091
buttonType="copy"
9192
labelPosition="top"
@@ -141,6 +142,19 @@ class Milestone extends AsyncComponent<RouteComponentProps<MilestoneRouteProps>,
141142
const result = await this._tangleService.milestoneDetails(Number.parseInt(index, 10));
142143

143144
if (result) {
145+
try {
146+
const tangleService = ServiceFactory.get<TangleService>("tangle");
147+
const info = await tangleService.info();
148+
149+
this.setState({
150+
messageId: messageIdFromMilestonePayload(info.protocol.protocolVersion, result)
151+
});
152+
} catch (error) {
153+
if (error instanceof Error) {
154+
console.log(error.message);
155+
}
156+
}
157+
144158
this.setState({
145159
milestone: result
146160
}, async () => this.checkForAdjacentMilestones());

src/app/routes/explorer/MilestoneState.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { IMilestoneResponse } from "@iota/iota.js";
1+
import { IMilestonePayload } from "@iota/iota.js";
22

33
export interface MilestoneState {
44
/**
55
* Milestone.
66
*/
7-
milestone?: IMilestoneResponse;
7+
milestone?: IMilestonePayload;
8+
9+
/**
10+
* The message id of the milestone.
11+
*/
12+
messageId?: string;
813

914
/**
1015
* The previous milestone is available.

src/models/tangle/ISearchResponse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IMessage, IMilestoneResponse, IOutputResponse } from "@iota/iota.js";
1+
import { IMilestonePayload, IMessage, IOutputResponse } from "@iota/iota.js";
22
import { IAddressDetails } from "../IAddressDetails";
33

44
export interface ISearchResponse {
@@ -35,5 +35,5 @@ export interface ISearchResponse {
3535
/**
3636
* Milestone if it was found.
3737
*/
38-
milestone?: IMilestoneResponse;
38+
milestone?: IMilestonePayload;
3939
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable camelcase */
22
export interface IConfirmedInfo {
3-
id: string;
3+
ids: string[];
44
excluded_ids?: string[];
55
}

src/models/websocket/IMs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable camelcase */
22
export interface IMs {
3-
messageID: string;
3+
milestoneId: string;
44
index: number;
55
}

0 commit comments

Comments
 (0)