Skip to content

Commit 9271bc7

Browse files
authored
Merge pull request #1617 from mars-protocol/develop
v2.11.2
2 parents 4760130 + dc7cab3 commit 9271bc7

File tree

4 files changed

+8
-19
lines changed

4 files changed

+8
-19
lines changed

src/components/Modals/FundWithdraw/FundAccount.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import AccountFundContent from 'components/account/AccountFund/AccountFundContent'
2-
import useAccounts from 'hooks/accounts/useAccounts'
32
import useStore from 'store'
43

54
interface Props {
@@ -11,8 +10,6 @@ export default function FundAccount(props: Props) {
1110
const { account, onConnectWallet } = props
1211

1312
const address = useStore((s) => s.address)
14-
const { data: accounts } = useAccounts('default', address)
15-
const hasNoAccounts = accounts?.length < 1
1613

1714
const accountId = account.id
1815
if (!address) return null
@@ -23,7 +20,6 @@ export default function FundAccount(props: Props) {
2320
address={address}
2421
accountId={accountId}
2522
onConnectWallet={onConnectWallet}
26-
hasExistingAccount={!hasNoAccounts}
2723
/>
2824
)
2925
}

src/components/account/AccountCreateFirst.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ export default function AccountCreateFirst() {
2626
const [isCreating, setIsCreating] = useToggle(false)
2727
const [isAutoLendEnabled] = useEnableAutoLendGlobal()
2828

29-
const { data: accounts, isLoading } = useAccounts('default', address)
29+
const { isLoading } = useAccounts('default', address)
3030
const currentAccount = useCurrentAccount()
3131
const { handleConnectWallet } = useWeb3WalletConnection()
3232

3333
useEffect(() => {
3434
if (!address) useStore.setState({ focusComponent: { component: <WalletSelect /> } })
3535
}, [address])
3636

37-
const hasExistingAccount = useMemo(() => accounts && accounts.length > 0, [accounts])
38-
3937
const handleClick = useCallback(async () => {
4038
setIsCreating(true)
4139
const accountId = await createAccount('default', isAutoLendEnabled)
@@ -96,7 +94,6 @@ export default function AccountCreateFirst() {
9694
accountId=''
9795
isFullPage
9896
onConnectWallet={handleConnectWallet}
99-
hasExistingAccount={hasExistingAccount}
10097
isCreateAccount
10198
/>
10299
</Card>

src/components/account/AccountFund/AccountFundContent.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ interface Props {
3939
accountId: string
4040
isFullPage?: boolean
4141
onConnectWallet: () => Promise<boolean>
42-
hasExistingAccount?: boolean
4342
isCreateAccount?: boolean
4443
}
4544

4645
export default function AccountFundContent(props: Props) {
46+
const { isCreateAccount = false } = props
47+
4748
const deposit = useStore((s) => s.deposit)
4849
const walletAssetModal = useStore((s) => s.walletAssetsModal)
4950
const [isConfirming, setIsConfirming] = useState(false)
@@ -52,7 +53,6 @@ export default function AccountFundContent(props: Props) {
5253
const { isAutoLendEnabledForCurrentAccount } = useAutoLend()
5354
const [isAutoLendEnabledGlobal] = useEnableAutoLendGlobal()
5455
const { data: walletBalances } = useWalletBalances(props.address)
55-
const { isCreateAccount = false } = props
5656
const { simulateDeposits } = useUpdatedAccount(props.account)
5757
const { usdcBalances } = useUSDCBalances(walletBalances)
5858
const selectedDenoms = useMemo(() => {
@@ -138,10 +138,9 @@ export default function AccountFundContent(props: Props) {
138138

139139
setIsConfirming(true)
140140
try {
141-
const shouldAutoLend =
142-
hasNoAccounts || !props.hasExistingAccount
143-
? isAutoLendEnabledGlobal
144-
: isAutoLendEnabledForCurrentAccount
141+
const shouldAutoLend = hasNoAccounts
142+
? isAutoLendEnabledGlobal
143+
: isAutoLendEnabledForCurrentAccount
145144

146145
const evmAssets = fundingAssets.filter(
147146
(asset) => asset.chain && chainNameToUSDCAttributes[asset.chain],
@@ -151,7 +150,7 @@ export default function AccountFundContent(props: Props) {
151150
)
152151

153152
let accountId = props.accountId
154-
const isNewAccount = hasNoAccounts || (isCreateAccount && !props.hasExistingAccount)
153+
const isNewAccount = hasNoAccounts || isCreateAccount
155154
const hasEvmAssets = evmAssets.length > 0
156155

157156
if (hasEvmAssets) {
@@ -234,7 +233,6 @@ export default function AccountFundContent(props: Props) {
234233
props.accountId,
235234
props.address,
236235
props.isFullPage,
237-
props.hasExistingAccount,
238236
deposit,
239237
fundingAssets,
240238
isAutoLendEnabledForCurrentAccount,

src/components/account/AccountFund/AccountFundFullPage.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export default function AccountFundFullPage({ isCreateAccount = false }: Props)
1919
const accountId = useAccountId()
2020

2121
const { data: accounts, isLoading } = useAccounts('default', address)
22-
const hasExistingAccount = useMemo(() => accounts && accounts.length > 0, [accounts])
2322

2423
const currentAccount = useCurrentAccount()
2524
const [selectedAccountId, setSelectedAccountId] = useState<null | string>(null)
@@ -63,8 +62,7 @@ export default function AccountFundFullPage({ isCreateAccount = false }: Props)
6362
accountId={selectedAccountId ?? ''}
6463
isFullPage
6564
onConnectWallet={handleConnectWallet}
66-
hasExistingAccount={hasExistingAccount}
67-
isCreateAccount
65+
isCreateAccount={isCreateAccount}
6866
/>
6967
</Card>
7068
)}

0 commit comments

Comments
 (0)