diff --git a/web/package.json b/web/package.json index aadd50fc9..d7d6a828d 100644 --- a/web/package.json +++ b/web/package.json @@ -19,6 +19,7 @@ "create-events": "./bin/generateEvents.cjs" }, "dependencies": { + "@2toad/profanity": "^2.2.0", "@chakra-ui/anatomy": "^2.1.1", "@chakra-ui/react": "^2.8.1", "@dojoengine/core": "^0.1.30", diff --git a/web/src/components/Leaderboard.tsx b/web/src/components/Leaderboard.tsx index 9bdd030ba..c46bb241d 100644 --- a/web/src/components/Leaderboard.tsx +++ b/web/src/components/Leaderboard.tsx @@ -30,6 +30,7 @@ import { Arrow, Skull } from "./icons"; import { useRyoMetas } from "@/dojo/queries/useRyoMetas"; import { useLeaderboardMetas } from "@/dojo/queries/useLeaderboardMetas"; import Countdown from "react-countdown"; +import { profanity } from '@2toad/profanity'; const renderer = ({ days, @@ -154,7 +155,7 @@ const Leaderboard = ({ nameEntry, ...props }: { nameEntry?: boolean } & StylePro const isOwn = score.playerId === account?.address; const color = isOwn ? colors.yellow["400"].toString() : colors.neon["200"].toString(); const avatarColor = isOwn ? "yellow" : "green"; - const displayName = score.name ? `${score.name}${isOwn ? " (you)" : ""}` : "Anonymous"; + const displayName = score.name ? `${profanity.censor(score.name)}${isOwn ? " (you)" : ""}` : "Anonymous"; return ( diff --git a/web/src/dojo/queries/usePlayerEntity.tsx b/web/src/dojo/queries/usePlayerEntity.tsx index 6661d4178..a18ec13d4 100644 --- a/web/src/dojo/queries/usePlayerEntity.tsx +++ b/web/src/dojo/queries/usePlayerEntity.tsx @@ -3,6 +3,7 @@ import { useEffect, useMemo, useState } from "react"; import { REFETCH_INTERVAL, SCALING_FACTOR } from "../constants"; import { PlayerStatus, ItemEnum, ItemTextEnum } from "../types"; import { shortString } from "starknet"; +import { profanity } from '@2toad/profanity'; type Drug = { id: string; @@ -43,7 +44,7 @@ export class PlayerEntity { gameOver: boolean; constructor(player: Player, drugs: Drug[], items: ShopItem[], encounters: Encounter[]) { - this.name = shortString.decodeShortString(player.name); + this.name = profanity.censor(shortString.decodeShortString(player.name)); this.avatarId = player.avatar_id; this.cash = Number(player.cash) / SCALING_FACTOR; this.health = player.health; diff --git a/web/yarn.lock b/web/yarn.lock index 345a63f5e..84c800e45 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@2toad/profanity@^2.2.0": + version "2.2.0" + resolved "https://registry.yarnpkg.com/@2toad/profanity/-/profanity-2.2.0.tgz#bb3232c1dbdd31d7f3bf0a5ff3b69437f9e5cbaf" + integrity sha512-EDoqDFFkw3g11xIHMQI4L91G+PT6OHrAHvwi+oxbYBH06G7EFrWVva+r604uscEPDZR4h+GrvVqkTD0g8JzZgg== + "@adraffy/ens-normalize@1.9.0": version "1.9.0" resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.9.0.tgz#223572538f6bea336750039bb43a4016dcc8182d" @@ -2250,7 +2255,6 @@ get-starknet-core "^3.2.0" js-cookie "^3.0.5" - "@dojoengine/utils@0.1.30": version "0.1.30" resolved "https://registry.yarnpkg.com/@dojoengine/utils/-/utils-0.1.30.tgz#4567e952cf189cb3e164382cad52f3c280906fe8"