Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add llc modal #297

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
remove error and async from isllcmember calls
0xfirefist committed Dec 7, 2023
commit 6d4c72b18a80e653e3162edf37662dd584df2794
18 changes: 7 additions & 11 deletions frontend/components/modals/LockedModal.tsx
Original file line number Diff line number Diff line change
@@ -195,18 +195,14 @@ function LockedModalButton({

const onStakeAll = useCallback(async () => {
if (mainStakeAccount === 'NA' || mainStakeAccount === undefined) return
try {
const isLlcMember = await stakeConnection!.isLlcMember(mainStakeAccount)
const isLlcMember = stakeConnection!.isLlcMember(mainStakeAccount)

if (isLlcMember === true)
unvestedLockAll.mutate({
mainStakeAccount: mainStakeAccount,
stakeConnection: stakeConnection!,
})
else setIsLlcModalOpen(true)
} catch {
toast.error('Connection error')
}
if (isLlcMember === true)
unvestedLockAll.mutate({
mainStakeAccount: mainStakeAccount,
stakeConnection: stakeConnection!,
})
else setIsLlcModalOpen(true)
}, [stakeConnection, mainStakeAccount])

if (mainStakeAccount === 'NA') return <></>
14 changes: 4 additions & 10 deletions frontend/components/panels/StakePanel.tsx
Original file line number Diff line number Diff line change
@@ -62,19 +62,13 @@ export function StakePanel({ mainStakeAccount }: StakePanelProps) {
const [isLlcModalOpen, setIsLlcModalOpen] = useState(false)

// This only executes if deposit action is enabled
const onAction = useCallback(async () => {
const onAction = useCallback(() => {
if (mainStakeAccount === 'NA') setIsLlcModalOpen(true)
else {
try {
const isLlcMember = await stakeConnection!.isLlcMember(
mainStakeAccount!
)
const isLlcMember = stakeConnection!.isLlcMember(mainStakeAccount!)

if (isLlcMember === true) deposit(amount)
else setIsLlcModalOpen(true)
} catch {
toast.error('Connection error')
}
if (isLlcMember === true) deposit(amount)
else setIsLlcModalOpen(true)
}
}, [deposit, amount, stakeConnection, mainStakeAccount])

6 changes: 2 additions & 4 deletions frontend/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -105,10 +105,8 @@ const Staking: NextPage = () => {
mainStakeAccount === 'NA'
)
return
;(async () => {
if (!(await stakeConnection.isLlcMember(mainStakeAccount)))
setIsLlcModalOpen(true)
})()

if (!stakeConnection.isLlcMember(mainStakeAccount)) setIsLlcModalOpen(true)
}, [stakeConnection, mainStakeAccount])

// First stake connection will load, then stake accounts, and