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

Michael/pg updates #592

Merged
merged 3 commits into from
Nov 8, 2024
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
54 changes: 54 additions & 0 deletions src/app/admin/membership/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"use client";

import { useWriteContract, useReadContract } from "wagmi";
import { useState } from "react";
import Tenant from "@/lib/tenant/tenant";
const AdminMembershipPage = () => {
const tenant = Tenant.current();
const [address, setAddress] = useState("");

const { data: memberBalance } = useReadContract({
address: tenant.contracts.token.address as `0x${string}`,
abi: tenant.contracts.token.abi,
functionName: "balanceOf",
args: [address as `0x${string}`],
});

const { writeContract: addMember, error: addMemberError } =
useWriteContract();

return (
<div className="flex flex-col gap-4">
<h2>Membership Admin</h2>
<div>
<h3>Add Member</h3>
<div className="flex flex-col gap-2">
<label>Address</label>
<input
type="text"
value={address}
onChange={(e) => setAddress(e.target.value)}
/>
<span>Member balance:</span>
<span>{memberBalance?.toString()}</span>
<button
className="bg-blue-500 text-white p-2 rounded-md"
onClick={() =>
addMember({
address: tenant.contracts.token.address as `0x${string}`,
abi: tenant.contracts.token.abi,
functionName: "safeMint",
args: [address as `0x${string}`],
})
}
>
Add Member
</button>
{addMemberError && <span>{addMemberError.message}</span>}
</div>
</div>
</div>
);
};

export default AdminMembershipPage;
2 changes: 1 addition & 1 deletion src/app/proposals/draft/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default async function DraftProposalPage({
<section className="col-span-1">
<div className="bg-wash border border-line rounded-2xl p-4">
<p className="mt-2">
<ReactMarkdown className="prose-h2:text-lg prose-h2:font-bold prose-h2:text-primary prose-p:text-secondary prose-p:mt-2">
<ReactMarkdown className="prose-h2:text-lg prose-h2:font-bold prose-h2:text-primary prose-p:text-secondary prose-p:mt-2 prose-li:list-inside prose-li:list-disc prose-li:my-2">
{
(proposalLifecycleToggle.config as PLMConfig)?.copy
.helperText
Expand Down
45 changes: 24 additions & 21 deletions src/components/Header/LogoLink.jsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import Tenant from "@/lib/tenant/tenant";
import Image from "next/image";
import Link from "next/link";
import { HStack } from "../Layout/Stack";
import logo from "@/assets/agora_logo.svg";
import { TENANT_NAMESPACES } from "@/lib/constants";

export default function LogoLink() {
const { namespace, ui } = Tenant.current();

return (
<HStack justifyContent="justify-between">
<Link href="/">
<HStack className="gap-2 h-full" alignItems="items-center">
{namespace !== TENANT_NAMESPACES.SCROLL && (
<>
<Image
src={logo}
alt="logo"
width="20"
height="20"
className="hidden sm:block"
/>
<div className="h-3 w-[2px] bg-line rounded-full hidden sm:block"></div>
</>
)}
<Image src={ui.logo} alt="logo" width="24" height="24" />
<span className="hidden sm:block font-medium text-primary">{`${ui.title}`}</span>
</HStack>
</Link>
</HStack>
<Link href="/" className="flex flex-row justify-between w-full">
<div className="gap-2 h-full flex flex-row items-center w-full">
{namespace !== TENANT_NAMESPACES.SCROLL && (
<>
<Image
src={logo}
alt="logo"
width="20"
height="20"
className="hidden sm:block"
/>
<div className="h-3 w-[2px] bg-line rounded-full hidden sm:block"></div>
</>
)}
<Image
src={ui.logo}
alt="logo"
width="24"
height="24"
className="h-[24px] w-auto"
/>
<span className="hidden sm:block font-medium text-primary flex-1">{`${ui.title}`}</span>
</div>
</Link>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ function AdvancedVoteDialog({
<HStack justifyContent="justify-between">
<VStack>
{delegate.address ? (
<div className="text-xs text-secondary font-medium">
<div className="text-xs text-tertiary font-medium">
<HumanAddress address={delegate.address} />
</div>
) : (
<div className="text-xs text-secondary font-medium">
<div className="text-xs text-tertiary font-medium">
Anonymous
</div>
)}
Expand All @@ -163,7 +163,7 @@ function AdvancedVoteDialog({
</div>
</VStack>
<VStack alignItems="items-end">
<div className="text-xs text-secondary font-medium">with</div>
<div className="text-xs text-tertiary font-medium">with</div>
<TokenAmountDisplay amount={vpToDisplay} />
</VStack>
</HStack>
Expand Down Expand Up @@ -240,7 +240,11 @@ export function SuccessMessage({
</div>
<div>
<div
onClick={closeDialog}
onClick={() => {
// temporary solution rather than actually changing UI state
window.location.reload();
closeDialog();
}}
className="text-center bg-neutral rounded-md border border-line font-medium shadow-newDefault cursor-pointer py-3 px-4 transition-all hover:bg-wash active:shadow-none disabled:bg-line disabled:text-secondary"
>
Got it
Expand Down
2 changes: 1 addition & 1 deletion src/lib/blockTimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getSecondsPerBlock(): number {

case 1: // Eth Mainnet
case 11155111: // Sepolia Testnet
return 12.05;
return 12;

default:
throw new Error(`Block time for chain:${chainId} not specified`);
Expand Down
21 changes: 12 additions & 9 deletions src/lib/tenant/configs/ui/protocol-guild.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { TenantUI } from "@/lib/tenant/tenantUI";
import pguildLogo from "@/assets/tenant/pguild_logo.svg";
import pguildHero from "@/assets/tenant/pguild_hero.svg";
import successImage from "@/assets/tenant/ens_success.svg";
import pendingImage from "@/assets/tenant/ens_pending.svg";
import infoPageCard01 from "@/assets/tenant/optimism_info_1.png";
import infoPageCard02 from "@/assets/tenant/optimism_info_2.png";
import infoPageCard03 from "@/assets/tenant/optimism_info_3.png";
import infoPageCard04 from "@/assets/tenant/optimism_info_4.png";
import delegateAvatar from "@/assets/icons/delegateAvatar.svg";
import { ProposalGatingType, ProposalType } from "@/app/proposals/draft/types";
import { ProposalStage as PrismaProposalStage } from "@prisma/client";
Expand All @@ -17,8 +11,8 @@ export const protocolGuildTenantUIConfig = new TenantUI({

assets: {
// TODO: Replace success and pending images
success: successImage,
pending: pendingImage,
success: pguildHero,
pending: pguildHero,
delegate: delegateAvatar,
},

Expand Down Expand Up @@ -129,6 +123,10 @@ export const protocolGuildTenantUIConfig = new TenantUI({
],

toggles: [
{
name: "admin",
enabled: true,
},
{
name: "proposals",
enabled: true,
Expand Down Expand Up @@ -187,7 +185,12 @@ export const protocolGuildTenantUIConfig = new TenantUI({
proposalTypes: [ProposalType?.BASIC],
copy: {
helperText: `
## Proposal checklist`.trim(),
## Proposal checklist
- Make sure that you have simulated and review your transactions before seeking sponsorship.
- Check your markdown previews to ensure you didn't break any links.
- Review your description and make sure it's clear and concise.
- Remember that everything lasts forever onchain, check your spelling and grammar and make this one count. You got this.
`.trim(),
},
gatingType: ProposalGatingType?.TOKEN_THRESHOLD,
},
Expand Down
5 changes: 3 additions & 2 deletions src/lib/tokenUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export function formatNumberForAdvancedDelegation(amount: string) {
// Advanced delegation needs a precision up to 3 decimal places,
// which is bit different from the formatNumber function used everywhere else and requires for max 4 significant digits

const { token } = Tenant.current();
const { token, contracts } = Tenant.current();
const isERC721 = contracts.token.isERC721();

const number = Number(ethers.formatUnits(amount.toString(), token.decimals));

Expand All @@ -86,7 +87,7 @@ export function formatNumberForAdvancedDelegation(amount: string) {
currencyDisplay: "code",
compactDisplay: "short",
notation: "compact",
maximumFractionDigits: 3,
maximumFractionDigits: isERC721 ? 0 : 3,
});

const parts = numberFormat.formatToParts(number);
Expand Down
Loading