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

token logo #477

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
908bea2
:recycle: Refactored subgraph URL generation
Corantin Oct 18, 2024
c825532
Merge branch 'dev' into plug-subgraph-protocol
Corantin Oct 18, 2024
5880de8
:recycle: Updated subgraph URL retrieval method
Corantin Oct 18, 2024
78dad7c
Merge remote-tracking branch 'origin/plug-subgraph-protocol' into plu…
Corantin Oct 18, 2024
3b3664f
:art: Refactor button and dispute components
Corantin Oct 18, 2024
8c2534b
Merge branch 'main' into dev
Corantin Oct 18, 2024
0e101cd
:recycle: Improved address display and button conditions
Corantin Oct 18, 2024
11ce525
Merge remote-tracking branch 'origin/dev' into dev
Corantin Oct 18, 2024
d54da4a
:recycle: Refactored dispute button and pool form components
Corantin Oct 18, 2024
2c2f138
:art: Adjusted CSS classes in garden pages
Corantin Oct 18, 2024
40154d5
:sparkles: Enhanced TooltipIfOverflow component
Corantin Oct 18, 2024
aa1f63d
:ambulance: Fix contract emptied the allowlist when setPoolParams cal…
Corantin Oct 19, 2024
d776819
:ambulance: Fix member stake not reset in pool when deactivating
Corantin Oct 20, 2024
fbd8775
:art: Improved UI responsiveness
Corantin Oct 20, 2024
77bb5b2
:bug: :ambulance: Remove bypass to trigger auto-repair
Corantin Oct 20, 2024
e1da13d
:art: Enhanced Ethereum address display
Corantin Oct 20, 2024
15f3145
:recycle: Removed unused imports and debug logs
Corantin Oct 20, 2024
85b45d9
Merge branch 'dev' into plug-subgraph-protocol
Corantin Oct 20, 2024
54b3ca0
Merge pull request #470 from 1Hive/plug-subgraph-protocol
Corantin Oct 20, 2024
15d5709
order garden cards by communities length from most to least
Mati0x Oct 21, 2024
a8cb885
fix membership stake amount decimals
Lucianosc Oct 23, 2024
bad46fc
Merge pull request #474 from 1Hive/fix/membership-stake-amount-decimals
Corantin Oct 23, 2024
e4517eb
Merge branch 'dev' into current-fixes
Mati0x Oct 23, 2024
f14dff5
Merge pull request #473 from 1Hive/current-fixes
Mati0x Oct 23, 2024
2a20898
first api interaction + added api key
Mati0x Oct 23, 2024
59f3f5b
upgrading api route
Mati0x Oct 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { useMetadataIpfsFetch } from "@/hooks/useIpfsFetch";
import { useSubgraphQuery } from "@/hooks/useSubgraphQuery";
import { alloABI } from "@/src/generated";
import { PoolTypes, ProposalStatus } from "@/types";
import { abiWithErrors } from "@/utils/abi";

import { useErrorDetails } from "@/utils/getErrorName";
import { prettyTimestamp } from "@/utils/text";

Expand Down Expand Up @@ -121,7 +121,7 @@ export default function Page({
isError: isErrorDistribute,
} = useContractWriteWithConfirmations({
address: data?.allos[0]?.id as Address,
abi: abiWithErrors(alloABI),
abi: alloABI,
functionName: "distribute",
contractName: "Allo",
fallbackErrorMessage: "Error executing proposal, please report a bug.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export default function Page({
poolId={poolId}
ipfsResult={ipfsResult}
isEnabled={isEnabled}
chainId={chain}
/>
{isEnabled && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ export default function Page({
<div className="flex flex-1 flex-col gap-2">
<div>
<h2>{communityName}</h2>
<EthAddress icon={false} address={communityAddr as Address} />
<EthAddress
icon={false}
address={communityAddr as Address}
label="Community address"
/>
</div>
<div className="flex flex-col gap-2">
<Statistic
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/(app)/gardens/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function Page() {
{tokenGardens
.sort(
(a, b) =>
(a.communities?.length ?? 0) - (b.communities?.length ?? 0),
(b.communities?.length ?? 0) - (a.communities?.length ?? 0),
)
.map((garden) => (
<div key={garden.id}>
Expand Down Expand Up @@ -81,7 +81,7 @@ export default function Page() {
return (
<>
<div className="flex flex-col items-center justify-center gap-8 relative">
<header className="flex flex-col items-center gap-8 2xl:mt-20">
<header className="flex flex-col items-center gap-8">
<div className="flex items-center text-center">
<div className="relative flex-1">
<Image src={clouds1} alt="clouds" width={205} height={205} />
Expand Down
128 changes: 128 additions & 0 deletions apps/web/app/api/coingecko/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { NextResponse } from "next/server";

// Define supported chains and their CoinGecko IDs
const SUPPORTED_CHAINS = {
ethereum: "ethereum",
gnosis: "gnosis",
polygon: "polygon-pos",
arbitrum: "arbitrum-one",
optimism: "optimistic-ethereum",
bsc: "binance-smart-chain",
} as const;

type ChainType = keyof typeof SUPPORTED_CHAINS;

interface Params {
params: {
chain: ChainType;
token: string;
};
}

export async function GET(request: Request, { params }: Params) {
try {
const { chain, token } = params;

// Validate chain
if (!chain || !(chain.toLowerCase() in SUPPORTED_CHAINS)) {
return NextResponse.json(
{
success: false,
error: `Unsupported chain. Supported chains are: ${Object.keys(SUPPORTED_CHAINS).join(", ")}`,
metadata: { chain, token, timestamp: new Date().toISOString() },
},
{ status: 400 },
);
}

// Validate token address format
if (!token || !/^0x[a-fA-F0-9]{40}$/.test(token)) {
return NextResponse.json(
{
success: false,
error: "Invalid token address format",
metadata: { chain, token, timestamp: new Date().toISOString() },
},
{ status: 400 },
);
}

const url = `https://api.coingecko.com/api/v3/coins/${chain}/contract/${token}`;

const response = await fetch(url, {
headers: {
accept: "application/json",
//TODO: undo this
// eslint-disable-next-line turbo/no-undeclared-env-vars
"x-cg-demo-api-key": process.env.COINGECKO_API_KEY ?? "",
},
//next: { revalidate: 60 }, // Cache for 60 seconds
});

if (!response.ok) {
if (response.status === 404) {
return NextResponse.json(
{
success: false,
error: "Token not found on the specified chain",
metadata: { chain, token, timestamp: new Date().toISOString() },
},
{ status: 404 },
);
}
throw new Error(`CoinGecko API error: ${response.status}`);
}

const data = await response.json();

// Format the response with the most relevant data
// const formattedData = {
// success: true,
// data: {
// id: data.id,
// symbol: data.symbol,
// name: data.name,
// asset_platform_id: data.asset_platform_id,
// contract_address: data.contract_address,
// market_data: {
// current_price: data.market_data?.current_price,
// market_cap: data.market_data?.market_cap,
// total_volume: data.market_data?.total_volume,
// price_change_percentage_24h:
// data.market_data?.price_change_percentage_24h,
// price_change_percentage_7d:
// data.market_data?.price_change_percentage_7d,
// price_change_percentage_30d:
// data.market_data?.price_change_percentage_30d,
// },
// last_updated: data.last_updated,
// },
// metadata: {
// chain,
// token,
// timestamp: new Date().toISOString(),
// },
// };

return NextResponse.json(data, {
status: 200,
headers: {
"Cache-Control": "public, s-maxage=60, stale-while-revalidate=30",
},
});
} catch (error) {
console.error("Error fetching token data:", error);
return NextResponse.json(
{
success: false,
error: "Failed to fetch token data",
metadata: {
chain: params.chain,
token: params.token,
timestamp: new Date().toISOString(),
},
},
{ status: 500 },
);
}
}
7 changes: 3 additions & 4 deletions apps/web/components/ActivatePoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import useCheckAllowList from "@/hooks/useCheckAllowList";
import { useContractWriteWithConfirmations } from "@/hooks/useContractWriteWithConfirmations";
import { ConditionObject, useDisableButtons } from "@/hooks/useDisableButtons";
import { cvStrategyABI } from "@/src/generated";
import { abiWithErrors } from "@/utils/abi";
import { useErrorDetails } from "@/utils/getErrorName";

type ActiveMemberProps = {
Expand Down Expand Up @@ -40,7 +39,7 @@ export function ActivatePoints({
chainId,
address: strategy.id as Address,
contractName: "CV Strategy",
abi: abiWithErrors(cvStrategyABI),
abi: cvStrategyABI,
functionName: "activatePoints",
fallbackErrorMessage: "Error activating points, please report a bug.",
onConfirmations: () => {
Expand All @@ -58,7 +57,7 @@ export function ActivatePoints({
const { write: writeDeactivatePoints, error: errorDeactivatePoints } =
useContractWriteWithConfirmations({
address: strategy.id as Address,
abi: abiWithErrors(cvStrategyABI),
abi: cvStrategyABI,
contractName: "CV Strategy",
functionName: "deactivatePoints",
fallbackErrorMessage: "Error deactivating points, please report a bug.",
Expand Down Expand Up @@ -117,7 +116,7 @@ export function ActivatePoints({
btnStyle={isMemberActivated ? "outline" : "filled"}
color={isMemberActivated ? "danger" : "primary"}
disabled={missmatchUrl || disableActiveBtn || !isAllowed}
tooltip={String(tooltipMessage)}
tooltip={tooltipMessage}
>
{isMemberActivated ? "Deactivate governance" : "Activate governance"}
</Button>
Expand Down
11 changes: 5 additions & 6 deletions apps/web/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ const btnStyles: BtnStyles = {

export function Button({
onClick,
className: styles,
className: styles = "",
disabled = false,
tooltip,
showToolTip = true,
tooltipClassName: tooltipStyles,
showToolTip = false,
tooltipClassName: tooltipStyles = "",
tooltipSide = "tooltip-top",
children,
btnStyle = "filled",
Expand All @@ -86,8 +86,7 @@ export function Button({
const buttonElement = (
<button
type={type}
className={`${btnStyles[btnStyle][disabled ? "disabled" : color]}
flex relative cursor-pointer justify-center rounded-lg px-6 py-4 transition-all ease-out disabled:cursor-not-allowed h-fit ${styles}`}
className={`${btnStyles[btnStyle][disabled ? "disabled" : color]} flex relative cursor-pointer justify-center rounded-lg px-6 py-4 transition-all ease-out disabled:cursor-not-allowed h-fit ${styles}`}
onClick={onClick}
disabled={disabled || isLoading}
>
Expand All @@ -105,7 +104,7 @@ export function Button({
return disabled || showToolTip ?
<div
className={`${tooltip ? "tooltip" : ""} ${tooltipSide} ${tooltipStyles}`}
data-tip={tooltip}
data-tip={tooltip ?? ""}
>
{buttonElement}
</div>
Expand Down
3 changes: 1 addition & 2 deletions apps/web/components/CancelButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useChainIdFromPath } from "@/hooks/useChainIdFromPath";
import { useContractWriteWithConfirmations } from "@/hooks/useContractWriteWithConfirmations";
import { MetadataV1 } from "@/hooks/useIpfsFetch";
import { cvStrategyABI } from "@/src/generated";
import { abiWithErrors } from "@/utils/abi";

type Props = {
proposalData: Maybe<
Expand All @@ -29,7 +28,7 @@ function CancelButton({ proposalData }: Props) {

const { write: writeCancel, isLoading } = useContractWriteWithConfirmations({
address: strategy.id as Address,
abi: abiWithErrors(cvStrategyABI),
abi: cvStrategyABI,
functionName: "cancelProposal",
contractName: "CV Strategy",
fallbackErrorMessage: "Error cancelling proposal, please report a bug.",
Expand Down
Loading
Loading