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

bump 32, adds 404 airball, change rules copy #72

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
130 changes: 65 additions & 65 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
{
"name": "juice-defifa-interface",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"ts:compile": "tsc",
"ts:compile:watch": "tsc --watch",
"ts:prune": "ts-prune"
},
"dependencies": {
"@apollo/client": "^3.7.1",
"@ballkidz/defifa-collection-deployer": "1.0.34",
"@headlessui/react": "^1.7.15",
"@heroicons/react": "^2.0.18",
"@jbx-protocol/juice-721-delegate": "7.0.0",
"@jbx-protocol/juice-contracts-v3": "3.1.2",
"@rainbow-me/rainbowkit": "^0.7.0",
"axios": "^1.1.3",
"bs58": "^4.0.1",
"ethers": "^5.7.1",
"forge-run-parser": "^1.0.3",
"google-spreadsheet": "^3.3.0",
"graphql": "^16.6.0",
"graphql-request": "^5.0.0",
"ipfs-http-client": "^60.0.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"next": "12.3.1",
"react": "^18.1.0",
"react-card-flip": "^1.2.0",
"react-confirm-alert": "^3.0.6",
"react-datepicker": "^4.12.0",
"react-dom": "18.2.0",
"react-query": "^3.39.2",
"react-table": "^7.8.0",
"react-tabs": "^6.0.0",
"react-toastify": "^9.1.1",
"reactjs-popup": "^2.0.5",
"sass": "^1.62.1",
"tailwind-merge": "^1.12.0",
"use-google-sheets": "^2.0.0",
"wagmi": "^0.6.7"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.3",
"@types/bs58": "^4.0.1",
"@types/lodash": "^4.14.188",
"@types/node": "18.7.19",
"@types/react": "18.0.21",
"@types/react-datepicker": "^4.11.2",
"@types/react-dom": "18.0.6",
"@types/react-slick": "^0.23.10",
"@types/react-table": "^7.7.14",
"autoprefixer": "^10.4.14",
"eslint": "8.24.0",
"eslint-config-next": "12.3.1",
"eslint-config-prettier": "^8.8.0",
"tailwindcss": "^3.3.2",
"ts-prune": "^0.10.3",
"typescript": "4.8.3"
}
}
"name": "juice-defifa-interface",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"ts:compile": "tsc",
"ts:compile:watch": "tsc --watch",
"ts:prune": "ts-prune"
},
"dependencies": {
"@apollo/client": "^3.7.1",
"@ballkidz/defifa-collection-deployer": "1.0.34",
"@headlessui/react": "^1.7.15",
"@heroicons/react": "^2.0.18",
"@jbx-protocol/juice-721-delegate": "7.0.0",
"@jbx-protocol/juice-contracts-v3": "3.1.2",
"@rainbow-me/rainbowkit": "^0.7.0",
"axios": "^1.1.3",
"bs58": "^4.0.1",
"ethers": "^5.7.1",
"forge-run-parser": "^1.0.3",
"google-spreadsheet": "^3.3.0",
"graphql": "^16.6.0",
"graphql-request": "^5.0.0",
"ipfs-http-client": "^60.0.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"next": "12.3.1",
"react": "^18.1.0",
"react-card-flip": "^1.2.0",
"react-confirm-alert": "^3.0.6",
"react-datepicker": "^4.12.0",
"react-dom": "18.2.0",
"react-query": "^3.39.2",
"react-table": "^7.8.0",
"react-tabs": "^6.0.0",
"react-toastify": "^9.1.1",
"reactjs-popup": "^2.0.5",
"sass": "^1.62.1",
"tailwind-merge": "^1.12.0",
"use-google-sheets": "^2.0.0",
"wagmi": "^0.6.7"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.3",
"@types/bs58": "^4.0.1",
"@types/lodash": "^4.14.188",
"@types/node": "18.7.19",
"@types/react": "18.0.21",
"@types/react-datepicker": "^4.11.2",
"@types/react-dom": "18.0.6",
"@types/react-slick": "^0.23.10",
"@types/react-table": "^7.7.14",
"autoprefixer": "^10.4.14",
"eslint": "8.24.0",
"eslint-config-next": "12.3.1",
"eslint-config-prettier": "^8.8.0",
"tailwindcss": "^3.3.2",
"ts-prune": "^0.10.3",
"typescript": "4.8.3"
}
}
Binary file added public/assets/404_Airball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export function RulesContent() {
<span className="ml-2">No fees are collected</span>
) : (
<>
{/* <EthAddress address={metadata?.fee_recipient} /> */}
<EthAddress address={tokenBeneficiary?.toString()} />
{/* <EnsName address={metadata?.fee_recipient} /> */}
<EnsName address={tokenBeneficiary?.toString()} />
<span className="ml-2">
collects a {metadata?.seller_fee_basis_points}% fee on each pick
minted.
Expand Down
62 changes: 62 additions & 0 deletions src/components/Mlb/Create/defaultState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { getChainData } from "config";
import { ETH_TOKEN_ADDRESS } from "constants/addresses";
import {
BALLKIDZ_MULTISIG_ADDRESS,
JUICEBOX_PROJECT_METADATA_DOMAIN,
MINT_PRICE,
} from "constants/constants";
import { constants } from "ethers";
import { formatUnits } from "ethers/lib/utils";
import { DefifaLaunchProjectData } from "types/defifa";

const DEFAULT_MINT_DURATION_SECONDS = 60 * 5; // 1 hour
const DEFAULT_REFUND_DURATION_SECONDS = 60 * 0; // 1 hour
const GAME_START_BUFFER_SECONDS = 60 * 1; // 1 minute

export const createDefaultLaunchProjectData = (): DefifaLaunchProjectData => {
const chainData = getChainData();
const currentUnixTimestamp = Math.floor(Date.now() / 1000);

const scoringStartTime =
currentUnixTimestamp +
DEFAULT_MINT_DURATION_SECONDS +
DEFAULT_REFUND_DURATION_SECONDS +
GAME_START_BUFFER_SECONDS;

return {
name: "",
rules: "",
mintDuration: DEFAULT_MINT_DURATION_SECONDS,
refundDuration: DEFAULT_REFUND_DURATION_SECONDS,
start: scoringStartTime,
votingPeriod: 0, // seconds, 0 to allow ratify as soon as quorum is reached.
votingStartTime: 0,
tiers: [],
splits: [],
token: ETH_TOKEN_ADDRESS,
ballkidzFeeProjectTokenAccount: BALLKIDZ_MULTISIG_ADDRESS,
defaultVotingDelegate: BALLKIDZ_MULTISIG_ADDRESS,
defaultTokenUriResolver: constants.AddressZero,
contractUri: "",
baseUri: "ipfs://",
distributionLimit: 0,
projectMetadata: {
content: "",
domain: JUICEBOX_PROJECT_METADATA_DOMAIN,
},
terminal: chainData.JBETHPaymentTerminal.address,
store: chainData.JBTiered721DelegateStore.address,
};
};

export const createDefaultTierData = () => {
return {
name: "",
price: formatUnits(MINT_PRICE),
reservedRate: 0,
reservedTokenBeneficiary: constants.AddressZero,
encodedIPFSUri:
"0x0000000000000000000000000000000000000000000000000000000000000000",
shouldUseReservedTokenBeneficiaryAsDefault: false,
};
};
125 changes: 125 additions & 0 deletions src/components/Mlb/Create/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import React, { useState, useEffect } from 'react';
import { useCreateGame } from 'hooks/write/useCreateGame';
import { DefifaLaunchProjectData, DefifaTierParams } from 'types/defifa';
import { contractUri, projectMetadataUri } from 'uri/contractUri';
import { createDefaultLaunchProjectData, createDefaultTierData } from './defaultState';
import { constants } from 'ethers';
import useScheduleData from '../../../hooks/read/AllMlbGames';

const MlbCreate = () => {
const [project, setProject] = useState<DefifaLaunchProjectData>(createDefaultLaunchProjectData());
const { tableData, loading, resetTableData } = useScheduleData();
const [tier, setTier] = useState<DefifaTierParams>(createDefaultTierData());

console.log('project', project);

const { write: createTournament, isLoading, isSuccess, transactionData } = useCreateGame(project);

function addSpacesToWords(str) {
const words = str.split(' ');
let result = '';
let count = 0;

for (let i = 0; i < words.length; i++) {
if (count + words[i].length > 10) {
result += ' ';
count = 0;
}
result += words[i] + ' ';
count += words[i].length + 1;
}

return result.trim();
}


const handleCheckboxClick = (event: React.ChangeEvent<HTMLInputElement>, game: any, index: number) => {
const checked = event.target.checked;
console.log('Checkbox clicked on row:', index, 'checked:', checked);

const awayTeam = addSpacesToWords(game?.teams?.away.team.name) || '';
const homeTeam = addSpacesToWords(game?.teams?.home.team.name) || '';
console.log('awayTeam', awayTeam);
console.log('homeTeam', homeTeam);

const startTime = Math.floor(new Date(game.gameDate).getTime() / 1000); // Convert to Unix epoch time
const now = Math.floor(Date.now() / 1000); // Current Unix epoch time
const oneMinute = 60; // One minute in seconds
const mintDuration = startTime - (now + oneMinute);
const refundDuration = 3600; // 1 hour in seconds
if (now >= startTime - refundDuration) {
console.log('Refund time has passed');
}
const updatedTiers = [
{
...tier,
name: awayTeam,
},
{
...tier,
name: homeTeam,
},
];

const updatedProject: DefifaLaunchProjectData = {
...project,
name: `${awayTeam} @ ${homeTeam} on ${game?.gameDate}`,
start: startTime,
mintDuration: mintDuration,
refundDuration: refundDuration,
tiers: updatedTiers,
};

setProject(updatedProject);

try {
createTournament(); // Call createTournament function to trigger game creation
} catch (error) {
console.error('Failed to create game:', error);
}
};

return (
<div>
{loading ? (
<p>Loading...</p>
) : (
<table className="border-collapse w-full">
<thead>
<tr>
<th className="border border-gray-300 py-2 px-4 ">Create</th>
<th className="border border-gray-300 py-2 px-4 ">First Pitch</th>
<th className="border border-gray-300 py-2 px-4 ">Away</th>
<th className="border border-gray-300 py-2 px-4 ">Home</th>
{/* Add more table header columns as needed */}
</tr>
</thead>
<tbody>
{tableData?.map((games, index) => (
<tr key={index}>
<td className="border border-gray-300 py-2 px-4">
<input
type="checkbox"
onChange={(event) => handleCheckboxClick(event, games, index)}
/>
</td>
<td className="border border-gray-300 py-2 px-4">
{new Date(games.gameDate).toLocaleString()}
</td>
<td className="border border-gray-300 py-2 px-4">
{games.teams?.away.team.name}
</td>
<td className="border border-gray-300 py-2 px-4">
{games.teams?.home.team.name}
</td>
{/* Render additional table cells based on your API response */}
</tr>
))}
</tbody>
</table>
)}
</div>
);
};

export default MlbCreate;
15 changes: 15 additions & 0 deletions src/components/Mlb/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Container from "components/layout/Container";
import Navbar from "../layout/Navbar";
import MlbCreate from "./Create";

const MlbWrapper = () => {
return (
<Container>
<Navbar />

<MlbCreate />
</Container>
);
};

export default MlbWrapper;
Loading