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: agent memeooorr frontend #526

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
dd2f9e6
feat: add feature flags for agents (#523)
mohandast52 Dec 2, 2024
969bee9
feat: Select your agent component (#524)
mohandast52 Dec 2, 2024
8686b09
chore: extend configs with memeooor
Tanya-atatakai Dec 2, 2024
d2e29c3
Merge pull request #527 from valory-xyz/tanya/memeooor-config
Tanya-atatakai Dec 2, 2024
1d73333
feat: agent switch header (#528)
mohandast52 Dec 2, 2024
8171057
Merge branch 'refactor/multi-chain-support-frontend' of github.com:va…
Tanya-atatakai Dec 3, 2024
3d1cf17
feat: add SetupYourAgent screen (#529)
mohandast52 Dec 3, 2024
6ac8d4d
feat: support base during onboarding (#531)
Tanya-atatakai Dec 3, 2024
ee50a70
feat: hide unwanted features for mememooorr (#535)
mohandast52 Dec 4, 2024
7339fe9
feat: validate twitter credentials (#533)
mohandast52 Dec 4, 2024
6c164d2
feat: Override memeooorr service template for service creation (#536)
mohandast52 Dec 4, 2024
d3dfe91
feat: navigation fixes
Tanya-atatakai Dec 4, 2024
b00fdbb
feat: disable back button for select agent during onboarding
Tanya-atatakai Dec 4, 2024
46f4be7
feat: create dummy service (#541)
mohandast52 Dec 4, 2024
d0f330b
chore: merge refactor/multi-chain-support-frontend and fix conflicts
Tanya-atatakai Dec 5, 2024
d558de8
chore: review fixes
Tanya-atatakai Dec 5, 2024
426f04c
Merge pull request #540 from valory-xyz/tanya/onboarding-complete
Tanya-atatakai Dec 5, 2024
5ad0487
chore: fix props
Tanya-atatakai Dec 5, 2024
56da142
chore: fix dummy service requests
Tanya-atatakai Dec 5, 2024
33c4e10
chore: fix errors and styles
Tanya-atatakai Dec 5, 2024
68d5690
chore: review fixes
Tanya-atatakai Dec 5, 2024
b49a09b
Merge pull request #542 from valory-xyz/tanya/fixes
Tanya-atatakai Dec 5, 2024
392c8a5
chore: fix validation
Tanya-atatakai Dec 5, 2024
d80f75a
Feat (Memeooorr): Support in the backend
OjusWiZard Dec 5, 2024
5c4628c
style: format for linters
OjusWiZard Dec 5, 2024
27982e7
Merge pull request #543 from valory-xyz/feat/be/memeooorr
OjusWiZard Dec 5, 2024
084304b
feat: keep last selected agent in storage (#539)
mohandast52 Dec 5, 2024
a36eb3c
feat: add isEligibleForRewards logic, some fixes around loading states
Tanya-atatakai Dec 6, 2024
ff71c47
chore: remove comment
Tanya-atatakai Dec 6, 2024
700e715
feat: enhance SetupEoaFunding and SetupWelcomeLogin components with i…
mohandast52 Dec 6, 2024
778d9a3
Merge pull request #547 from valory-xyz/tanya/activity
Tanya-atatakai Dec 6, 2024
82b707b
feat: (Settings page) dynamic explorer url (#549)
mohandast52 Dec 9, 2024
555a33c
Fix (Memeooorr): Backend env configurations
OjusWiZard Dec 9, 2024
36c6db0
fix: balance chain independent (#552)
mohandast52 Dec 9, 2024
56ccfe9
fix: consistent cookies path with the db
OjusWiZard Dec 9, 2024
d48de03
Merge pull request #553 from valory-xyz/feat/be/memeooorr
OjusWiZard Dec 9, 2024
826422d
fix: remove border
Tanya-atatakai Dec 9, 2024
05f681c
Merge pull request #558 from valory-xyz/tanya/fix-border
Tanya-atatakai Dec 9, 2024
e409eb5
feat: share streak on X (#560)
mohandast52 Dec 10, 2024
9de0de0
feat: Agent animation when running (#562)
mohandast52 Dec 10, 2024
c3a470a
chore: merge refactor/multi-chain-support-frontend and fix conflicts
Tanya-atatakai Dec 10, 2024
89e81e6
feat: Improve visibility of entry point to wallet management screen (…
mohandast52 Dec 10, 2024
d173f03
refactor: simplify backup owners check in AddBackupWalletAlert component
mohandast52 Dec 10, 2024
bc7b987
feat: add LowFunds component and rename LowTradingBalanceAlert
mohandast52 Dec 10, 2024
1774348
feat: add InlineBanner component and update LowOperatingBalanceAlert …
mohandast52 Dec 10, 2024
52d4ca5
feat: enhance InlineBanner layout and improve LowOperatingBalanceAler…
mohandast52 Dec 10, 2024
1311f98
feat: add LowSafeSignerBalanceAlert component to notify users of low …
mohandast52 Dec 10, 2024
19227c2
feat: refactor useMasterBalances to simplify native gas balance calcu…
mohandast52 Dec 11, 2024
dcd9510
feat: update LowSafeSignerBalanceAlert to use new balance threshold a…
mohandast52 Dec 11, 2024
0835840
chore: conflict fixes
mohandast52 Dec 11, 2024
3275229
feat: refactor LowOperatingBalanceAlert to use useMasterBalances and …
mohandast52 Dec 11, 2024
34c5ceb
feat: update InlineBanner component to enhance layout and improve add…
mohandast52 Dec 11, 2024
45758b7
feat: enhance balance comparison logic in useMasterBalances and add f…
mohandast52 Dec 11, 2024
01a20ef
fix: correct agent native gas requirement check in useMasterBalances …
mohandast52 Dec 11, 2024
ead9d08
refactor: clean up imports and remove unused QR code functionality in…
mohandast52 Dec 11, 2024
7cb42a7
feat: add MainNeedsFunds component to display funding requirements an…
mohandast52 Dec 11, 2024
b35f02b
feat: refactor LowSafeSignerBalanceAlert to use useLowFundsDetails ho…
mohandast52 Dec 11, 2024
affa47a
Merge pull request #566 from valory-xyz/mohan/handling-low-fees
mohandast52 Dec 11, 2024
8e12aad
feat: refactor LowOperatingBalanceAlert to use useLowFundsDetails hoo…
mohandast52 Dec 11, 2024
2cf1d3f
fix: templates
jmoreira-valory Dec 11, 2024
bebdbc7
fix: operate fixes for memeooorr
jmoreira-valory Dec 11, 2024
82f3286
feat: add EmptyFunds and FundsToActivate components for displaying fu…
mohandast52 Dec 11, 2024
ea30237
feat: refactor funding components to streamline requirements display …
mohandast52 Dec 11, 2024
ce17893
feat: enhance X username input with addon and prevent '@' key input
mohandast52 Dec 11, 2024
1df3d1b
Merge pull request #571 from valory-xyz/fix/misc_memeooorr_fixes
jmoreira-valory Dec 11, 2024
d87319a
Merge pull request #573 from valory-xyz/mohan/twitter-username-valida…
mohandast52 Dec 11, 2024
3aa08fa
Merge pull request #568 from valory-xyz/mohan/handling-low-fees-2
mohandast52 Dec 11, 2024
455f68a
feat: enhance LowFunds components to improve balance checks and visib…
mohandast52 Dec 11, 2024
2d357b5
feat: refactor LowFunds components to improve balance checks and add …
mohandast52 Dec 11, 2024
27077ad
fix: make chainId dynamic when create a service
Tanya-atatakai Dec 11, 2024
bc7b4e8
fix: linter
Tanya-atatakai Dec 12, 2024
979aaea
Merge pull request #570 from valory-xyz/tanya/fix-chainId
Tanya-atatakai Dec 12, 2024
d366bfb
Merge pull request #572 from valory-xyz/mohan/handling-low-fees-3
mohandast52 Dec 12, 2024
e49b4e4
feat: update staking contract addresses
Tanya-atatakai Dec 13, 2024
3a30e36
fix: change all staking contract details loaded check to use some ins…
mohandast52 Dec 13, 2024
1db2e47
feat: update celo staking address
Tanya-atatakai Dec 13, 2024
6503134
fix: optimize EachAgent component with memoization and improve code c…
mohandast52 Dec 13, 2024
f38dec1
fix: update comment for clarity and remove unnecessary console logs i…
mohandast52 Dec 13, 2024
a3391e9
fix: handle empty staking information with an alert message
mohandast52 Dec 13, 2024
c0816bd
feat: update service template
Tanya-atatakai Dec 13, 2024
dc1846e
Merge pull request #579 from valory-xyz/tanya/staking-contracts-update
Tanya-atatakai Dec 13, 2024
03e12b5
Merge pull request #580 from valory-xyz/mohan/debug-multiple-account-…
mohandast52 Dec 13, 2024
e7ecf6a
feat: add low-funds feature flag to conditionally render LowFunds alert
mohandast52 Dec 13, 2024
922a1f6
Merge pull request #581 from valory-xyz/mohan/disable-low-funds
mohandast52 Dec 13, 2024
a80a22c
feat: implement operating thresholds for wallet types in agent config…
truemiller Dec 13, 2024
4aea6c2
fix: update token symbol reference for operating thresholds in AgentN…
truemiller Dec 13, 2024
3ef4e0e
refactor: remove outdated comment and clean up LOW_AGENT_SAFE_BALANCE…
truemiller Dec 13, 2024
617787b
refactor: simplify SetupEoaFundingWaiting component by removing curre…
mohandast52 Dec 13, 2024
8f4069a
Merge pull request #584 from valory-xyz/mohan/remove-eth-text-in-onbo…
mohandast52 Dec 13, 2024
381bc81
Merge pull request #583 from valory-xyz/fix/agent-specific-thresholds
mohandast52 Dec 13, 2024
22ded04
fix: update service if hash is different in AgentNotRunningButton com…
truemiller Dec 13, 2024
557bc78
fix: replace formatEther with parseEther for accurate token value par…
truemiller Dec 13, 2024
5156a79
refactor: remove parseEther usage for static values in agent configur…
truemiller Dec 13, 2024
3882f89
Merge pull request #586 from valory-xyz/fix/format-ether
mohandast52 Dec 13, 2024
7c6465b
Update frontend/components/MainPage/header/AgentButton/AgentNotRunnin…
truemiller Dec 13, 2024
23c63be
Merge pull request #585 from valory-xyz/fix/check-service-update
truemiller Dec 13, 2024
3c0941a
fix: update agent names to reflect branding changes
truemiller Dec 13, 2024
f8eba60
fix: update terminology from trading balance to operating balance in …
truemiller Dec 13, 2024
9c7a4ef
fix: isMasterSafeNativeGas should check masterSafe, not agentSafe
truemiller Dec 13, 2024
64809a1
Merge pull request #587 from valory-xyz/fix/misc-text-low-balance
mohandast52 Dec 13, 2024
d0549a9
fix: serviceTemplate values for memeooorr
truemiller Dec 13, 2024
a4c6f6b
fix: update hash value for Memeooorr service template
truemiller Dec 13, 2024
13bd3ae
Merge pull request #588 from valory-xyz/fix/service-template-funding-…
truemiller Dec 13, 2024
88a51d4
fix: update version to 0.2.0-rc23 in package.json and pyproject.toml
truemiller Dec 13, 2024
77312dd
fix: correct eligibility condition for staking in AgentNotRunningButt…
truemiller Dec 14, 2024
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
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ Creates a Gnosis safe for given chain.
```js
{
"chain": Chain,
"fund_amount": 10000000000000000
}
```

Expand Down
22 changes: 20 additions & 2 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const os = require('os');
const next = require('next/dist/server/next');
const http = require('http');
const AdmZip = require('adm-zip');
const { validateEnv } = require('./utils/env-validation');

const { setupDarwin, setupUbuntu, setupWindows, Env } = require('./install');

Expand All @@ -26,6 +25,7 @@ const { setupStoreIpc } = require('./store');
const { logger } = require('./logger');
const { isDev } = require('./constants');
const { PearlTray } = require('./components/PearlTray');
const { Scraper } = require('agent-twitter-client');

// Validates environment variables required for Pearl
// kills the app/process if required environment variables are unavailable
Expand Down Expand Up @@ -256,6 +256,24 @@ const createMainWindow = async () => {

ipcMain.handle('app-version', () => app.getVersion());

// Handle twitter login
ipcMain.handle('validate-twitter-login', async (_event, credentials) => {
const scraper = new Scraper();

const { username, password, email } = credentials;
if (!username || !password || !email) {
return { success: false, error: 'Missing credentials' };
}

try {
await scraper.login(username, password, email);
return { success: true };
} catch (error) {
console.error('Twitter login error:', error);
return { success: false, error: error.message };
}
});

mainWindow.webContents.on('did-fail-load', () => {
mainWindow.webContents.reloadIgnoringCache();
});
Expand All @@ -277,7 +295,7 @@ const createMainWindow = async () => {

try {
logger.electron('Setting up store IPC');
await setupStoreIpc(ipcMain, mainWindow);
setupStoreIpc(ipcMain, mainWindow);
} catch (e) {
logger.electron('Store IPC failed:', JSON.stringify(e));
}
Expand Down
2 changes: 2 additions & 0 deletions electron/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
saveLogs: (data) => ipcRenderer.invoke('save-logs', data),
openPath: (filePath) => ipcRenderer.send('open-path', filePath),
getAppVersion: () => ipcRenderer.invoke('app-version'),
validateTwitterLogin: (credentials) =>
ipcRenderer.invoke('validate-twitter-login', credentials),
});
Binary file added electron/public/agent-memeooorr-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added electron/public/agent-trader-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion electron/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const schema = {

environmentName: { type: 'string', default: '' },
currentStakingProgram: { type: 'string', default: '' },

// agent settings
lastSelectedAgentType: { type: 'string', default: 'trader' },
};

/**
Expand All @@ -16,7 +19,7 @@ const schema = {
* @param {Electron.BrowserWindow} mainWindow - The main Electron browser window.
* @returns {Promise<void>} - A promise that resolves once the store is set up.
*/
const setupStoreIpc = async (ipcMain, mainWindow) => {
const setupStoreIpc = (ipcMain, mainWindow) => {
const store = new Store({ schema });

store.onDidAnyChange((data) => {
Expand Down
44 changes: 44 additions & 0 deletions frontend/abis/memeActivityChecker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const MEME_ACTIVITY_CHECKER_ABI = [
{
inputs: [
{ internalType: 'address', name: '_memeFactory', type: 'address' },
{ internalType: 'uint256', name: '_livenessRatio', type: 'uint256' },
],
stateMutability: 'nonpayable',
type: 'constructor',
},
{ inputs: [], name: 'ZeroAddress', type: 'error' },
{ inputs: [], name: 'ZeroValue', type: 'error' },
{
inputs: [{ internalType: 'address', name: 'multisig', type: 'address' }],
name: 'getMultisigNonces',
outputs: [{ internalType: 'uint256[]', name: 'nonces', type: 'uint256[]' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{ internalType: 'uint256[]', name: 'curNonces', type: 'uint256[]' },
{ internalType: 'uint256[]', name: 'lastNonces', type: 'uint256[]' },
{ internalType: 'uint256', name: 'ts', type: 'uint256' },
],
name: 'isRatioPass',
outputs: [{ internalType: 'bool', name: 'ratioPass', type: 'bool' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'livenessRatio',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'memeFactory',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'view',
type: 'function',
},
];
2 changes: 1 addition & 1 deletion frontend/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export type ConfigurationTemplate = {
agent_id: number;
threshold: number;
use_staking: boolean;
use_mech_marketplace: boolean;
use_mech_marketplace?: boolean;
cost_of_bond: number;
monthly_gas_estimate: number;
fund_requirements: FundRequirementsTemplate;
Expand Down
13 changes: 11 additions & 2 deletions frontend/components/AddressLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@ import { EXPLORER_URL_BY_MIDDLEWARE_CHAIN } from '@/constants/urls';
import { Address } from '@/types/Address';
import { truncateAddress } from '@/utils/truncate';

type AddressLinkProps = { address?: Address; hideLinkArrow?: boolean };
type AddressLinkProps = {
address?: Address;
hideLinkArrow?: boolean;

// TODO: mark as required once balance breakdown is updated.
// and remove the default value
middlewareChain?: MiddlewareChain;
};

export const AddressLink = ({
address,
hideLinkArrow = false,
middlewareChain = MiddlewareChain.GNOSIS,
}: AddressLinkProps) => {
if (!address) return null;
if (!middlewareChain) return null;

return (
<a
target="_blank"
href={`${EXPLORER_URL_BY_MIDDLEWARE_CHAIN[MiddlewareChain.GNOSIS]}/address/${address}`}
href={`${EXPLORER_URL_BY_MIDDLEWARE_CHAIN[middlewareChain]}/address/${address}`}
>
{truncateAddress(address)}

Expand Down
146 changes: 146 additions & 0 deletions frontend/components/AgentSelection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import { Button, Card, Flex, Typography } from 'antd';
import { entries } from 'lodash';
import Image from 'next/image';
import { memo, useCallback } from 'react';

import { AGENT_CONFIG } from '@/config/agents';
import { COLOR } from '@/constants/colors';
import { AgentType } from '@/enums/Agent';
import { Pages } from '@/enums/Pages';
import { SetupScreen } from '@/enums/SetupScreen';
import { usePageState } from '@/hooks/usePageState';
import { useServices } from '@/hooks/useServices';
import { useSetup } from '@/hooks/useSetup';
import { useMasterWalletContext } from '@/hooks/useWallet';
import { AgentConfig } from '@/types/Agent';
import { delayInSeconds } from '@/utils/delay';

import { SetupCreateHeader } from './SetupPage/Create/SetupCreateHeader';
import { CardFlex } from './styled/CardFlex';

const { Title, Text } = Typography;

type EachAgentProps = {
showSelected: boolean;
agentType: AgentType;
agentConfig: AgentConfig;
};

const EachAgent = memo(
({ showSelected, agentType, agentConfig }: EachAgentProps) => {
const { goto: gotoSetup } = useSetup();
const { goto: gotoPage } = usePageState();
const { selectedAgentType, updateAgentType } = useServices();
const { masterSafes, isLoading } = useMasterWalletContext();

const isCurrentAgent = showSelected
? selectedAgentType === agentType
: false;

const handleSelectAgent = useCallback(async () => {
updateAgentType(agentType);

// DO NOTE REMOVE THIS DELAY
// NOTE: the delay is added so that agentType is updated in electron store
// and re-rendered with the updated agentType
await delayInSeconds(0.5);

const isSafeCreated = masterSafes?.find(
(masterSafe) =>
masterSafe.evmChainId === AGENT_CONFIG[agentType].evmHomeChainId,
);

// If safe is created for the agent type, then go to main page
if (isSafeCreated) {
gotoPage(Pages.Main);
return;
}

// If safe is NOT created, then go to setup page based on the agent type
if (agentType === AgentType.Memeooorr) {
// if the selected type is Memeooorr - should set up the agent first
gotoPage(Pages.Setup);
gotoSetup(SetupScreen.SetupYourAgent);
} else if (agentType === AgentType.PredictTrader) {
gotoPage(Pages.Setup);
gotoSetup(SetupScreen.SetupEoaFunding);
}
}, [agentType, gotoPage, gotoSetup, masterSafes, updateAgentType]);

return (
<Card
key={agentType}
style={{ padding: 0, marginBottom: 6 }}
styles={{
body: {
padding: '12px 16px',
gap: 6,
borderRadius: 'inherit',
background: isCurrentAgent ? COLOR.GRAY_1 : 'transparent',
opacity: isCurrentAgent ? 0.75 : 1,
},
}}
>
<Flex vertical>
<Flex align="center" justify="space-between" className="mb-8">
<Image
src={`/agent-${agentType}-icon.png`}
width={36}
height={36}
alt={agentConfig.displayName}
/>
{isCurrentAgent ? (
<Text>Selected Agent</Text>
) : (
<Button
type="primary"
onClick={handleSelectAgent}
disabled={isLoading}
>
Select
</Button>
)}
</Flex>
</Flex>

<Title level={5} className="m-0">
{agentConfig.displayName}
</Title>

<Text type="secondary">{agentConfig.description}</Text>
</Card>
);
},
);

EachAgent.displayName = 'EachAgent';

type AgentSelectionProps = {
showSelected?: boolean;
canGoBack?: boolean;
onPrev?: () => void;
};

/**
* Component to select the agent type.
*/
export const AgentSelection = ({
showSelected = true,
onPrev,
}: AgentSelectionProps) => (
<CardFlex gap={10} styles={{ body: { padding: '12px 24px' } }}>
<SetupCreateHeader prev={onPrev} />
<Title level={3}>Select your agent</Title>

{entries(AGENT_CONFIG).map(([agentType, agentConfig]) => {
return (
<EachAgent
key={agentType}
showSelected={showSelected}
agentType={agentType as AgentType}
agentConfig={agentConfig}
/>
);
})}
</CardFlex>
);
11 changes: 11 additions & 0 deletions frontend/components/FeatureNotEnabled.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Alert } from 'antd';

export const FeatureNotEnabled = () => (
<Alert
message="Oops!"
description="This feature is not enabled for your current agent type."
type="error"
showIcon
style={{ border: 'none' }}
/>
);
56 changes: 0 additions & 56 deletions frontend/components/MainPage/MainHeader/FirstRunModal.tsx

This file was deleted.

Loading
Loading