-
Notifications
You must be signed in to change notification settings - Fork 0
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
[pending]Bera #144
base: main
Are you sure you want to change the base?
[pending]Bera #144
Changes from 9 commits
a7dc370
f174611
5f9fbd8
07343b0
8abb54d
de71a9a
7b67161
c5902a8
3d965cd
9c562cf
b89e165
2c4b448
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,10 +87,11 @@ export async function unstake(address: string, amount: number) { | |
amount: BigNumber(amount).times(SHARE_UNIT_MODIFIER).toFixed(), | ||
}); | ||
} | ||
export async function transfer(address: string, amount: string) { | ||
export async function transfer(address: string, amount: string, token?: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我记得mpc那边是精准判断字符串的,这里补个类型把 |
||
await http.post<null>('/xfans/api/shares/transfer', { | ||
amount, | ||
address, | ||
token, | ||
}); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { contractRequestHttp as http } from '../request'; | ||
|
||
export async function getAccounts() { | ||
const accounts = await http.get<{ accounts: string[]; balance: string }>( | ||
const accounts = await http.get<{ accounts: string[]; balance: string; weth_balance: string }>( | ||
'/xfans/api/user/accounts' | ||
); | ||
return accounts; | ||
} | ||
|
||
export async function getBalance() { | ||
const balance = await http.get<string>('/xfans/api/user/getBalance'); | ||
return balance; | ||
} | ||
// todo: 建议删除,后端暂时没删除 | ||
// export async function getBalance() { | ||
// const balance = await http.get<string>('/xfans/api/user/getBalance'); | ||
// return balance; | ||
// } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ const useGlobalStore = create<GlobalStoreProps>()( | |
}); | ||
}, | ||
userVote: null, | ||
chain: Chain.Arb, | ||
chain: Chain.Bera, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 感觉把 chain 做成环境变量好点把,不然产品找你要 Arb 版本我们还得改源码。。 |
||
}), | ||
{ | ||
name: 'xfans-user-config', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,15 @@ import * as toaster from '../../components/Toaster'; | |
import { ContractError } from '../../constants'; | ||
import useAccount from '../../hooks/useAccount'; | ||
import { useETHPrice } from '../../hooks/useETHPrice'; | ||
import { BeraIcon } from '../../components/icons/ETHIcon'; | ||
import { | ||
buyShares, | ||
getBuyPrice, | ||
getBuyPriceAfterFee, | ||
getFloorPrice, | ||
getSupply, | ||
} from '../../service/contract/shares'; | ||
import { getBalance } from '../../service/contract/user'; | ||
import { getAccounts } from '../../service/contract/user'; | ||
import useProfileModal from '../../store/useProfileModal'; | ||
import { formatDollar } from '../../utils'; | ||
|
||
|
@@ -69,6 +70,7 @@ const BuyModal = ({ onClose }: BuyModalProps) => { | |
const [amount, setAmount] = useState<number>(0); | ||
const [priceAfterFee, setPriceAfterFee] = useState('0'); | ||
const [balance, setBalance] = useState('0'); | ||
const [WETHbalance, setWETHBalance] = useState('0'); | ||
const [isBuying, setIsBuying] = useState(false); | ||
const [floorPrice, setFloorPrice] = useState('0'); | ||
const [supply, setSupply] = useState(0); | ||
|
@@ -133,9 +135,10 @@ const BuyModal = ({ onClose }: BuyModalProps) => { | |
useEffect(() => { | ||
if (wallet) { | ||
setLoadingBalance(true); | ||
getBalance().then((balance) => { | ||
getAccounts().then((result) => { | ||
setLoadingBalance(false); | ||
setBalance(balance); | ||
setBalance(result.balance); | ||
setWETHBalance(result.weth_balance); | ||
}); | ||
} | ||
}, [wallet]); | ||
|
@@ -165,9 +168,10 @@ const BuyModal = ({ onClose }: BuyModalProps) => { | |
numberInputRef.current?.reset(); | ||
refreshAccount(); | ||
setLoadingBalance(true); | ||
getBalance().then((balance) => { | ||
getAccounts().then((result) => { | ||
setLoadingBalance(false); | ||
setBalance(balance); | ||
setBalance(result.balance); | ||
setWETHBalance(result.weth_balance); | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
setLoadingFloorPrice(true); | ||
|
@@ -285,7 +289,7 @@ const BuyModal = ({ onClose }: BuyModalProps) => { | |
<span className="text-lg font-medium text-[#919099]">Est. Gas Fee</span> | ||
<div className="flex flex-col items-end"> | ||
<div className="flex items-center space-x-1"> | ||
<Icon1 /> | ||
<BeraIcon /> | ||
<span className="text-lg font-medium"> | ||
<NumberDisplayer text={gasFee} loading={loadingPrice} /> | ||
</span> | ||
|
@@ -310,7 +314,17 @@ const BuyModal = ({ onClose }: BuyModalProps) => { | |
<div className="flex items-center space-x-1"> | ||
<Icon1 /> | ||
<span className="text-2xl font-bold"> | ||
<NumberDisplayer text={total} loading={loadingPrice || loadingPirceAfterFee} /> | ||
<NumberDisplayer | ||
text={new BigNumber(priceAfterFee).toFixed()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里为什么要new 以下来着,之前是 total 现在改成 priceAfterFee 是预期的吗 |
||
loading={loadingPrice || loadingPirceAfterFee} | ||
/> | ||
</span> | ||
<BeraIcon /> | ||
<span className="text-2xl font-bold"> | ||
<NumberDisplayer | ||
text={new BigNumber(gasFee).toFixed()} | ||
loading={loadingPrice || loadingPirceAfterFee} | ||
/> | ||
</span> | ||
</div> | ||
</div> | ||
|
@@ -319,7 +333,7 @@ const BuyModal = ({ onClose }: BuyModalProps) => { | |
<div className="flex items-center justify-center space-x-1 rounded-full bg-[#F5F5F5] px-5 py-1"> | ||
<Icon1 /> | ||
<span className="text-lg font-medium"> | ||
<NumberDisplayer text={balance} loading={loadingBalance} /> | ||
<NumberDisplayer text={WETHbalance} loading={loadingBalance} /> | ||
</span> | ||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,11 @@ import { useToggle } from 'ahooks'; | |
import { BackButton, BasicButton, PrimaryButton } from '../../components/Button'; | ||
import Modal from '../../components/Modal'; | ||
import * as toaster from '../../components/Toaster'; | ||
import TSelect from '../../components/Select'; | ||
import { chainNameMap } from '../../config/chainConfig'; | ||
import useGlobalStore from '../../store/useGlobalStore'; | ||
import useGlobalUserStore from '../../store/useGlobalUserStore'; | ||
import { Token } from '../../constants'; | ||
|
||
const Deposit = () => { | ||
const [isOpen, { setLeft: close, setRight: open }] = useToggle(false); | ||
|
@@ -52,9 +54,11 @@ const Deposit = () => { | |
</div> | ||
<div className="flex flex-col space-y-[14px]"> | ||
<span className="text-base font-medium text-[#919099]">Asset</span> | ||
<div className="rounded-[8px] bg-[#F7F9FA] py-[18px] pl-[26px] text-base font-medium text-[#1A1D1F]"> | ||
ETH | ||
</div> | ||
<TSelect | ||
defaultValue={Token.WETH} | ||
options={[Token.WETH, Token.Bera]} | ||
onChange={(x) => {}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 既然 onChange 没用上是不是它的类型改成可选的好点 |
||
/> | ||
</div> | ||
</div> | ||
<div className="my-[30px] flex w-full justify-between"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
options 的类型最好是
{ value, label }
,不然无法满足后面的需求