Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: update code #135

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# arb
VITE_ARB_SOCKET_BASE_URL="wss://dev-chat-xfans-api.buidlerdao.xyz"
VITE_ARB_ROOM_BASE_URL="https://dev-chat-xfans-api.buidlerdao.xyz"
VITE_ARB_CONTRACT_BASE_URL="http://localhost:3001"
VITE_ARB_CONTRACT_BASE_URL="https://test-mpc-xfans-api.buidlerdao.xyz"
VITE_ARB_BASE_URL="https://test-api.xfans.tech"

# bera
VITE_BERA_SOCKET_BASE_URL="wss://dev-chat-xfans-api.buidlerdao.xyz"
VITE_BERA_ROOM_BASE_URL="https://dev-chat-xfans-api.buidlerdao.xyz"
VITE_BERA_CONTRACT_BASE_URL="http://localhost:3001"
VITE_BERA_CONTRACT_BASE_URL="https://test-mpc-xfans-api.buidlerdao.xyz"
VITE_BERA_BASE_URL="https://test-bera-api.xfans.tech"

4 changes: 2 additions & 2 deletions src/components/Select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { Select, MenuItem, SelectChangeEvent } from '@mui/material';

import { getCurrentChain } from '../../config/chainConfig';
interface TSelectProps {
handleChange: (value: string) => void;
}

const TSelect: React.FC<TSelectProps> = ({ handleChange }) => {
const [selectedValue, setSelectedValue] = React.useState('arb');
const [selectedValue, setSelectedValue] = React.useState(getCurrentChain());

const handleInternalChange = (event: SelectChangeEvent<string>) => {
const value = event.target.value;
Expand Down
5 changes: 5 additions & 0 deletions src/config/chainConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { XFANS_NETWORK_ARB, XFANS_NETWORK_BERA } from '../constants';
interface ChainConfigType {
vite_socket_base_url: string;
vite_room_base_url: string;
Expand Down Expand Up @@ -31,4 +32,8 @@ export const setCurrentChain = (chain: string) => {
localStorage.setItem('current_chain', chain);
};

export const getCurrentChainName = () => {
return getCurrentChain() == 'arb' ? XFANS_NETWORK_ARB : XFANS_NETWORK_BERA;
};

export default ChainConfig;
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export enum ContractError {
export const XFANS_CONTENT_WIDTH = 433;
export const XFANS_MIN_WIDTH = 458;

export const XFANS_NETWORK = 'Arb Sepolia';
export const XFANS_NETWORK_ARB = 'Arb Sepolia';
export const XFANS_NETWORK_BERA = 'Bera Artio';
7 changes: 7 additions & 0 deletions src/content/drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import CongratulationPage from '../loginPage/congratulationPage';
import InvitePage from '../loginPage/invitePage';
import SignInWithXPage from '../loginPage/signInWithXPage';
import ChainSelectPage from '../loginPage/chainSelectPage';

Check failure on line 21 in src/content/drawer/index.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module '../loginPage/chainSelectPage' or its corresponding type declarations.

Check failure on line 21 in src/content/drawer/index.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find module '../loginPage/chainSelectPage' or its corresponding type declarations.

import LogoButton from './logoButton';

import '../../tailwind.css';
import { setCurrentChain, getCurrentChain } from '../../config/chainConfig';

export default function PersistentDrawerRight() {
const { isShowDrawer, goPage, page, logout } = useGlobalStore((state) => ({ ...state }));
Expand Down Expand Up @@ -242,6 +244,11 @@
});
clickLogin();
}}
handleSwitchSelect={(x: string) => {
setCurrentChain(x);
console.log('select chain', getCurrentChain());
checkProfileData();
}}
/>
)}
{page === PageType.Invite && (
Expand Down
15 changes: 7 additions & 8 deletions src/content/loginPage/signInWithXPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ import '../../tailwind.css';

interface SignInWithXPageProps {
handleButtonClick: () => void; // 定义一个函数类型的属性
handleSwitchSelect: (x: string) => void;
showLoading: boolean;
}

const SignInWithXPage: FC<SignInWithXPageProps> = ({ handleButtonClick, showLoading }) => {
const SignInWithXPage: FC<SignInWithXPageProps> = ({
handleButtonClick,
handleSwitchSelect,
showLoading,
}) => {
return (
<div className="h-full min-h-screen w-full items-center justify-center text-center">
<img
Expand Down Expand Up @@ -54,13 +59,7 @@ const SignInWithXPage: FC<SignInWithXPageProps> = ({ handleButtonClick, showLoad
'Login With X'
)}
</NextButton>
<TSelect
handleChange={(x: string) => {
console.log('select', x);
setCurrentChain(x);
console.log('getCurrentChain', getCurrentChain());
}}
/>
<TSelect handleChange={handleSwitchSelect} />
</div>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/welcome/Wallet/Deposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BackButton, BasicButton, PrimaryButton } from '../../components/Button'
import Modal from '../../components/Modal';
import * as toaster from '../../components/Toaster';
import useGlobalUserStore from '../../store/useGlobalUserStore';
import { XFANS_NETWORK } from '../../constants';
import { getCurrentChainName } from '../../config/chainConfig';
const Deposit = () => {
const [isOpen, { setLeft: close, setRight: open }] = useToggle(false);
const accounts = useGlobalUserStore((state) => state.accounts);
Expand Down Expand Up @@ -38,7 +38,7 @@ const Deposit = () => {
<div className="flex flex-col space-y-[14px]">
<span className="text-base font-medium text-[#919099]">Network</span>
<div className="rounded-[8px] bg-[#F7F9FA] py-[18px] pl-[26px] text-base font-medium text-[#1A1D1F]">
{XFANS_NETWORK}
{getCurrentChainName()}
</div>
</div>
<div className="flex flex-col space-y-[14px]">
Expand Down
4 changes: 2 additions & 2 deletions src/welcome/Wallet/WithDraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { error, success } from '../../components/Toaster';
import { ContractError } from '../../constants';
import useAccount from '../../hooks/useAccount';
import { transfer as transferApi } from '../../service/contract/shares';
import { XFANS_NETWORK } from '../../constants';
import { getCurrentChainName } from '../../config/chainConfig';
const TextField = styled(MTextField)({
width: '493px',
'& label.Mui-focused': {
Expand Down Expand Up @@ -95,7 +95,7 @@ const WithDraw = ({ onClose }: Props) => {
<h2 className="xfans-font-sf text-[24px] font-medium text-[#2E2E32]">Withdraw</h2>
<div className="mt-[15px] h-[1px] w-[438px] bg-[#EBEEF0]"></div>
<p className="xfans-font-sf my-6 text-sm text-black text-opacity-50">
{`Send your ETH to another wallet address on the ${XFANS_NETWORK}`}
{`Send your ETH to another wallet address on the ${getCurrentChainName()}`}
</p>

<div className="mb-6 w-full space-y-6">
Expand Down
4 changes: 2 additions & 2 deletions src/welcome/Wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useWalletAccounts } from '../../service/wallet';
import useGlobalStore from '../../store/useGlobalStore';
import useGlobalUserStore from '../../store/useGlobalUserStore';
import useProfileModal from '../../store/useProfileModal';
import { XFANS_NETWORK } from '../../constants';
import { getCurrentChainName } from '../../config/chainConfig';
import Deposit from './Deposit';
import InviteFriends from './InviteFriends';
import WithDraw from './WithDraw';
Expand Down Expand Up @@ -76,7 +76,7 @@ const Wallet = (props: { back?: () => void; logout?: () => void }) => {
</CopyToClipboard>

<div className="flex items-center space-x-1">
<span className="text-[#919099]">{`Network:${XFANS_NETWORK}`}</span>
<span className="text-[#919099]">{`Network:${getCurrentChainName()}`}</span>
<Network />
</div>
</div>
Expand Down
Loading