diff --git a/frontend/src/components/modals/PlantModal.tsx b/frontend/src/components/modals/PlantModal.tsx index e4a2dfd..887b33c 100644 --- a/frontend/src/components/modals/PlantModal.tsx +++ b/frontend/src/components/modals/PlantModal.tsx @@ -39,7 +39,7 @@ export default function PlantModal({ setModal, }: PlantModalProps) { const [status, setStatus] = useState< - "error" | "none" | "loading" | "retrying" + "error" | "none" | "loading" | "retrying" | "accelerating" >("none"); const { wallet } = useWallet(); const paymaster = usePaymaster(); @@ -166,6 +166,7 @@ export default function PlantModal({ tx = await wallet.sendTransaction(request); } else { + setStatus("accelerating"); const scope = contract.functions .accelerate_plant_seed_at_index( seedType, @@ -289,6 +290,12 @@ export default function PlantModal({ return (
{status === "loading" && } + {status === "accelerating" && ( +
+

$FARM detected, accelerating harvest...

+ +
+ )} {status === "retrying" && } {status === "error" && (
diff --git a/frontend/src/components/show/ShowCoins.tsx b/frontend/src/components/show/ShowCoins.tsx index d960be4..c2e8518 100644 --- a/frontend/src/components/show/ShowCoins.tsx +++ b/frontend/src/components/show/ShowCoins.tsx @@ -30,7 +30,7 @@ export default function ShowCoins({ }, [wallet, updateNum, contract]); if (balance) { - return Farm Coins: {balance.format()}; + return In-app Coins: {balance.format()}; } return null; diff --git a/frontend/src/components/show/ShowPlayerInfo.tsx b/frontend/src/components/show/ShowPlayerInfo.tsx index 0e0dad1..11459d8 100644 --- a/frontend/src/components/show/ShowPlayerInfo.tsx +++ b/frontend/src/components/show/ShowPlayerInfo.tsx @@ -1,6 +1,7 @@ import { cssObj } from "@fuel-ui/css"; import { Flex, Box } from "@fuel-ui/react"; import type { BytesLike } from "fuels"; +import { useWallet } from "@fuels/react"; import type { FarmContract, @@ -8,6 +9,8 @@ import type { } from "../../sway-api/contracts/FarmContract"; import ShowCoins from "./ShowCoins"; +import { useState } from "react"; +import { useEffect } from "react"; interface PlayerProps { player: PlayerOutput | null; @@ -15,7 +18,8 @@ interface PlayerProps { updateNum: number; farmCoinAssetID: BytesLike; } - +const dollarFarmAssetID = + "0x9858ea1307794a769dc91aaad7dc7ddb9fa29dadb08345ba82c8f762b2eb0c97"; export default function ShowPlayerInfo({ player, contract, @@ -26,6 +30,16 @@ export default function ShowPlayerInfo({ if (player !== null) { valSold = parseFloat(player.total_value_sold.format().toLocaleString()); } + const [balance, setBalance] = useState(); + const { wallet } = useWallet(); + useEffect(() => { + (async () => { + const balance = await wallet?.getBalance(dollarFarmAssetID); + const balanceinBN = balance?.div(10 ** 9); + setBalance(balanceinBN?.toString()); + })(); + }, [wallet]); + console.log("balance", balance); return ( @@ -36,6 +50,7 @@ export default function ShowPlayerInfo({ updateNum={updateNum} farmCoinAssetID={farmCoinAssetID} /> + $FARM: {balance ?? "0"} );