Skip to content

Commit

Permalink
fix - wallet address
Browse files Browse the repository at this point in the history
  • Loading branch information
YuChanGongzhu committed Dec 11, 2024
1 parent 635a17e commit 6864deb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions components/MainUI/Init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import TxError from "../SolanaPopups/TxError";
import InitializeGameAccount from "../SolanaPopups/Initialize";
import { extractKeywords, findRelatedEmojis } from "@/utils/emojiUtils";
import { callOpenRouterAPI, separateEmojisAndText } from "@/utils/reply";
import type { Account } from "@ant-design/web3";

export type PageState = "chat" | "shop" | "info" | "user";

Expand All @@ -42,6 +43,7 @@ export default function Init({
const [isDialogOpen, setIsDialogOpen] = useState(true);
const [emojisContent, setEmojisContent] = useState<string>(""); //气泡表情内容
const [walletConnected, setWalletConnected] = useState(false);
const [address, setAddress] = useState<Account | undefined>(undefined);

const { program } = useGameProgram();
const { publicKey } = usePublicKey();
Expand Down Expand Up @@ -318,6 +320,8 @@ export default function Init({
>
<UserPage
userInfo={userInfo}
address={address}
setAddress={setAddress}
gameAccount={gameAccount}
solanaProvider={provider}
onWalletConnect={() => {
Expand Down
8 changes: 4 additions & 4 deletions components/MainUI/SlideUI/UserPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { WindowContent } from "react95";
import Image from "next/image";
import { Page, WindowWrapper, Avatar } from "./styles";
import { useNavHeight } from "@/components/Root/navHeightContext";

import { ConnectButton } from "@ant-design/web3";
import type { Account } from "@ant-design/web3";
import { showInitializeModal } from "@/utils/solana";
Expand All @@ -16,22 +15,23 @@ const pressStart2P = Press_Start_2P({

export default function UserPage({
userInfo,
address,
setAddress,
gameAccount,
solanaProvider,
onWalletConnect,
onWalletDisconnect,
}: {
userInfo: any;
address: Account | undefined;
setAddress: (address: Account | undefined) => void;
gameAccount: any;
solanaProvider: any;
onWalletConnect: () => void;
onWalletDisconnect: () => void;
}) {
const { navHeight } = useNavHeight(); // 获取导航栏高度

const [address, setAddress] = useState<Account | undefined>(undefined);

// 处理钱包连接
const handleConnect = async () => {
const res = await solanaProvider?.connect({}, false);
const walletAddress = solanaProvider?.publicKey?.toString();
Expand Down

0 comments on commit 6864deb

Please sign in to comment.