Skip to content

Commit

Permalink
Merge pull request #540 from BibliothecaDAO/feat/general-improvements
Browse files Browse the repository at this point in the history
Feat/general improvements
  • Loading branch information
starknetdev authored Jan 19, 2024
2 parents ed78f22 + 6b58851 commit 6724ae4
Show file tree
Hide file tree
Showing 7 changed files with 1,036 additions and 173 deletions.
10 changes: 8 additions & 2 deletions ui/src/app/components/ArcadeDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface ArcadeDialogProps {
lordsBalance: number;
ethBalance: number;
costToPlay: bigint;
getAccountBalances: () => Promise<void>;
}

export const ArcadeDialog = ({
Expand All @@ -45,6 +46,7 @@ export const ArcadeDialog = ({
lordsBalance,
ethBalance,
costToPlay,
getAccountBalances,
}: ArcadeDialogProps) => {
const [fetchedBalances, setFetchedBalances] = useState(false);
const [recoverArcade, setRecoverArcade] = useState(false);
Expand Down Expand Up @@ -117,7 +119,7 @@ export const ArcadeDialog = ({
setFetchedBalances(true);
};

const getAccountBalances = async (account: string) => {
const getArcadeBalances = async (account: string) => {
const balances = await fetchBalances(
account,
ethContract!,
Expand Down Expand Up @@ -234,14 +236,15 @@ export const ArcadeDialog = ({
genNewKey={genNewKey}
setPermissions={setPermissions}
balances={arcadebalances[account.name]}
getAccountBalances={getAccountBalances}
getAccountBalances={getArcadeBalances}
topUpEth={topUpEth}
topUpLords={topUpLords}
withdraw={withdraw}
isWithdrawing={isWithdrawing}
lordsBalance={lordsBalance}
ethBalance={ethBalance}
lordsGameCost={lordsGameCost}
getBalances={getAccountBalances}
/>
);
})}
Expand Down Expand Up @@ -305,6 +308,7 @@ interface ArcadeAccountCardProps {
lordsBalance: number;
ethBalance: number;
lordsGameCost: number;
getBalances: () => Promise<void>;
}

export const ArcadeAccountCard = ({
Expand All @@ -326,6 +330,7 @@ export const ArcadeAccountCard = ({
lordsBalance,
ethBalance,
lordsGameCost,
getBalances,
}: ArcadeAccountCardProps) => {
const { connect, connectors } = useConnect();
const [isCopied, setIsCopied] = useState(false);
Expand Down Expand Up @@ -502,6 +507,7 @@ export const ArcadeAccountCard = ({
balances?.lords
);
await getAccountBalances(account.name);
await getBalances();
}}
disabled={isWithdrawing || minimalBalance}
>
Expand Down
8 changes: 6 additions & 2 deletions ui/src/app/components/arcade/TopupInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const TopupInput = ({
const [showInput, setShowInput] = useState(false);
const [inputValue, setInputValue] = useState(0);

const onMainnet = process.env.NEXT_PUBLIC_NETWORK === "mainnet";

const handleChange = (
e: ChangeEvent<HTMLInputElement | HTMLSelectElement>
) => {
Expand Down Expand Up @@ -76,7 +78,7 @@ const TopupInput = ({

const mainTopupDisabled =
balanceType === "eth"
? ethBalance < 0.01 * 10 ** 18
? ethBalance < (onMainnet ? 0.01 : 0.001) * 10 ** 18
: lordsBalance < lordsGameCost;
const inputTopupInvalid =
inputValue * 10 ** 18 > (balanceType === "eth" ? ethBalance : lordsBalance);
Expand Down Expand Up @@ -138,7 +140,9 @@ const TopupInput = ({
disabled={disabled || mainTopupDisabled}
>
{balanceType === "eth"
? "Add 0.01 ETH"
? onMainnet
? "Add 0.01 ETH"
: "Add 0.001 ETH"
: `Add ${formatCurrency(lordsGameCost)} LORDS`}
</Button>
<Button
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/components/navigation/TransactionCart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ const TransactionCart = ({
upgradeTx = newUpgradeTx;
}
}
setDisplayCart(false);
await multicall(loadingMessage, notification, upgradeTx);
handleResetCalls();
}}
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/components/start/AdventurersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface AdventurerListProps {
isActive: boolean;
onEscape: () => void;
adventurers: Adventurer[];
handleSwitchAdventurer: (...args: any[]) => any;
handleSwitchAdventurer: (adventurerId: number) => Promise<void>;
gameContract: Contract;
}

Expand Down Expand Up @@ -95,9 +95,9 @@ export const AdventurersList = ({
variant={
selectedIndex === index && isActive ? "default" : "ghost"
}
onClick={() => {
onClick={async () => {
setAdventurer(adventurer);
handleSwitchAdventurer(adventurer.id);
await handleSwitchAdventurer(adventurer.id!);
setSelectedIndex(index);
}}
disabled={adventurer?.health === 0}
Expand Down
Loading

1 comment on commit 6724ae4

@vercel
Copy link

@vercel vercel bot commented on 6724ae4 Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.