Skip to content

Commit 3fe1481

Browse files
authored
Merge pull request #1569 from input-output-hk/djo/1554/explorer/improve-ctx-ui
Explorer: Improve Cardano Transaction Certification & Certificate Chain Validation UI
2 parents 22dbdf1 + e591c7e commit 3fe1481

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2601
-465
lines changed

mithril-explorer/.fantasticonrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** @type {import("fantasticon").RunnerOptions} */
2+
module.exports = {
3+
inputDir: "./icons",
4+
outputDir: "./public/fonts",
5+
fontTypes: ["woff", "woff2"],
6+
assetTypes: ["css"],
7+
fontsUrl: "/explorer/fonts",
8+
formatOptions: {},
9+
name: "mithril-icons",
10+
prefix: "mi",
11+
templates: {
12+
css: "./font.css.hbs",
13+
},
14+
pathOptions: {
15+
css: "./src/app/mithril-icons.css",
16+
},
17+
codepoints: {
18+
logo: 57344, // 0xe000 = start of unicode private use area
19+
},
20+
};

mithril-explorer/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
out
22
explorer
3+
font.css.hbs

mithril-explorer/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ dev: build
2727
@echo "\033[1mServing dev build at: http://localhost:3000/explorer \033[0m"
2828
npm run dev
2929

30+
icons-font:
31+
npm run icons-font
32+
npm exec -- prettier ./src/app/mithril-icons.css --write
33+
3034
test: package-lock.json
3135
npm run test:ci
3236

@@ -61,6 +65,7 @@ upgrade: clean install
6165
@testing-library/react@latest \
6266
eslint@latest \
6367
eslint-config-next@latest \
68+
fantasticon@latest \
6469
jest@latest \
6570
jest-environment-jsdom@latest \
6671
next-router-mock@latest \

mithril-explorer/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,24 @@ make dev
2525
```
2626

2727
Open [http://localhost:3000](http://localhost:3000/explorer) with your browser to see the result.
28+
29+
## Adding or updating an icon of the 'Mithril' font
30+
31+
In the `./icons` folder add or modify a svg.
32+
33+
If you add a new icon you need to reference and associate it with a codepoint in the `./fantasticonrc.js`
34+
configuration file.
35+
The codepoint must be part of the [unicode private use area](https://www.unicode.org/charts/PDF/UE000.pdf), as
36+
such it must be an integer between 57344 and 63743 (hex: E000-F8FF).
37+
38+
Then rebuild the font:
39+
40+
```bash
41+
make icons-font
42+
```
43+
44+
You can then use the icon in the js, ie if your icon name is `shield`:
45+
46+
```jsx
47+
<i className={`bi mi mi-shield`}></i>
48+
```

mithril-explorer/__tests__/AggregatorSetter.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { render, screen } from "@testing-library/react";
22
import "@testing-library/jest-dom";
3-
import AggregatorSetter from "../src/components/AggregatorSetter";
43
import { initStore } from "./helpers";
54
import { Provider } from "react-redux";
6-
import default_available_aggregators from "../src/aggregators-list";
7-
import { settingsSlice } from "../src/store/settingsSlice";
5+
import AggregatorSetter from "#/AggregatorSetter";
6+
import default_available_aggregators from "@/aggregators-list";
7+
import { settingsSlice } from "@/store/settingsSlice";
88

99
function renderAggregatorSetter(default_state = undefined) {
1010
const store = initStore(default_state);

mithril-explorer/__tests__/CardanoTransactionsFormInput.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fireEvent, render, screen } from "@testing-library/react";
22
import "@testing-library/jest-dom";
3-
import CardanoTransactionsFormInput from "../src/components/CardanoTransactionsFormInput";
3+
import CardanoTransactionsFormInput from "#/CardanoTransactionsFormInput";
44

55
function setup() {
66
const utils = [render(<CardanoTransactionsFormInput />)];

mithril-explorer/__tests__/PoolTicker.test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { render, screen } from "@testing-library/react";
22
import "@testing-library/jest-dom";
33
import { initStore } from "./helpers";
44
import { Provider } from "react-redux";
5-
import { poolsSlice } from "../src/store/poolsSlice";
6-
import PoolTicker from "../src/components/PoolTicker";
7-
import { getCExplorerUrlForPool } from "../src/utils";
8-
import { settingsSlice } from "../src/store/settingsSlice";
5+
import PoolTicker from "#/PoolTicker";
6+
import { settingsSlice } from "@/store/settingsSlice";
7+
import { poolsSlice } from "@/store/poolsSlice";
8+
import { getCExplorerUrl } from "@/utils";
99

1010
function renderPoolTickerComponent(partyId, default_state = undefined) {
1111
const store = initStore(default_state);
@@ -19,6 +19,11 @@ function renderPoolTickerComponent(partyId, default_state = undefined) {
1919
];
2020
}
2121

22+
function getCExplorerUrlForPool(network, partyId) {
23+
const cExplorerUrl = getCExplorerUrl(network);
24+
return cExplorerUrl ? `${cExplorerUrl}/pool/${partyId}` : undefined;
25+
}
26+
2227
describe("PoolTicker", () => {
2328
it("Pool ticker not on the three main network doesn't show link to cexplorer", () => {
2429
const partyId = "pool1zmtm8yef33z2n7x4nn0kvv9xpzjuj7725p9y9m5t960g5qy51ua";
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { render, screen } from "@testing-library/react";
2+
import "@testing-library/jest-dom";
3+
import TransactionCertificationBreadcrumb from "#/CertifyCardanoTransactionsModal/TransactionCertificationBreadcrumb";
4+
import { validationSteps } from "#/CertifyCardanoTransactionsModal";
5+
6+
function setup(currentStep, isProofValid, isCertificateChainValid) {
7+
const utils = [
8+
render(
9+
<TransactionCertificationBreadcrumb
10+
currentStep={currentStep}
11+
isProofValid={isProofValid}
12+
isCertificateChainValid={isCertificateChainValid}
13+
/>,
14+
),
15+
];
16+
17+
const tabs = new Map();
18+
tabs.set(validationSteps.fetchingProof, screen.getByText(/Fetching Transactions Proof/i));
19+
tabs.set(validationSteps.validatingProof, screen.getByText(/Verifying Transactions Proof/i));
20+
tabs.set(
21+
validationSteps.validatingCertificateChain,
22+
screen.getByText(/Validating Certificate Chain/i),
23+
);
24+
tabs.set(validationSteps.done, screen.getByText(/Finish/i));
25+
26+
return {
27+
tabs: tabs,
28+
...utils,
29+
};
30+
}
31+
32+
const classForVariant = (variant) => `list-group-item-${variant}`;
33+
34+
describe("TransactionCertificationBreadcrumb", () => {
35+
it("The tab variant are light when default", () => {
36+
const { tabs } = setup(validationSteps.ready, false, false);
37+
38+
for (const [_key, tab] of tabs) {
39+
expect(tab).toHaveClass(classForVariant("light"));
40+
}
41+
});
42+
43+
it.each([
44+
["fetchingProof", validationSteps.fetchingProof],
45+
["validatingProof", validationSteps.validatingProof],
46+
["validatingCertificateChain", validationSteps.validatingCertificateChain],
47+
])("The tab variant is primary when current and checks are valid : %s", (stepName, stepIndex) => {
48+
const { tabs } = setup(stepIndex, true, true);
49+
50+
expect(tabs.get(stepIndex)).toHaveClass(classForVariant("primary"));
51+
});
52+
53+
it("Current step is done and checks are valid then tabs are light except done step tab that is success", () => {
54+
const { tabs } = setup(validationSteps.done, true, true);
55+
56+
expect(tabs.get(validationSteps.fetchingProof)).toHaveClass(classForVariant("light"));
57+
expect(tabs.get(validationSteps.validatingProof)).toHaveClass(classForVariant("light"));
58+
expect(tabs.get(validationSteps.validatingCertificateChain)).toHaveClass(
59+
classForVariant("light"),
60+
);
61+
expect(tabs.get(validationSteps.done)).toHaveClass(classForVariant("success"));
62+
});
63+
64+
it("Current step is done and proof check is invalid then tabs are danger except tabs before proof validation", () => {
65+
const { tabs } = setup(validationSteps.done, false, true);
66+
67+
expect(tabs.get(validationSteps.fetchingProof)).toHaveClass(classForVariant("light"));
68+
expect(tabs.get(validationSteps.validatingProof)).toHaveClass(classForVariant("danger"));
69+
expect(tabs.get(validationSteps.validatingCertificateChain)).toHaveClass(
70+
classForVariant("danger"),
71+
);
72+
expect(tabs.get(validationSteps.done)).toHaveClass(classForVariant("danger"));
73+
});
74+
75+
it("Current step is done and certificate chain check is invalid then tabs are danger except tabs before certificate chain validation", () => {
76+
const { tabs } = setup(validationSteps.done, true, false);
77+
78+
expect(tabs.get(validationSteps.fetchingProof)).toHaveClass(classForVariant("light"));
79+
expect(tabs.get(validationSteps.validatingProof)).toHaveClass(classForVariant("light"));
80+
expect(tabs.get(validationSteps.validatingCertificateChain)).toHaveClass(
81+
classForVariant("danger"),
82+
);
83+
expect(tabs.get(validationSteps.done)).toHaveClass(classForVariant("danger"));
84+
});
85+
});

mithril-explorer/__tests__/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { saveToLocalStorage, storeBuilder } from "../src/store/store";
1+
import { saveToLocalStorage, storeBuilder } from "@/store/store";
22
import * as mockRouter from "next-router-mock";
33

44
const baseLocation = "http://localhost";

mithril-explorer/__tests__/partyIdFormat.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { formatPartyId } from "../src/utils";
1+
import { formatPartyId } from "@/utils";
22

33
describe("Stake formatting", () => {
44
it.each([

0 commit comments

Comments
 (0)