From 5eff7eef60c5eb1b81c7c23aae253e0a4e0121bc Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Tue, 23 Jul 2024 16:29:47 +0530 Subject: [PATCH 01/36] feat: Update NotifyRewards component name --- frontend/components/Main/MainRewards.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/components/Main/MainRewards.tsx b/frontend/components/Main/MainRewards.tsx index 8f775b163..50ef32f30 100644 --- a/frontend/components/Main/MainRewards.tsx +++ b/frontend/components/Main/MainRewards.tsx @@ -65,7 +65,7 @@ const DisplayRewards = () => { const SHARE_TEXT = `I just earned my first reward through the Operate app powered by #olas!\n\nDownload the Pearl app:`; const OPERATE_URL = 'https://olas.network/operate?pearl=first-reward'; -const NotifyRewards = () => { +const NotifyRewardsModal = () => { const { isEligibleForRewards, availableRewardsForEpochEth } = useReward(); const { totalOlasBalance } = useBalance(); const { showNotification, store } = useElectronApi(); @@ -179,6 +179,6 @@ const NotifyRewards = () => { export const MainRewards = () => ( <> - + ); From 34d0eb6769c2a86e5d3b6165e5bb1dc3e0406b9a Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Tue, 23 Jul 2024 17:45:01 +0530 Subject: [PATCH 02/36] feat: Add agent eviction alert to MainOlasBalance component --- electron/store.js | 1 + frontend/components/Main/MainOlasBalance.tsx | 84 ++++++++++++++++++-- frontend/components/Main/MainRewards.tsx | 3 + frontend/types/ElectronApi.ts | 1 + 4 files changed, 81 insertions(+), 8 deletions(-) diff --git a/electron/store.js b/electron/store.js index 5577decff..afbc7f62d 100644 --- a/electron/store.js +++ b/electron/store.js @@ -4,6 +4,7 @@ const defaultSchema = { isInitialFunded: { type: 'boolean', default: false }, firstStakingRewardAchieved: { type: 'boolean', default: false }, firstRewardNotificationShown: { type: 'boolean', default: false }, + agentEvictionAlertShown: { type: 'boolean', default: false }, }; const setupStoreIpc = async (ipcChannel, mainWindow, storeInitialValues) => { diff --git a/frontend/components/Main/MainOlasBalance.tsx b/frontend/components/Main/MainOlasBalance.tsx index f51cf2ef9..2595a15bf 100644 --- a/frontend/components/Main/MainOlasBalance.tsx +++ b/frontend/components/Main/MainOlasBalance.tsx @@ -1,17 +1,20 @@ import { InfoCircleOutlined } from '@ant-design/icons'; -import { Flex, Skeleton, Tooltip, Typography } from 'antd'; +import { Button, Flex, Skeleton, Tooltip, Typography } from 'antd'; import { useMemo } from 'react'; import styled from 'styled-components'; +import { Alert } from '@/components/Alert'; import { COLOR } from '@/constants/colors'; import { UNICODE_SYMBOLS } from '@/constants/symbols'; import { useBalance } from '@/hooks/useBalance'; +import { useElectronApi } from '@/hooks/useElectronApi'; import { useReward } from '@/hooks/useReward'; +import { useStore } from '@/hooks/useStore'; import { balanceFormat } from '@/utils/numberFormatters'; import { CardSection } from '../styled/CardSection'; -const { Text } = Typography; +const { Text, Title } = Typography; const Balance = styled.span` letter-spacing: -2px; margin-right: 4px; @@ -103,6 +106,68 @@ const CurrentBalance = () => { ); }; +// const AvoidSuspensionAlert = styled(Alert)` +// .anticon.ant-alert-icon { +// height: 20px; +// width: 20px; +// svg { +// width: 100%; +// height: 100%; +// } +// } +// `; +const AvoidSuspensionAlert = () => { + const { store } = useElectronApi(); + + return ( + + + Avoid suspension! + + + Run your agent for at least half an hour a day to make sure it hits + its targets. If it misses its targets 2 days in a row, it’ll be + suspended. You won’t be able to run it or earn rewards for several + days. + + + + } + style={{ marginBottom: 8 }} + /> + ); +}; + +const AvoidSuspension = () => { + const { storeState } = useStore(); + + // console.log(storeState); + + // If first reward notification is shown BUT + // agent eviction alert is not shown, show this alert + const isAvoidSuspensionAlertShown = + storeState?.firstRewardNotificationShown && + !storeState?.agentEvictionAlertShown; + + if (!isAvoidSuspensionAlertShown) { + return ; + } + + return null; +}; + export const MainOlasBalance = () => { const { isBalanceLoaded, totalOlasBalance } = useBalance(); @@ -113,14 +178,17 @@ export const MainOlasBalance = () => { return ( + {isBalanceLoaded ? ( <> - - - {UNICODE_SYMBOLS.OLAS} - {balance} - OLAS - +
+ + + {UNICODE_SYMBOLS.OLAS} + {balance} + OLAS + +
) : ( diff --git a/frontend/components/Main/MainRewards.tsx b/frontend/components/Main/MainRewards.tsx index 50ef32f30..bb022d1ec 100644 --- a/frontend/components/Main/MainRewards.tsx +++ b/frontend/components/Main/MainRewards.tsx @@ -101,6 +101,9 @@ const NotifyRewardsModal = () => { // once the notification is closed, set the flag to true store?.set?.('firstRewardNotificationShown', true); + + // and show the eviction educate information to the user + // store?.set?.('agentEvictionAlertShown', true); }, [store]); const onTwitterShare = useCallback(() => { diff --git a/frontend/types/ElectronApi.ts b/frontend/types/ElectronApi.ts index 2f586a0d9..df0456a47 100644 --- a/frontend/types/ElectronApi.ts +++ b/frontend/types/ElectronApi.ts @@ -3,6 +3,7 @@ export type ElectronStore = { isInitialFunded?: boolean; firstStakingRewardAchieved?: boolean; firstRewardNotificationShown?: boolean; + agentEvictionAlertShown?: boolean; }; export type ElectronTrayIconStatus = 'low-gas' | 'running' | 'paused'; From 8b59c2a2e0cb89ed4066d1aa82ba21abaf16abbb Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Tue, 23 Jul 2024 17:54:17 +0530 Subject: [PATCH 03/36] feat: Refactor AvoidSuspensionAlert in MainOlasBalance component --- frontend/components/Main/MainOlasBalance.tsx | 121 +++++++++---------- frontend/components/Main/MainRewards.tsx | 3 - 2 files changed, 59 insertions(+), 65 deletions(-) diff --git a/frontend/components/Main/MainOlasBalance.tsx b/frontend/components/Main/MainOlasBalance.tsx index 2595a15bf..38e358350 100644 --- a/frontend/components/Main/MainOlasBalance.tsx +++ b/frontend/components/Main/MainOlasBalance.tsx @@ -106,70 +106,69 @@ const CurrentBalance = () => { ); }; -// const AvoidSuspensionAlert = styled(Alert)` -// .anticon.ant-alert-icon { -// height: 20px; -// width: 20px; -// svg { -// width: 100%; -// height: 100%; -// } -// } -// `; +const AvoidSuspensionAlertContainer = styled.div` + .ant-alert-info { + margin-bottom: 8px; + .anticon.ant-alert-icon { + height: 20px; + width: 20px; + svg { + width: 100%; + height: 100%; + } + } + } +`; + const AvoidSuspensionAlert = () => { const { store } = useElectronApi(); return ( - - - Avoid suspension! - - - Run your agent for at least half an hour a day to make sure it hits - its targets. If it misses its targets 2 days in a row, it’ll be - suspended. You won’t be able to run it or earn rewards for several - days. - - - - } - style={{ marginBottom: 8 }} - /> + + + + Avoid suspension! + + + Run your agent for at least half an hour a day to make sure it + hits its targets. If it misses its targets 2 days in a row, it’ll + be suspended. You won’t be able to run it or earn rewards for + several days. + + + + } + /> + ); }; -const AvoidSuspension = () => { +export const MainOlasBalance = () => { const { storeState } = useStore(); - - // console.log(storeState); + const { isBalanceLoaded, totalOlasBalance } = useBalance(); // If first reward notification is shown BUT - // agent eviction alert is not shown, show this alert - const isAvoidSuspensionAlertShown = - storeState?.firstRewardNotificationShown && - !storeState?.agentEvictionAlertShown; - - if (!isAvoidSuspensionAlertShown) { - return ; - } + // agent eviction alert is NOT yet shown, show this alert. + const canShowAvoidSuspensionAlert = useMemo(() => { + if (!storeState) return false; - return null; -}; - -export const MainOlasBalance = () => { - const { isBalanceLoaded, totalOlasBalance } = useBalance(); + return ( + storeState.firstRewardNotificationShown && + !storeState.agentEvictionAlertShown + ); + }, [storeState]); const balance = useMemo(() => { if (totalOlasBalance === undefined) return '--'; @@ -178,17 +177,15 @@ export const MainOlasBalance = () => { return ( - + {canShowAvoidSuspensionAlert ? : null} {isBalanceLoaded ? ( <> -
- - - {UNICODE_SYMBOLS.OLAS} - {balance} - OLAS - -
+ + + {UNICODE_SYMBOLS.OLAS} + {balance} + OLAS + ) : ( diff --git a/frontend/components/Main/MainRewards.tsx b/frontend/components/Main/MainRewards.tsx index bb022d1ec..50ef32f30 100644 --- a/frontend/components/Main/MainRewards.tsx +++ b/frontend/components/Main/MainRewards.tsx @@ -101,9 +101,6 @@ const NotifyRewardsModal = () => { // once the notification is closed, set the flag to true store?.set?.('firstRewardNotificationShown', true); - - // and show the eviction educate information to the user - // store?.set?.('agentEvictionAlertShown', true); }, [store]); const onTwitterShare = useCallback(() => { From ee0db5afeb7abfc6733a264f6ad13cba6a1398bb Mon Sep 17 00:00:00 2001 From: sarthak_dev Date: Tue, 23 Jul 2024 20:07:27 +0530 Subject: [PATCH 04/36] add download binaries script --- download_binaries.sh | 8 ++++++++ package.json | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100755 download_binaries.sh diff --git a/download_binaries.sh b/download_binaries.sh new file mode 100755 index 000000000..eb40216d8 --- /dev/null +++ b/download_binaries.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +ARCH=$1 +BIN_DIR="electron/bins/" +mkdir -p $BIN_DIR + +trader_version=$(poetry run python -c "import yaml; config = yaml.safe_load(open('templates/trader.yaml')); print(config['configuration']['trader_version'])") +curl -L -o "${BIN_DIR}aea_bin" "https://github.com/valory-xyz/trader/releases/download/${trader_version}/trader_bin_${ARCH}" diff --git a/package.json b/package.json index e41167849..fa7de32dc 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "productName": "Pearl", "description": "An all-in-one application designed to streamline your entry into the world of autonomous agents and earning OLAS through staking.", "scripts": { - "build": "rm -rf dist/ && node build.tester.js", "build:frontend": "cd frontend && yarn build && rm -rf ../electron/.next && cp -r .next ../electron/.next && rm -rf ../electron/public && cp -r public ../electron/public", "dev:backend": "poetry run python operate/cli.py", "dev:frontend": "cd frontend && yarn dev", @@ -52,9 +51,10 @@ "install:backend": "poetry install --no-root", "install:frontend": "cd frontend && yarn", "lint:frontend": "cd frontend && yarn lint", - "start": "electron .", + "start": "dotenv -e .env -- yarn electron .", "start:frontend": "cd frontend && yarn start", - "test:frontend": "cd frontend && yarn test" + "test:frontend": "cd frontend && yarn test", + "download-binaries": "sh download_binaries.sh x64" }, "version": "0.1.0-rc71" } From 694ff4e08ccd6ad574c2d063af0021313bb68ddc Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Wed, 24 Jul 2024 16:34:59 +0530 Subject: [PATCH 05/36] chore: Update LOW_BALANCE threshold to 3 --- frontend/constants/thresholds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/constants/thresholds.ts b/frontend/constants/thresholds.ts index ced09c8c5..f26aa18ef 100644 --- a/frontend/constants/thresholds.ts +++ b/frontend/constants/thresholds.ts @@ -7,4 +7,4 @@ export const MIN_ETH_BALANCE_THRESHOLDS = { }, }; -export const LOW_BALANCE = 0.5; +export const LOW_BALANCE = 3; From 7638b6bcea0dfa95160ab604eb0c12ba749d2e9e Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Wed, 24 Jul 2024 17:17:21 +0530 Subject: [PATCH 06/36] feat: Add low trading balance alert to MainOlasBalance component --- frontend/components/Main/MainOlasBalance.tsx | 45 +++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/frontend/components/Main/MainOlasBalance.tsx b/frontend/components/Main/MainOlasBalance.tsx index f51cf2ef9..e9ed2a132 100644 --- a/frontend/components/Main/MainOlasBalance.tsx +++ b/frontend/components/Main/MainOlasBalance.tsx @@ -3,15 +3,17 @@ import { Flex, Skeleton, Tooltip, Typography } from 'antd'; import { useMemo } from 'react'; import styled from 'styled-components'; +import { Alert } from '@/components/Alert'; import { COLOR } from '@/constants/colors'; import { UNICODE_SYMBOLS } from '@/constants/symbols'; +import { LOW_BALANCE } from '@/constants/thresholds'; import { useBalance } from '@/hooks/useBalance'; import { useReward } from '@/hooks/useReward'; import { balanceFormat } from '@/utils/numberFormatters'; import { CardSection } from '../styled/CardSection'; -const { Text } = Typography; +const { Text, Title } = Typography; const Balance = styled.span` letter-spacing: -2px; margin-right: 4px; @@ -103,6 +105,46 @@ const CurrentBalance = () => { ); }; +const LowTradingBalanceAlertContainer = styled.div` + .ant-alert { + margin-bottom: 8px; + .anticon.ant-alert-icon { + height: 20px; + width: 20px; + svg { + width: 100%; + height: 100%; + } + } + } +`; + +const LowTradingBalanceAlert = () => { + return ( + + + + Trading balance is too low + + + {`To run your agent, add at least $${LOW_BALANCE - 0.5} XDAI to your account.`} + + + Do it quickly to avoid your agent missing its targets and getting + suspended! + + + } + /> + + ); +}; + export const MainOlasBalance = () => { const { isBalanceLoaded, totalOlasBalance } = useBalance(); @@ -113,6 +155,7 @@ export const MainOlasBalance = () => { return ( + {isBalanceLoaded ? ( <> From 802d3c54dc1c986e62981f072c33e473989f1fd8 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Wed, 24 Jul 2024 17:17:46 +0530 Subject: [PATCH 07/36] fix: Update MainGasBalance component to display 'Too low' status for empty ETH balance --- frontend/components/Main/MainGasBalance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/Main/MainGasBalance.tsx b/frontend/components/Main/MainGasBalance.tsx index 3f8e77487..f370e63c2 100644 --- a/frontend/components/Main/MainGasBalance.tsx +++ b/frontend/components/Main/MainGasBalance.tsx @@ -39,7 +39,7 @@ const BalanceStatus = () => { const status = useMemo(() => { if (!safeBalance || safeBalance.ETH === 0) { - return { statusName: 'Empty', StatusComponent: EmptyDot }; + return { statusName: 'Too low', StatusComponent: EmptyDot }; } if (safeBalance.ETH < LOW_BALANCE) { From a9386a4e6d7d130e6905ff427fe24a7adcf1b4de Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Wed, 24 Jul 2024 18:52:54 +0530 Subject: [PATCH 08/36] Update MainGasBalance component to display 'Too low' status for empty ETH balance --- frontend/components/Main/MainGasBalance.tsx | 9 +-------- frontend/components/Main/MainHeader/index.tsx | 3 +++ frontend/components/Main/MainOlasBalance.tsx | 2 +- frontend/constants/thresholds.ts | 2 +- frontend/context/BalanceProvider.tsx | 8 ++++++++ frontend/hooks/useBalance.ts | 2 ++ 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/frontend/components/Main/MainGasBalance.tsx b/frontend/components/Main/MainGasBalance.tsx index f370e63c2..98155f1cb 100644 --- a/frontend/components/Main/MainGasBalance.tsx +++ b/frontend/components/Main/MainGasBalance.tsx @@ -30,22 +30,15 @@ const EmptyDot = styled(Dot)` const FineDot = styled(Dot)` background-color: ${COLOR.GREEN_2}; `; -const LowDot = styled(Dot)` - background-color: ${COLOR.ORANGE}; -`; const BalanceStatus = () => { const { safeBalance } = useBalance(); const status = useMemo(() => { - if (!safeBalance || safeBalance.ETH === 0) { + if (!safeBalance || safeBalance.ETH < LOW_BALANCE) { return { statusName: 'Too low', StatusComponent: EmptyDot }; } - if (safeBalance.ETH < LOW_BALANCE) { - return { statusName: 'Low', StatusComponent: LowDot }; - } - return { statusName: 'Fine', StatusComponent: FineDot }; }, [safeBalance]); diff --git a/frontend/components/Main/MainHeader/index.tsx b/frontend/components/Main/MainHeader/index.tsx index 8942363f8..b15e14ad0 100644 --- a/frontend/components/Main/MainHeader/index.tsx +++ b/frontend/components/Main/MainHeader/index.tsx @@ -263,6 +263,8 @@ export const MainHeader = () => { if (safeOlasBalanceWithStaked === undefined) return false; if (!services) return false; + if (!safeBalance || safeBalance.ETH < LOW_BALANCE) return false; + // deployment statuses where agent should not be deployed // if (serviceStatus === DeploymentStatus.DEPLOYED) return false; // condition already checked above if (serviceStatus === DeploymentStatus.DEPLOYING) return false; @@ -303,6 +305,7 @@ export const MainHeader = () => { totalEthBalance, isEligibleForStakingAction, canStartEvictedAgent, + safeBalance, ]); return ( diff --git a/frontend/components/Main/MainOlasBalance.tsx b/frontend/components/Main/MainOlasBalance.tsx index e9ed2a132..e4327b7a0 100644 --- a/frontend/components/Main/MainOlasBalance.tsx +++ b/frontend/components/Main/MainOlasBalance.tsx @@ -132,7 +132,7 @@ const LowTradingBalanceAlert = () => { Trading balance is too low - {`To run your agent, add at least $${LOW_BALANCE - 0.5} XDAI to your account.`} + {`To run your agent, add at least $${LOW_BALANCE} XDAI to your account.`} Do it quickly to avoid your agent missing its targets and getting diff --git a/frontend/constants/thresholds.ts b/frontend/constants/thresholds.ts index f26aa18ef..fb5ab3515 100644 --- a/frontend/constants/thresholds.ts +++ b/frontend/constants/thresholds.ts @@ -7,4 +7,4 @@ export const MIN_ETH_BALANCE_THRESHOLDS = { }, }; -export const LOW_BALANCE = 3; +export const LOW_BALANCE = 2; diff --git a/frontend/context/BalanceProvider.tsx b/frontend/context/BalanceProvider.tsx index 12c5400ec..6d56d186c 100644 --- a/frontend/context/BalanceProvider.tsx +++ b/frontend/context/BalanceProvider.tsx @@ -16,6 +16,7 @@ import { useInterval } from 'usehooks-ts'; import { Wallet } from '@/client'; import { FIVE_SECONDS_INTERVAL } from '@/constants/intervals'; +import { LOW_BALANCE } from '@/constants/thresholds'; import { TOKENS } from '@/constants/tokens'; import { ServiceRegistryL2ServiceState } from '@/enums/ServiceRegistryL2ServiceState'; import { Token } from '@/enums/Token'; @@ -41,6 +42,8 @@ export const BalanceContext = createContext<{ olasDepositBalance?: number; eoaBalance?: ValueOf; safeBalance?: ValueOf; + /** If the safe balance is below the threshold (LOW_BALANCE) */ + isSafeBalanceBelowThreshold: boolean; totalEthBalance?: number; totalOlasBalance?: number; wallets?: Wallet[]; @@ -56,6 +59,7 @@ export const BalanceContext = createContext<{ olasDepositBalance: undefined, eoaBalance: undefined, safeBalance: undefined, + isSafeBalanceBelowThreshold: true, totalEthBalance: undefined, totalOlasBalance: undefined, wallets: undefined, @@ -195,6 +199,9 @@ export const BalanceProvider = ({ children }: PropsWithChildren) => { () => masterSafeAddress && walletBalances[masterSafeAddress], [masterSafeAddress, walletBalances], ); + const isSafeBalanceBelowThreshold = safeBalance + ? safeBalance.ETH < LOW_BALANCE + : false; useInterval( () => { @@ -213,6 +220,7 @@ export const BalanceProvider = ({ children }: PropsWithChildren) => { olasDepositBalance, eoaBalance, safeBalance, + isSafeBalanceBelowThreshold, totalEthBalance, totalOlasBalance, wallets, diff --git a/frontend/hooks/useBalance.ts b/frontend/hooks/useBalance.ts index 4132572a1..8fdac2716 100644 --- a/frontend/hooks/useBalance.ts +++ b/frontend/hooks/useBalance.ts @@ -9,6 +9,7 @@ export const useBalance = () => { isBalanceLoaded, eoaBalance, safeBalance, + isSafeBalanceBelowThreshold, totalEthBalance, totalOlasBalance, wallets, @@ -24,6 +25,7 @@ export const useBalance = () => { isBalanceLoaded, eoaBalance, safeBalance, + isSafeBalanceBelowThreshold, totalEthBalance, totalOlasBalance, wallets, From 9be7b1fcb3e5346d92cae1c0aeab16f6c1796635 Mon Sep 17 00:00:00 2001 From: SarthakDev12 Date: Wed, 24 Jul 2024 19:50:43 +0530 Subject: [PATCH 09/36] make requested changes --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index fa7de32dc..2c75d489c 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ "install:backend": "poetry install --no-root", "install:frontend": "cd frontend && yarn", "lint:frontend": "cd frontend && yarn lint", - "start": "dotenv -e .env -- yarn electron .", + "start": "yarn electron .", + "dev": "dotenv -e .env -- yarn start", "start:frontend": "cd frontend && yarn start", "test:frontend": "cd frontend && yarn test", "download-binaries": "sh download_binaries.sh x64" From 8550c0de17ab31235192831ec8063fbdb4cfbb4f Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 25 Jul 2024 00:50:44 +0530 Subject: [PATCH 10/36] chore: Update MainHeader component to prevent starting agent with low balance --- frontend/components/Main/MainHeader/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/components/Main/MainHeader/index.tsx b/frontend/components/Main/MainHeader/index.tsx index b15e14ad0..13a73c94c 100644 --- a/frontend/components/Main/MainHeader/index.tsx +++ b/frontend/components/Main/MainHeader/index.tsx @@ -263,7 +263,15 @@ export const MainHeader = () => { if (safeOlasBalanceWithStaked === undefined) return false; if (!services) return false; - if (!safeBalance || safeBalance.ETH < LOW_BALANCE) return false; + // if the agent is NOT running and the balance is too low, + // user should not be able to start the agent + if ( + serviceButtonState === ServiceButtonLoadingState.NotLoading && + safeBalance && + safeBalance.ETH < LOW_BALANCE + ) { + return false; + } // deployment statuses where agent should not be deployed // if (serviceStatus === DeploymentStatus.DEPLOYED) return false; // condition already checked above From b5e27b0c8dc738e5df80304409aa49ead515e3ec Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 25 Jul 2024 01:19:37 +0530 Subject: [PATCH 11/36] feat: Show low balance notification in MainGasBalance component --- frontend/components/Main/MainGasBalance.tsx | 32 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/frontend/components/Main/MainGasBalance.tsx b/frontend/components/Main/MainGasBalance.tsx index 98155f1cb..7dbd78181 100644 --- a/frontend/components/Main/MainGasBalance.tsx +++ b/frontend/components/Main/MainGasBalance.tsx @@ -1,11 +1,12 @@ import { ArrowUpOutlined, InfoCircleOutlined } from '@ant-design/icons'; import { Skeleton, Tooltip, Typography } from 'antd'; -import { useMemo } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import styled from 'styled-components'; import { COLOR } from '@/constants/colors'; import { LOW_BALANCE } from '@/constants/thresholds'; import { useBalance } from '@/hooks/useBalance'; +import { useElectronApi } from '@/hooks/useElectronApi'; import { useWallet } from '@/hooks/useWallet'; import { CardSection } from '../styled/CardSection'; @@ -32,7 +33,34 @@ const FineDot = styled(Dot)` `; const BalanceStatus = () => { - const { safeBalance } = useBalance(); + const { isBalanceLoaded, safeBalance } = useBalance(); + const { showNotification } = useElectronApi(); + + const [isLowBalanceNotificationShown, setIsLowBalanceNotificationShown] = + useState(false); + + // show notification if balance is too low + useEffect(() => { + if (!isBalanceLoaded) return; + if (!safeBalance) return; + if (!showNotification) return; + + if (safeBalance.ETH < LOW_BALANCE && !isLowBalanceNotificationShown) { + showNotification('Trading balance is too low'); + setIsLowBalanceNotificationShown(true); + } + + // if already shown and the balance has increased, + // can show the notification again if it goes below the threshold + if (safeBalance.ETH >= LOW_BALANCE && isLowBalanceNotificationShown) { + setIsLowBalanceNotificationShown(false); + } + }, [ + isBalanceLoaded, + isLowBalanceNotificationShown, + safeBalance, + showNotification, + ]); const status = useMemo(() => { if (!safeBalance || safeBalance.ETH < LOW_BALANCE) { From 82e229bbc69712f8c59196145b624b165f8f32b4 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 25 Jul 2024 01:27:31 +0530 Subject: [PATCH 12/36] chore: Remove unused isSafeBalanceBelowThreshold property from BalanceContext --- frontend/context/BalanceProvider.tsx | 8 -------- frontend/hooks/useBalance.ts | 2 -- 2 files changed, 10 deletions(-) diff --git a/frontend/context/BalanceProvider.tsx b/frontend/context/BalanceProvider.tsx index 6d56d186c..12c5400ec 100644 --- a/frontend/context/BalanceProvider.tsx +++ b/frontend/context/BalanceProvider.tsx @@ -16,7 +16,6 @@ import { useInterval } from 'usehooks-ts'; import { Wallet } from '@/client'; import { FIVE_SECONDS_INTERVAL } from '@/constants/intervals'; -import { LOW_BALANCE } from '@/constants/thresholds'; import { TOKENS } from '@/constants/tokens'; import { ServiceRegistryL2ServiceState } from '@/enums/ServiceRegistryL2ServiceState'; import { Token } from '@/enums/Token'; @@ -42,8 +41,6 @@ export const BalanceContext = createContext<{ olasDepositBalance?: number; eoaBalance?: ValueOf; safeBalance?: ValueOf; - /** If the safe balance is below the threshold (LOW_BALANCE) */ - isSafeBalanceBelowThreshold: boolean; totalEthBalance?: number; totalOlasBalance?: number; wallets?: Wallet[]; @@ -59,7 +56,6 @@ export const BalanceContext = createContext<{ olasDepositBalance: undefined, eoaBalance: undefined, safeBalance: undefined, - isSafeBalanceBelowThreshold: true, totalEthBalance: undefined, totalOlasBalance: undefined, wallets: undefined, @@ -199,9 +195,6 @@ export const BalanceProvider = ({ children }: PropsWithChildren) => { () => masterSafeAddress && walletBalances[masterSafeAddress], [masterSafeAddress, walletBalances], ); - const isSafeBalanceBelowThreshold = safeBalance - ? safeBalance.ETH < LOW_BALANCE - : false; useInterval( () => { @@ -220,7 +213,6 @@ export const BalanceProvider = ({ children }: PropsWithChildren) => { olasDepositBalance, eoaBalance, safeBalance, - isSafeBalanceBelowThreshold, totalEthBalance, totalOlasBalance, wallets, diff --git a/frontend/hooks/useBalance.ts b/frontend/hooks/useBalance.ts index 8fdac2716..4132572a1 100644 --- a/frontend/hooks/useBalance.ts +++ b/frontend/hooks/useBalance.ts @@ -9,7 +9,6 @@ export const useBalance = () => { isBalanceLoaded, eoaBalance, safeBalance, - isSafeBalanceBelowThreshold, totalEthBalance, totalOlasBalance, wallets, @@ -25,7 +24,6 @@ export const useBalance = () => { isBalanceLoaded, eoaBalance, safeBalance, - isSafeBalanceBelowThreshold, totalEthBalance, totalOlasBalance, wallets, From d5a884aad803b1830268640478e285e0850d19a3 Mon Sep 17 00:00:00 2001 From: Ardian Date: Tue, 23 Jul 2024 17:53:55 +0200 Subject: [PATCH 13/36] fix: remove invalid services --- operate/services/manage.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index 927fff7cc..4d3041b93 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -111,8 +111,14 @@ def json(self) -> t.List[t.Dict]: continue if not path.name.startswith("bafybei"): continue - service = Service.load(path=path) - data.append(service.json) + try: + service = Service.load(path=path) + data.append(service.json) + except Exception as e: + self.logger.warning(f"Failed to load service: {path.name}. Exception: {e}") + # delete the invalid path + shutil.rmtree(path) + self.logger.info(f"Deleted invalid service: {path.name}") return data def exists(self, service: str) -> bool: From 29bf7d6419e91de56d28d1ed2e93c153511fe6af Mon Sep 17 00:00:00 2001 From: Ardian Date: Wed, 24 Jul 2024 10:23:16 +0200 Subject: [PATCH 14/36] release: rc86 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index ba13ac9f8..04893a6dc 100644 --- a/electron/install.js +++ b/electron/install.js @@ -13,7 +13,7 @@ const { paths } = require('./constants'); * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc71'; +const OlasMiddlewareVersion = '0.1.0rc86'; const Env = { ...process.env, diff --git a/package.json b/package.json index e41167849..967f801ce 100644 --- a/package.json +++ b/package.json @@ -56,5 +56,5 @@ "start:frontend": "cd frontend && yarn start", "test:frontend": "cd frontend && yarn test" }, - "version": "0.1.0-rc71" + "version": "0.1.0-rc86" } diff --git a/pyproject.toml b/pyproject.toml index 8ac78d250..71d3158cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc71" +version = "0.1.0-rc86" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From 8232ff5c1ef50cc94ae656a23e65f1e485cd41b7 Mon Sep 17 00:00:00 2001 From: Ardian Date: Thu, 25 Jul 2024 11:02:42 +0200 Subject: [PATCH 15/36] chore: lint --- operate/services/manage.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/operate/services/manage.py b/operate/services/manage.py index 4d3041b93..2673b991c 100644 --- a/operate/services/manage.py +++ b/operate/services/manage.py @@ -114,8 +114,10 @@ def json(self) -> t.List[t.Dict]: try: service = Service.load(path=path) data.append(service.json) - except Exception as e: - self.logger.warning(f"Failed to load service: {path.name}. Exception: {e}") + except Exception as e: # pylint: disable=broad-except + self.logger.warning( + f"Failed to load service: {path.name}. Exception: {e}" + ) # delete the invalid path shutil.rmtree(path) self.logger.info(f"Deleted invalid service: {path.name}") From 3ae15add1137d68cc8a6fbfcf7b2e6fa15ed7d6b Mon Sep 17 00:00:00 2001 From: SarthakDev12 Date: Thu, 25 Jul 2024 14:51:17 +0530 Subject: [PATCH 16/36] fix unstyled text visible after splash screen --- frontend/components/Loading.tsx | 9 +++++++ frontend/pages/_app.tsx | 27 ++++++++++++++++++- frontend/pages/_document.tsx | 47 +++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 frontend/components/Loading.tsx create mode 100644 frontend/pages/_document.tsx diff --git a/frontend/components/Loading.tsx b/frontend/components/Loading.tsx new file mode 100644 index 000000000..aa3570888 --- /dev/null +++ b/frontend/components/Loading.tsx @@ -0,0 +1,9 @@ +import styled from 'styled-components'; + +const LoadingWrapper = styled.div` + background-color: #0000; +`; + +const Loading = () => ; + +export default Loading; diff --git a/frontend/pages/_app.tsx b/frontend/pages/_app.tsx index 7a6c2efe8..442d6e14c 100644 --- a/frontend/pages/_app.tsx +++ b/frontend/pages/_app.tsx @@ -2,7 +2,7 @@ import '../styles/globals.scss'; import { ConfigProvider } from 'antd'; import type { AppProps } from 'next/app'; -import { useEffect, useRef } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { Layout } from '@/components/Layout'; import { BalanceProvider } from '@/context/BalanceProvider'; @@ -18,17 +18,42 @@ import { StakingContractInfoProvider } from '@/context/StakingContractInfoProvid import { StoreProvider } from '@/context/StoreProvider'; import { WalletProvider } from '@/context/WalletProvider'; import { mainTheme } from '@/theme'; +import Loading from '@/components/Loading'; export default function App({ Component, pageProps }: AppProps) { const isMounted = useRef(false); + const [isLoaded, setIsLoaded] = useState(false); + const [loadingTimeReached, setLoadingTimeReached] = useState(false); useEffect(() => { isMounted.current = true; + + const handleLoad = () => { + setIsLoaded(true); + }; + const checkStylesLoaded = () => { + const styles = document.querySelectorAll('link[rel="stylesheet"]'); + if (styles.length > 0) { + handleLoad(); + } + }; + + const timer = setTimeout(() => { + setLoadingTimeReached(true); + }, 1000); + + checkStylesLoaded(); + window.addEventListener('load', checkStylesLoaded); return () => { isMounted.current = false; + clearTimeout(timer); + window.removeEventListener('load', checkStylesLoaded); }; }, []); + if (!loadingTimeReached || !isLoaded) { + return ; + } return ( diff --git a/frontend/pages/_document.tsx b/frontend/pages/_document.tsx new file mode 100644 index 000000000..2d1d90e53 --- /dev/null +++ b/frontend/pages/_document.tsx @@ -0,0 +1,47 @@ +// _document.tsx +import Document, { Html, Head, Main, NextScript, DocumentContext, DocumentInitialProps } from 'next/document'; +import { ServerStyleSheet } from 'styled-components'; + +class MyDocument extends Document { + static async getInitialProps(ctx: DocumentContext): Promise { + const sheet = new ServerStyleSheet(); + const originalRenderPage = ctx.renderPage; + + try { + ctx.renderPage = () => + originalRenderPage({ + enhanceApp: (App) => (props) => sheet.collectStyles(), + }); + + const initialProps = await Document.getInitialProps(ctx); + return { + ...initialProps, + styles: ( + <> + {initialProps.styles} + {sheet.getStyleElement()} + + ), + }; + } finally { + sheet.seal(); + } + } + + render() { + return ( + + + + + + +
+ + + + ); + } +} + +export default MyDocument; From 66b0943d62cab0de5b7318c1c703fda4e9934f69 Mon Sep 17 00:00:00 2001 From: SarthakDev12 Date: Thu, 25 Jul 2024 16:14:31 +0530 Subject: [PATCH 17/36] add both variant x64 and arm64 in script --- download_binaries.sh | 6 ++++-- package.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/download_binaries.sh b/download_binaries.sh index eb40216d8..db12c6223 100755 --- a/download_binaries.sh +++ b/download_binaries.sh @@ -1,8 +1,10 @@ #!/bin/bash -ARCH=$1 BIN_DIR="electron/bins/" mkdir -p $BIN_DIR trader_version=$(poetry run python -c "import yaml; config = yaml.safe_load(open('templates/trader.yaml')); print(config['configuration']['trader_version'])") -curl -L -o "${BIN_DIR}aea_bin" "https://github.com/valory-xyz/trader/releases/download/${trader_version}/trader_bin_${ARCH}" + +curl -L -o "${BIN_DIR}aea_bin_x64" "https://github.com/valory-xyz/trader/releases/download/${trader_version}/trader_bin_x64" + +curl -L -o "${BIN_DIR}aea_bin_arm64" "https://github.com/valory-xyz/trader/releases/download/${trader_version}/trader_bin_arm64" diff --git a/package.json b/package.json index 2c75d489c..b116e7068 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "dev": "dotenv -e .env -- yarn start", "start:frontend": "cd frontend && yarn start", "test:frontend": "cd frontend && yarn test", - "download-binaries": "sh download_binaries.sh x64" + "download-binaries": "sh download_binaries.sh" }, "version": "0.1.0-rc71" } From fecab4899fb37194e4d119795b59a3898cab7ed6 Mon Sep 17 00:00:00 2001 From: SarthakDev12 Date: Thu, 25 Jul 2024 18:14:40 +0530 Subject: [PATCH 18/36] Fix linting --- frontend/pages/_app.tsx | 10 +++++----- frontend/pages/_document.tsx | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/frontend/pages/_app.tsx b/frontend/pages/_app.tsx index 442d6e14c..2d4394736 100644 --- a/frontend/pages/_app.tsx +++ b/frontend/pages/_app.tsx @@ -5,6 +5,7 @@ import type { AppProps } from 'next/app'; import { useEffect, useRef, useState } from 'react'; import { Layout } from '@/components/Layout'; +import Loading from '@/components/Loading'; import { BalanceProvider } from '@/context/BalanceProvider'; import { ElectronApiProvider } from '@/context/ElectronApiProvider'; import { MasterSafeProvider } from '@/context/MasterSafeProvider'; @@ -18,11 +19,10 @@ import { StakingContractInfoProvider } from '@/context/StakingContractInfoProvid import { StoreProvider } from '@/context/StoreProvider'; import { WalletProvider } from '@/context/WalletProvider'; import { mainTheme } from '@/theme'; -import Loading from '@/components/Loading'; export default function App({ Component, pageProps }: AppProps) { const isMounted = useRef(false); - const [isLoaded, setIsLoaded] = useState(false); + const [isLoaded, setIsLoaded] = useState(false); const [loadingTimeReached, setLoadingTimeReached] = useState(false); useEffect(() => { @@ -31,14 +31,14 @@ export default function App({ Component, pageProps }: AppProps) { const handleLoad = () => { setIsLoaded(true); }; - const checkStylesLoaded = () => { + const checkStylesLoaded = () => { const styles = document.querySelectorAll('link[rel="stylesheet"]'); if (styles.length > 0) { handleLoad(); } }; - const timer = setTimeout(() => { + const timer = setTimeout(() => { setLoadingTimeReached(true); }, 1000); @@ -51,7 +51,7 @@ export default function App({ Component, pageProps }: AppProps) { }; }, []); - if (!loadingTimeReached || !isLoaded) { + if (!loadingTimeReached || !isLoaded) { return ; } return ( diff --git a/frontend/pages/_document.tsx b/frontend/pages/_document.tsx index 2d1d90e53..722104270 100644 --- a/frontend/pages/_document.tsx +++ b/frontend/pages/_document.tsx @@ -1,16 +1,26 @@ // _document.tsx -import Document, { Html, Head, Main, NextScript, DocumentContext, DocumentInitialProps } from 'next/document'; +import Document, { + DocumentContext, + DocumentInitialProps, + Head, + Html, + Main, + NextScript, +} from 'next/document'; import { ServerStyleSheet } from 'styled-components'; class MyDocument extends Document { - static async getInitialProps(ctx: DocumentContext): Promise { + static async getInitialProps( + ctx: DocumentContext, + ): Promise { const sheet = new ServerStyleSheet(); const originalRenderPage = ctx.renderPage; try { ctx.renderPage = () => originalRenderPage({ - enhanceApp: (App) => (props) => sheet.collectStyles(), + enhanceApp: (App) => (props) => + sheet.collectStyles(), }); const initialProps = await Document.getInitialProps(ctx); From 3b95c45f4ab10ae3bdf9fe7ce19b9a9e8429a7b1 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Thu, 25 Jul 2024 19:19:37 +0530 Subject: [PATCH 19/36] feat: Add low trading balance alert to MainOlasBalance component --- frontend/components/Main/MainOlasBalance.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/components/Main/MainOlasBalance.tsx b/frontend/components/Main/MainOlasBalance.tsx index e4327b7a0..46a26d780 100644 --- a/frontend/components/Main/MainOlasBalance.tsx +++ b/frontend/components/Main/MainOlasBalance.tsx @@ -120,6 +120,12 @@ const LowTradingBalanceAlertContainer = styled.div` `; const LowTradingBalanceAlert = () => { + const { isBalanceLoaded, safeBalance } = useBalance(); + + if (!isBalanceLoaded) return null; + if (!safeBalance) return null; + if (safeBalance.ETH >= LOW_BALANCE) return null; + return ( Date: Thu, 25 Jul 2024 19:43:20 +0530 Subject: [PATCH 20/36] feat: update comment --- frontend/components/Main/MainGasBalance.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/components/Main/MainGasBalance.tsx b/frontend/components/Main/MainGasBalance.tsx index 7dbd78181..f9eb5de6a 100644 --- a/frontend/components/Main/MainGasBalance.tsx +++ b/frontend/components/Main/MainGasBalance.tsx @@ -46,12 +46,12 @@ const BalanceStatus = () => { if (!showNotification) return; if (safeBalance.ETH < LOW_BALANCE && !isLowBalanceNotificationShown) { - showNotification('Trading balance is too low'); + showNotification('Trading balance is too low.'); setIsLowBalanceNotificationShown(true); } - // if already shown and the balance has increased, - // can show the notification again if it goes below the threshold + // If it has already been shown and the balance has increased, + // should show the notification again if it goes below the threshold. if (safeBalance.ETH >= LOW_BALANCE && isLowBalanceNotificationShown) { setIsLowBalanceNotificationShown(false); } From 4ffddccfde68aa889cb21ec8141f56ec6fb7eade Mon Sep 17 00:00:00 2001 From: SarthakDev12 Date: Fri, 26 Jul 2024 12:18:13 +0530 Subject: [PATCH 21/36] make recommended changes --- frontend/components/Loading.tsx | 9 ------ frontend/pages/_app.tsx | 43 ++++--------------------- frontend/pages/_document.tsx | 57 --------------------------------- 3 files changed, 7 insertions(+), 102 deletions(-) delete mode 100644 frontend/components/Loading.tsx delete mode 100644 frontend/pages/_document.tsx diff --git a/frontend/components/Loading.tsx b/frontend/components/Loading.tsx deleted file mode 100644 index aa3570888..000000000 --- a/frontend/components/Loading.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import styled from 'styled-components'; - -const LoadingWrapper = styled.div` - background-color: #0000; -`; - -const Loading = () => ; - -export default Loading; diff --git a/frontend/pages/_app.tsx b/frontend/pages/_app.tsx index 2d4394736..68727cf8c 100644 --- a/frontend/pages/_app.tsx +++ b/frontend/pages/_app.tsx @@ -2,10 +2,9 @@ import '../styles/globals.scss'; import { ConfigProvider } from 'antd'; import type { AppProps } from 'next/app'; -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useState } from 'react'; import { Layout } from '@/components/Layout'; -import Loading from '@/components/Loading'; import { BalanceProvider } from '@/context/BalanceProvider'; import { ElectronApiProvider } from '@/context/ElectronApiProvider'; import { MasterSafeProvider } from '@/context/MasterSafeProvider'; @@ -21,39 +20,11 @@ import { WalletProvider } from '@/context/WalletProvider'; import { mainTheme } from '@/theme'; export default function App({ Component, pageProps }: AppProps) { - const isMounted = useRef(false); - const [isLoaded, setIsLoaded] = useState(false); - const [loadingTimeReached, setLoadingTimeReached] = useState(false); - + const [isMounted, setIsMounted] = useState(false); useEffect(() => { - isMounted.current = true; - - const handleLoad = () => { - setIsLoaded(true); - }; - const checkStylesLoaded = () => { - const styles = document.querySelectorAll('link[rel="stylesheet"]'); - if (styles.length > 0) { - handleLoad(); - } - }; - - const timer = setTimeout(() => { - setLoadingTimeReached(true); - }, 1000); - - checkStylesLoaded(); - window.addEventListener('load', checkStylesLoaded); - return () => { - isMounted.current = false; - clearTimeout(timer); - window.removeEventListener('load', checkStylesLoaded); - }; + setIsMounted(true); }, []); - if (!loadingTimeReached || !isLoaded) { - return ; - } return ( @@ -67,13 +38,13 @@ export default function App({ Component, pageProps }: AppProps) { - {isMounted ? ( - + + {isMounted ? ( - - ) : null} + ) : null} + diff --git a/frontend/pages/_document.tsx b/frontend/pages/_document.tsx deleted file mode 100644 index 722104270..000000000 --- a/frontend/pages/_document.tsx +++ /dev/null @@ -1,57 +0,0 @@ -// _document.tsx -import Document, { - DocumentContext, - DocumentInitialProps, - Head, - Html, - Main, - NextScript, -} from 'next/document'; -import { ServerStyleSheet } from 'styled-components'; - -class MyDocument extends Document { - static async getInitialProps( - ctx: DocumentContext, - ): Promise { - const sheet = new ServerStyleSheet(); - const originalRenderPage = ctx.renderPage; - - try { - ctx.renderPage = () => - originalRenderPage({ - enhanceApp: (App) => (props) => - sheet.collectStyles(), - }); - - const initialProps = await Document.getInitialProps(ctx); - return { - ...initialProps, - styles: ( - <> - {initialProps.styles} - {sheet.getStyleElement()} - - ), - }; - } finally { - sheet.seal(); - } - } - - render() { - return ( - - - - - - -
- - - - ); - } -} - -export default MyDocument; From 480cfe740bafea8ee47ab9e54b512be56b38ae0c Mon Sep 17 00:00:00 2001 From: Ardian Date: Wed, 31 Jul 2024 18:36:51 +0200 Subject: [PATCH 22/36] release: rc95 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index f85e72e9d..c629576df 100644 --- a/electron/install.js +++ b/electron/install.js @@ -14,7 +14,7 @@ const { paths } = require('./constants'); * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc93'; +const OlasMiddlewareVersion = '0.1.0rc95'; const Env = { ...process.env, diff --git a/package.json b/package.json index 7354222bf..67b1d8c1f 100644 --- a/package.json +++ b/package.json @@ -57,5 +57,5 @@ "test:frontend": "cd frontend && yarn test", "download-binaries": "sh download_binaries.sh" }, - "version": "0.1.0-rc93" + "version": "0.1.0-rc95" } diff --git a/pyproject.toml b/pyproject.toml index 1a4727d41..76d5cf9f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc93" +version = "0.1.0-rc95" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From ab41eedeeb2df1cba635e18e0eb2fb932c1261a5 Mon Sep 17 00:00:00 2001 From: Ardian Date: Thu, 1 Aug 2024 19:06:01 +0200 Subject: [PATCH 23/36] feat: add dev build --- .github/workflows/release.yml | 19 +++++++++++++++++++ build.js | 12 +++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0eade5ffb..78dc854d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -102,4 +102,23 @@ jobs: NODE_ENV: production DEV_RPC: https://rpc-gate.autonolas.tech/gnosis-rpc/ FORK_URL: https://rpc-gate.autonolas.tech/gnosis-rpc/ + run: node build.js + - name: "Build frontend with dev env vars" + run: yarn build:frontend + env: + NODE_ENV: development + DEV_RPC: https://virtual.gnosis.rpc.tenderly.co/78ca845d-2b24-44a6-9ce2-869a979e8b5b + IS_STAGING: ${{ github.ref != 'refs/heads/main' && 'true' || 'false' }} + FORK_URL: https://virtual.gnosis.rpc.tenderly.co/78ca845d-2b24-44a6-9ce2-869a979e8b5b + - name: "Build, notarize, publish dev build" + env: + APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLEIDPASS }} + APPLE_ID: ${{ secrets.APPLEID }} + APPLETEAMID: ${{ secrets.APPLETEAMID }} + CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }} + CSC_LINK: ${{ secrets.CSC_LINK }} + GH_TOKEN: ${{ secrets.github_token}} + NODE_ENV: development + DEV_RPC: https://virtual.gnosis.rpc.tenderly.co/78ca845d-2b24-44a6-9ce2-869a979e8b5b + FORK_URL: https://virtual.gnosis.rpc.tenderly.co/78ca845d-2b24-44a6-9ce2-869a979e8b5b run: node build.js \ No newline at end of file diff --git a/build.js b/build.js index a7e15a32b..8570e3bdd 100644 --- a/build.js +++ b/build.js @@ -6,6 +6,16 @@ const build = require('electron-builder').build; const { publishOptions } = require('./electron/constants'); +/** + * Get the artifact name for the build based on the environment. + * @returns {string} + */ +function artifactName() { + const env = process.env.NODE_ENV; + const prefix = env !== 'production' ? 'dev-' : ''; + return prefix + '${productName}-${version}-${platform}-${arch}.${ext}'; +} + const main = async () => { console.log('Building...'); @@ -14,7 +24,7 @@ const main = async () => { publish: 'onTag', config: { appId: 'xyz.valory.olas-operate-app', - artifactName: '${productName}-${version}-${platform}-${arch}.${ext}', + artifactName: artifactName(), productName: 'Pearl', files: ['electron/**/*', 'package.json'], directories: { From 21d38f9b23053284ddda5a2869d6a2874f779986 Mon Sep 17 00:00:00 2001 From: Ardian Date: Thu, 1 Aug 2024 19:35:31 +0200 Subject: [PATCH 24/36] release: rc97 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index c629576df..73f17892c 100644 --- a/electron/install.js +++ b/electron/install.js @@ -14,7 +14,7 @@ const { paths } = require('./constants'); * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc95'; +const OlasMiddlewareVersion = '0.1.0rc97'; const Env = { ...process.env, diff --git a/package.json b/package.json index 67b1d8c1f..66ccdaace 100644 --- a/package.json +++ b/package.json @@ -57,5 +57,5 @@ "test:frontend": "cd frontend && yarn test", "download-binaries": "sh download_binaries.sh" }, - "version": "0.1.0-rc95" + "version": "0.1.0-rc97" } diff --git a/pyproject.toml b/pyproject.toml index 76d5cf9f7..8a4765170 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc95" +version = "0.1.0-rc97" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From dec9eb82c247cedc6238cc33434c49a695a1e31e Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 2 Aug 2024 02:25:28 +0530 Subject: [PATCH 25/36] chore: Update AgentButton to open support URL in Discord --- .../components/Main/MainHeader/AgentButton/index.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/components/Main/MainHeader/AgentButton/index.tsx b/frontend/components/Main/MainHeader/AgentButton/index.tsx index cd6f72c59..642b48a26 100644 --- a/frontend/components/Main/MainHeader/AgentButton/index.tsx +++ b/frontend/components/Main/MainHeader/AgentButton/index.tsx @@ -4,6 +4,7 @@ import { useCallback, useMemo } from 'react'; import { Chain, DeploymentStatus } from '@/client'; import { COLOR } from '@/constants/colors'; +import { SUPPORT_URL } from '@/constants/urls'; import { useBalance } from '@/hooks/useBalance'; import { useElectronApi } from '@/hooks/useElectronApi'; import { useServices } from '@/hooks/useServices'; @@ -259,8 +260,12 @@ export const AgentButton = () => { } return ( - ); }, [ From d63263b60e0134acceeac5279bcf0482c217cc14 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 2 Aug 2024 02:30:17 +0530 Subject: [PATCH 26/36] feat: Add external link symbol to 'Seek help in Discord' button --- frontend/components/Main/MainHeader/AgentButton/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/components/Main/MainHeader/AgentButton/index.tsx b/frontend/components/Main/MainHeader/AgentButton/index.tsx index 642b48a26..756471bc2 100644 --- a/frontend/components/Main/MainHeader/AgentButton/index.tsx +++ b/frontend/components/Main/MainHeader/AgentButton/index.tsx @@ -4,6 +4,7 @@ import { useCallback, useMemo } from 'react'; import { Chain, DeploymentStatus } from '@/client'; import { COLOR } from '@/constants/colors'; +import { UNICODE_SYMBOLS } from '@/constants/symbols'; import { SUPPORT_URL } from '@/constants/urls'; import { useBalance } from '@/hooks/useBalance'; import { useElectronApi } from '@/hooks/useElectronApi'; @@ -265,7 +266,7 @@ export const AgentButton = () => { size="large" onClick={() => window.open(SUPPORT_URL, '_blank')} > - Seek help in Discord + Seek help in Discord {UNICODE_SYMBOLS.EXTERNAL_LINK} ); }, [ From 057846b3df83549b8176822aa307b908ff106b2e Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 2 Aug 2024 19:00:27 +0530 Subject: [PATCH 27/36] chore: Update tray icons for logged-out status --- electron/main.js | 14 +++++++++++--- frontend/types/ElectronApi.ts | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/electron/main.js b/electron/main.js index e2c66a668..5a01cae73 100644 --- a/electron/main.js +++ b/electron/main.js @@ -131,17 +131,18 @@ const createTray = () => { tray.setContextMenu(contextMenu); ipcMain.on('tray', (_event, status) => { + const isSupportedOS = isWindows || isMac; switch (status) { case 'low-gas': { const icon = getUpdatedTrayIcon( - isWindows || isMac ? TRAY_ICONS.LOW_GAS : TRAY_ICONS_PATHS.LOW_GAS, + isSupportedOS ? TRAY_ICONS.LOW_GAS : TRAY_ICONS_PATHS.LOW_GAS, ); tray.setImage(icon); break; } case 'running': { const icon = getUpdatedTrayIcon( - isWindows || isMac ? TRAY_ICONS.RUNNING : TRAY_ICONS_PATHS.RUNNING, + isSupportedOS ? TRAY_ICONS.RUNNING : TRAY_ICONS_PATHS.RUNNING, ); tray.setImage(icon); @@ -149,7 +150,14 @@ const createTray = () => { } case 'paused': { const icon = getUpdatedTrayIcon( - isWindows || isMac ? TRAY_ICONS.PAUSED : TRAY_ICONS_PATHS.PAUSED, + isSupportedOS ? TRAY_ICONS.PAUSED : TRAY_ICONS_PATHS.PAUSED, + ); + tray.setImage(icon); + break; + } + case 'logged-out': { + const icon = getUpdatedTrayIcon( + isSupportedOS ? TRAY_ICONS.LOGGED_OUT : TRAY_ICONS_PATHS.LOGGED_OUT, ); tray.setImage(icon); break; diff --git a/frontend/types/ElectronApi.ts b/frontend/types/ElectronApi.ts index df0456a47..61d551e8b 100644 --- a/frontend/types/ElectronApi.ts +++ b/frontend/types/ElectronApi.ts @@ -6,4 +6,8 @@ export type ElectronStore = { agentEvictionAlertShown?: boolean; }; -export type ElectronTrayIconStatus = 'low-gas' | 'running' | 'paused'; +export type ElectronTrayIconStatus = + | 'low-gas' + | 'running' + | 'paused' + | 'logged-out'; From 1c8e6f66df0c83a7d52c53384da3516db755164c Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 2 Aug 2024 19:00:58 +0530 Subject: [PATCH 28/36] feat: update icon for BUILT deployment status --- frontend/components/Main/MainHeader/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/components/Main/MainHeader/index.tsx b/frontend/components/Main/MainHeader/index.tsx index c24b0d430..78ffde06f 100644 --- a/frontend/components/Main/MainHeader/index.tsx +++ b/frontend/components/Main/MainHeader/index.tsx @@ -23,6 +23,8 @@ const useSetupTrayIcon = () => { setTrayIcon?.('running'); } else if (serviceStatus === DeploymentStatus.STOPPED) { setTrayIcon?.('paused'); + } else if (serviceStatus === DeploymentStatus.BUILT) { + setTrayIcon?.('logged-out'); } }, [safeBalance, serviceStatus, setTrayIcon]); From bcd9e6ff8eef87ad37a63430286ea2b4cf6d7588 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 2 Aug 2024 19:13:57 +0530 Subject: [PATCH 29/36] chore: move AgentHead to it's own file from index.tsx --- .../Main/MainHeader/{AgentHead/index.tsx => AgentHead.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename frontend/components/Main/MainHeader/{AgentHead/index.tsx => AgentHead.tsx} (100%) diff --git a/frontend/components/Main/MainHeader/AgentHead/index.tsx b/frontend/components/Main/MainHeader/AgentHead.tsx similarity index 100% rename from frontend/components/Main/MainHeader/AgentHead/index.tsx rename to frontend/components/Main/MainHeader/AgentHead.tsx From 38a24769a74e247bf651b6fc2aceddf98a393b95 Mon Sep 17 00:00:00 2001 From: mohandast52 Date: Fri, 2 Aug 2024 19:21:04 +0530 Subject: [PATCH 30/36] chore: add 'CannotStartAgentDueToUnexpectedError' component --- .../Main/MainHeader/AgentButton/index.tsx | 17 +++------- .../Main/MainHeader/CannotStartAgent.tsx | 31 ++++++++++++++++--- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/frontend/components/Main/MainHeader/AgentButton/index.tsx b/frontend/components/Main/MainHeader/AgentButton/index.tsx index 756471bc2..8ec174417 100644 --- a/frontend/components/Main/MainHeader/AgentButton/index.tsx +++ b/frontend/components/Main/MainHeader/AgentButton/index.tsx @@ -4,8 +4,6 @@ import { useCallback, useMemo } from 'react'; import { Chain, DeploymentStatus } from '@/client'; import { COLOR } from '@/constants/colors'; -import { UNICODE_SYMBOLS } from '@/constants/symbols'; -import { SUPPORT_URL } from '@/constants/urls'; import { useBalance } from '@/hooks/useBalance'; import { useElectronApi } from '@/hooks/useElectronApi'; import { useServices } from '@/hooks/useServices'; @@ -17,7 +15,10 @@ import { ServicesService } from '@/service/Services'; import { WalletService } from '@/service/Wallet'; import { getMinimumStakedAmountRequired } from '@/utils/service'; -import { CannotStartAgent } from '../CannotStartAgent'; +import { + CannotStartAgent, + CannotStartAgentDueToUnexpectedError, +} from '../CannotStartAgent'; import { requiredGas, requiredOlas } from '../constants'; const { Text } = Typography; @@ -260,15 +261,7 @@ export const AgentButton = () => { return ; } - return ( - - ); + return ; }, [ hasInitialLoaded, serviceStatus, diff --git a/frontend/components/Main/MainHeader/CannotStartAgent.tsx b/frontend/components/Main/MainHeader/CannotStartAgent.tsx index 9206d6fa0..556512f5d 100644 --- a/frontend/components/Main/MainHeader/CannotStartAgent.tsx +++ b/frontend/components/Main/MainHeader/CannotStartAgent.tsx @@ -15,6 +15,32 @@ const cannotStartAgentText = ( ); +const otherPopoverProps: PopoverProps = { + arrow: false, + placement: 'bottomRight', +}; + +export const CannotStartAgentDueToUnexpectedError = () => ( + + + Try to restart the app. If the issue persists, join the Olas community + Discord server to report or stay up to date on the issue. + + + + Olas community Discord server {UNICODE_SYMBOLS.EXTERNAL_LINK} + + + } + > + {cannotStartAgentText} + +); + 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 = () => ( @@ -27,11 +53,6 @@ const AgentEvictedPopover = () => ( ); -const otherPopoverProps: PopoverProps = { - arrow: false, - placement: 'bottomRight', -}; - const JoinOlasCommunity = () => (
From ccac0721271a5d693c82af513c4e1d938278f5da Mon Sep 17 00:00:00 2001 From: Mohan Date: Mon, 5 Aug 2024 19:14:35 +0530 Subject: [PATCH 31/36] Update build.js --- build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.js b/build.js index 8570e3bdd..ed96764e0 100644 --- a/build.js +++ b/build.js @@ -12,7 +12,7 @@ const { publishOptions } = require('./electron/constants'); */ function artifactName() { const env = process.env.NODE_ENV; - const prefix = env !== 'production' ? 'dev-' : ''; + const prefix = env === 'production' ? '' : 'dev-'; return prefix + '${productName}-${version}-${platform}-${arch}.${ext}'; } From deddd89555b15c829a7f893514d56ef61612df2e Mon Sep 17 00:00:00 2001 From: Ardian <30511811+0xArdi@users.noreply.github.com> Date: Fri, 9 Aug 2024 13:04:55 +0200 Subject: [PATCH 32/36] fix/ env vars electron (#266) * chore: add .env to `build` * release: rc101 * chore: load env vars * release: rc 102 * release: rc 103 * release: rc 104 * release: rc 105 --- .github/workflows/release.yml | 7 +++++-- build.js | 4 ++++ electron/install.js | 12 +++++++++++- package.json | 2 +- pyproject.toml | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 78dc854d7..7187504d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,7 +85,7 @@ jobs: - run: yarn install-deps - name: "Build frontend with env vars" run: yarn build:frontend - env: + env: NODE_ENV: production DEV_RPC: https://rpc-gate.autonolas.tech/gnosis-rpc/ IS_STAGING: ${{ github.ref != 'refs/heads/main' && 'true' || 'false' }} @@ -121,4 +121,7 @@ jobs: NODE_ENV: development DEV_RPC: https://virtual.gnosis.rpc.tenderly.co/78ca845d-2b24-44a6-9ce2-869a979e8b5b FORK_URL: https://virtual.gnosis.rpc.tenderly.co/78ca845d-2b24-44a6-9ce2-869a979e8b5b - run: node build.js \ No newline at end of file + run: | + echo "DEV_RPC=https://virtual.gnosis.rpc.tenderly.co/78ca845d-2b24-44a6-9ce2-869a979e8b5b" >> .env + echo -e "FORK_URL=https://virtual.gnosis.rpc.tenderly.co/78ca845d-2b24-44a6-9ce2-869a979e8b5b" >> .env + node build.js \ No newline at end of file diff --git a/build.js b/build.js index ed96764e0..fa1e1b0db 100644 --- a/build.js +++ b/build.js @@ -36,6 +36,10 @@ const main = async () => { to: 'bins', filter: ['**/*'], }, + { + from: '.env', + to: '.env' + }, ], cscKeyPassword: process.env.CSC_KEY_PASSWORD, cscLink: process.env.CSC_LINK, diff --git a/electron/install.js b/electron/install.js index 73f17892c..372c7b368 100644 --- a/electron/install.js +++ b/electron/install.js @@ -14,7 +14,17 @@ const { paths } = require('./constants'); * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc97'; +const OlasMiddlewareVersion = '0.1.0rc105'; + +const path = require('path'); +const { app } = require('electron'); + +// load env vars +require('dotenv').config({ + path: app.isPackaged + ? path.join(process.resourcesPath, '.env') + : path.resolve(process.cwd(), '.env'), +}); const Env = { ...process.env, diff --git a/package.json b/package.json index 66ccdaace..3dd422bfe 100644 --- a/package.json +++ b/package.json @@ -57,5 +57,5 @@ "test:frontend": "cd frontend && yarn test", "download-binaries": "sh download_binaries.sh" }, - "version": "0.1.0-rc97" + "version": "0.1.0-rc105" } diff --git a/pyproject.toml b/pyproject.toml index 8a4765170..8ed25abe0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc97" +version = "0.1.0-rc105" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From 4c1e58e93b06f21d15ae521f5c704487e5f718d7 Mon Sep 17 00:00:00 2001 From: Atatakai Date: Mon, 12 Aug 2024 12:56:44 +0400 Subject: [PATCH 33/36] chore: update agent needs funds alert --- frontend/components/Main/MainNeedsFunds.tsx | 55 ++++++++++++--------- frontend/styles/globals.scss | 6 ++- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/frontend/components/Main/MainNeedsFunds.tsx b/frontend/components/Main/MainNeedsFunds.tsx index f275136bf..71464a615 100644 --- a/frontend/components/Main/MainNeedsFunds.tsx +++ b/frontend/components/Main/MainNeedsFunds.tsx @@ -1,6 +1,7 @@ import { Flex, Typography } from 'antd'; import { formatUnits } from 'ethers/lib/utils'; import { ReactNode, useEffect, useMemo } from 'react'; +import styled from 'styled-components'; import { UNICODE_SYMBOLS } from '@/constants/symbols'; import { useBalance } from '@/hooks/useBalance'; @@ -12,9 +13,16 @@ import { getMinimumStakedAmountRequired } from '@/utils/service'; import { Alert } from '../Alert'; import { CardSection } from '../styled/CardSection'; -const { Text, Paragraph } = Typography; +const { Text } = Typography; const COVER_PREV_BLOCK_BORDER_STYLE = { marginTop: '-1px' }; +const FundingValue = styled.div` + font-size: 24px; + font-weight: 700; + line-height: 32px; + letter-spacing: -0.72px; +`; + const useNeedsFunds = () => { const { getServiceTemplates } = useServiceTemplates(); @@ -94,29 +102,28 @@ export const MainNeedsFunds = () => { const message: ReactNode = useMemo( () => ( - - Your agent needs funds - - USE THE ACCOUNT CREDENTIALS PROVIDED IN THE “ADD FUNDS” INSTRUCTIONS - BELOW. - - - To run your agent, you must add these amounts to your account: - - {!hasEnoughOlasForInitialFunding && ( - - {`${UNICODE_SYMBOLS.OLAS}${serviceFundRequirements.olas} OLAS `} - - for staking. - - )} - {!hasEnoughEthForInitialFunding && ( - - - {`${serviceFundRequirements.eth} XDAI `} - - - for trading balance. - - )} + + Your agent needs funds + + {!hasEnoughOlasForInitialFunding && ( +
+ {`${UNICODE_SYMBOLS.OLAS}${serviceFundRequirements.olas} OLAS `} + for staking +
+ )} + {!hasEnoughEthForInitialFunding && ( +
+ + {`$${serviceFundRequirements.eth} XDAI `} + + for trading +
+ )} +
+
    +
  • Do not add more than these amounts.
  • +
  • Use the address in the “Add Funds” section below.
  • +
), [ diff --git a/frontend/styles/globals.scss b/frontend/styles/globals.scss index 13afcf16c..6999610fb 100644 --- a/frontend/styles/globals.scss +++ b/frontend/styles/globals.scss @@ -66,7 +66,7 @@ button, input, select, textarea, .ant-input-suffix { &--primary { border-color: #ECD7FE; background-color: #F8F0FF; - color: #36075F; + color: #7E22CE; .ant-alert-icon { color: #7E22CE; @@ -136,6 +136,10 @@ button, input, select, textarea, .ant-input-suffix { margin-top: 12px !important; } +.p-0 { + padding: 0 !important; +} + .mx-auto { margin-left: auto !important; margin-right: auto !important; From 3f354d06127c35c967daf80318ddf143c5e98abf Mon Sep 17 00:00:00 2001 From: SarthakDev12 Date: Mon, 12 Aug 2024 15:11:20 +0530 Subject: [PATCH 34/36] Script for building middleware binary locally (#250) * add script for building middleware binaries locally * add valory header --- build_pearl.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 +++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 build_pearl.sh diff --git a/build_pearl.sh b/build_pearl.sh new file mode 100755 index 000000000..65e5d4ac9 --- /dev/null +++ b/build_pearl.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# +# Copyright 2023-2024 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +cd "$(dirname "$0")" + +BIN_DIR="electron/bins/" +mkdir -p $BIN_DIR + +poetry install + +poetry run pyinstaller operate/services/utils/tendermint.py --onefile --distpath $BIN_DIR + +poetry run pyinstaller \ + --collect-data eth_account \ + --collect-all aea \ + --collect-all autonomy \ + --collect-all operate \ + --collect-all aea_ledger_ethereum \ + --collect-all aea_ledger_cosmos \ + --collect-all aea_ledger_ethereum_flashbots \ + --hidden-import aea_ledger_ethereum \ + --hidden-import aea_ledger_cosmos \ + --hidden-import aea_ledger_ethereum_flashbots \ + operate/pearl.py \ + --add-binary ${BIN_DIR}/aea_bin_x64:. \ + --add-binary ${BIN_DIR}/aea_bin_arm64:. \ + --onefile \ + --distpath $BIN_DIR \ + --name pearl_$(uname -m) + diff --git a/package.json b/package.json index 3dd422bfe..4fb27af76 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,9 @@ "dev": "dotenv -e .env -- yarn start", "start:frontend": "cd frontend && yarn start", "test:frontend": "cd frontend && yarn test", - "download-binaries": "sh download_binaries.sh" + "download-binaries": "sh download_binaries.sh", + "build:pearl": "sh build_pearl.sh" + }, "version": "0.1.0-rc105" } From 7fea6a9352aad9a11d1a5ad5d6c0b93975b7b3e6 Mon Sep 17 00:00:00 2001 From: Ardian <30511811+0xArdi@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:45:15 +0200 Subject: [PATCH 35/36] Fix/intel build (#270) * fix: intel build * release: rc107 --- .github/workflows/release.yml | 22 +++++++++++++++------- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- templates/trader.yaml | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7187504d4..044325707 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,10 +11,10 @@ on: jobs: build-macos-pyinstaller: - runs-on: macos-latest + runs-on: ${{ matrix.os }} strategy: matrix: - arch: [ x64, arm64 ] + os: [ macos-14, macos-14-large ] steps: - uses: actions/checkout@v3 @@ -34,22 +34,30 @@ jobs: - name: Install dependencies run: poetry install + - name: Set arch environment variable for macos-latest-large + if: contains(matrix.os, 'large') + run: echo "OS_ARCH=x64" >> $GITHUB_ENV + + - name: Set arch environment variable for other macOS versions + if: ${{ !contains(matrix.os, 'large') }} + run: echo "OS_ARCH=arm64" >> $GITHUB_ENV + - name: Get trader bin run: | - trader_version=$(poetry run python -c "import yaml; config = yaml.safe_load(open('templates/trader.yaml')); print(config['configuration']['trader_version'])") + trader_version=$(poetry run python -c "import yaml; config = yaml.safe_load(open('templates/trader.yaml')); print(config['trader_version'])") echo $trader_version - mkdir dist && curl -L -o dist/aea_bin "https://github.com/valory-xyz/trader/releases/download/${trader_version}/trader_bin_${{ matrix.arch }}" + mkdir dist && curl -L -o dist/aea_bin "https://github.com/valory-xyz/trader/releases/download/${trader_version}/trader_bin_${{ env.OS_ARCH }}" - name: Build with PyInstaller run: | poetry run pyinstaller operate/services/utils/tendermint.py --onefile - poetry run pyinstaller --collect-data eth_account --collect-all aea --collect-all autonomy --collect-all operate --collect-all aea_ledger_ethereum --collect-all aea_ledger_cosmos --collect-all aea_ledger_ethereum_flashbots --hidden-import aea_ledger_ethereum --hidden-import aea_ledger_cosmos --hidden-import aea_ledger_ethereum_flashbots operate/pearl.py --add-binary dist/aea_bin:. --add-binary dist/tendermint:. --onefile --name pearl_${{ matrix.arch }} + poetry run pyinstaller --collect-data eth_account --collect-all aea --collect-all autonomy --collect-all operate --collect-all aea_ledger_ethereum --collect-all aea_ledger_cosmos --collect-all aea_ledger_ethereum_flashbots --hidden-import aea_ledger_ethereum --hidden-import aea_ledger_cosmos --hidden-import aea_ledger_ethereum_flashbots operate/pearl.py --add-binary dist/aea_bin:. --add-binary dist/tendermint:. --onefile --name pearl_${{ env.OS_ARCH }} - name: Upload Release Assets uses: actions/upload-artifact@v2 with: - name: pearl_${{ matrix.arch }} - path: dist/pearl_${{ matrix.arch }} + name: pearl_${{ env.OS_ARCH }} + path: dist/pearl_${{ env.OS_ARCH }} release-operate: runs-on: macos-latest diff --git a/electron/install.js b/electron/install.js index 372c7b368..f2dcd865f 100644 --- a/electron/install.js +++ b/electron/install.js @@ -14,7 +14,7 @@ const { paths } = require('./constants'); * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc105'; +const OlasMiddlewareVersion = '0.1.0rc107'; const path = require('path'); const { app } = require('electron'); diff --git a/package.json b/package.json index 4fb27af76..b921e49cc 100644 --- a/package.json +++ b/package.json @@ -59,5 +59,5 @@ "build:pearl": "sh build_pearl.sh" }, - "version": "0.1.0-rc105" + "version": "0.1.0-rc107" } diff --git a/pyproject.toml b/pyproject.toml index 8ed25abe0..478a65f63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc105" +version = "0.1.0-rc107" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" diff --git a/templates/trader.yaml b/templates/trader.yaml index f59a98e11..63a87f47c 100644 --- a/templates/trader.yaml +++ b/templates/trader.yaml @@ -2,8 +2,8 @@ name: "Trader Agent" description: "A single-agent service (sovereign agent) placing bets on Omen" hash: bafybeidgjgjj5ul6xkubicbemppufgsbx5sr5rwhtrwttk2oivp5bkdnce image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75 +trader_version: v0.18.1 configuration: - trader_version: v0.16.4 nft: bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq rpc: http://localhost:8545 # User provided agent_id: 14 From 50b07e1370b4bc9d116dc6aae3118577a895a5ce Mon Sep 17 00:00:00 2001 From: Atatakai Date: Mon, 12 Aug 2024 19:50:23 +0400 Subject: [PATCH 36/36] chore: hide low gas alert if is not initial funded --- frontend/components/Main/MainGasBalance.tsx | 4 ++++ frontend/components/Main/MainOlasBalance.tsx | 2 ++ 2 files changed, 6 insertions(+) diff --git a/frontend/components/Main/MainGasBalance.tsx b/frontend/components/Main/MainGasBalance.tsx index f9eb5de6a..0d1f83f26 100644 --- a/frontend/components/Main/MainGasBalance.tsx +++ b/frontend/components/Main/MainGasBalance.tsx @@ -7,6 +7,7 @@ import { COLOR } from '@/constants/colors'; import { LOW_BALANCE } from '@/constants/thresholds'; import { useBalance } from '@/hooks/useBalance'; import { useElectronApi } from '@/hooks/useElectronApi'; +import { useStore } from '@/hooks/useStore'; import { useWallet } from '@/hooks/useWallet'; import { CardSection } from '../styled/CardSection'; @@ -34,6 +35,7 @@ const FineDot = styled(Dot)` const BalanceStatus = () => { const { isBalanceLoaded, safeBalance } = useBalance(); + const { storeState } = useStore(); const { showNotification } = useElectronApi(); const [isLowBalanceNotificationShown, setIsLowBalanceNotificationShown] = @@ -44,6 +46,7 @@ const BalanceStatus = () => { if (!isBalanceLoaded) return; if (!safeBalance) return; if (!showNotification) return; + if (!storeState?.isInitialFunded) return; if (safeBalance.ETH < LOW_BALANCE && !isLowBalanceNotificationShown) { showNotification('Trading balance is too low.'); @@ -60,6 +63,7 @@ const BalanceStatus = () => { isLowBalanceNotificationShown, safeBalance, showNotification, + storeState?.isInitialFunded, ]); const status = useMemo(() => { diff --git a/frontend/components/Main/MainOlasBalance.tsx b/frontend/components/Main/MainOlasBalance.tsx index 28e0170a4..fa6d87b9b 100644 --- a/frontend/components/Main/MainOlasBalance.tsx +++ b/frontend/components/Main/MainOlasBalance.tsx @@ -123,9 +123,11 @@ const MainOlasBalanceAlert = styled.div` const LowTradingBalanceAlert = () => { const { isBalanceLoaded, safeBalance } = useBalance(); + const { storeState } = useStore(); if (!isBalanceLoaded) return null; if (!safeBalance) return null; + if (!storeState?.isInitialFunded) return; if (safeBalance.ETH >= LOW_BALANCE) return null; return (