Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function truncateAddress(address: string): string {
return `${address.slice(0, 6)}...${address.slice(-4)}`;
}
5 changes: 1 addition & 4 deletions src/app/story/[storylineId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import { RatingSummary } from "../../../components/RatingSummary";
import { getTokenPrice, type TokenPriceInfo } from "../../../../lib/price";
import { IS_TESTNET } from "../../../../lib/contracts/constants";
import { type Address } from "viem";
import { truncateAddress } from "../../../../lib/utils";

type Params = Promise<{ storylineId: string }>;

function truncateAddress(address: string): string {
return `${address.slice(0, 6)}...${address.slice(-4)}`;
}

export default async function StoryPage({ params }: { params: Params }) {
const { storylineId } = await params;
const id = Number(storylineId);
Expand Down
5 changes: 1 addition & 4 deletions src/components/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import { useAccount, useConnect, useDisconnect } from "wagmi";
import { injected } from "wagmi/connectors";

function truncateAddress(address: string): string {
return `${address.slice(0, 6)}...${address.slice(-4)}`;
}
import { truncateAddress } from "../../lib/utils";

export function ConnectWallet() {
const { address, isConnected } = useAccount();
Expand Down
5 changes: 1 addition & 4 deletions src/components/RatingWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useQuery } from "@tanstack/react-query";
import { publicClient } from "../../lib/rpc";
import { erc20Abi } from "../../lib/price";
import type { Address } from "viem";
import { truncateAddress } from "../../lib/utils";

interface RatingData {
id: number;
Expand All @@ -29,10 +30,6 @@ interface RatingWidgetProps {
tokenAddress: string;
}

function truncateAddress(address: string): string {
return `${address.slice(0, 6)}...${address.slice(-4)}`;
}

function StarDisplay({ rating, size = "sm" }: { rating: number; size?: "sm" | "lg" }) {
const sizeClass = size === "lg" ? "text-base" : "text-xs";
return (
Expand Down
5 changes: 1 addition & 4 deletions src/components/StoryCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import Link from "next/link";
import type { Storyline } from "../../lib/supabase";

function truncateAddress(address: string): string {
return `${address.slice(0, 6)}...${address.slice(-4)}`;
}
import { truncateAddress } from "../../lib/utils";

export function StoryCard({
storyline,
Expand Down
Loading