From 652691326531ac7d0bba0c8e930d60fab6369ea7 Mon Sep 17 00:00:00 2001
From: mezger75 <110202847+mezger75@users.noreply.github.com>
Date: Sun, 30 Jun 2024 19:45:41 +0300
Subject: [PATCH] Feature/ik/smart wallet integration (#192)
* update deps for smartwallet
* add base sepolia config
* add smart wallet connect button raw
* update deps for smartwallet
* fix smartwallet button visibility & text color, fix curryncy symbol at user profile
* show blockExplorer links depending on chosen network
* add base sepolia faucets & update faucets show depending on chain id
* add logic to use smartwallet batch transactions on deposit and join, update web3provider to export wagmiconfig
* add logic for deposit&join as batch transactions with 0 ingame balance before start game
* update start button text about batch txs and delete commented code
---
.../startDepositButton.tsx | 74 ++++---------------
1 file changed, 14 insertions(+), 60 deletions(-)
diff --git a/frontend/src/app/components/start-deposit-button/startDepositButton.tsx b/frontend/src/app/components/start-deposit-button/startDepositButton.tsx
index 731419f..0ff6395 100644
--- a/frontend/src/app/components/start-deposit-button/startDepositButton.tsx
+++ b/frontend/src/app/components/start-deposit-button/startDepositButton.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect, useRef, useState } from "react";
+import React, { useEffect, useRef } from "react";
import { useModal, useSIWE } from "connectkit";
import {
@@ -6,7 +6,7 @@ import {
useWaitForTransactionReceipt,
useWriteContract,
} from "wagmi";
-import { Address, keccak256, parseEther, toBytes } from "viem";
+import { Address, parseEther } from "viem";
import WsApiService, { RaceStatistic } from "@/app/api/ws-api-service";
import {
@@ -22,12 +22,6 @@ import { Button } from "@/app/components/ui/button";
import { useConfigStore } from "@/app/store/configStore";
import Spinner from "@/app/components/ui/spinner";
import { useQueryClient } from "@tanstack/react-query";
-import {
- writeContracts,
- showCallsStatus,
- getCallsStatus,
-} from "@wagmi/core/experimental";
-import { wagmiConfig } from "@/app/helpers/web3-provider";
interface IStartDepositButton {
txSuccessful: boolean;
@@ -48,7 +42,6 @@ function StartDepositButton({
isConfirmingJoin,
handleBatchStartGame,
}: IStartDepositButton) {
- const [batchStatusConfirmed, setBatchStatusConfirmed] = useState(false);
const { contractConfig } = useConfigStore();
const { isSignedIn, signIn } = useSIWE();
const { isConnected, chainId, address, chain, connector } = useAccount();
@@ -75,33 +68,6 @@ function StartDepositButton({
}
if (connector?.id === "coinbaseWalletSDK") {
handleBatchStartGame();
- // const sessionId = sessionStorage.getItem("sessionId");
- // const hashSessionId = keccak256(toBytes(sessionId as string));
- // const id = await writeContracts(wagmiConfig, {
- // // account: address,
- // contracts: [
- // {
- // address: contractAddress as Address,
- // abi: contractConfig.abi,
- // functionName: "deposit",
- // args: [],
- // value: parseEther("0.001"),
- // },
- // {
- // address: contractAddress as Address,
- // abi: contractConfig.abi,
- // functionName: "joinGame",
- // args: [hashSessionId],
- // },
- // ],
- // });
- // console.log("ID", id);
- // await showCallsStatus(wagmiConfig, { id: id });
- // const status = await getCallsStatus(wagmiConfig, { id: id });
- // console.log("STATus", status);
- // if (status.status === "CONFIRMED") {
- // setBatchStatusConfirmed(true);
- // }
} else {
writeContract({
address: contractAddress as Address,
@@ -123,18 +89,7 @@ function StartDepositButton({
if (isConfirmed) {
queryClient.invalidateQueries({ queryKey });
}
- if (batchStatusConfirmed) {
- // setTxSuccessful(true);
-
- wsApiServiceRef.current?.register(
- localStorage.getItem("userId") ?? "",
- address as Address
- );
- queryClient.invalidateQueries({ queryKey });
- // setIsButtonDisabled(true);
- // setUserStats([]);
- }
- }, [isConfirmed, batchStatusConfirmed]);
+ }, [isConfirmed]);
const showDepositButton =
isSignedIn &&
@@ -149,20 +104,19 @@ function StartDepositButton({
return (
<>
- {showDepositButton &&
- !isConfirmed &&
- userStatus !== "registered" &&
- !batchStatusConfirmed ? (
+ {showDepositButton && !isConfirmed && userStatus !== "registered" ? (
) : (