Skip to content

Commit

Permalink
v2.3.0 (#846)
Browse files Browse the repository at this point in the history
* feat: handle URLs with or without trailing slash (#803)

* feat: handle URLs with or without trailing slash

* tidy: cleanup slashes

* Fix docker build (#805)

* fix: fixed the docker build

* tidy: cleanup

* env: remove env contents (#808)

* Portfolio fix (#809)

* fix: fixed the portfolio account detail page layout

* fix: fixed portfolio cards

* tidy: refactor

* align buttons, perps row clickable (#807)

* align buttons, perps row clickable

* fix comments

* update to v2.2.4

* fix borrowbutton logic, add vault deposit manage btn, fix icon size vault modal

---------

Co-authored-by: Linkie Link <[email protected]>

* Update .env.production

* Update Dockerbuild (#813)

* v2.2.4 (#810)

* feat: handle URLs with or without trailing slash (#803)

* feat: handle URLs with or without trailing slash

* tidy: cleanup slashes

* Fix docker build (#805)

* fix: fixed the docker build

* tidy: cleanup

* env: remove env contents (#808)

* Portfolio fix (#809)

* fix: fixed the portfolio account detail page layout

* fix: fixed portfolio cards

* tidy: refactor

* align buttons, perps row clickable (#807)

* align buttons, perps row clickable

* fix comments

* update to v2.2.4

* fix borrowbutton logic, add vault deposit manage btn, fix icon size vault modal

---------

Co-authored-by: Linkie Link <[email protected]>

---------

Co-authored-by: Bob van der Helm <[email protected]>

* Update Dockerfile

* remove   .env files

* tidy: format

---------

Co-authored-by: Bob van der Helm <[email protected]>

* update health computer for perps (#823)

* update health computer for perps

* update health computer + fix comments

* Build(deps-dev): bump @types/react from 18.2.55 to 18.2.58 (#827)

Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.2.55 to 18.2.58.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Build(deps): bump @keplr-wallet/cosmos from 0.12.67 to 0.12.70 (#824)

Bumps @keplr-wallet/cosmos from 0.12.67 to 0.12.70.

---
updated-dependencies:
- dependency-name: "@keplr-wallet/cosmos"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Build(deps-dev): bump @types/node from 20.11.17 to 20.11.20 (#826)

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 20.11.17 to 20.11.20.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Build(deps-dev): bump dotenv from 16.4.3 to 16.4.5 (#825)

Bumps [dotenv](https://github.com/motdotla/dotenv) from 16.4.3 to 16.4.5.
- [Changelog](https://github.com/motdotla/dotenv/blob/master/CHANGELOG.md)
- [Commits](motdotla/dotenv@v16.4.3...v16.4.5)

---
updated-dependencies:
- dependency-name: dotenv
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Build(deps): bump zustand from 4.5.0 to 4.5.1 (#822)

Bumps [zustand](https://github.com/pmndrs/zustand) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/pmndrs/zustand/releases)
- [Commits](pmndrs/zustand@v4.5.0...v4.5.1)

---
updated-dependencies:
- dependency-name: zustand
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Build(deps): bump react-router-dom from 6.22.0 to 6.22.2 (#829)

Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.22.0 to 6.22.2.
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/[email protected]/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router-dom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Build(deps): bump next from 14.1.0 to 14.1.3 (#835)

Bumps [next](https://github.com/vercel/next.js) from 14.1.0 to 14.1.3.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](vercel/next.js@v14.1.0...v14.1.3)

---
updated-dependencies:
- dependency-name: next
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Build(deps-dev): bump eslint-config-next from 14.1.0 to 14.1.3 (#836)

Bumps [eslint-config-next](https://github.com/vercel/next.js/tree/HEAD/packages/eslint-config-next) from 14.1.0 to 14.1.3.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/commits/v14.1.3/packages/eslint-config-next)

---
updated-dependencies:
- dependency-name: eslint-config-next
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Tv implementation fix (#842)

* fix: change tradingView to check for server

* fix: adjust tv rules

* fix: isServer dependency

* fix: update after server check

* fix: useEffect adjustments

* debug: tv load

* fix: use headerReady instead of onChartReady

* fic: check chartContainerRef

* Mobile finetuning (#843)

* fix: fix mobile navigation interaction

* fix: chart interactions

* fix: disable scrolling events

* tidy: refactor

* Implement dynamic routes + price impact (#748)

* Implement dynamic routes + price impact

* updated branch + fix small bugs

* Mobile Adjustments (#845)

* env: update version

* feat: set min asset amount to > 0

* debug: broadcast options

* feat: update app logo

* fix: fixed walletConnect

* fix: update pinned tab

* fix: favicon refactor

* fix: fixed the asset selector overlay

* fix: adjust cosmClient

* fix: fix wallet switch and v1 first connect

* tidy: cleanup and remove spline

* fix: create hook for tx fees

* Build(deps): bump @keplr-wallet/cosmos from 0.12.70 to 0.12.72 (#838)

Bumps @keplr-wallet/cosmos from 0.12.70 to 0.12.72.

---
updated-dependencies:
- dependency-name: "@keplr-wallet/cosmos"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Build(deps): bump react-router-dom from 6.22.2 to 6.22.3 (#839)

Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.22.2 to 6.22.3.
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/[email protected]/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router-dom
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Build(deps-dev): bump @types/react-dom from 18.2.19 to 18.2.21 (#841)

Bumps [@types/react-dom](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-dom) from 18.2.19 to 18.2.21.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-dom)

---
updated-dependencies:
- dependency-name: "@types/react-dom"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

* Build(deps-dev): bump prettier-plugin-tailwindcss from 0.5.11 to 0.5.12 (#840)

Bumps [prettier-plugin-tailwindcss](https://github.com/tailwindlabs/prettier-plugin-tailwindcss) from 0.5.11 to 0.5.12.
- [Release notes](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/releases)
- [Changelog](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/blob/main/CHANGELOG.md)
- [Commits](tailwindlabs/prettier-plugin-tailwindcss@v0.5.11...v0.5.12)

---
updated-dependencies:
- dependency-name: prettier-plugin-tailwindcss
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Linkie Link <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Bob van der Helm <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 15, 2024
1 parent e4d1b98 commit d3dc32b
Show file tree
Hide file tree
Showing 55 changed files with 939 additions and 908 deletions.
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mars-v2-frontend",
"version": "2.2.4",
"version": "2.3.0",
"homepage": "./",
"private": false,
"license": "SEE LICENSE IN LICENSE FILE",
Expand All @@ -20,11 +20,9 @@
]
},
"dependencies": {
"@cosmjs/cosmwasm-stargate": "^0.32.2",
"@cosmjs/cosmwasm-stargate": "^0.32.3",
"@delphi-labs/shuttle-react": "^3.19.1",
"@keplr-wallet/cosmos": "^0.12.70",
"@splinetool/react-spline": "^2.2.6",
"@splinetool/runtime": "^1.0.55",
"@keplr-wallet/cosmos": "^0.12.74",
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/react-table": "^8.13.2",
"@tippyjs/react": "^4.2.6",
Expand All @@ -35,14 +33,14 @@
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"moment": "^2.30.1",
"next": "^14.1.0",
"next": "^14.1.3",
"react": "^18.2.0",
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
"react-draggable": "^4.4.6",
"react-helmet-async": "^2.0.4",
"react-qr-code": "^2.0.12",
"react-router-dom": "^6.22.2",
"react-router-dom": "^6.22.3",
"react-spring": "^9.7.3",
"react-toastify": "^10.0.4",
"react-use-clipboard": "^1.0.9",
Expand All @@ -58,19 +56,19 @@
"@types/lodash.throttle": "^4.1.9",
"@types/node": "^20.11.24",
"@types/react": "18.2.61",
"@types/react-dom": "18.2.19",
"@types/react-dom": "18.2.21",
"@types/react-helmet": "^6.1.11",
"autoprefixer": "^10.4.17",
"dotenv": "^16.4.5",
"dotenv-cli": "^7.3.0",
"eslint": "^8.57.0",
"eslint-config-next": "^14.1.0",
"eslint-config-next": "^14.1.3",
"eslint-plugin-import": "^2.29.1",
"husky": "^9.0.11",
"identity-obj-proxy": "^3.0.0",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.11",
"prettier-plugin-tailwindcss": "^0.5.12",
"shelljs": "^0.8.5",
"tailwindcss": "^3.4.1",
"typescript": "5.3.3"
Expand Down
172 changes: 144 additions & 28 deletions public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
383 changes: 137 additions & 246 deletions public/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions public/tradingview.css
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ button[class^='button-'][class*='secondary-']:hover {
background-image: linear-gradient(0deg, var(--tv-background), transparent) !important;
}

[class^='noWrapWrapper-'] * {
pointer-events: none !important;
border: none !important;
background: transparent !important;
outline: none !important;
}

html.theme-dark ::selection {
background: var(--tv-background) !important;
color: var(--tv-menu-text-hover) !important;
Expand Down
7 changes: 3 additions & 4 deletions src/components/Modals/v1/Deposit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useCallback, useEffect, useMemo, useState } from 'react'

import AssetAmountSelectActionModal from 'components/Modals/AssetAmountSelectActionModal'
import DetailsHeader from 'components/Modals/LendAndReclaim/DetailsHeader'
import WalletBridges from 'components/Wallet/WalletBridges'
import { BN_ZERO } from 'constants/math'
import useBaseAsset from 'hooks/assets/useBasetAsset'
Expand All @@ -9,10 +11,7 @@ import useWalletBalances from 'hooks/useWalletBalances'
import useStore from 'store'
import { BNCoin } from 'types/classes/BNCoin'
import { byDenom } from 'utils/array'
import { defaultFee } from 'utils/constants'
import { BN } from 'utils/helpers'
import AssetAmountSelectActionModal from 'components/Modals/AssetAmountSelectActionModal'
import DetailsHeader from 'components/Modals/LendAndReclaim/DetailsHeader'

interface Props {
account: Account
Expand Down Expand Up @@ -47,7 +46,7 @@ export default function Deposit(props: Props) {
}, [v1Action, fundingAsset, close])

useEffect(() => {
if (BN(baseBalance).isLessThan(defaultFee.amount[0].amount)) {
if (BN(baseBalance).isZero()) {
useStore.setState({ focusComponent: { component: <WalletBridges /> } })
}
}, [baseBalance])
Expand Down
6 changes: 3 additions & 3 deletions src/components/Wallet/WalletBridges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import { useShuttle } from '@delphi-labs/shuttle-react'
import Image from 'next/image'
import { useCallback, useEffect, useMemo } from 'react'

import WalletFetchBalancesAndAccounts from 'components/Wallet/WalletFetchBalancesAndAccounts'
import WalletSelect from 'components/Wallet/WalletSelect'
import Button from 'components/common/Button'
import FullOverlayContent from 'components/common/FullOverlayContent'
import { ChevronRight } from 'components/common/Icons'
import Text from 'components/common/Text'
import WalletFetchBalancesAndAccounts from 'components/Wallet/WalletFetchBalancesAndAccounts'
import WalletSelect from 'components/Wallet/WalletSelect'
import { BRIDGES } from 'constants/bridges'
import useBaseAsset from 'hooks/assets/useBasetAsset'
import useChainConfig from 'hooks/useChainConfig'
import useCurrentWallet from 'hooks/useCurrentWallet'
import useToggle from 'hooks/useToggle'
import useWalletBalances from 'hooks/useWalletBalances'
import useStore from 'store'
import { byDenom } from 'utils/array'
import { defaultFee } from 'utils/constants'
import { BN } from 'utils/helpers'
import useChainConfig from 'hooks/useChainConfig'

function Bridge({ name, url, image }: Bridge) {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Wallet/WalletConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function WalletConnectButton(props: Props) {

const handleClick = useCallback(() => {
const component = hasAgreedToTerms ? <WalletSelect /> : <TermsOfService />
useStore.setState({ focusComponent: { component } })
useStore.setState({ focusComponent: { component }, mobileNavExpanded: false })
}, [hasAgreedToTerms])

return (
Expand Down
5 changes: 2 additions & 3 deletions src/components/Wallet/WalletConnecting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import useChainConfig from 'hooks/useChainConfig'
import useCurrentWallet from 'hooks/useCurrentWallet'
import useToggle from 'hooks/useToggle'
import useStore from 'store'
import { getUrl } from 'utils/url'

interface Props {
providerId?: string
Expand Down Expand Up @@ -54,7 +53,7 @@ export default function WalletConnecting(props: Props) {
setIsConnecting(true)
try {
const response = await connect({ extensionProviderId, chainId: chainConfig.id })
const cosmClient = await CosmWasmClient.connect(getUrl(chainConfig.endpoints.rpc))
const cosmClient = await CosmWasmClient.connect(chainConfig.endpoints.rpc)
const walletClient: WalletClient = {
broadcast,
cosmWasmClient: cosmClient,
Expand Down Expand Up @@ -138,7 +137,7 @@ export default function WalletConnecting(props: Props) {
setIsConnecting(true)
try {
await mobileConnect({ mobileProviderId, chainId: chainConfig.id })
const cosmClient = await CosmWasmClient.connect(getUrl(chainConfig.endpoints.rpc))
const cosmClient = await CosmWasmClient.connect(chainConfig.endpoints.rpc)
const walletClient: WalletClient = {
broadcast,
cosmWasmClient: cosmClient,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Wallet/WalletFetchBalancesAndAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ function Content() {
])

if (isLoadingAccounts || isLoadingBalances) return <FetchLoading />
if (BN(baseBalance).isLessThan(defaultFee.amount[0].amount)) return <WalletBridges />
if (BN(baseBalance).isZero()) return <WalletBridges />
if (accountIds && accountIds.length === 0 && !isV1) return <AccountCreateFirst />
if (isV1) useStore.setState({ focusComponent: null })
return null
}

Expand Down
5 changes: 2 additions & 3 deletions src/components/Wallet/WalletSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default function WalletSelect(props: Props) {
const chainConfig = useChainConfig()
const { extensionProviders, mobileProviders, mobileConnect } = useShuttle()
const [qrCodeUrl, setQRCodeUrl] = useState('')
const address = useStore((s) => s.address)
const [error, setError] = useState(props.error)
const [isLoading, setIsLoading] = useState<string | boolean>(false)
const sortedExtensionProviders = extensionProviders.sort((a, b) => +b - +a)
Expand Down Expand Up @@ -102,7 +101,7 @@ export default function WalletSelect(props: Props) {
}

useEffect(() => {
if (!address && !recentWallet) return
if (!recentWallet) return
useStore.setState({
focusComponent: {
component: <WalletConnecting providerId={recentWallet?.providerId} />,
Expand All @@ -111,7 +110,7 @@ export default function WalletSelect(props: Props) {
},
},
})
}, [address, recentWallet])
}, [recentWallet])

useEffect(() => {
if (error?.message && error?.title) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function Wallet() {
const address = useStore((s) => s.address)

useEffect(() => {
if (address) return
if (address && currentWallet?.account.address === address) return
useStore.setState({
address: undefined,
userDomain: undefined,
Expand Down
3 changes: 1 addition & 2 deletions src/components/account/AccountFund/AccountFundContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import useWalletBalances from 'hooks/useWalletBalances'
import useStore from 'store'
import { BNCoin } from 'types/classes/BNCoin'
import { byDenom } from 'utils/array'
import { defaultFee } from 'utils/constants'
import { getCapLeftWithBuffer } from 'utils/generic'
import { BN } from 'utils/helpers'

Expand Down Expand Up @@ -90,7 +89,7 @@ export default function AccountFundContent(props: Props) {
}, [props.accountId, deposit, fundingAssets, isLending, props.isFullPage])

useEffect(() => {
if (BN(baseBalance).isLessThan(defaultFee.amount[0].amount)) {
if (BN(baseBalance).isZero()) {
useStore.setState({ focusComponent: { component: <WalletBridges /> } })
}
}, [baseBalance])
Expand Down
21 changes: 5 additions & 16 deletions src/components/account/AccountMenuContent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames'
import { useCallback } from 'react'
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'
import { isMobile } from 'react-device-detect'
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'

import WalletBridges from 'components/Wallet/WalletBridges'
import AccountCreateFirst from 'components/account/AccountCreateFirst'
Expand All @@ -12,15 +12,12 @@ import { Account, Plus, PlusCircled } from 'components/common/Icons'
import Overlay from 'components/common/Overlay'
import Text from 'components/common/Text'
import useAccountIds from 'hooks/accounts/useAccountIds'
import useBaseAsset from 'hooks/assets/useBasetAsset'
import useEnableAutoLendGlobal from 'hooks/localStorage/useEnableAutoLendGlobal'
import useAccountId from 'hooks/useAccountId'
import useAutoLend from 'hooks/useAutoLend'
import useCurrentWalletBalance from 'hooks/useCurrentWalletBalance'
import useHasFundsForTxFee from 'hooks/useHasFundsForTxFee'
import useToggle from 'hooks/useToggle'
import useStore from 'store'
import { defaultFee } from 'utils/constants'
import { BN } from 'utils/helpers'
import { isNumber } from 'utils/parsers'
import { getPage, getRoute } from 'utils/route'

Expand All @@ -40,24 +37,16 @@ export default function AccountMenuContent(props: Props) {
const [searchParams] = useSearchParams()

const createAccount = useStore((s) => s.createAccount)
const baseAsset = useBaseAsset()
const [showMenu, setShowMenu] = useToggle()
const [isCreating, setIsCreating] = useToggle()
const transactionFeeCoinBalance = useCurrentWalletBalance(baseAsset.denom)
const hasFundsForTxFee = useHasFundsForTxFee()
const [enableAutoLendGlobal] = useEnableAutoLendGlobal()
const { enableAutoLendAccountId } = useAutoLend()

const hasCreditAccounts = !!accountIds?.length
const isAccountSelected =
hasCreditAccounts && accountId && isNumber(accountId) && accountIds.includes(accountId)

const checkHasFunds = useCallback(() => {
return (
transactionFeeCoinBalance &&
BN(transactionFeeCoinBalance.amount).isGreaterThan(defaultFee.amount[0].amount)
)
}, [transactionFeeCoinBalance])

const performCreateAccount = useCallback(async () => {
setShowMenu(false)
setIsCreating(true)
Expand Down Expand Up @@ -90,15 +79,15 @@ export default function AccountMenuContent(props: Props) {

const handleCreateAccountClick = useCallback(() => {
setShowMenu(!showMenu)
if (!checkHasFunds() && !hasCreditAccounts) {
if (!hasFundsForTxFee && !hasCreditAccounts) {
useStore.setState({ focusComponent: { component: <WalletBridges /> } })
return
}
if (!hasCreditAccounts) {
useStore.setState({ focusComponent: { component: <AccountCreateFirst /> } })
return
}
}, [checkHasFunds, hasCreditAccounts, setShowMenu, showMenu])
}, [hasFundsForTxFee, hasCreditAccounts, setShowMenu, showMenu])

if (!address) return null

Expand Down
3 changes: 1 addition & 2 deletions src/components/common/Button/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default function ActionButton(props: Props) {
const defaultProps = { className, color, variant, size }
const address = useStore((s) => s.address)
const isV1 = useStore((s) => s.isV1)

const { data: accountIds } = useAccountIds(address || '')
const selectedAccountId = useAccountId()

Expand All @@ -29,7 +28,7 @@ export default function ActionButton(props: Props) {
if (!address)
return <WalletConnectButton {...defaultProps} textOverride={short ? 'Connect' : undefined} />

if (accountIds && accountIds.length === 0) {
if (accountIds && accountIds.length === 0 && !isV1) {
return (
<Button
onClick={handleCreateAccountClick}
Expand Down
18 changes: 8 additions & 10 deletions src/components/common/DefaultPageHead.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Head from 'next/head'
import { isMobile } from 'react-device-detect'

function DefaultPageHead() {
return (
<Head>
<title>Mars Protocol V2</title>
<title>Mars Protocol</title>
<meta charSet='utf-8' />
<link href='/favicon.svg' rel='icon' />
<link href='/apple-touch-icon.png' rel='apple-touch-icon' sizes='180x180' />
Expand All @@ -14,16 +13,15 @@ function DefaultPageHead() {
<meta content='summary_large_image' name='twitter:card' />
<meta content='@mars_protocol' name='twitter:site' />
<meta content='@mars_protocol' name='twitter:creator' />
<meta content='https://osmosis.marsprotocol.io' property='og:url' />
<meta content='https://osmosis.marsprotocol.io/banner.png' property='og:image' />
<meta content='Mars Protocol V2' property='og:site_name' />
<meta content='https://app.marsprotocol.io' property='og:url' />
<meta content='https://app.marsprotocol.io/banner.png' property='og:image' />
<meta content='Mars Protocol' property='og:site_name' />
<meta content='#ffffff' name='msapplication-TileColor' />
<meta content='#ffffff' name='theme-color' />
{isMobile ? (
<meta name='viewport' content='width=device-width, initial-scale=1, user-scalable=no' />
) : (
<meta name='viewport' content='width=device-width, initial-scale=1' />
)}
<meta
name='viewport'
content='width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0'
/>
</Head>
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/LeverageSlider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ function LeverageSlider(props: Props) {
'relative w-full appearance-none bg-transparent hover:cursor-pointer',
'[&::-webkit-slider-runnable-track]:bg-white [&::-webkit-slider-runnable-track]:bg-opacity-20 [&::-webkit-slider-runnable-track]:h-[9px] [&::-webkit-slider-runnable-track]:rounded-lg',
'[&::-moz-range-track]:bg-white [&::-moz-range-track]:bg-opacity-20 [&::-moz-range-track]:h-1 [&::-moz-range-track]:pb-[5px] [&::-moz-range-track]:rounded-lg',
'[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:-mt-1 [&::-webkit-slider-thumb]:w-[33px] [&::-webkit-slider-thumb]:h-4',
'[&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:opacity-0 [&::-moz-range-thumb]:w-[33px] [&::-moz-range-thumb]:h-4',
'[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:bg-transparent [&::-webkit-slider-thumb]:-mt-1 [&::-webkit-slider-thumb]:w-[33px] [&::-webkit-slider-thumb]:h-4',
'[&::-moz-range-thumb]:appearance-none [&::-moz-range-thumb]:bg-transparent [&::-moz-range-thumb]:opacity-0 [&::-moz-range-thumb]:w-[33px] [&::-moz-range-thumb]:h-4',
)}
type='range'
value={value.toFixed(2)}
Expand Down
Loading

0 comments on commit d3dc32b

Please sign in to comment.