diff --git a/client/src/app/App.tsx b/client/src/app/App.tsx index 7e543fc55..fbfcbdf0d 100644 --- a/client/src/app/App.tsx +++ b/client/src/app/App.tsx @@ -45,7 +45,8 @@ const App: React.FC> = ({ }, [networksLoaded]); const networkConfig = networks.find((n) => n.network === network); - const identityResolverEnabled = networkConfig?.identityResolverEnabled ?? true; + const protocolVersion = networkConfig?.protocolVersion ?? STARDUST; + const identityResolverEnabled = protocolVersion !== STARDUST && (networkConfig?.identityResolverEnabled ?? true); const currentNetworkName = networkConfig?.network; const isShimmer = isShimmerUiTheme(networkConfig?.uiTheme); const nodeService = ServiceFactory.get("node-info"); diff --git a/client/src/app/AppUtils.tsx b/client/src/app/AppUtils.tsx index b75c349ee..b53930ab1 100644 --- a/client/src/app/AppUtils.tsx +++ b/client/src/app/AppUtils.tsx @@ -28,9 +28,7 @@ export const getPages = (currentNetwork: INetwork | undefined, networks: INetwor const pages = []; if (networks.length > 0 && currentNetwork !== undefined) { pages.push({ label: "Explorer", url: `/${currentNetwork.network}/` }); - if (currentNetwork.network !== CHRYSALIS_MAINNET) { - pages.push({ label: "Visualizer", url: `/${currentNetwork.network}/visualizer/` }); - } + pages.push({ label: "Visualizer", url: `/${currentNetwork.network}/visualizer/` }); if (currentNetwork.hasStatisticsSupport) { pages.push({ label: "Statistics", url: `/${currentNetwork.network}/statistics/` }); @@ -42,7 +40,7 @@ export const getPages = (currentNetwork: INetwork | undefined, networks: INetwor export const buildUtilities = (currentNetwork: string, networks: INetwork[], identityResolverEnabled: boolean) => { const utilities = []; - if (networks.length > 0 && currentNetwork !== CHRYSALIS_MAINNET) { + if (networks.length > 0) { utilities.push({ label: "Streams v0", url: `/${currentNetwork}/streams/0/` }); if (identityResolverEnabled) { utilities.push({ label: "Decentralized Identifier", url: `/${currentNetwork}/identity-resolver/` }); @@ -63,13 +61,11 @@ export const getFooterItems = (currentNetwork: string, networks: INetwork[], ide if (networks.length > 0) { let footerArray = networks.filter((network) => network.isEnabled).map((n) => ({ label: n.label, url: n.network.toString() })); - if (currentNetwork !== CHRYSALIS_MAINNET) { - footerArray = footerArray - .concat({ label: "Streams v0", url: `${currentNetwork}/streams/0/` }) - .concat({ label: "Visualizer", url: `${currentNetwork}/visualizer/` }); - } + footerArray = footerArray + .concat({ label: "Streams v0", url: `${currentNetwork}/streams/0/` }) + .concat({ label: "Visualizer", url: `${currentNetwork}/visualizer/` }); - if (identityResolverEnabled && currentNetwork !== CHRYSALIS_MAINNET) { + if (identityResolverEnabled) { footerArray.push({ label: "Identity Resolver", url: `${currentNetwork}/identity-resolver/` }); } diff --git a/client/src/app/components/JsonViewer.scss b/client/src/app/components/JsonViewer.scss index 95c2549ce..66b5ef475 100644 --- a/client/src/app/components/JsonViewer.scss +++ b/client/src/app/components/JsonViewer.scss @@ -6,6 +6,13 @@ font-family: "Courier New", Courier, monospace; white-space: pre-wrap; + @include font-size(12px, 20px); + + color: var(--did-color); + font-family: $ibm-plex-mono; + letter-spacing: 0.02em; + white-space: pre-wrap; + .string { color: green; } diff --git a/client/src/app/components/identity/IdentityStardustResolver.scss b/client/src/app/components/identity/DIDResolver.scss similarity index 100% rename from client/src/app/components/identity/IdentityStardustResolver.scss rename to client/src/app/components/identity/DIDResolver.scss diff --git a/client/src/app/components/identity/IdentityStardustResolver.tsx b/client/src/app/components/identity/DIDResolver.tsx similarity index 93% rename from client/src/app/components/identity/IdentityStardustResolver.tsx rename to client/src/app/components/identity/DIDResolver.tsx index 3c2dceb43..382fbe090 100644 --- a/client/src/app/components/identity/IdentityStardustResolver.tsx +++ b/client/src/app/components/identity/DIDResolver.tsx @@ -7,17 +7,17 @@ import { LinkedDomainService, } from "@iota/identity-wasm/web"; import React, { Fragment, useEffect, useState } from "react"; -import IdentityDomainResolver from "./domains/IdentityDomainResolver"; -import { IdentityStardustResolverProps } from "./IdentityStardustResolverProps"; +import DIDDomainResolver from "./domains/DIDDomainResolver"; +import { DIDResolverProps } from "./DIDResolverProps"; import { ServiceFactory } from "~factories/serviceFactory"; import { IdentityService } from "~services/identityService"; -import "./IdentityStardustResolver.scss"; +import "./DIDResolver.scss"; import CopyButton from "../CopyButton"; import JsonViewer from "../JsonViewer"; import Spinner from "../Spinner"; -import { IIdentityStardustResolveResponse } from "~/models/api/IIdentityStardustResolveResponse"; +import { IDIDResolverResponse } from "~/models/api/IDIDResolverResponse"; -const IdentityStardustResolver: React.FC = ({ resolvedDID, network }) => { +const IdentityStardustResolver: React.FC = ({ resolvedDID, network }) => { const [DID, setDID] = useState(""); const [governorAddress, setGovernorAddress] = useState(""); const [stateControllerAddress, setStateControllerAddress] = useState(""); @@ -86,7 +86,7 @@ const IdentityStardustResolver: React.FC = ({ res
Linked Domains
- +
)} @@ -146,7 +146,7 @@ const IdentityStardustResolver: React.FC = ({ res // } export default IdentityStardustResolver; -async function constructVerifiedDomains(resolvedDID: IIdentityStardustResolveResponse): Promise>> { +async function constructVerifiedDomains(resolvedDID: IDIDResolverResponse): Promise>> { const newVerifiedDomains = new Map>(); await ServiceFactory.get("identity").initLibrary(); diff --git a/client/src/app/components/identity/DIDResolverProps.ts b/client/src/app/components/identity/DIDResolverProps.ts new file mode 100644 index 000000000..134928fc7 --- /dev/null +++ b/client/src/app/components/identity/DIDResolverProps.ts @@ -0,0 +1,7 @@ +import { IDIDResolverResponse } from "~/models/api/IDIDResolverResponse"; + +export interface DIDResolverProps { + resolvedDID: IDIDResolverResponse | null; + + network: string; +} diff --git a/client/src/app/components/identity/IdentitySearchInput.tsx b/client/src/app/components/identity/IdentitySearchInput.tsx index a5f8522c7..9d2413fd9 100644 --- a/client/src/app/components/identity/IdentitySearchInput.tsx +++ b/client/src/app/components/identity/IdentitySearchInput.tsx @@ -79,21 +79,6 @@ class SearchInput extends AsyncComponent { - constructor(props: IdentityDomainResolverProps) { +class DIDDomainResolver extends AsyncComponent { + constructor(props: DIDDomainResolverProps) { super(props); this.state = { verifiedDomainsPresentation: new Map(), @@ -20,7 +20,7 @@ class IdentityDomainResolver extends AsyncComponent>; } diff --git a/client/src/app/components/identity/domains/IdentityDomainResolverState.ts b/client/src/app/components/identity/domains/DIDDomainResolverState.ts similarity index 83% rename from client/src/app/components/identity/domains/IdentityDomainResolverState.ts rename to client/src/app/components/identity/domains/DIDDomainResolverState.ts index 7790a85bd..7cd443429 100644 --- a/client/src/app/components/identity/domains/IdentityDomainResolverState.ts +++ b/client/src/app/components/identity/domains/DIDDomainResolverState.ts @@ -4,7 +4,7 @@ export enum Status { Error = "ERROR", } -export interface IdentityDomainResolverState { +export interface DIDDomainResolverState { verifiedDomainsPresentation: Map< string, { diff --git a/client/src/app/components/stardust/address/section/did/DidSection.tsx b/client/src/app/components/stardust/address/section/did/DidSection.tsx index 89dec513e..7e64123fd 100644 --- a/client/src/app/components/stardust/address/section/did/DidSection.tsx +++ b/client/src/app/components/stardust/address/section/did/DidSection.tsx @@ -1,9 +1,9 @@ import React from "react"; -import IdentityStardustResolver from "../../../../identity/IdentityStardustResolver"; -import { IIdentityStardustResolveResponse } from "~/models/api/IIdentityStardustResolveResponse"; +import IdentityStardustResolver from "../../../../identity/DIDResolver"; +import { IDIDResolverResponse } from "~/models/api/IDIDResolverResponse"; interface DIDSectionProps { - resolvedDID: IIdentityStardustResolveResponse | null; + resolvedDID: IDIDResolverResponse | null; network: string; } diff --git a/client/src/app/routes.tsx b/client/src/app/routes.tsx index 1ad83ecf5..d2db67221 100644 --- a/client/src/app/routes.tsx +++ b/client/src/app/routes.tsx @@ -62,14 +62,21 @@ const buildAppRoutes = (protocolVersion: string, withNetworkContext: (wrappedCom key={keys.next().value} component={(props: RouteComponentProps) => } />, + ]; + + const IdentiyResolverRoute = ( ) => ( )} - />, - ]; + /> + ); + + if (protocolVersion !== STARDUST) { + commonRoutes.push(IdentiyResolverRoute); + } const legacyRoutes = [ { constructor(props: RouteComponentProps & { protocolVersion: string }) { super(props); - - this.state = { - didExample: undefined, - }; } public async componentDidMount(): Promise { super.componentDidMount(); - - this.setDidExample(); } /** @@ -44,10 +36,6 @@ class IdentityResolver extends AsyncComponent<
{!this.props.match.params.did && ( - {this.props.protocolVersion === LEGACY && ( -
This network is not supported!
- )} -

Decentralized Identifier

@@ -61,45 +49,22 @@ class IdentityResolver extends AsyncComponent< network.

- {this.props.protocolVersion !== LEGACY && ( -
- { - this.props.history.push( - `/${this.props.match.params.network}/identity-resolver/${e}`, - ); - }} - network={this.props.match.params.network} - /> -
- )} - - {this.state.didExample && this.props.protocolVersion === STARDUST && ( - - )} + network={this.props.match.params.network} + /> +
)} {this.props.match.params.did && ( -
- {this.props.protocolVersion === LEGACY && ( -
-
This network is not supported!
-
- )} - {this.props.protocolVersion === CHRYSALIS && } -
+
{this.props.protocolVersion === CHRYSALIS && }
)} @@ -108,16 +73,6 @@ class IdentityResolver extends AsyncComponent< ); } - - private setDidExample() { - const networkService = ServiceFactory.get("network"); - const networks = networkService.networks(); - - const network = networks.find((n) => n.network === this.props.match.params.network); - this.setState({ - didExample: network?.didExample, - }); - } } export default IdentityResolver; diff --git a/client/src/app/routes/stardust/AddressState.ts b/client/src/app/routes/stardust/AddressState.ts index bc26829d8..bd414d5eb 100644 --- a/client/src/app/routes/stardust/AddressState.ts +++ b/client/src/app/routes/stardust/AddressState.ts @@ -32,7 +32,7 @@ import NetworkContext from "../../context/NetworkContext"; import { AddressRouteProps } from "../AddressRouteProps"; import { useAliasContainsDID } from "~/helpers/hooks/useAliasContainsDID"; import { useResolvedDID } from "~/helpers/hooks/useResolvedDID"; -import { IIdentityStardustResolveResponse } from "~/models/api/IIdentityStardustResolveResponse"; +import { IDIDResolverResponse } from "~/models/api/IDIDResolverResponse"; export interface IAddressState { bech32AddressDetails: IBech32AddressDetails | null; @@ -63,7 +63,7 @@ export interface IAddressState { associatedOutputCount: number; aliasContainsDID: boolean; isDIDLoading: boolean; - resolvedDID: IIdentityStardustResolveResponse | null; + resolvedDID: IDIDResolverResponse | null; } const initialState = { diff --git a/client/src/helpers/hooks/useResolvedDID.ts b/client/src/helpers/hooks/useResolvedDID.ts index 6f6bf2a0c..a21c29e32 100644 --- a/client/src/helpers/hooks/useResolvedDID.ts +++ b/client/src/helpers/hooks/useResolvedDID.ts @@ -2,7 +2,7 @@ import { useEffect, useState } from "react"; import { useIsMounted } from "./useIsMounted"; import { ServiceFactory } from "~factories/serviceFactory"; import { IdentityService } from "~/services/identityService"; -import { IIdentityStardustResolveResponse } from "~/models/api/IIdentityStardustResolveResponse"; +import { IDIDResolverResponse } from "~/models/api/IDIDResolverResponse"; /** * Fetch resolved DID @@ -11,14 +11,10 @@ import { IIdentityStardustResolveResponse } from "~/models/api/IIdentityStardust * @param addressHex Hex representation of the alias address * @returns The DID response and loading bool. */ -export function useResolvedDID( - network: string, - bech32Hrp: string, - addressHex: string | null, -): [IIdentityStardustResolveResponse | null, boolean] { +export function useResolvedDID(network: string, bech32Hrp: string, addressHex: string | null): [IDIDResolverResponse | null, boolean] { const isMounted = useIsMounted(); const [identityService] = useState(ServiceFactory.get("identity")); - const [identityResponse, setidentityResponse] = useState(null); + const [identityResponse, setidentityResponse] = useState(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { diff --git a/client/src/models/api/IIdentityStardustResolveRequest.ts b/client/src/models/api/IDIDResolverRequest.ts similarity index 72% rename from client/src/models/api/IIdentityStardustResolveRequest.ts rename to client/src/models/api/IDIDResolverRequest.ts index ca7ab06ac..a10439946 100644 --- a/client/src/models/api/IIdentityStardustResolveRequest.ts +++ b/client/src/models/api/IDIDResolverRequest.ts @@ -1,4 +1,4 @@ -export interface IIdentityStardustResolveRequest { +export interface IDIDResolverRequest { /** * The network to search on. */ diff --git a/client/src/models/api/IIdentityStardustResolveResponse.ts b/client/src/models/api/IDIDResolverResponse.ts similarity index 86% rename from client/src/models/api/IIdentityStardustResolveResponse.ts rename to client/src/models/api/IDIDResolverResponse.ts index 2ff799278..00ce257b4 100644 --- a/client/src/models/api/IIdentityStardustResolveResponse.ts +++ b/client/src/models/api/IDIDResolverResponse.ts @@ -1,6 +1,6 @@ import { IResponse } from "./IResponse"; -export interface IIdentityStardustResolveResponse extends IResponse { +export interface IDIDResolverResponse extends IResponse { /** * The resolved DID Document. */ diff --git a/client/src/services/identityService.ts b/client/src/services/identityService.ts index 2c5f861f3..4b53e1c32 100644 --- a/client/src/services/identityService.ts +++ b/client/src/services/identityService.ts @@ -4,7 +4,7 @@ import { StardustApiClient } from "./stardust/stardustApiClient"; import { ServiceFactory } from "~factories/serviceFactory"; import { IIdentityDidHistoryResponse } from "~models/api/IIdentityDidHistoryResponse"; import { IIdentityDidResolveResponse } from "~models/api/IIdentityResolveResponse"; -import { IIdentityStardustResolveResponse } from "~models/api/IIdentityStardustResolveResponse"; +import { IDIDResolverResponse } from "~models/api/IDIDResolverResponse"; import { CHRYSALIS, STARDUST } from "~models/config/protocolVersion"; import * as identity from "@iota/identity-wasm/web"; @@ -61,7 +61,7 @@ export class IdentityService { * @param {string} network network name * @returns Promise */ - public async resolveIdentityStardust(did: string, network: string): Promise { + public async resolveIdentityStardust(did: string, network: string): Promise { const apiClient = ServiceFactory.get(`api-client-${STARDUST}`); const response = await apiClient.didDocument({ did, network }); return response; diff --git a/client/src/services/stardust/stardustApiClient.ts b/client/src/services/stardust/stardustApiClient.ts index 19e586421..55450d2db 100644 --- a/client/src/services/stardust/stardustApiClient.ts +++ b/client/src/services/stardust/stardustApiClient.ts @@ -1,7 +1,7 @@ import { IOutputsResponse } from "@iota/sdk-wasm/web"; import { FetchHelper } from "~helpers/fetchHelper"; -import { IIdentityStardustResolveRequest } from "~models/api/IIdentityStardustResolveRequest"; -import { IIdentityStardustResolveResponse } from "~models/api/IIdentityStardustResolveResponse"; +import { IDIDResolverRequest } from "~models/api/IDIDResolverRequest"; +import { IDIDResolverResponse } from "~models/api/IDIDResolverResponse"; import { IMilestoneDetailsRequest } from "~models/api/IMilestoneDetailsRequest"; import { INetworkBoundGetRequest } from "~models/api/INetworkBoundGetRequest"; import { IOutputDetailsRequest } from "~models/api/IOutputDetailsRequest"; @@ -340,8 +340,8 @@ export class StardustApiClient extends ApiClient { ); } - public async didDocument(request: IIdentityStardustResolveRequest): Promise { - return this.callApi(`stardust/did/${request.network}/${request.did}/document`, "get"); + public async didDocument(request: IDIDResolverRequest): Promise { + return this.callApi(`stardust/did/${request.network}/${request.did}/document`, "get"); } /**