Skip to content

Commit

Permalink
fix: tank not updated to support multigame, bounty was broken
Browse files Browse the repository at this point in the history
  • Loading branch information
rsproule committed Jan 4, 2024
1 parent c5f15b4 commit c764bbd
Show file tree
Hide file tree
Showing 3 changed files with 6,820 additions and 11,122 deletions.
24 changes: 17 additions & 7 deletions frontend/src/components/tankGame/Tank.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Droplet, Heart, Target, User, Zap } from "lucide-react";
import { ITank } from "./ITank";
import { useTankGameGetEpoch, useTankGameLastDripEpoch } from "@/src/generated";
import { DropdownMenu, DropdownMenuContent } from "../ui/dropdown-menu";
import { Address} from "viem";
import { Address } from "viem";
import { useTankNameFromId } from "./EventsStream";

interface TankProps {
Expand All @@ -13,17 +13,29 @@ interface TankProps {
left: number;
} | null;
onChange: () => void;
address: Address
address: Address;
}
export function Tank({ tankObj, open, position, onChange, address }: TankProps) {
export function Tank({
tankObj,
open,
position,
onChange,
address,
}: TankProps) {
const { tank, tankId } = tankObj;
const tankName = useTankNameFromId(address, tankId);
let lastDripEpoch = useTankGameLastDripEpoch({
args: [tankId],
enabled: !!tankId,
watch: true,
// @ts-ignore
address: address,
});
let currentEpoch = useTankGameGetEpoch({
watch: true,
// @ts-ignore
address: address,
});
let currentEpoch = useTankGameGetEpoch({ watch: true });
return (
<div>
<DropdownMenu open={open} onOpenChange={onChange}>
Expand All @@ -48,9 +60,7 @@ export function Tank({ tankObj, open, position, onChange, address }: TankProps)
</div>
<div className="flex items-center pt-2">
<User className="mr-2 h-4 w-4 " />
<span className="text-xs">
Owner name: {tankName}
</span>
<span className="text-xs">Owner name: {tankName}</span>
</div>
<div className="flex items-center pt-2">
<Heart className="mr-2 h-4 w-4 " />{" "}
Expand Down
21 changes: 15 additions & 6 deletions frontend/src/components/treaties/Bounty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
} from "@/src/generated";
import { useState, useEffect } from "react";
import { Address, BaseError, formatEther } from "viem";
import { useAccount, useBlockNumber, useWaitForTransaction } from "wagmi";
import {
useAccount,
useBlockNumber,
useWaitForTransaction,
} from "wagmi";
import { getPublicClient } from "wagmi/actions";
import {
getTankNameFromJoinIndex,
Expand Down Expand Up @@ -69,9 +73,9 @@ export default function Bounty({
} else {
return acc.map((item: any) =>
item.address === current.address &&
item.args.tankId === current.args.tankId &&
item.args.target === current.args.target &&
item.args.amount > current.args.amount
item.args.tankId === current.args.tankId &&
item.args.target === current.args.target &&
item.args.amount > current.args.amount
? current
: item
);
Expand All @@ -92,8 +96,11 @@ export default function Bounty({
}, [hookAddress, blockNumber]);
const { config: addHooksConfig } = usePrepareTankGameAddHooks({
args: [ownerTank.data!, hookAddress],
enabled: !!ownerTank,
// @ts-ignore
address: gameAddress,
enabled: !!ownerTank.data,
});
// console.log(addHooksConfig);
const { write: addHook, data: addHookData } =
useTankGameAddHooks(addHooksConfig);
useWaitForTransaction({
Expand Down Expand Up @@ -264,7 +271,9 @@ function BountyCard({
<button
className="bg-white text-black px-2 disabled:opacity-50 enabled:cursor-pointer"
disabled={!addHook}
onClick={() => addHook?.()}
onClick={() =>
addHook?.()
}
>
Accept
</button>
Expand Down
Loading

0 comments on commit c764bbd

Please sign in to comment.