-
Notifications
You must be signed in to change notification settings - Fork 2
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: Add checks against contract no funds and full slots cases #162
Merged
+354
−115
Merged
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
825583d
chore: Update package.json and yarn.lock with zustand dependency
mohandast52 be4eb87
chore: Add StakingValidations component and getStakingContractInfo fu…
mohandast52 cb35f72
chore: Update StakingContractInfo type in Autonolas.ts
mohandast52 788edae
chore: Add useStakingContractInfo hook for fetching staking contract …
mohandast52 93c93e3
chore: Refactor useStakingContractInfo hook and fetchStakingContractI…
mohandast52 9c77e1c
chore: Refactor StakingValidations component and fetchStakingContract…
mohandast52 1cafb91
chore: Add StakingValidations component to Main
mohandast52 df6c489
feat: Add canStartAgent check to MainHeader component
mohandast52 79108c8
chore: Remove unused maxNumServices property in useStakingContractInf…
mohandast52 4a384ab
conflict fixes
mohandast52 073d18b
Merge branch 'main' of github.aaakk.us.kg-personal:valory-xyz/olas-operate-ap…
mohandast52 abb11e2
feat: Update file paths and imports for MainHeader and StakingValidat…
mohandast52 f126199
Merge branch 'main' of github.aaakk.us.kg-personal:valory-xyz/olas-operate-ap…
mohandast52 936fe4a
chore: Update StakingContractInfo to use serviceIds instead of getSer…
mohandast52 ee44d09
chore: Update MainHeader component with new features and improvements
mohandast52 83a2358
chore: Update AgentEvictedPopover content
mohandast52 6556a8d
chore: Implement isAgentEvicted flag in StakingContractInfo store
mohandast52 696f71d
chore: Remove StakingValidations component from MainHeader
mohandast52 2d95886
chore: Update MainHeader component with new features and improvements…
mohandast52 2cc967a
chore: Add FirstRunModal component to MainHeader
mohandast52 630b06a
chore: Refactor MainHeader component and dependencies
mohandast52 98c7d2f
chore: Update MainHeader component with useStakingContractInfo hook
mohandast52 f956a4a
Refactor MainHeader component and dependencies
mohandast52 6e18beb
chore: move to constants and components
mohandast52 905304f
Refactor MainHeader component and dependencies
mohandast52 0300647
refractor: StakingContractProvider context added
mohandast52 8466d40
refractor: remove zustand
mohandast52 fbbfbf9
chore: move to variable
mohandast52 a1605a1
chore: address review changes
mohandast52 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { InfoCircleOutlined } from '@ant-design/icons'; | ||
import { Popover, PopoverProps, Typography } from 'antd'; | ||
|
||
import { COLOR, SUPPORT_URL } from '@/constants'; | ||
import { UNICODE_SYMBOLS } from '@/constants/unicode'; | ||
import { useStakingContractInfo } from '@/hooks/useStakingContractInfo'; | ||
|
||
const { Paragraph, Text } = Typography; | ||
|
||
const cannotStartAgentText = ( | ||
<Text style={{ color: COLOR.RED }}> | ||
Cannot start agent | ||
<InfoCircleOutlined /> | ||
</Text> | ||
); | ||
|
||
const evictedDescription = | ||
"You didn't run your agent enough and it missed its targets multiple times. Please wait a few days and try to run your agent again."; | ||
const AgentEvictedPopover = () => ( | ||
<Popover | ||
{...otherPopoverProps} | ||
title="Your agent was evicted" | ||
content={<div style={{ maxWidth: 340 }}>{evictedDescription}</div>} | ||
> | ||
{cannotStartAgentText} | ||
</Popover> | ||
); | ||
|
||
const otherPopoverProps: PopoverProps = { | ||
arrow: false, | ||
placement: 'bottomRight', | ||
}; | ||
|
||
const JoinOlasCommunity = () => ( | ||
<div style={{ maxWidth: 340 }}> | ||
<Paragraph> | ||
Join the Olas community Discord server to report or stay up to date on the | ||
issue. | ||
</Paragraph> | ||
|
||
<a href={SUPPORT_URL} target="_blank" rel="noreferrer"> | ||
Olas community Discord server {UNICODE_SYMBOLS.EXTERNAL_LINK} | ||
</a> | ||
</div> | ||
); | ||
|
||
const NoRewardsAvailablePopover = () => ( | ||
<Popover | ||
{...otherPopoverProps} | ||
title="No rewards available" | ||
content={<JoinOlasCommunity />} | ||
> | ||
{cannotStartAgentText} | ||
</Popover> | ||
); | ||
|
||
const NoJobsAvailablePopover = () => ( | ||
<Popover | ||
{...otherPopoverProps} | ||
title="No jobs available" | ||
content={<JoinOlasCommunity />} | ||
> | ||
{cannotStartAgentText} | ||
</Popover> | ||
); | ||
|
||
export const CannotStartAgent = () => { | ||
const { | ||
canStartAgent, | ||
hasEnoughServiceSlots, | ||
isRewardsAvailable, | ||
isAgentEvicted, | ||
} = useStakingContractInfo(); | ||
|
||
if (canStartAgent) return null; | ||
if (!hasEnoughServiceSlots) return <NoJobsAvailablePopover />; | ||
if (!isRewardsAvailable) return <NoRewardsAvailablePopover />; | ||
if (isAgentEvicted) return <AgentEvictedPopover />; | ||
throw new Error('Cannot start agent, please contact support'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Button, Flex, Modal, Typography } from 'antd'; | ||
import Image from 'next/image'; | ||
import { FC } from 'react'; | ||
|
||
import { useReward } from '@/hooks/useReward'; | ||
|
||
const { Title, Paragraph } = Typography; | ||
|
||
type FirstRunModalProps = { open: boolean; onClose: () => void }; | ||
|
||
export const FirstRunModal: FC<FirstRunModalProps> = ({ open, onClose }) => { | ||
const { minimumStakedAmountRequired } = useReward(); | ||
|
||
if (!open) return null; | ||
return ( | ||
<Modal | ||
open={open} | ||
width={412} | ||
onCancel={onClose} | ||
footer={[ | ||
<Button | ||
key="ok" | ||
type="primary" | ||
block | ||
size="large" | ||
className="mt-8" | ||
onClick={onClose} | ||
> | ||
Got it | ||
</Button>, | ||
]} | ||
> | ||
<Flex align="center" justify="center"> | ||
<Image | ||
src="/splash-robot-head.png" | ||
width={100} | ||
height={100} | ||
alt="OLAS logo" | ||
/> | ||
</Flex> | ||
<Title level={5} className="mt-12 text-center"> | ||
{`Your agent is running and you've staked ${minimumStakedAmountRequired} OLAS!`} | ||
</Title> | ||
<Paragraph>Your agent is working towards earning rewards.</Paragraph> | ||
<Paragraph> | ||
Pearl is designed to make it easy for you to earn staking rewards every | ||
day. Simply leave the app and agent running in the background for ~1hr a | ||
day. | ||
</Paragraph> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to a separate file -
FirstRunModal.tsx