Skip to content

Commit

Permalink
supports all token types on the frontend and deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobHomanics committed Mar 27, 2024
1 parent ff5d21b commit d30751d
Show file tree
Hide file tree
Showing 22 changed files with 393 additions and 1,768 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"account": "yarn workspace @se-2/foundry account",
"chain": "yarn workspace @se-2/foundry chain",
"compile": "yarn workspace @se-2/foundry compile",
"deployDemo": "yarn workspace @se-2/foundry deployDemo",
"deployDemo:verify": "yarn workspace @se-2/foundry deployDemo:verify",
"deploy": "yarn workspace @se-2/foundry deploy",
"deploy:verify": "yarn workspace @se-2/foundry deploy:verify",
"fork": "yarn workspace @se-2/foundry fork",
"foundry:lint": "yarn workspace @se-2/foundry lint",
"foundry:test": "yarn workspace @se-2/foundry test",
Expand Down
2 changes: 1 addition & 1 deletion packages/foundry/lib/reputation
Submodule reputation updated 1263 files
4 changes: 2 additions & 2 deletions packages/foundry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"account": "node script/ListAccount.js",
"chain": "anvil --config-out localhost.json",
"compile": "forge compile",
"deployDemo": "forge build --build-info --build-info-path out/build-info/ && forge script script/DeployDemo.s.sol --rpc-url ${1:-default_network} --broadcast --legacy && node script/generateTsAbis__deployDemo.js",
"deployDemo:verify": "forge build --build-info --build-info-path out/build-info/ && forge script script/DeployDemo.s.sol --rpc-url ${1:-default_network} --broadcast --legacy --verify ; node script/generateTsAbis__deployDemo.js",
"deploy": "forge build --build-info --build-info-path out/build-info/ && forge script script/Deploy.s.sol --rpc-url ${1:-default_network} --broadcast --legacy && node script/generateTsAbis.js",
"deploy:verify": "forge build --build-info --build-info-path out/build-info/ && forge script script/Deploy.s.sol --rpc-url ${1:-default_network} --broadcast --legacy --verify ; node script/generateTsAbis.js",
"fork": "anvil --fork-url ${0:-mainnet} --chain-id 31337 --config-out localhost.json",
"generate": "node script/generateAccount.js",
"lint": "forge fmt",
Expand Down
2 changes: 1 addition & 1 deletion packages/foundry/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts
@atxdao/contracts/reputation=lib/reputation/src
@atxdao/contracts/reputation=lib/reputation/contracts
25 changes: 25 additions & 0 deletions packages/foundry/script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {console} from "forge-std/console.sol";

import {ScaffoldETHDeploy} from "./DeployHelpers.s.sol";
import {ReputationTokensStandalone} from "@atxdao/contracts/reputation/ReputationTokensStandalone.sol";
import {TokensPropertiesStorage} from "@atxdao/contracts/reputation/storage/TokensPropertiesStorage.sol";
import {IReputationTokensInternal} from "@atxdao/contracts/reputation/interfaces/IReputationTokensInternal.sol";
import {Hats} from "../contracts/Hats/Hats.sol";

import {DeployDemoScript} from "./DeployDemo.s.sol";

contract DeployScript is ScaffoldETHDeploy {
error InvalidPrivateKey(string);

address controller = 0x62286D694F89a1B12c0214bfcD567bb6c2951491; //replace with burner or other address from wallet!

function run() external {
DeployDemoScript deployer = new DeployDemoScript();
deployer.run();

exportDeployments();
}
}
28 changes: 22 additions & 6 deletions packages/foundry/script/DeployDemo.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {Hats} from "../contracts/Hats/Hats.sol";
contract DeployDemoScript is ScaffoldETHDeploy {
error InvalidPrivateKey(string);

address controller = 0x62286D694F89a1B12c0214bfcD567bb6c2951491; //replace with burner or other address from wallet!
address controller = 0x4161f8A8DfF60aEdB63baFb7d5843b0988393eC9; //replace with burner or other address from wallet!

function run() external {
uint256 deployerPrivateKey = setupLocalhostEnv();
Expand Down Expand Up @@ -64,8 +64,6 @@ contract DeployDemoScript is ScaffoldETHDeploy {
// console.log(newHatId);

vm.stopBroadcast();

exportDeployments();
}

///////////////////////////////////
Expand All @@ -87,19 +85,27 @@ contract DeployDemoScript is ScaffoldETHDeploy {
function batchCreateTokens(ReputationTokensStandalone instance) public {
TokensPropertiesStorage.TokenProperties[]
memory tokensProperties = new TokensPropertiesStorage.TokenProperties[](
2
3
);

tokensProperties[0] = TokensPropertiesStorage.TokenProperties(
true,
false,
100
);

tokensProperties[1] = TokensPropertiesStorage.TokenProperties(
true,
true,
100
);

tokensProperties[2] = TokensPropertiesStorage.TokenProperties(
false,
false,
100
);

instance.batchCreateTokens(tokensProperties);
}

Expand All @@ -109,22 +115,32 @@ contract DeployDemoScript is ScaffoldETHDeploy {

instance.setTokenURI(0, string.concat(BASE_URI, "0"));
instance.setTokenURI(1, string.concat(BASE_URI, "1"));
instance.setTokenURI(
2,
"ipfs://bafkreiheocygb3ty4uo3znjw2wz2asjzavn56owlqjoz4cvxvspg64egtq"
);
}

function batchMint(ReputationTokensStandalone instance) public {
IReputationTokensInternal.TokensOperations memory mintOperations;
mintOperations.to = controller;

mintOperations
.operations = new IReputationTokensInternal.TokenOperation[](2);
.operations = new IReputationTokensInternal.TokenOperation[](3);
mintOperations.operations[0] = IReputationTokensInternal.TokenOperation(
0,
50
);
mintOperations.operations[1] = IReputationTokensInternal.TokenOperation(
1,
50
25
);

mintOperations.operations[2] = IReputationTokensInternal.TokenOperation(
2,
75
);

instance.mint(mintOperations);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ function getArtifactOfContract(contractName) {

function getInheritedFromContracts(artifact) {
let inheritedFromContracts = [];
for (const astNode of artifact.ast.nodes) {
if (astNode.nodeType == "ContractDefinition") {
if (astNode.baseContracts.length > 0) {
inheritedFromContracts = astNode.baseContracts.map(
({ baseName }) => baseName.name
);
if (artifact.ast) {
for (const astNode of artifact.ast.nodes) {
if (astNode.nodeType == "ContractDefinition") {
if (astNode.baseContracts.length > 0) {
inheritedFromContracts = astNode.baseContracts.map(
({ baseName }) => baseName.name
);
}
}
}
}

return inheritedFromContracts;
}

Expand All @@ -69,7 +72,7 @@ function main() {
const current_path_to_broadcast = path.join(
__dirname,
"..",
"broadcast/DeployDemo.s.sol"
"broadcast/Deploy.s.sol"
);
const current_path_to_deployments = path.join(__dirname, "..", "deployments");

Expand Down
84 changes: 47 additions & 37 deletions packages/nextjs/app/rep-tokens-demo/_components/RepTokensDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { addressConfigProps } from "./configs/values/AddressCardConfig";
import { balanceConfigProps } from "./configs/values/BalanceCardConfig";
import { descriptionConfigProps } from "./configs/values/DescriptionCardConfig";
import { imageConfigProps } from "./configs/values/ImageCardConfig";
import { isTradeableConfigProps } from "./configs/values/IsTradeableCardConfig";
import { isRedeemableConfigProps } from "./configs/values/IsRedeemableCardConfig";
import { isSoulboundConfigProps } from "./configs/values/IsSoulboundCardConfig";
import { maxMintAmountConfigProps } from "./configs/values/MaxMintAmountCardConfig";
import { nameConfigProps } from "./configs/values/NameCardConfig";
import { useAccount } from "wagmi";
Expand Down Expand Up @@ -44,29 +45,6 @@ export function RepTokensDemo() {
////// Card Creation
/////

// Individual Components
const balanceProps = buildBalanceCard(tokensData?.tokens[0]?.balance, balanceConfigProps);
const nameProps = buildStringCard(tokensData?.tokens[0]?.name, nameConfigProps);
const descriptionsProps = buildStringCard(tokensData?.tokens[0]?.description, descriptionConfigProps);
const imageProps = buildImageCard(tokensData?.tokens[0]?.image, imageConfigProps);
const addressProps = buildStringCard(tokensData?.address, addressConfigProps);

const isTradeableProps = buildStringCard(
tokensData?.tokens[0]?.properties?.isTradeable !== undefined
? `Is Tradeable: ${tokensData?.tokens[0]?.properties.isTradeable}`
: undefined,
isTradeableConfigProps,
);
const maxMintAmountProps = buildStringCard(
tokensData?.tokens[0]?.properties?.maxMintAmountPerTx !== undefined
? `Max Mint Amount Per Tx: ${tokensData?.tokens[0]?.properties.maxMintAmountPerTx}`
: undefined,
maxMintAmountConfigProps,
);

// Single Card
const singleCard = buildTokenCard(tokensData?.tokens[0], tokensData.address, singleCardConfig);

// Multi-card
const mainTokenCards = buildTokenCards(
tokensData.tokens,
Expand Down Expand Up @@ -116,31 +94,63 @@ export function RepTokensDemo() {
navBarTokenGroupCardProps.addressOutput = <Address props={navBarTokenGroupCardProps.addressProps} />;
}

// Single Card
const singleCard = buildTokenCard(tokensData?.tokens[0], tokensData.address, singleCardConfig);

// Individual Components
const balanceProps = buildBalanceCard(tokensData?.tokens[0]?.balance, balanceConfigProps);
const nameProps = buildStringCard(tokensData?.tokens[0]?.name, nameConfigProps);
const descriptionsProps = buildStringCard(tokensData?.tokens[0]?.description, descriptionConfigProps);
const imageProps = buildImageCard(tokensData?.tokens[0]?.image, imageConfigProps);
const addressProps = buildStringCard(tokensData?.address, addressConfigProps);

const isSoulboundProps = buildStringCard(
tokensData?.tokens[0]?.properties?.isSoulbound !== undefined
? `Is Soulbound: ${tokensData?.tokens[0]?.properties.isSoulbound}`
: undefined,
isSoulboundConfigProps,
);

const isRedeemableProps = buildStringCard(
tokensData?.tokens[0]?.properties?.isRedeemable !== undefined
? `Is Redeemable: ${tokensData?.tokens[0]?.properties.isRedeemable}`
: undefined,
isRedeemableConfigProps,
);

const maxMintAmountProps = buildStringCard(
tokensData?.tokens[0]?.properties?.maxMintAmountPerTx !== undefined
? `Max Mint Amount Per Tx: ${tokensData?.tokens[0]?.properties.maxMintAmountPerTx}`
: undefined,
maxMintAmountConfigProps,
);

return (
<>
<div className="py-5 space-y-5 flex flex-col justify-center items-center bg-primary bg-[length:100%_100%] py-1 px-5 sm:px-0 lg:py-auto max-w-[100vw] ">
<p className="text-center text-4xl">Widget</p>
<TokenGroupCard props={navBarTokenGroupCardProps} />

<p className="text-center text-4xl">Multi-Card</p>
<TokenGroupCard props={mainTokenGroupCardProps} />

<p className="text-center text-4xl">Multi-Card W/ Overlay</p>
<TokenGroupCard props={mainTokenGroupOverlayCardProps} />

<p className="text-center text-4xl">Single Card</p>
<TokenCard props={singleCard} />

<p className="text-center text-4xl">Individual Components</p>
<div className="flex flex-wrap justify-center items-center space-x-3 space-y-3">
<BalanceCard props={balanceProps} />
<ImageCard props={imageProps} />
<StringCard props={nameProps} />
<StringCard props={descriptionsProps} />
<Address props={addressProps} />
<StringCard props={isTradeableProps} />
<StringCard props={isSoulboundProps} />
<StringCard props={isRedeemableProps} />
<StringCard props={maxMintAmountProps} />
</div>

<p className="text-center text-4xl">Single Card</p>
<TokenCard props={singleCard} />

<p className="text-center text-4xl">Multi-Card</p>
<TokenGroupCard props={mainTokenGroupCardProps} />

<p className="text-center text-4xl">Multi-Card W/ Overlay</p>
<TokenGroupCard props={mainTokenGroupOverlayCardProps} />

<p className="text-center text-4xl">Widget</p>
<TokenGroupCard props={navBarTokenGroupCardProps} />
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ export const addressConfigProps = {
},
} as ValueCardConfigProps;

export const isTradeableConfigProps = {
export const isSoulboundConfigProps = {
isRendering: true,
classes: {
card: "rounded-lg bg-slate-300 ",
value: "text-1xl text-center object-center mx-auto font-bold break-all text-black",
},
} as ValueCardConfigProps;

export const isRedeemableConfigProps = {
isRendering: true,
classes: {
card: "rounded-lg bg-slate-300 ",
Expand All @@ -70,7 +78,8 @@ export const tokenCardValuesProps = {
nameConfigProps,
descriptionConfigProps,
addressConfigProps,
isTradeableConfigProps,
isSoulboundConfigProps,
isRedeemableConfigProps,
maxMintAmountConfigProps,
} as TokenCardValuesConfigProps;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ export const addressConfigProps = {
},
} as ValueCardConfigProps;

export const isTradeableConfigProps = {
export const isSoulboundConfigProps = {
isRendering: true,
classes: {
card: "rounded-lg bg-slate-300 ",
value: "text-1xl text-center object-center mx-auto font-bold break-all text-black",
},
} as ValueCardConfigProps;

export const isRedeemableConfigProps = {
isRendering: true,
classes: {
card: "rounded-lg bg-slate-300 ",
Expand All @@ -70,7 +78,8 @@ export const tokenCardValuesProps = {
nameConfigProps,
descriptionConfigProps,
addressConfigProps,
isTradeableConfigProps,
isSoulboundConfigProps,
isRedeemableConfigProps,
maxMintAmountConfigProps,
} as TokenCardValuesConfigProps;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ export const addressConfigProps = {
},
} as ValueCardConfigProps;

export const isTradeableConfigProps = {
export const isSoulboundConfigProps = {
isRendering: true,
classes: {
card: "rounded-lg bg-indigo-300 ",
card: "rounded-lg bg-slate-300 ",
value: "text-1xl text-center object-center mx-auto font-bold break-all text-black",
},
} as ValueCardConfigProps;

export const isRedeemableConfigProps = {
isRendering: true,
classes: {
card: "rounded-lg bg-slate-300 ",
value: "text-1xl text-center object-center mx-auto font-bold break-all text-black",
},
} as ValueCardConfigProps;
Expand All @@ -69,7 +77,8 @@ export const tokenCardValuesProps = {
nameConfigProps,
descriptionConfigProps,
addressConfigProps,
isTradeableConfigProps,
isSoulboundConfigProps,
isRedeemableConfigProps,
maxMintAmountConfigProps,
} as TokenCardValuesConfigProps;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ValueCardConfigProps } from "~~/components/rep-tokens/types/Types";

export const isRedeemableConfigProps = {
isRendering: true,
classes: {
card: "w-64 rounded-lg bg-indigo-300 ",
value: "text-1xl text-center object-center mx-auto font-bold break-all text-black",
},
isPrettyLoading: {
classes: "text-black text-center",
message: "Loading Is Tradeable...",
},
} as ValueCardConfigProps;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ValueCardConfigProps } from "~~/components/rep-tokens/types/Types";

export const isTradeableConfigProps = {
export const isSoulboundConfigProps = {
isRendering: true,
classes: {
card: "w-64 rounded-lg bg-indigo-300 ",
Expand Down
Loading

0 comments on commit d30751d

Please sign in to comment.