Skip to content

Commit

Permalink
fix: dynamic route
Browse files Browse the repository at this point in the history
  • Loading branch information
karanpargal committed Sep 7, 2024
1 parent e33c20c commit 3790164
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ export default dynamic(
))}
</section>
<section className="relative grid w-full grid-cols-7 grid-rows-6 p-2 after:pointer-events-none after:absolute after:inset-0 after:rounded-xl after:border-8 after:border-blue-700 after:shadow-[inset_0_0_0_1px_#1d4ed8]">
{gameState.board.flatMap((row) =>
row.map((cell) => <Cell value={cell} />),
{gameState.board.flatMap((row, i) =>
row.map((cell) => <Cell value={cell} key={i} />),
)}
</section>
{enemy && (
Expand Down Expand Up @@ -447,7 +447,9 @@ export default dynamic(
tier_id={tier_id}
// ! Todo: Add game id to the staking modal
game_id={
"0xbca4cc033c6fc7a4eebc355a0473e863ef63427291fb322d24139fd430f87e4e"
gameState.state === "staking"
? gameState.room_id
: ""
}
onSuccess={() => {
if (gameState.state !== "staking") return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ export default dynamic(
tier_id={tier_id}
// ! Todo: Add game id to the staking modal
game_id={
"0xbca4cc033c6fc7a4eebc355a0473e863ef63427291fb322d24139fd430f87e4e"
gameState.state === "staking"
? gameState.room_id
: ""
}
onSuccess={() => {
if (gameState.state !== "staking") return;
Expand Down
44 changes: 22 additions & 22 deletions packages/frontend/src/utils/functions/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ import { createWalletClient, custom, WalletClient } from "viem";
import { sepolia } from "viem/chains";

export const getWalletClient = async (
provider: IProvider
provider: IProvider,
): Promise<WalletClient> => {
console.log("provider", provider);
const walletClient = createWalletClient({
chain: sepolia,
transport: custom(provider),
});
console.log("provider", provider);
const walletClient = createWalletClient({
chain: sepolia,
transport: custom(provider),
});

return walletClient;
return walletClient;
};

export const getWalletAddress = async (
provider: IProvider
provider: IProvider,
): Promise<string> => {
const walletClient = new ethers.BrowserProvider(provider);
const walletAddress = (await walletClient.provider.getSigner()).address;
const walletClient = new ethers.BrowserProvider(provider);
const walletAddress = (await walletClient.provider.getSigner()).address;

return walletAddress;
return walletAddress;
};

export const getTokenBalance = async (
provider: IProvider,
walletAddress: string,
tokenAddress: string
provider: IProvider,
walletAddress: string,
tokenAddress: string,
): Promise<string> => {
const walletClient = new ethers.BrowserProvider(provider);
const contract = new ethers.Contract(
tokenAddress,
Contracts.ERC_20_ABI,
walletClient.provider
);
const balance = await contract.balanceOf(walletAddress);
const walletClient = new ethers.BrowserProvider(provider);
const contract = new ethers.Contract(
tokenAddress,
Contracts.ERC_20_ABI,
walletClient.provider,
);
const balance = await contract.balanceOf(walletAddress);

return (Number(balance) / Math.pow(10, 6)).toString();
return (Number(balance) / Math.pow(10, 6)).toString();
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class ArcadeService {
chain_id: number,
): Promise<void> {
try {
console.log(chain_id);
console.log("Initializing ArcadeService");
console.log("Provider: ", provider);
this.provider = new ethers.BrowserProvider(provider);
Expand Down

0 comments on commit 3790164

Please sign in to comment.