From ed23a13953a388c1a38b5ec6def42d1a26aefa49 Mon Sep 17 00:00:00 2001 From: starknetdev Date: Mon, 9 Oct 2023 14:07:57 +0100 Subject: [PATCH] add lords mint to spawn --- .../app/components/start/CreateAdventurer.tsx | 14 +++++- ui/src/app/components/start/Spawn.tsx | 48 +++++++++++++------ ui/src/app/containers/AdventurerScreen.tsx | 6 +++ ui/src/app/lib/utils/syscalls.ts | 2 + ui/src/app/page.tsx | 3 +- 5 files changed, 57 insertions(+), 16 deletions(-) diff --git a/ui/src/app/components/start/CreateAdventurer.tsx b/ui/src/app/components/start/CreateAdventurer.tsx index 96785d61e..34459adca 100644 --- a/ui/src/app/components/start/CreateAdventurer.tsx +++ b/ui/src/app/components/start/CreateAdventurer.tsx @@ -8,12 +8,16 @@ export interface CreateAdventurerProps { isActive: boolean; onEscape: () => void; spawn: (...args: any[]) => any; + lordsBalance?: bigint; + mintLords: (...args: any[]) => any; } export const CreateAdventurer = ({ isActive, onEscape, spawn, + lordsBalance, + mintLords, }: CreateAdventurerProps) => { const [formData, setFormData] = useState({ startingWeapon: "", @@ -87,7 +91,15 @@ export const CreateAdventurer = ({ /> ); } else if (step === 3) { - return ; + return ( + + ); } else { return null; } diff --git a/ui/src/app/components/start/Spawn.tsx b/ui/src/app/components/start/Spawn.tsx index 8f1783867..73f6e7850 100644 --- a/ui/src/app/components/start/Spawn.tsx +++ b/ui/src/app/components/start/Spawn.tsx @@ -15,9 +15,17 @@ export interface SpawnProps { formData: FormData; spawn: (...args: any[]) => any; handleBack: () => void; + lordsBalance?: bigint; + mintLords: (...args: any[]) => any; } -export const Spawn = ({ formData, spawn, handleBack }: SpawnProps) => { +export const Spawn = ({ + formData, + spawn, + handleBack, + lordsBalance, + mintLords, +}: SpawnProps) => { const [showWalletTutorial, setShowWalletTutorial] = useState(false); const [formFilled, setFormFilled] = useState(false); const isWrongNetwork = useUIStore((state) => state.isWrongNetwork); @@ -49,6 +57,8 @@ export const Spawn = ({ formData, spawn, handleBack }: SpawnProps) => { await spawn(formData); }; + const checkEnoughLords = lordsBalance! >= BigInt(25000000000000000000); + return (
{showWalletTutorial && ( @@ -116,19 +126,29 @@ export const Spawn = ({ formData, spawn, handleBack }: SpawnProps) => { } }} > - +
+ + {!checkEnoughLords && ( + + )} +
)}
diff --git a/ui/src/app/containers/AdventurerScreen.tsx b/ui/src/app/containers/AdventurerScreen.tsx index 59f8e3fe8..531dfe4a8 100644 --- a/ui/src/app/containers/AdventurerScreen.tsx +++ b/ui/src/app/containers/AdventurerScreen.tsx @@ -13,6 +13,8 @@ import useUIStore from "../hooks/useUIStore"; interface AdventurerScreenProps { spawn: (...args: any[]) => any; handleSwitchAdventurer: (...args: any[]) => any; + lordsBalance?: bigint; + mintLords: (...args: any[]) => any; } /** @@ -22,6 +24,8 @@ interface AdventurerScreenProps { export default function AdventurerScreen({ spawn, handleSwitchAdventurer, + lordsBalance, + mintLords, }: AdventurerScreenProps) { const [activeMenu, setActiveMenu] = useState(0); const [loading, setLoading] = useState(false); @@ -85,6 +89,8 @@ export default function AdventurerScreen({ isActive={activeMenu == 1} onEscape={() => setActiveMenu(0)} spawn={spawn} + lordsBalance={lordsBalance} + mintLords={mintLords} /> )} diff --git a/ui/src/app/lib/utils/syscalls.ts b/ui/src/app/lib/utils/syscalls.ts index a5a31db01..ec7c16bd0 100644 --- a/ui/src/app/lib/utils/syscalls.ts +++ b/ui/src/app/lib/utils/syscalls.ts @@ -252,6 +252,8 @@ export function syscalls({ account ); + console.log(balanceEmpty); + if (!balanceEmpty) { startLoading( "Create", diff --git a/ui/src/app/page.tsx b/ui/src/app/page.tsx index 8987a2033..a38361ead 100644 --- a/ui/src/app/page.tsx +++ b/ui/src/app/page.tsx @@ -129,7 +129,6 @@ export default function Home() { const setStartOption = useUIStore((state) => state.setStartOption); const arcadeConnectors = getArcadeConnectors(available); - console.log(arcadeConnectors); const lordsBalance = useBalance({ token: lordsContract?.address, address, @@ -439,6 +438,8 @@ export default function Home() { await mintLords()} /> )} {screen === "play" && (