From 560442370954650e1165b2495d417d7a4bb9b392 Mon Sep 17 00:00:00 2001 From: Tyler Shipe Date: Fri, 3 Dec 2021 18:33:28 -0500 Subject: [PATCH] add loading spinner when claiming mngo rewards --- components/AccountInfo.tsx | 22 +++++++++++++++------- yarn.lock | 9 ++------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/components/AccountInfo.tsx b/components/AccountInfo.tsx index 854b377b..5368f17d 100644 --- a/components/AccountInfo.tsx +++ b/components/AccountInfo.tsx @@ -26,6 +26,7 @@ import { useViewport } from '../hooks/useViewport' import { breakpoints } from './TradePageGrid' import { useTranslation } from 'next-i18next' import useMangoAccount from '../hooks/useMangoAccount' +import Loading from './Loading' const I80F48_100 = I80F48.fromString('100') @@ -40,6 +41,7 @@ export default function AccountInfo() { const actions = useMangoStore((s) => s.actions) const { width } = useViewport() const isMobile = width ? width < breakpoints.sm : false + const [redeeming, setRedeeming] = useState(false) const [showDepositModal, setShowDepositModal] = useState(false) const [showWithdrawModal, setShowWithdrawModal] = useState(false) @@ -69,6 +71,7 @@ export default function AccountInfo() { mangoGroup.rootBankAccounts[MNGO_INDEX].nodeBankAccounts[0] try { + setRedeeming(true) const txid = await mangoClient.redeemAllMngo( mangoGroup, mangoAccount, @@ -91,6 +94,7 @@ export default function AccountInfo() { }) } finally { actions.reloadMangoAccount() + setRedeeming(false) } } @@ -261,13 +265,17 @@ export default function AccountInfo() { ) : ( 0 )} - - {t('claim')} - + {redeeming ? ( + + ) : ( + + {t('claim')} + + )} diff --git a/yarn.lock b/yarn.lock index f0afa36c..e230460b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -997,7 +997,7 @@ "@blockworks-foundation/mango-client@git+https://github.com/blockworks-foundation/mango-client-v3.git": version "3.2.13" - resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#d4a90b154d527f97961b122c8a32931381a34222" + resolved "git+https://github.com/blockworks-foundation/mango-client-v3.git#5bfe5f092e5d6ff1b41290eb320206d625522554" dependencies: "@project-serum/anchor" "^0.16.2" "@project-serum/serum" "0.13.55" @@ -2483,16 +2483,11 @@ bindings@^1.3.0: dependencies: file-uri-to-path "1.0.0" -bn.js@5.1.3, bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9, bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.1, bn.js@^5.1.2: +bn.js@5.1.3, bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9, bn.js@^5.0.0, bn.js@^5.1.0, bn.js@^5.1.1, bn.js@^5.1.2, bn.js@^5.2.0: version "5.1.3" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b" integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ== -bn.js@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" - integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== - boolbase@^1.0.0, boolbase@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"