Skip to content

Commit

Permalink
feat: [lw 11882] Connect DApp Explorer to DApp Radar API (#1649)
Browse files Browse the repository at this point in the history
* feat: load dapps data from dapp radar api

* feat: fetch dapp categories from dapp radar

* ci: add dappradar credentials to github action

* feat: cover edge cases of api requests implementation

* feat: show single show all category when no dapp radar api token

* fix: code cleanup, small ui adjustments

* docs: document how to get dapp radar api token for local development

* fix: dapp details drawer redirect button

* fix: lint

* feat: prepare CI to consume dapp radar api token and use it for extension build

* fix: capturing active category by analytics

* feat: allow to render dapp explorer page with/out content depending on feature flag

* fix: rendering of icons in the categories carousel

* fix: add elipsis to dapp tile texts

* fix: ui fixes

---------

Co-authored-by: John Oshalusi <[email protected]>
  • Loading branch information
szymonmaslowski and greatertomi authored Jan 21, 2025
1 parent 89c58f1 commit 798e959
Show file tree
Hide file tree
Showing 50 changed files with 380 additions and 521 deletions.
4 changes: 4 additions & 0 deletions .github/actions/build/app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
LACE_EXTENSION_KEY:
description: 'Public extended manifest key'
required: true
DAPP_RADAR_API_KEY:
description: 'Production api token of DApp Radar API'
required: true
BUILD_DEV_PREVIEW:
description: 'Build developer preview of Lace'
required: false
Expand Down Expand Up @@ -76,6 +79,7 @@ runs:
BLOCKFROST_PROJECT_ID_PREPROD: ${{ inputs.BLOCKFROST_PROJECT_ID_PREPROD }}
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ inputs.BLOCKFROST_PROJECT_ID_PREVIEW }}
LACE_EXTENSION_KEY: ${{ inputs.LACE_EXTENSION_KEY }}
DAPP_RADAR_API_KEY: ${{ inputs.DAPP_RADAR_API_KEY }}
BUILD_DEV_PREVIEW: ${{ inputs.BUILD_DEV_PREVIEW }}
POSTHOG_PRODUCTION_TOKEN: ${{ inputs.POSTHOG_PRODUCTION_TOKEN }}
PRODUCTION_MODE_TRACKING: ${{ inputs.PRODUCTION_MODE_TRACKING }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ jobs:
SENTRY_ORG: ${{ startsWith(github.ref, 'refs/heads/release') && vars.SENTRY_ORG || '' }}
SENTRY_PROJECT: ${{ startsWith(github.ref, 'refs/heads/release') && vars.SENTRY_PROJECT || ''}}
SENTRY_ENVIRONMENT: 'production'
DAPP_RADAR_API_KEY: ${{ startsWith(github.ref, 'refs/heads/release') && secrets.DAPP_RADAR_API_KEY || '' }}
build:
name: Build Lace
runs-on: ubuntu-22.04
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ cp ./apps/.env.defaults ./apps/.env

Once `.env` files is created adjust it to your needs, and update `LACE_EXTENSION_KEY`

> If you want to develop DApp Explorer please refer to the [Setting up local connection with DApp Radar API](apps/browser-extension-wallet/src/views/browser-view/features/dapp/README.md) page
### Build packages and extension

```sh
Expand Down
4 changes: 4 additions & 0 deletions apps/browser-extension-wallet/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ PRODUCTION_MODE_TRACKING=false

# Post Hog
POSTHOG_DEV_TOKEN=phc_gH96Lx5lEVXTTWEyytSdTFPDk3Xsxwi4BqG88mKObd1

# Sentry
SENTRY_AUTH_TOKEN=
SENTRY_DSN=
Expand Down Expand Up @@ -100,6 +101,9 @@ CEXPLORER_URL_PREVIEW=https://preview.cexplorer.io
CEXPLORER_URL_PREPROD=https://preprod.cexplorer.io
CEXPLORER_URL_SANCHONET=https://sancho.cexplorer.io

# DApp Radar API
DAPP_RADAR_API_URL=https://apis.dappradar.com

# Manifest.json
LACE_EXTENSION_KEY=gafhhkghbfjjkeiendhlofajokpaflmk
LACE_EXTENSION_ID=gafhhkghbfjjkeiendhlofajokpaflmk
Expand Down
3 changes: 3 additions & 0 deletions apps/browser-extension-wallet/.env.developerpreview
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ CEXPLORER_URL_PREVIEW=https://preview.cexplorer.io
CEXPLORER_URL_PREPROD=https://preprod.cexplorer.io
CEXPLORER_URL_SANCHONET=https://sancho.cexplorer.io

# DApp Radar API
DAPP_RADAR_API_URL=https://apis.dappradar.com

# Manifest.json
LACE_EXTENSION_KEY=djcdfchkaijggdjokfomholkalbffgil
LACE_EXTENSION_ID=djcdfchkaijggdjokfomholkalbffgil
Expand Down
4 changes: 4 additions & 0 deletions apps/browser-extension-wallet/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ CEXPLORER_URL_PREVIEW=https://preview.cexplorer.io
CEXPLORER_URL_PREPROD=https://preprod.cexplorer.io
CEXPLORER_URL_SANCHONET=https://sancho.cexplorer.io

# DApp Radar API
DAPP_RADAR_API_URL=https://apis.dappradar.com
DAPP_RADAR_API_KEY=

# Manifest.json
LACE_EXTENSION_KEY=gafhhkghbfjjkeiendhlofajokpaflmk
LACE_EXTENSION_ID=gafhhkghbfjjkeiendhlofajokpaflmk
Expand Down
2 changes: 1 addition & 1 deletion apps/browser-extension-wallet/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"permissions": ["webRequest", "storage", "tabs", "unlimitedStorage"],
"host_permissions": ["<all_urls>"],
"content_security_policy": {
"extension_pages": "default-src 'self' $LOCALHOST_DEFAULT_SRC; frame-src https://connect.trezor.io/ https://www.youtube-nocookie.com; script-src 'self' 'wasm-unsafe-eval' $LOCALHOST_SCRIPT_SRC; font-src 'self' https://use.typekit.net; object-src 'self'; connect-src $BLOCKFROST_URLS $CARDANO_SERVICES_URLS $CARDANO_WS_SERVER_URLS $SENTRY_URL https://coingecko.live-mainnet.eks.lw.iog.io https://muesliswap.live-mainnet.eks.lw.iog.io $LOCALHOST_CONNECT_SRC $POSTHOG_HOST https://use.typekit.net data:; style-src * 'unsafe-inline'; img-src * data:;"
"extension_pages": "default-src 'self' $LOCALHOST_DEFAULT_SRC; frame-src https://connect.trezor.io/ https://www.youtube-nocookie.com; script-src 'self' 'wasm-unsafe-eval' $LOCALHOST_SCRIPT_SRC; font-src 'self' https://use.typekit.net; object-src 'self'; connect-src $BLOCKFROST_URLS $CARDANO_SERVICES_URLS $CARDANO_WS_SERVER_URLS $SENTRY_URL $DAPP_RADAR_APPI_URL https://coingecko.live-mainnet.eks.lw.iog.io https://muesliswap.live-mainnet.eks.lw.iog.io $LOCALHOST_CONNECT_SRC $POSTHOG_HOST https://use.typekit.net data:; style-src * 'unsafe-inline'; img-src * data:;"
},
"content_scripts": [
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Setting up local connection with DApp Radar API

DApp Explorer uses [DApp Radar API](https://apis-portal.dappradar.com/full-api-reference)
as a data source.
For the local development you need to set up your personal
[subscription](https://apis-portal.dappradar.com/subscriptions) to obtain an api token.
You can use a free plan allowing you to perform 100 api calls per month.

Once you have your personal api token set it in your `.env` file
under the `DAPP_RADAR_API_KEY` name.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import capitalize from 'lodash/fp/capitalize';
import { IogImage } from '../../Image';
import { IogCardProps } from './types';
import './styles.scss';
Expand Down Expand Up @@ -30,7 +31,7 @@ export const IogCardClassic: React.FC<IogCardProps> = ({ onClick, ...props }) =>
</Text.Body.Normal>
<Box w="$fill">
<Text.Body.Small weight="$semibold" color="secondary" data-testid="dappCategory">
{categories?.map((category, index) => (categories.length !== index + 1 ? `${category} ` : category))}
{categories.map((c) => capitalize(c)).join(', ')}
</Text.Body.Small>
</Box>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

span {
display: block;
white-space: normal;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
interface IIogCardImage {
alt: string;
src: string;
width: number;
height: number;
}

export interface IogCardProps {
categories?: string[];
categories: string[];
title: string;
description?: string;
isCertified?: boolean;
image?: Partial<IIogCardImage>;
onClick?: () => void;
image?: IIogCardImage;
onClick: () => void;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Layout, SectionLayout } from '@views/browser/components';
import SimpleView from './SimpleView';
import React from 'react';
import { ExperimentName } from '@providers/ExperimentsProvider/types';
import { usePostHogClientContext } from '@providers/PostHogClientProvider';

export const DAppExplorer: React.FC = () => (
<>
<Layout noAside>
<SectionLayout>
<SimpleView />
</SectionLayout>
</Layout>
<div id={'dAppStore'} />
</>
);
export const DAppExplorer: React.FC = () => {
const posthog = usePostHogClientContext();
const dappExplorerEnabled = posthog.isFeatureEnabled(ExperimentName.DAPP_EXPLORER);
return (
<>
<Layout noAside>
<SectionLayout>{dappExplorerEnabled && <SimpleView />}</SectionLayout>
</Layout>
<div id={'dAppStore'} />
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { Text } from '@input-output-hk/lace-ui-toolkit';
import { useTranslation } from 'react-i18next';
import { IogText } from '../Typography';
import Empty from './images/Empty';
Expand All @@ -12,9 +13,9 @@ const IogEmptyState: React.FC = () => {
<div data-testid="empty-state-image">
<Empty />
</div>
<IogText xxMedium bold as="div" color="black" data-testid="empty-state-header">
<Text.Body.Large weight={'$bold'} data-testid="empty-state-header">
{t('dappdiscovery.empty_state.no_dapps_title')}
</IogText>
</Text.Body.Large>
<IogText as="div" small normal color="dark" center data-testid="empty-state-text">
{t('dappdiscovery.empty_state.no_dapps_content1')}
</IogText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ export const AboutDapp: React.FC = () => {
return (
<>
<Box my="$24">
<Text.Body.Normal>{data?.longDescription}</Text.Body.Normal>
<Box mb="$12">
<Text.SubHeading>{'Summary'}</Text.SubHeading>
</Box>
<Text.Body.Normal>{data?.shortDescription}</Text.Body.Normal>
</Box>
<Box my="$24">
<Box mb="$12">
<Text.SubHeading>{'DApp Description'}</Text.SubHeading>
</Box>
<Text.Body.Normal>
<div dangerouslySetInnerHTML={{ __html: data?.longDescription }} />
</Text.Body.Normal>
</Box>
{data?.screenshots && (
<Box mb="$16">
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 798e959

Please sign in to comment.