Skip to content

Commit

Permalink
Merge pull request #1059 from mars-protocol/develop
Browse files Browse the repository at this point in the history
v2.6.1
  • Loading branch information
linkielink authored Aug 20, 2024
2 parents dd5be78 + a95ae41 commit 5852d1b
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 128 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mars-v2-frontend",
"version": "2.6.0",
"version": "2.6.1",
"homepage": "./",
"license": "SEE LICENSE IN LICENSE FILE",
"private": false,
Expand Down
32 changes: 17 additions & 15 deletions src/api/gasPrice/getGasPrice.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import { ChainInfoID } from 'types/enums';
import { ChainInfoID } from 'types/enums'

export default async function getGasPrice(chainConfig: ChainConfig) {
const { id, endpoints, gasPrice, defaultCurrency } = chainConfig;

if (!endpoints.gasPrices) return gasPrice;
const { id, endpoints, gasPrice, defaultCurrency } = chainConfig

const uri = id === ChainInfoID.Osmosis1
? new URL(endpoints.gasPrices)
: new URL(endpoints.gasPrices, endpoints.rest);
if (!endpoints.gasPrices) return gasPrice

const uri =
id === ChainInfoID.Osmosis1
? new URL(endpoints.gasPrices)
: new URL(endpoints.gasPrices, endpoints.rest)

try {
const response = await fetch(uri.toString());
const data = await response.json();
const response = await fetch(uri.toString())
const data = await response.json()

const price = id === ChainInfoID.Osmosis1
? (data as { base_fee: string }).base_fee
: (data as { price: Coin }).price.amount;
const price =
id === ChainInfoID.Osmosis1
? (data as { base_fee: string }).base_fee
: (data as { price: Coin }).price.amount

return `${price}${defaultCurrency.coinMinimalDenom}`;
return `${price}${defaultCurrency.coinMinimalDenom}`
} catch (e) {
console.error('Failed to fetch gas price:', e);
return gasPrice;
console.error('Failed to fetch gas price:', e)
return gasPrice
}
}
25 changes: 11 additions & 14 deletions src/components/Wallet/WalletFetchBalancesAndAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import useBaseAsset from 'hooks/assets/useBasetAsset'
import useWalletBalances from 'hooks/wallet/useWalletBalances'
import useStore from 'store'
import { byDenom } from 'utils/array'
import { defaultFee } from 'utils/constants'
import { BN } from 'utils/helpers'
import { getPage, getRoute } from 'utils/route'

Expand Down Expand Up @@ -49,25 +48,24 @@ function Content() {

useEffect(() => {
const page = getPage(pathname)

if (page === 'portfolio' && urlAddress && urlAddress !== address) {
navigate(getRoute(page, searchParams, urlAddress as string))
useStore.setState({ balances: walletBalances, focusComponent: null })
return
}

if (
accountIds &&
accountIds.length !== 0 &&
BN(baseBalance).isGreaterThanOrEqualTo(defaultFee.amount[0].amount)
) {
const currentAccountIsHLS = urlAccountId && !accountIds.includes(urlAccountId)
const currentAccount = currentAccountIsHLS || !urlAccountId ? accountIds[0] : urlAccountId
navigate(getRoute(page, searchParams, address, isV1 ? undefined : currentAccount))
useStore.setState({ balances: walletBalances, focusComponent: null })
}
if (!accountIds || accountIds.length === 0) return

const currentAccountIsHLS = urlAccountId && !accountIds.includes(urlAccountId)
const currentAccount = currentAccountIsHLS || !urlAccountId ? accountIds[0] : urlAccountId

navigate(getRoute(page, searchParams, address, isV1 ? undefined : currentAccount), {
replace: true,
})
setTimeout(() => useStore.setState({ balances: walletBalances, focusComponent: null }), 500)
}, [
accountIds,
baseBalance,
navigate,
pathname,
address,
Expand All @@ -81,8 +79,7 @@ function Content() {
if (isLoadingAccounts || isLoadingBalances) return <FetchLoading />
if (BN(baseBalance).isZero()) return <WalletBridges />
if (accountIds && accountIds.length === 0 && !isV1) return <AccountCreateFirst />
useStore.setState({ focusComponent: null })
return null
return <FetchLoading />
}

export default function WalletFetchBalancesAndAccounts() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function useLendingMarketAssetsTableData(): {
}

if (lendingMarketAsset.accountLentAmount?.isZero()) {
availableAssets.push(lendingMarketAsset)
if (!market.asset.isDeprecated) availableAssets.push(lendingMarketAsset)
} else {
accountLentAssets.push(lendingMarketAsset)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/v1/Table/useV1DepositsTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function useV1DepositsTableData(): {
accountLentValue: value,
accountLentAmount: amount,
}

if (market.asset.isDeprecated) return
depositAssets.push(lendingMarketAsset)
})

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/assets/useAssetsNoOraclePrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async function fetchSortAndMapAllAssets(
...asset,
isPoolToken: !!currentAssetPoolInfo,
isWhitelisted:
currentAssetParams && currentAssetParams.credit_manager.whitelisted && !isDeprecated,
currentAssetParams && (currentAssetParams.credit_manager.whitelisted || isDeprecated),
isAutoLendEnabled: currentAssetParams?.red_bank.borrow_enabled ?? false,
isBorrowEnabled: currentAssetParams?.red_bank.borrow_enabled ?? false,
isDepositEnabled: isAnyAssetAndNoPool ? true : isDepositEnabled,
Expand Down
Loading

0 comments on commit 5852d1b

Please sign in to comment.