Skip to content

Commit

Permalink
fix: non-aggression was using the wrong epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
rsproule committed Jan 3, 2024
1 parent da7ed27 commit c5f15b4
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 18 deletions.
3 changes: 0 additions & 3 deletions frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import Link from "next/link";
import { EventStream } from "../components/tankGame/EventsStream";
import { TankGame } from "../components/tankGame/TankGame";
import { Button } from "../components/ui/button";
import { Toaster } from "../components/ui/toaster";
import { Connected } from "../components/wagmi/Connected";
import Manifesto from "../components/tankGame/Manifesto";
export default function HomePage() {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { ConnectKitProvider } from 'connectkit'
import * as React from 'react'
import { WagmiConfig } from 'wagmi'

import { config } from '../wagmi'

export function Providers({ children }: { children: React.ReactNode }) {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/tankGame/EventsStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export async function getTankNameFromJoinIndex(
}
let logs = await getLogs(address);
let joinLogs = logs.filter((log) => log.eventName == "PlayerJoined");
console.log({ joinLogs });
// @ts-ignore
let name = joinLogs.find((log) => log.args.tankId === tankId);
// @ts-ignore
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/tankGame/PlayerDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export default function PlayerDropdown({
targetTank: string | undefined;
gameAddress: Address;
}) {
console.log({ gameAddress })
const tanks = useTanks(gameAddress);
console.log({ tanks });
return (
<Select value={targetTank} onValueChange={setTargetTank}>
<SelectTrigger>
Expand All @@ -28,7 +26,7 @@ export default function PlayerDropdown({
{tanks.map((tank, i) => {
return (
<SelectItem key={i} value={(i + 1).toString()}>
{tank}
{i} - {tank}
</SelectItem>
);
})}
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/treaties/Bounty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export default function Bounty({
addedHooks: any;
}) {
const tankName = useTankNameFromId(gameAddress, tankId);
console.log({ tankName });
console.log({ tankId });
const { address } = useAccount();
const ownerTank = useTankGamePlayers({
// @ts-ignore
Expand Down Expand Up @@ -300,6 +298,5 @@ function TankName({
gameAddress: Address;
}) {
const tankName = useTankNameFromId(gameAddress, tankId);
console.log({ tankName });
return <div>{tankName}</div>;
}
6 changes: 3 additions & 3 deletions frontend/src/components/treaties/NonAggression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
useNonAggressionAccept,
useGameViewGetEpoch,
gameViewAddress,
useGameViewGetGameEpoch,
} from "@/src/generated";
import { useState, useEffect } from "react";
import { Address, BaseError } from "viem";
Expand Down Expand Up @@ -40,7 +41,7 @@ export default function NonAggression({
enabled: !!address,
});
const { chain } = useNetwork();
const { data: epoch } = useGameViewGetEpoch({
const { data: epoch } = useGameViewGetGameEpoch({
// @ts-ignore
address: gameViewAddress[chain?.id as keyof typeof gameViewAddress],
watch: true,
Expand All @@ -66,7 +67,6 @@ export default function NonAggression({
const acceptedTreaties = allLogs.filter(
(bounty: any) => bounty.eventName === "AcceptedTreaty"
);

const filteredProposedTreaties = proposedTreaties
.filter(
(proposedTreaty: any) =>
Expand All @@ -76,7 +76,7 @@ export default function NonAggression({
acceptedTreaty.args.proposee === proposedTreaty.args.proposee &&
acceptedTreaty.args.expiry === proposedTreaty.args.expiry &&
acceptedTreaty.args.hookProposer ===
proposedTreaty.args.proposalHook
proposedTreaty.args.proposalHook
)
)
.filter((treaty: any) => treaty.args.expiry > epoch!);
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/wagmi/Connected.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"use client";

import Manifesto from "../tankGame/Manifesto";

export function Connected({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
4 changes: 2 additions & 2 deletions frontend/src/wagmi.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getDefaultConfig } from "connectkit";
import { goerli, foundry } from "viem/chains";
import { foundry, goerli } from "viem/chains";
import { createConfig } from "wagmi";
const walletConnectProjectId = process.env.NEXT_PUBLIC_WALLET_CONNECT_APP!;
const alchemyId = process.env.NEXT_PUBLIC_ALCHEMY_ID!;

export const config = createConfig(
getDefaultConfig({
autoConnect: true,
appName: "TactV2",
appName: "Tact",
walletConnectProjectId,
alchemyId: alchemyId,
chains: [goerli, foundry],
Expand Down

0 comments on commit c5f15b4

Please sign in to comment.