Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed Apr 6, 2024
1 parent 5d9e140 commit 75eb0f3
Show file tree
Hide file tree
Showing 8 changed files with 426 additions and 489 deletions.
3 changes: 2 additions & 1 deletion packages/foundry/contracts/Reputation/ReputationFaucet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
pragma solidity ^0.8.19;

import {ReputationTokens} from "@atxdao/contracts/reputation/ReputationTokens.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";

contract ReputationFaucet {
contract ReputationFaucet is ERC1155Holder {
ReputationTokens reputationTokens;

constructor(address addr) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { NextPage } from "next";
import { useScaffoldContract } from "~~/hooks/scaffold-eth";

const Home: NextPage = () => {
const { data: repTokensInstance } = useScaffoldContract({ contractName: "ReputationTokensStandalone" });
const { data: repTokensInstance } = useScaffoldContract({ contractName: "ReputationTokens" });

return (
<>
Expand Down
29 changes: 13 additions & 16 deletions packages/nextjs/app/rep-tokens-demo/_components/RepTokensDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ import { DescriptionCard } from "~~/components/rep-tokens/cards/stylized-cards/t
import { ImageCard } from "~~/components/rep-tokens/cards/stylized-cards/token-properties/ImageCard";
import { MaxMintAmountPerTxCard } from "~~/components/rep-tokens/cards/stylized-cards/token-properties/MaxMintAmountPerTxCard";
import { NameCard } from "~~/components/rep-tokens/cards/stylized-cards/token-properties/NameCard";
import { RedeemableCard } from "~~/components/rep-tokens/cards/stylized-cards/token-properties/RedeemableCard";
import { SoulboundCard } from "~~/components/rep-tokens/cards/stylized-cards/token-properties/SoulboundCard";
// import { RedeemableCard } from "~~/components/rep-tokens/cards/stylized-cards/token-properties/RedeemableCard";
// import { SoulboundCard } from "~~/components/rep-tokens/cards/stylized-cards/token-properties/SoulboundCard";
import { TokenTypeCard } from "~~/components/rep-tokens/cards/stylized-cards/token-properties/TokenTypeCard";
import { useGetRepToken } from "~~/components/rep-tokens/hooks/Hooks";

// import { useScaffoldContract, useScaffoldContractWrite } from "~~/hooks/scaffold-eth";

export function RepTokensDemo() {
console.log("Hello");
const { address } = useAccount();

const { token } = useGetRepToken(address, BigInt(0));
Expand Down Expand Up @@ -63,6 +65,8 @@ export function RepTokensDemo() {

// const widgetComponents: ReputationComponent[] = ["Balance", "Image"];

console.log(token);

return (
<>
<div className="py-5 space-y-5 flex flex-col justify-center items-center bg-[length:100%_100%] py-1 px-5 sm:px-0 lg:py-auto max-w-[100vw] ">
Expand All @@ -84,11 +88,9 @@ export function RepTokensDemo() {
>
Claim Tokens
</button> */}

{/* <StylizedTokenGroupCard2 tokens={tokensData.tokens} components={mainComponents}>
<StylizedAddressCard address={tokensData.address} isGroup={true} />
</StylizedTokenGroupCard2> */}

<div className="flex">
<div>
<p className="text-center text-4xl">Individual Components 1</p>
Expand All @@ -97,8 +99,7 @@ export function RepTokensDemo() {
<StylizedStringCard value={token?.name} type="bold" />
<StylizedStringCard value={token?.description} />
<StylizedAddressCard address={token?.address} />
<StylizedStringCard value={`Soulbound: ${token?.properties?.isSoulbound?.toString()}`} />
<StylizedStringCard value={`Redeemable: \n ${token?.properties?.isRedeemable?.toString()}`} />
<StylizedStringCard value={`Token Type: ${token?.properties?.tokenType?.toString()}`} />
<StylizedStringCard
value={`Max Mint Amount Per Tx: \n${token?.properties?.maxMintAmountPerTx?.toString()}`}
/>
Expand All @@ -111,8 +112,7 @@ export function RepTokensDemo() {
<NameCard name={token?.name} />
<DescriptionCard description={token?.description} />
<AddressCard address={token?.address} />
<SoulboundCard isSoulbound={token?.properties?.isSoulbound} />
<RedeemableCard isRedeemable={token?.properties?.isRedeemable} />
<TokenTypeCard tokenType={token?.properties?.tokenType} />
<MaxMintAmountPerTxCard maxMintAmountPerTx={token?.properties?.maxMintAmountPerTx} />
</div>

Expand All @@ -123,12 +123,10 @@ export function RepTokensDemo() {
<NameCard token={token} />
<DescriptionCard token={token} />
<AddressCard token={token} />
<SoulboundCard token={token} />
<RedeemableCard token={token} />
<TokenTypeCard token={token} />
<MaxMintAmountPerTxCard token={token} />
</div>
</div>

<div className="flex">
<div>
<p className="text-center text-4xl">Single Card 1</p>
Expand All @@ -143,8 +141,8 @@ export function RepTokensDemo() {
<StylizedStringCard value={token?.name} type="bold" />
<StylizedStringCard value={token?.description} />
<StylizedAddressCard address={token?.address} />
<StylizedStringCard value={`Soulbound: ${token?.properties?.isSoulbound?.toString()}`} />
<StylizedStringCard value={`Redeemable: \n ${token?.properties?.isRedeemable?.toString()}`} />
<StylizedStringCard value={`Token Type: ${token?.properties?.tokenType?.toString()}`} />

<StylizedStringCard
value={`Max Mint Amount Per Tx \n${token?.properties?.maxMintAmountPerTx?.toString()}`}
/>
Expand All @@ -159,13 +157,12 @@ export function RepTokensDemo() {
<NameCard token={token} />
<DescriptionCard token={token} />
<AddressCard token={token} />
<SoulboundCard token={token} />
<RedeemableCard token={token} />
<TokenTypeCard token={token} />

<MaxMintAmountPerTxCard token={token} />
</StylizedTokenCard2>
</div>
</div>

{/* <p className="text-center text-4xl">Multi-Card</p>
<StylizedTokenGroupCard tokens={tokensData.tokens} components={mainComponents}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@ export const StylizedTokenCard = ({
size = "base",
// children,
token,
components = [
"Balance",
"Image",
"Name",
"Description",
"Address",
"IsSoulbound",
"IsRedeemable",
"MaxMintAmountPerTx",
],
components = ["Balance", "Image", "Name", "Description", "Address", "TokenType", "MaxMintAmountPerTx"],
isBalanceOverlayed = false,
}: TokenCardInternalProps) => {
const cardContent: JSX.Element[] = [];
Expand Down Expand Up @@ -85,16 +76,8 @@ export const StylizedTokenCard = ({
cardContent.push(<StylizedStringCard key={j} value={token?.description} />);
}

if (components[j] === "IsSoulbound") {
cardContent.push(
<StylizedStringCard key={j} value={`Soulbound: ${token?.properties?.isSoulbound?.toString()}`} />,
);
}

if (components[j] === "IsRedeemable") {
cardContent.push(
<StylizedStringCard key={j} value={`Redeemable: ${token?.properties?.isRedeemable?.toString()}`} />,
);
if (components[j] === "TokenType") {
cardContent.push(<StylizedStringCard value={`Token Type: ${token?.properties?.tokenType?.toString()}`} />);
}

if (components[j] === "MaxMintAmountPerTx") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,12 @@ export type ReputationComponent =
| "Name"
| "Description"
| "Address"
| "IsSoulbound"
| "IsRedeemable"
| "TokenType"
| "MaxMintAmountPerTx";

export const StylizedTokenGroupCard = ({
tokens,
components = [
"Balance",
"Image",
"Name",
"Description",
"Address",
"IsSoulbound",
"IsRedeemable",
"MaxMintAmountPerTx",
],
components = ["Balance", "Image", "Name", "Description", "Address", "TokenType", "MaxMintAmountPerTx"],
isBalanceOverlayed,
children,
size = "base",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { StylizedStringCard } from "../StylizedStringCard";
import { Token } from "~~/components/rep-tokens/hooks/Hooks";

type Props = {
token?: Token;
tokenType?: number;
type?: "default" | "bold";
};

export const TokenTypeCard = ({ token, tokenType, type = "default" }: Props) => {
let i = "Token Type: ";

if (token) {
if (token?.properties?.tokenType === 0) {
i += "Transferable";
} else if (token?.properties?.tokenType === 1) {
i += "Soulbound";
} else if (token?.properties?.tokenType === 2) {
i += "Redeemable";
}
} else if (tokenType) {
if (tokenType === 0) {
i += "Transferable";
} else if (tokenType === 1) {
i += "Soulbound";
} else if (tokenType === 2) {
i += "Redeemable";
}
}

return (
<StylizedStringCard
value={i}
// value={`Soulbound: ` + (token ? token?.properties?.isSoulbound?.toString() : isSoulbound?.toString())}
type={type}
/>
);
};
10 changes: 5 additions & 5 deletions packages/nextjs/components/rep-tokens/hooks/Hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ export interface Nft {

export const useUri = (tokenId?: number) => {
return useScaffoldContractRead({
contractName: "ReputationTokensStandalone",
contractName: "ReputationTokens",
functionName: "uri",
args: [BigInt(Number(tokenId))],
});
};

export const useBalanceOf = (address?: string, tokenId?: number) => {
return useScaffoldContractRead({
contractName: "ReputationTokensStandalone",
contractName: "ReputationTokens",
functionName: "balanceOf",
args: [address, BigInt(Number(tokenId))],
});
Expand Down Expand Up @@ -139,18 +139,18 @@ export function useGetTokensProperties(repTokensInstance: any, tokenIds: bigint[
// }

export const useGetRepToken = (address?: string, tokenId?: bigint) => {
const { data: repTokensInstance } = useScaffoldContract({ contractName: "ReputationTokensStandalone" });
const { data: repTokensInstance } = useScaffoldContract({ contractName: "ReputationTokens" });

const { data: balanceOf, refetch: refetchBalance } = useScaffoldContractRead({
contractName: "ReputationTokensStandalone",
contractName: "ReputationTokens",
functionName: "balanceOf",
args: [address, tokenId],
});

const { tokenProperties } = useGetTokenProperties(repTokensInstance, tokenId || BigInt(0));

const { data: uri } = useScaffoldContractRead({
contractName: "ReputationTokensStandalone",
contractName: "ReputationTokens",
functionName: "uri",
args: [tokenId],
});
Expand Down
Loading

0 comments on commit 75eb0f3

Please sign in to comment.