Skip to content

Commit

Permalink
needed to approve the use of BAO be the veBAO contract for increasing…
Browse files Browse the repository at this point in the history
… a veBAO lock amount works (#85)
  • Loading branch information
zfogg authored Nov 26, 2022
1 parent 9246fcf commit bbf0e5e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '@/styles/globals.css'
import '@fortawesome/fontawesome-svg-core/styles.css'

import { Web3ReactProvider } from '@web3-react/core'
import type { AppProps } from 'next/app'
import dynamic from 'next/dynamic'
Expand All @@ -12,7 +11,6 @@ import { Web3Provider } from '@ethersproject/providers'
import { QueryClientProvider } from '@tanstack/react-query'
import queryClient from '@/utils/queryClient'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'

import fetcher from '@/bao/lib/fetcher'
import Header from '@/components/Header'
import Page from '@/components/Page'
Expand All @@ -25,7 +23,7 @@ import TransactionProvider from '@/contexts/Transactions'
import TxPopup from '@/components/TxPopup'
import '@/components/TxPopup/styles.css'

console.log('v1.0.6')
console.log('v1.0.7')

function getLibrary(provider: any): Web3Provider {
const library = new Web3Provider(provider)
Expand Down
28 changes: 26 additions & 2 deletions src/pages/vebao/components/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const Actions = ({ baoBalance, lockInfo }: ActionProps) => {
</div>
</div>
<div className='flex flex-col'>
{isNaN(lockInfo && parseFloat(formatUnits(lockInfo.balance))) || (lockInfo && lockInfo.balance.lte(0)) ? (
{isNaN(lockInfo && parseFloat(formatUnits(lockInfo.balance))) || lockInfo.balance.lte(0) ? (
<div className='mt-3 flex flex-row gap-4'>
{allowance && allowance.lte(0) ? (
<>
Expand Down Expand Up @@ -209,7 +209,31 @@ const Actions = ({ baoBalance, lockInfo }: ActionProps) => {
) : (
<div className='flex w-full flex-row gap-4'>
<div className='mt-3 grid w-full gap-2 md:grid-cols-2'>
{pendingTx ? (
{allowance && allowance.lte(0) ? (
<>
{pendingTx ? (
<Button fullWidth disabled={true}>
Approving BAO
</Button>
) : (
<Button
fullWidth
disabled={baoBalance.lte(0) && !shouldBeWarned}
onClick={async () => {
if (shouldBeWarned) {
modalShow()
} else {
// TODO: give the user a notice that we're approving max uint and instruct them how to change this value.
const approveTx = baoV2.approve(votingEscrow.address, ethers.constants.MaxUint256)
handleTx(approveTx, `veBAO: Approve BAO`)
}
}}
>
{shouldBeWarned ? 'Read Warning' : 'Approve BAO'}
</Button>
)}
</>
) : pendingTx ? (
<Button disabled={true}>
{typeof pendingTx === 'string' ? (
<Link href={`${Config.defaultRpc.blockExplorerUrls}/tx/${pendingTx}`} target='_blank' rel='noopener noreferrer'>
Expand Down

0 comments on commit bbf0e5e

Please sign in to comment.