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

feat(farm): add stake vault button #132

Merged
merged 1 commit into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions components/FarmHeaderComponent/FarmHeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const FarmHeaderComponent = () => {
collectionTotalNumber,
rewardTokenName,
handleRefreshRewardsButtonClick,
claimRewards
claimRewards,
farmerState,
stakedNFTsInFarm,
farmerVaultLocked,
lockVault
} = useGemFarm();

const [txLoading, setTxLoading] = useState({
Expand Down Expand Up @@ -105,6 +109,14 @@ const FarmHeaderComponent = () => {
{farmerCount}
</Text>
</Stack>
<Stack direction="vertical" space="1" align="center">
<Text size="small" align="center" variant="label">
Your vault
</Text>
<Text size="small" variant="small">
{farmerState}
</Text>
</Stack>
{Boolean(unstakingFee) && (
<Stack direction="vertical" space="1" align="center">
<Text align="center" variant="label">
Expand All @@ -118,7 +130,6 @@ const FarmHeaderComponent = () => {
</Stack>
<Stack space="3" justify="center" direction="horizontal">
<Button

onClick={handleRefreshRewardsButtonClick}
variant="secondary"
shape="square"
Expand All @@ -134,6 +145,18 @@ const FarmHeaderComponent = () => {
>
{`Claim $${rewardTokenName}`}
</Button>
{(Object.values(stakedNFTsInFarm).length > 0 &&
!farmerVaultLocked) && (
<Button
onClick={() => withTxLoading(lockVault, 'stake')}
loading={txLoading.value && txLoading.txName === 'stake'}
size="small"
tone="green"
variant="primary"
>
{`Stake Vault`}
</Button>
)}
</Stack>
</Stack>
</Box>
Expand Down
2 changes: 2 additions & 0 deletions hooks/useGemFarm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ const useGemFarm = () => {
const tx = new Transaction();
tx.add(await gf!.stakeWalletIx(new PublicKey(farmAddress!)));
await gf!.provider.sendAndConfirm!(tx);
await fetchFarmerDetails(gf, gb);
}
};

Expand Down Expand Up @@ -569,6 +570,7 @@ const useGemFarm = () => {

return {
claimRewards,
lockVault,
initializeFarmerAcc,
refreshNFTsWithLoadingIcon,
onWalletNFTSelect,
Expand Down