Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dApps] API and Data #2763

Open
wants to merge 40 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e3ccd28
adding logic without design to the newDapps page
TalBenAvi Apr 18, 2024
bb2938a
Merge branch 'dev' into adding-api-for-the-dapps-section
TalBenAvi Apr 18, 2024
3ef1add
Merge branch 'dev' into adding-api-for-the-dapps-section
TalBenAvi May 1, 2024
caf698c
Merge branch 'dev' into adding-api-for-the-dapps-section
TalBenAvi May 6, 2024
67dee68
remove unused code
TalBenAvi May 6, 2024
304ecdd
update cms jobs
TalBenAvi May 6, 2024
1e6155c
fixing error with file creation
TalBenAvi May 6, 2024
00d1a87
Update 0288fca7-f91a-48de-8582-f5bf49b7862b.yml
TalBenAvi May 6, 2024
7e8e7df
Update 09548ebb-0617-44cb-a91a-31c9fb64eb2a.yml
TalBenAvi May 6, 2024
fca441c
Update 13e6db50-ffb8-4e1a-9d8a-7e5861ee28cf.yml
TalBenAvi May 6, 2024
fbed78d
Update 1f73f99c-b264-4bfa-a8bb-6046d30c550f.yml
TalBenAvi May 6, 2024
5bc8d20
Update 221b0b01-07e4-48f2-9a18-46715d6faa47.yml
TalBenAvi May 6, 2024
9f40e70
Update 2612dc8e-1485-4c12-97a6-22a5329e87f5.yml
TalBenAvi May 6, 2024
f9b1366
Update 2ff1a712-b121-48ea-9465-76c5f8e48e72.yml
TalBenAvi May 6, 2024
d806956
Update 4528fc2a-0b43-4bda-96c3-888ec0887042.yml
TalBenAvi May 6, 2024
35de669
Update 49e30ff8-3e58-4043-9b12-d92afbe8bf83.yml
TalBenAvi May 6, 2024
effc4bf
Update 5141b37f-5fcb-4f9e-92ca-55c25dcd1657.yml
TalBenAvi May 6, 2024
e3fe1df
Update 52f4cae7-4825-4574-8653-79d2706859ad.yml
TalBenAvi May 6, 2024
bbc8ce4
Update 69447136-1854-49d5-8808-5dddb902f94f.yml
TalBenAvi May 6, 2024
72c3287
Update 6a53c549-6317-4b07-839a-518dd3f3cdfd.yml
TalBenAvi May 6, 2024
1ca9e38
Update 6c9e4b8f-f702-48c1-9029-af0892f01d08.yml
TalBenAvi May 6, 2024
48f34cf
Update 7027c387-6558-475e-97e6-6631442a2bd1.yml
TalBenAvi May 6, 2024
a4fabb5
Update 7f048883-3bea-4d32-bc63-56308e641d6f.yml
TalBenAvi May 6, 2024
b251e76
Update 8103d5a3-65ae-4829-862c-c69ef39c559f.yml
TalBenAvi May 6, 2024
17170bf
Update 86927b27-2449-414d-8396-5ca93152f0e7.yml
TalBenAvi May 6, 2024
51a09d7
Update 88b77a93-a42d-4635-85cf-98e436ee9730.yml
TalBenAvi May 6, 2024
931d48f
Update 955801e9-4e6f-46e0-81f4-c3439acb94b7.yml
TalBenAvi May 6, 2024
e6d24eb
Update 984f65d3-9bf1-4735-9a34-cc43091fa26c.yml
TalBenAvi May 6, 2024
7a26006
Update a27362c6-b4e2-4543-a7a7-2d8e20670f7e.yml
TalBenAvi May 6, 2024
c36696d
Update a37fa639-11a8-4895-b9ce-0cca859fd79d.yml
TalBenAvi May 6, 2024
07ecaf3
Update a6f392f1-d809-4455-994d-f42638dadc8b.yml
TalBenAvi May 6, 2024
116acf3
Update b6d6f28d-2f3c-4e20-994f-2f81b300bc62.yml
TalBenAvi May 6, 2024
33aa56d
Update bc93267e-d1ed-425a-bbc8-012fa9e5332f.yml
TalBenAvi May 6, 2024
b8c6356
Update d0599c81-e305-44ea-8891-5472bb3ed370.yml
TalBenAvi May 6, 2024
5b7e690
Update e117916c-93b9-4544-a605-80838649c149.yml
TalBenAvi May 6, 2024
006b466
Update e16224ab-674d-439d-926c-9a20031e1aeb.yml
TalBenAvi May 6, 2024
1a7aff9
Update e93a7528-dcd3-46fb-bac3-ab91a60e20e1.yml
TalBenAvi May 6, 2024
f155704
Update job1.yml
TalBenAvi May 6, 2024
3c29a31
Merge branch 'dev' into adding-api-for-the-dapps-section
TalBenAvi May 7, 2024
1878802
update design
TalBenAvi May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions _data/pages/dapps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,10 @@ breadcrumbs: false
page_last_updated: true
blocks:
- type: hero
variant: block_explorers
title: Hundreds of dApps, Services & Wallets
description: Immerse yourself in the Starknet Ecosystem by discovering projects, jobs, metrics and learning resources.
- type: dapps
variant: dapps
title: dApps
description: Discover apps in the Starknet ecosystem across NFTs, Gaming, Defi,
DAOs and more.
- type: card_list
card_list_items:
- title: Starknet-ecosystem
description: Immerse yourself in the Starknet Ecosystem by discovering projects,
jobs, metrics and learning resources.
website_url: https://www.starknet-ecosystem.com
twitter: https://twitter.com/StarkNetEco
link_url: https://www.starknet-ecosystem.com
image: /assets/sn-ecosystem.jpg
- title: Dappland
description: Discover and rate the best apps on Starknet.
link_url: https://www.dappland.com
website_url: https://www.dappland.com
twitter: https://twitter.com/argentHQ
image: /assets/dappland.jpg
- website_url: https://www.ethereum-ecosystem.com/blockchains/starknet
title: Ethereum Ecosystem
description: Discover the best of Ethereum and its layer 2s. All in one place.
image: /assets/logo.webp
twitter: https://twitter.com/web3xplore
randomize: true
description: ""
11 changes: 11 additions & 0 deletions workspaces/cms-config/src/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,17 @@ export const blocks = [
},
],
},
{
name: "dapps",
label: "Dapps",
widget: "object",
fields: [
{
name: "type",
widget: "hidden",
},
],
},
{
name: "community_events",
label: "Community events block",
Expand Down
9 changes: 7 additions & 2 deletions workspaces/cms-data/src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getShuffledArray,
} from "@starknet-io/cms-utils/src/index";
import type { Meta } from "@starknet-io/cms-utils/src/index";
import { Project } from "./starknet-db-projects-dapps";

export interface MarkdownBlock {
readonly type: "markdown";
Expand Down Expand Up @@ -256,13 +257,17 @@ export interface HeadingContainerBlock {
readonly heading_variant: HeadingVariant;
readonly blocks: readonly Block[];
}

export interface DappsBlock {
readonly type: "dapps";
readonly blocks?: readonly Project[];
}
export type TopLevelBlock =
| Block
| FlexLayoutBlock
| GroupBlock
| Container
| HeadingContainerBlock;
| HeadingContainerBlock
| DappsBlock;

export interface Page extends Meta {
readonly id: string;
Expand Down
52 changes: 52 additions & 0 deletions workspaces/cms-data/src/starknet-db-projects-dapps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { getJSON } from "@starknet-io/cms-utils/src/index";
export interface Project {
readonly id: string;
readonly name: string;
readonly shortName: string;
readonly description: string;
readonly image: string;
readonly network: {
readonly website?: string;
readonly github?: string;
readonly twitter?: string;
readonly twitterImage?: string;
readonly twitterBanner?: string;
readonly medium?: string;
readonly discord?: string;
readonly telegram?: string;
};
readonly tags: string[];
readonly socialMetrics: {
readonly twitterFollower: number;
readonly twitterCount: number;
readonly tweetWithStarknet: number;
readonly socialActivity: number;
readonly date: number;
};
readonly isLive: boolean;
readonly isHidden: boolean;
readonly isTestnetLive: boolean;
}
export interface TagObject {
label: string;
slug: string;
}
export interface DappsProps {
readonly list: Project[];
readonly categories: TagObject[];
}
export async function getStarknetDappsDbProjects(
context: EventContext<{}, any, Record<string, unknown>>
): Promise<DappsProps> {
try {
const sections = await getJSON(
"data/starknet-db-projects-dapps/starknet-db-projects-dapps",
context
);
return sections;
} catch (cause) {
throw new Error("getStarknetDappsDbProjects failed!", {
cause,
});
}
}
70 changes: 67 additions & 3 deletions workspaces/cms-scripts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from "fs/promises";
import * as path from "path";

import { ApiResponse } from "./types";
import { Project } from "../../cms-data/src/starknet-db-projects-dapps";
process.chdir(path.resolve(__dirname, "../../.."));

import slugify from "slugify";
import { write, yaml } from "./utils";
import { locales } from "@starknet-io/cms-data/src/i18n/config";
import { MainMenu } from "./main-menu";
Expand All @@ -22,7 +23,7 @@ import {
updateBlocks,
} from "./data";
import { translateFile } from "./crowdin";

import fetch from "node-fetch";
const createRoadmapDetails = async () => {
await fs.mkdir(`public/data/roadmap-details`, { recursive: true });
for (const locale of locales) {
Expand Down Expand Up @@ -301,7 +302,70 @@ await write(
`public/data/featured-sections/featured-sections.json`,
featuredSections
);
const fetchProjects = async () => {
try {
return await fetch("https://api.starknet-db.com/projects?size=10000").then(
(response) => response.json() as unknown as ApiResponse
);
} catch (error) {
console.error("Error fetching projects from api.starknet-db:", error);
throw error;
}
};
const dAppsData: ApiResponse = await fetchProjects();
export interface TagObject {
label: string;
slug: string;
}
const blackListTags = [
"all",
"governance",
"pfp",
"green finance",
"cairo",
"formal-verification",
"dex, wallet, multi-chain, cross-chain, okx, bridge, blockchain",
"staking",
"access node",
"data",
"starkware",
];

const slugifyTags = (objects: Project[]): Project[] => {
return objects.map((obj) => {
const newObj: Project = {
...obj,
tags: obj.tags.map((tag) => slugify(tag, "_")),
};
return newObj;
});
};

const extractTags = (projects: Project[]): TagObject[] => {
const tagsSet = new Set<string>();
projects.forEach((project) => {
project.tags.forEach((tag: string) => tagsSet.add(tag.toLowerCase()));
});
// const tagArray = Array.from(tagsSet);
const filteredArray = Array.from(tagsSet).filter(
(item) => !blackListTags.includes(item)
);

return filteredArray.map((tag) => ({
label: tag,
slug: slugify(tag, "_"),
}));
};
const slugifyDApps = slugifyTags(dAppsData.content);
const categories = extractTags(dAppsData.content).sort((a, b) =>
a.label > b.label ? 1 : b.label > a.label ? -1 : 0
);

await fs.mkdir("public/data/starknet-db-projects-dapps", { recursive: true });
await write(
`public/data/starknet-db-projects-dapps/starknet-db-projects-dapps.json`,
{ list: slugifyDApps, categories }
);
await createRoadmapDetails();
await createAnnouncementDetails();
await createSharedData();
30 changes: 30 additions & 0 deletions workspaces/cms-scripts/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Project } from "../../cms-data/src/starknet-db-projects-dapps";

export type ApiResponse = {
content: Project[];
pageable: {
sort: {
empty: boolean;
sorted: boolean;
unsorted: boolean;
};
offset: number;
pageSize: number;
pageNumber: number;
paged: boolean;
unpaged: boolean;
};
last: boolean;
totalElements: number;
totalPages: number;
size: number;
number: number;
sort: {
empty: boolean;
sorted: boolean;
unsorted: boolean;
};
first: boolean;
numberOfElements: number;
empty: boolean;
};
1 change: 1 addition & 0 deletions workspaces/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-streaming": "^0.3.10",
"slugify": "^1.6.6",
"vite": "^4.3.9",
"vite-node": "0.30.1",
"vite-plugin-ssr": "^0.4.131",
Expand Down
9 changes: 8 additions & 1 deletion workspaces/website/src/blocks/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import VideoSectionBlock from "./VideoSectionBlock";
import { NewsletterCard } from "@ui/Card/NewsletterCard";
import { YoutubePlayer } from "@ui/YoutubePlayer/YoutubePlayer";
import NavbarStickyBanner from "../pages/(components)/NavbarStickyBanner/NavbarStickyBanner";
import DappsPage from "src/pages/starknet-db-projects-dapps/(components)/DappsPage";
import { getStarknetDappsDbProjects } from "@starknet-io/cms-data/src/starknet-db-projects-dapps";
import DisplayCardItems from "./DisplayCardItems";

export enum BlockPlacements {
Expand All @@ -48,6 +50,7 @@ export function Block({
}: Props): JSX.Element | null {
switch (placement) {
case BlockPlacements.DEFAULT:
const pageContext = usePageContext();
switch (block.type) {
case "basic_card":
return <BasicCard {...block} locale={locale} />;
Expand Down Expand Up @@ -172,9 +175,13 @@ export function Block({
darkTextColor={block.darkTextColor}
/>
);
case "dapps":
const data = useAsync(["getBlockExplorers", locale], () =>
getStarknetDappsDbProjects(pageContext.context)
);
return <DappsPage list={data.list} categories={data.categories} />;

case "home_hero":
const pageContext = usePageContext();
const homeSEO = useAsync(["getBlockExplorers", locale], () =>
getHomeSEO(locale, pageContext.context)
);
Expand Down
22 changes: 22 additions & 0 deletions workspaces/website/src/hooks/useQueryString.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useEffect, useState } from "react";

export interface QueryParams {
[key: string]: string;
}

const useQueryString = () => {
const [queryString, setQueryString] = useState<QueryParams>({});

const url = new URL(window.location.href);
useEffect(() => {
const queryString = url.search;
const searchParams = new URLSearchParams(queryString);

const paramsObject = Object.fromEntries(searchParams.entries());
setQueryString(paramsObject);
}, [url.pathname]);

return queryString;
};

export default useQueryString;
Loading
Loading