From 7b8b073c3c282894576a46f1f26dc3078fe0c510 Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Wed, 8 Feb 2023 00:17:04 +0100 Subject: [PATCH 1/3] fix: fixed ledger support --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31e7006..64130fe 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@cosmjs/launchpad": "^0.27.1", "@cosmjs/proto-signing": "^0.29.5", "@cosmjs/stargate": "^0.29.5", - "@marsprotocol/wallet-connector": "^1.3.0", + "@marsprotocol/wallet-connector": "^1.3.1", "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", "@ramonak/react-progress-bar": "^5.0.3", From 6c02a85514d35060c6d47809a800d7a9c24660b1 Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Wed, 8 Feb 2023 00:22:24 +0100 Subject: [PATCH 2/3] update: yarn.lock --- yarn.lock | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/yarn.lock b/yarn.lock index 17114a5..d77114d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -537,10 +537,10 @@ resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.29.5.tgz#3fed1b3528ae8c5f1eb5d29b68755bebfd3294ee" integrity sha512-m7h+RXDUxOzEOGt4P+3OVPX7PuakZT3GBmaM/Y2u+abN3xZkziykD/NvedYFvvCCdQo714XcGl33bwifS9FZPQ== -"@delphi-labs/shuttle@^2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@delphi-labs/shuttle/-/shuttle-2.3.2.tgz#d05890bca91b3b18fc451bde3cb03d83072c1c42" - integrity sha512-xgebNiS761IPiqQ5q3no1CBNGD/Q5vznV7ydUqismzR/Vw4GIEAqJv6QFIe7HbjHPXkIPeL/enimEGwAnNB1Ag== +"@delphi-labs/shuttle@^2.3.6": + version "2.3.6" + resolved "https://registry.yarnpkg.com/@delphi-labs/shuttle/-/shuttle-2.3.6.tgz#91d047d31e077fe001f155e4abed9faf36a9100c" + integrity sha512-dhUphKn/MhUdbKIVmZFL5QvK5CqjJBrQ+io/euncgMwjAQyCOwLReXoncpF8DzwEcADJdFpmHhUurAWlWxG5ZA== dependencies: "@cosmjs/amino" "^0.29.5" "@cosmjs/cosmwasm-stargate" "^0.29.2" @@ -560,9 +560,11 @@ "@walletconnect/utils" "^1.8.0" cosmjs-types "^0.6.1" ethereumjs-util "^7.1.5" + isomorphic-ws "^5.0.0" long "^5.2.1" secp256k1 "^5.0.0" tslib "^2.4.0" + ws "^8.12.0" zustand "^4.3.1" "@discoveryjs/json-ext@^0.5.0": @@ -1495,13 +1497,13 @@ resolved "https://registry.yarnpkg.com/@kurkle/color/-/color-0.3.2.tgz#5acd38242e8bde4f9986e7913c8fdf49d3aa199f" integrity sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw== -"@marsprotocol/wallet-connector@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@marsprotocol/wallet-connector/-/wallet-connector-1.3.0.tgz#1d7a47c5a2ee94e23f7b3703638a7526b35fd8ba" - integrity sha512-O9zyUtWNrggRE1LeilofR8BunhwP6lCY5g5+WU1BDI/V2AqzV9tdNdjYg5CGEO2Z8iXb21Y+o4RoiZ7mknezzQ== +"@marsprotocol/wallet-connector@^1.3.1": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@marsprotocol/wallet-connector/-/wallet-connector-1.3.1.tgz#1875c92f87876342469a9190ae5ca44d6c0f552e" + integrity sha512-zi6QsPt5/1nvX/4IlpoGubJO2M4/gqlmTd6WdHACeeCOYNV2UtlpNepvjPDIcTJn5Ls0xK8Ig+3JiEtGJeiWpw== dependencies: "@cosmjs/cosmwasm-stargate" "^0.29.5" - "@delphi-labs/shuttle" "^2.3.2" + "@delphi-labs/shuttle" "^2.3.6" "@keplr-wallet/cosmos" "^0.11.38" axios "^1.3.2" react-device-detect "^2.2.2" @@ -2218,7 +2220,7 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== -"@types/node@*", "@types/node@>=13.7.0", "@types/node@^18.11.18": +"@types/node@*", "@types/node@>=13.7.0": version "18.11.18" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f" integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA== @@ -2233,6 +2235,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== +"@types/node@^18.13.0": + version "18.13.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.13.0.tgz#0400d1e6ce87e9d3032c19eb6c58205b0d3f7850" + integrity sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg== + "@types/numeral@^2.0.2": version "2.0.2" resolved "https://registry.yarnpkg.com/@types/numeral/-/numeral-2.0.2.tgz#8ea2c4f4e64c0cc948ad7da375f6f827778a7912" @@ -5177,6 +5184,11 @@ isomorphic-ws@^4.0.1: resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== +isomorphic-ws@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz#e5529148912ecb9b451b46ed44d53dae1ce04bbf" + integrity sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw== + istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz#189e7909d0a39fa5a3dfad5b03f71947770191d3" @@ -7944,7 +7956,7 @@ ws@^7: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== -ws@^8.11.0: +ws@^8.11.0, ws@^8.12.0: version "8.12.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.12.0.tgz#485074cc392689da78e1828a9ff23585e06cddd8" integrity sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig== From c0b35bf01c8aa5ee4926b4c15fc7cf8572fa6777 Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Fri, 10 Feb 2023 18:27:20 +0100 Subject: [PATCH 3/3] feat: updated the wallet connector --- package.json | 2 +- sentry.client.config.js | 19 ------- sentry.properties | 4 -- sentry.server.config.js | 18 ------- src/components/common/Button/Button.tsx | 5 +- .../ErrorMessage/ErrorMessage.module.scss | 18 +++++++ .../common/ErrorMessage/ErrorMessage.tsx | 14 +++++ .../Header/IncentivesButton.module.scss | 9 ---- .../common/Header/IncentivesButton.tsx | 30 +++++++++-- .../InputSection/InputSection.module.scss | 1 + .../common/InputSection/InputSection.tsx | 13 ++--- .../common/MobileNav/MobileNav.module.scss | 20 +++++-- src/components/common/MobileNav/MobileNav.tsx | 9 ++-- src/components/common/Tutorial/Tutorial.tsx | 11 ++-- .../common/TxModal/Action.module.scss | 6 --- src/components/common/TxModal/Action.tsx | 30 ++++++----- src/components/common/index.ts | 1 + .../useActiveVaultsColumns.tsx | 2 +- .../useAvailableVaultsColumns.tsx | 15 ++++-- .../BreakdownTable/BreakdownTable.tsx | 8 ++- .../redbank/RedbankAction/RedbankAction.tsx | 15 ++++-- src/configs/osmosis-1.ts | 20 +++---- src/hooks/queries/useEstimateFee.tsx | 22 ++++---- src/images/farm.svg | 1 + src/images/redbank.svg | 1 + src/pages/_document.tsx | 2 +- .../farm/vault/[address]/create/index.tsx | 20 +++++-- .../[address]/create/setup/SetupPosition.tsx | 2 +- .../farm/vault/[address]/edit/EditVault.tsx | 9 +++- .../farm/vault/[address]/repay/RepayVault.tsx | 9 +++- src/pages/redbank/index.tsx | 19 +++++-- src/store/interfaces/redBank.interface.ts | 1 + src/store/slices/common.ts | 6 ++- src/store/slices/redBank.ts | 1 + yarn.lock | 53 ++++++++++++------- 35 files changed, 260 insertions(+), 156 deletions(-) delete mode 100644 sentry.client.config.js delete mode 100644 sentry.properties delete mode 100644 sentry.server.config.js create mode 100644 src/components/common/ErrorMessage/ErrorMessage.module.scss create mode 100644 src/components/common/ErrorMessage/ErrorMessage.tsx create mode 100644 src/images/farm.svg create mode 100644 src/images/redbank.svg diff --git a/package.json b/package.json index 64130fe..c99916b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@cosmjs/launchpad": "^0.27.1", "@cosmjs/proto-signing": "^0.29.5", "@cosmjs/stargate": "^0.29.5", - "@marsprotocol/wallet-connector": "^1.3.1", + "@marsprotocol/wallet-connector": "^1.4.2", "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", "@ramonak/react-progress-bar": "^5.0.3", diff --git a/sentry.client.config.js b/sentry.client.config.js deleted file mode 100644 index aa866db..0000000 --- a/sentry.client.config.js +++ /dev/null @@ -1,19 +0,0 @@ -// This file configures the initialization of Sentry on the browser. -// The config you add here will be used whenever a page is visited. -// https://docs.sentry.io/platforms/javascript/guides/nextjs/ - -import * as Sentry from '@sentry/nextjs' - -const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN - -Sentry.init({ - environment: process.env.NEXT_PUBLIC_SENTRY_ENV, - dsn: SENTRY_DSN, - // Adjust this value in production, or use tracesSampler for greater control - tracesSampleRate: 0.5, - // ... - // Note: if you want to override the automatic release value, do not set a - // `release` value here - use the environment variable `SENTRY_RELEASE`, so - // that it will also get attached to your source maps - enabled: process.env.NODE_ENV !== 'development', -}) diff --git a/sentry.properties b/sentry.properties deleted file mode 100644 index 5ab042b..0000000 --- a/sentry.properties +++ /dev/null @@ -1,4 +0,0 @@ -defaults.url=https://sentry.io/ -defaults.org=delphi-mars -defaults.project=mars-dapp -cli.executable=../../../.npm/_npx/a8388072043b4cbc/node_modules/@sentry/cli/bin/sentry-cli diff --git a/sentry.server.config.js b/sentry.server.config.js deleted file mode 100644 index 320b83f..0000000 --- a/sentry.server.config.js +++ /dev/null @@ -1,18 +0,0 @@ -// This file configures the initialization of Sentry on the server. -// The config you add here will be used whenever the server handles a request. -// https://docs.sentry.io/platforms/javascript/guides/nextjs/ - -import * as Sentry from '@sentry/nextjs' - -const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN - -Sentry.init({ - dsn: SENTRY_DSN, - // Adjust this value in production, or use tracesSampler for greater control - tracesSampleRate: 0.5, - // ... - // Note: if you want to override the automatic release value, do not set a - // `release` value here - use the environment variable `SENTRY_RELEASE`, so - // that it will also get attached to your source maps - enabled: process.env.NODE_ENV !== 'development', -}) diff --git a/src/components/common/Button/Button.tsx b/src/components/common/Button/Button.tsx index 41a8165..bec03ae 100644 --- a/src/components/common/Button/Button.tsx +++ b/src/components/common/Button/Button.tsx @@ -1,7 +1,6 @@ import classNames from 'classnames' import { CircularProgress } from 'components/common' -import React from 'react' -import { ReactNode } from 'react' +import React, { ReactNode } from 'react' import styles from './Button.module.scss' @@ -46,7 +45,7 @@ export const Button = React.forwardRef( styles[size], styles[color], styles[variant], - disabled && styles.disabled, + (disabled || showProgressIndicator) && styles.disabled, className, ) return ( diff --git a/src/components/common/ErrorMessage/ErrorMessage.module.scss b/src/components/common/ErrorMessage/ErrorMessage.module.scss new file mode 100644 index 0000000..439e202 --- /dev/null +++ b/src/components/common/ErrorMessage/ErrorMessage.module.scss @@ -0,0 +1,18 @@ +@import 'src/styles/master'; + +.errorMessage { + text-align: left; + @include margin(2, 0, -2); + display: block; + width: 100%; + @include typoXS; + color: $colorInfoWarning; + + &.center { + text-align: center; + } + + &.right { + text-align: right; + } +} diff --git a/src/components/common/ErrorMessage/ErrorMessage.tsx b/src/components/common/ErrorMessage/ErrorMessage.tsx new file mode 100644 index 0000000..2a859cf --- /dev/null +++ b/src/components/common/ErrorMessage/ErrorMessage.tsx @@ -0,0 +1,14 @@ +import classNames from 'classnames' + +import styles from './ErrorMessage.module.scss' + +interface Props { + errorMessage?: string + alignment?: 'left' | 'center' | 'right' +} + +export const ErrorMessage = (props: Props) => { + const classes = classNames(styles.errorMessage, props.alignment && styles[props.alignment]) + + return props.errorMessage ?

{props.errorMessage}

: null +} diff --git a/src/components/common/Header/IncentivesButton.module.scss b/src/components/common/Header/IncentivesButton.module.scss index d6bc8e1..7343eff 100644 --- a/src/components/common/Header/IncentivesButton.module.scss +++ b/src/components/common/Header/IncentivesButton.module.scss @@ -220,15 +220,6 @@ button { width: 100%; } - - .error { - @include margin(2, 0, 0); - @include typoS; - width: 100%; - text-align: center; - font-weight: $fontWeightSemibold; - color: $colorInfoLoss; - } } } diff --git a/src/components/common/Header/IncentivesButton.tsx b/src/components/common/Header/IncentivesButton.tsx index dc55f94..b7f6b26 100644 --- a/src/components/common/Header/IncentivesButton.tsx +++ b/src/components/common/Header/IncentivesButton.tsx @@ -1,7 +1,15 @@ import { ChainInfoID, SimpleChainInfoList, TxBroadcastResult } from '@marsprotocol/wallet-connector' import { useQueryClient } from '@tanstack/react-query' import classNames from 'classnames' -import { AnimatedNumber, Button, DisplayCurrency, SVG, Tooltip, TxLink } from 'components/common' +import { + AnimatedNumber, + Button, + DisplayCurrency, + ErrorMessage, + SVG, + Tooltip, + TxLink, +} from 'components/common' import { MARS_DECIMALS, MARS_SYMBOL } from 'constants/appConstants' import { getClaimUserRewardsMsgOptions } from 'functions/messages' import { useEstimateFee } from 'hooks/queries' @@ -36,6 +44,7 @@ export const IncentivesButton = () => { // --------------- const [showDetails, setShowDetails] = useState(false) const [disabled, setDisabled] = useState(true) + const [fetching, setFetching] = useState(false) const [submitted, setSubmitted] = useState(false) const [response, setResponse] = useState() const [error, setError] = useState() @@ -53,6 +62,7 @@ export const IncentivesButton = () => { const onClickAway = useCallback(() => { setShowDetails(false) setResponse(undefined) + setError(undefined) }, []) useEffect(() => { @@ -64,12 +74,22 @@ export const IncentivesButton = () => { return getClaimUserRewardsMsgOptions() }, [hasUnclaimedRewards]) - const { data: fee } = useEstimateFee({ + const { data: fee, error: feeError } = useEstimateFee({ msg: txMsgOptions?.msg, funds: [], contract: incentivesContractAddress, }) + if (feeError && error !== feeError && !fee) { + setError(feeError as string) + } + + useEffect(() => { + const isFetching = submitted || (!fee && !response && hasUnclaimedRewards) + if (fetching === isFetching) return + setFetching(isFetching) + }, [submitted, fetching, fee, response, hasUnclaimedRewards]) + useEffect(() => { if (error) { setDisabled(!hasUnclaimedRewards) @@ -186,8 +206,8 @@ export const IncentivesButton = () => { )}
diff --git a/src/components/common/InputSection/InputSection.module.scss b/src/components/common/InputSection/InputSection.module.scss index 73ecbac..5b69114 100644 --- a/src/components/common/InputSection/InputSection.module.scss +++ b/src/components/common/InputSection/InputSection.module.scss @@ -153,6 +153,7 @@ display: flex; justify-content: center; margin-bottom: space(3); + flex-wrap: wrap; } } diff --git a/src/components/common/InputSection/InputSection.tsx b/src/components/common/InputSection/InputSection.tsx index 48adcbd..30562d9 100644 --- a/src/components/common/InputSection/InputSection.tsx +++ b/src/components/common/InputSection/InputSection.tsx @@ -18,6 +18,7 @@ interface Props { disabled?: boolean amountUntilDepositCap: number activeView: ViewType + walletBalance: number inputCallback: (value: number) => void onEnterHandler: () => void setAmountCallback: (value: number) => void @@ -33,6 +34,7 @@ export const InputSection = ({ disabled, amountUntilDepositCap, activeView, + walletBalance, inputCallback, onEnterHandler, setAmountCallback, @@ -90,15 +92,14 @@ export const InputSection = ({ useEffect( () => { + if (asset.denom !== baseCurrency.denom || !checkForMaxValue) return if ( - amount >= maxUsableAmount && - asset.denom === baseCurrency.denom && - !depositWarning && - checkForMaxValue + (activeView === ViewType.Repay && walletBalance <= amount) || + (activeView === ViewType.Deposit && amount >= maxUsableAmount) ) { - setDepositWarning(true) + if (!depositWarning) setDepositWarning(true) } else { - setDepositWarning(false) + if (depositWarning) setDepositWarning(false) } }, // eslint-disable-next-line react-hooks/exhaustive-deps [sliderValue, amount, maxUsableAmount], diff --git a/src/components/common/MobileNav/MobileNav.module.scss b/src/components/common/MobileNav/MobileNav.module.scss index 8501305..ec472c0 100644 --- a/src/components/common/MobileNav/MobileNav.module.scss +++ b/src/components/common/MobileNav/MobileNav.module.scss @@ -27,7 +27,7 @@ opacity: 0.4; &.active { - filter: grayscale(0); + filter: unset; opacity: 1; } @@ -37,9 +37,23 @@ @include typoXScaps; } - svg { + .icon { width: rem-calc(50); - height: auto; + height: rem-calc(50); + display: block; + + svg { + width: 100%; + height: auto; + } + + &.redBank { + background: url('../../../images/redbank.svg'); + } + + &.farm { + background: url('../../../images/farm.svg'); + } } } } diff --git a/src/components/common/MobileNav/MobileNav.tsx b/src/components/common/MobileNav/MobileNav.tsx index 45d8f0e..7767bf9 100644 --- a/src/components/common/MobileNav/MobileNav.tsx +++ b/src/components/common/MobileNav/MobileNav.tsx @@ -20,11 +20,14 @@ export const MobileNav = () => { passHref className={classNames(styles.nav, !router.pathname.includes('farm') && styles.active)} > - +
{t('global.redBank')} + - +
+ +
{t('global.council')}
{FIELDS_FEATURE && ( @@ -33,7 +36,7 @@ export const MobileNav = () => { passHref className={classNames(styles.nav, router.pathname.includes('farm') && styles.active)} > - +
{t('global.fields')} )} diff --git a/src/components/common/Tutorial/Tutorial.tsx b/src/components/common/Tutorial/Tutorial.tsx index f7413a8..f0067ca 100644 --- a/src/components/common/Tutorial/Tutorial.tsx +++ b/src/components/common/Tutorial/Tutorial.tsx @@ -52,11 +52,14 @@ export const Tutorial = (props: Props) => { }, [tutorialStep, props.step]) const hideTutorial = () => { - localStorage.setItem( - props.type === 'fields' ? FIELDS_TUTORIAL_KEY : RED_BANK_TUTORIAL_KEY, - 'true', - ) + if (props.type === 'fields') { + localStorage.setItem(FIELDS_TUTORIAL_KEY, 'true') + return + } + localStorage.setItem(RED_BANK_TUTORIAL_KEY, 'true') + useStore.setState({ showRedBankTutorial: false }) } + const handleButtonClick = () => { if (props.step === 3) hideTutorial() setTutorialStep(props.type) diff --git a/src/components/common/TxModal/Action.module.scss b/src/components/common/TxModal/Action.module.scss index 150ae1c..288de50 100644 --- a/src/components/common/TxModal/Action.module.scss +++ b/src/components/common/TxModal/Action.module.scss @@ -72,12 +72,6 @@ opacity: 0.4; margin-bottom: space(9); } - - .actionButton { - display: flex; - justify-content: center; - margin-bottom: space(3); - } } .feeTooltipContent { diff --git a/src/components/common/TxModal/Action.tsx b/src/components/common/TxModal/Action.tsx index 9a48ed4..9e60472 100644 --- a/src/components/common/TxModal/Action.tsx +++ b/src/components/common/TxModal/Action.tsx @@ -8,6 +8,7 @@ import { Card, ConnectButton, DisplayCurrency, + ErrorMessage, InputSection, } from 'components/common' import { findByDenom } from 'functions' @@ -44,6 +45,7 @@ interface Props { totalBorrowBaseCurrencyAmount: number actionButtonSpec: ModalActionButton submitted: boolean + feeError?: string txFee?: Coin activeView: ViewType denom: string @@ -64,6 +66,7 @@ export const Action = ({ totalBorrowBaseCurrencyAmount, actionButtonSpec, submitted, + feeError, txFee, activeView, denom, @@ -313,22 +316,22 @@ export const Action = ({ if (microValue >= maxUsableAmount) microValue = maxUsableAmount setAmountCallback(Number(formatValue(microValue, 0, 0, false, false, false, false, false))) - setCapHit(amount > amountUntilDepositCap) + setCapHit(amount > amountUntilDepositCap && activeView === ViewType.Deposit) } const produceTabActionButton = () => { return ( -
diff --git a/src/components/redbank/RedbankAction/RedbankAction.tsx b/src/components/redbank/RedbankAction/RedbankAction.tsx index 7de97ae..17bbc47 100644 --- a/src/components/redbank/RedbankAction/RedbankAction.tsx +++ b/src/components/redbank/RedbankAction/RedbankAction.tsx @@ -120,7 +120,7 @@ export const RedbankAction = React.memo( } }, [activeView, amount, redBankContractAddress, denom, isMax, userBalances]) - const { data: fee } = useEstimateFee({ + const { data: fee, error: feeError } = useEstimateFee({ msg: txMsgOptions?.msg, funds: activeView === ViewType.Deposit || activeView === ViewType.Repay @@ -131,8 +131,8 @@ export const RedbankAction = React.memo( const produceActionButtonSpec = (): ModalActionButton => { return { - disabled: !Number(amount) || amount === 0 || typeof fee === 'undefined' || submitted, - fetching: !!Number(amount) && amount > 0 && typeof fee === 'undefined' && !capHit, + disabled: amount === 0 || capHit, + fetching: (amount > 0 && typeof fee === 'undefined') || submitted, text: t(`redbank.${activeView.toLowerCase()}`), clickHandler: handleAction, color: 'primary', @@ -157,10 +157,14 @@ export const RedbankAction = React.memo( // @ts-ignore funds: txMsgOptions.funds || [], contract: redBankContractAddress, - fee, + fee: fee, }) - setResponse(res) + if (res?.response.code !== 0) { + setError(res?.rawLogs) + } else { + setResponse(res) + } } catch (error) { const e = error as { message: string } setError(e.message as string) @@ -248,6 +252,7 @@ export const RedbankAction = React.memo( ) : ( { } const result = await client.simulate(simulateOptions) - return result.success - ? { - amount: result.fee ? result.fee.amount : [], - gas: new BigNumber(result.fee ? result.fee.gas : 0) - .multipliedBy(gasAdjustment) - .toFixed(0), - } - : null - } catch { - return null + + if (result.success) { + return { + amount: result.fee ? result.fee.amount : [], + gas: new BigNumber(result.fee ? result.fee.gas : 0) + .multipliedBy(gasAdjustment) + .toFixed(0), + } + } + throw result.error + } catch (e) { + throw e } }, { diff --git a/src/images/farm.svg b/src/images/farm.svg new file mode 100644 index 0000000..9550936 --- /dev/null +++ b/src/images/farm.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/images/redbank.svg b/src/images/redbank.svg new file mode 100644 index 0000000..075a959 --- /dev/null +++ b/src/images/redbank.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 4eda6ee..d898ebe 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -18,7 +18,7 @@ export default function Document() { - + { return } + const vaultCap = (availableVault.vaultCap?.max || 0) * VAULT_DEPOSIT_BUFFER + const isVaultCapReached = availableVault.vaultCap + ? availableVault.vaultCap.used + position.values.total > vaultCap + : false + const isDisabled = position.values.total === 0 || isVaultCapReached + return ( router.replace('/farm')} - tooltip={'placeholder'} + tooltip={ + <> + {t('fields.tooltips.editPosition')} +
+
+ {t('fields.tooltips.apy.available')} + + } > @@ -41,11 +55,11 @@ const Create = () => {