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: staging to main #253

Merged
merged 49 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
5eff7ee
feat: Update NotifyRewards component name
mohandast52 Jul 23, 2024
34d0eb6
feat: Add agent eviction alert to MainOlasBalance component
mohandast52 Jul 23, 2024
8b59c2a
feat: Refactor AvoidSuspensionAlert in MainOlasBalance component
mohandast52 Jul 23, 2024
ee0db5a
add download binaries script
SarthakDev12 Jul 23, 2024
694ff4e
chore: Update LOW_BALANCE threshold to 3
mohandast52 Jul 24, 2024
7638b6b
feat: Add low trading balance alert to MainOlasBalance component
mohandast52 Jul 24, 2024
802d3c5
fix: Update MainGasBalance component to display 'Too low' status for …
mohandast52 Jul 24, 2024
a9386a4
Update MainGasBalance component to display 'Too low' status for empty…
mohandast52 Jul 24, 2024
9be7b1f
make requested changes
SarthakDev12 Jul 24, 2024
8550c0d
chore: Update MainHeader component to prevent starting agent with low…
mohandast52 Jul 24, 2024
b5e27b0
feat: Show low balance notification in MainGasBalance component
mohandast52 Jul 24, 2024
82e229b
chore: Remove unused isSafeBalanceBelowThreshold property from Balanc…
mohandast52 Jul 24, 2024
d5a884a
fix: remove invalid services
0xArdi Jul 23, 2024
29bf7d6
release: rc86
0xArdi Jul 24, 2024
8232ff5
chore: lint
0xArdi Jul 25, 2024
f3ce66f
Merge pull request #245 from valory-xyz/fix/rm-invalid-services
0xArdi Jul 25, 2024
3ae15ad
fix unstyled text visible after splash screen
SarthakDev12 Jul 25, 2024
66b0943
add both variant x64 and arm64 in script
SarthakDev12 Jul 25, 2024
fecab48
Fix linting
SarthakDev12 Jul 25, 2024
3b95c45
feat: Add low trading balance alert to MainOlasBalance component
mohandast52 Jul 25, 2024
1ff6766
feat: update comment
mohandast52 Jul 25, 2024
28bee44
Merge pull request #242 from valory-xyz/mohan/educate-eviction
mohandast52 Jul 25, 2024
4ffddcc
make recommended changes
SarthakDev12 Jul 26, 2024
f60616c
Merge pull request #243 from valory-xyz/feat/add_binaries
SarthakDev12 Jul 26, 2024
083856d
chore: conflict fixes
mohandast52 Jul 26, 2024
e20b014
Merge pull request #247 from valory-xyz/bug/unstyled_text_fix
truemiller Jul 26, 2024
5135af9
chore: conflict fixes
mohandast52 Jul 29, 2024
480cfe7
release: rc95
0xArdi Jul 31, 2024
98e55a6
Merge pull request #255 from valory-xyz/release/rc95
0xArdi Jul 31, 2024
ab41eed
feat: add dev build
0xArdi Aug 1, 2024
21d38f9
release: rc97
0xArdi Aug 1, 2024
dec9eb8
chore: Update AgentButton to open support URL in Discord
mohandast52 Aug 1, 2024
d63263b
feat: Add external link symbol to 'Seek help in Discord' button
mohandast52 Aug 1, 2024
0557ae3
chore: conflict fixes
mohandast52 Aug 2, 2024
057846b
chore: Update tray icons for logged-out status
mohandast52 Aug 2, 2024
1c8e6f6
feat: update icon for BUILT deployment status
mohandast52 Aug 2, 2024
bcd9e6f
chore: move AgentHead to it's own file from index.tsx
mohandast52 Aug 2, 2024
38a2476
chore: add 'CannotStartAgentDueToUnexpectedError' component
mohandast52 Aug 2, 2024
39703ab
Merge pull request #244 from valory-xyz/mohan/low-balance-prompt
oaksprout Aug 2, 2024
63378c1
Merge pull request #256 from valory-xyz/mohan/us-removal
mohandast52 Aug 2, 2024
ccac072
Update build.js
mohandast52 Aug 5, 2024
39679a3
Merge pull request #259 from valory-xyz/feat/dev-build
mohandast52 Aug 5, 2024
deddd89
fix/ env vars electron (#266)
0xArdi Aug 9, 2024
4c1e58e
chore: update agent needs funds alert
Aug 12, 2024
3f354d0
Script for building middleware binary locally (#250)
SarthakDev12 Aug 12, 2024
7fea6a9
Fix/intel build (#270)
0xArdi Aug 12, 2024
50b07e1
chore: hide low gas alert if is not initial funded
Aug 12, 2024
7d5bfef
Merge branch 'main' into staging
0xArdi Aug 13, 2024
d917f72
Merge pull request #269 from valory-xyz/tanya/20-olas-alert
Tanya-atatakai Aug 13, 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
26 changes: 24 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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' }}
Expand All @@ -110,4 +110,26 @@ 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
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: |
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
16 changes: 15 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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...');

Expand All @@ -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: {
Expand All @@ -26,6 +36,10 @@ const main = async () => {
to: 'bins',
filter: ['**/*'],
},
{
from: '.env',
to: '.env'
},
],
cscKeyPassword: process.env.CSC_KEY_PASSWORD,
cscLink: process.env.CSC_LINK,
Expand Down
47 changes: 47 additions & 0 deletions build_pearl.sh
Original file line number Diff line number Diff line change
@@ -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)

10 changes: 10 additions & 0 deletions download_binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

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_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"
12 changes: 11 additions & 1 deletion electron/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.0rc110';
const OlasMiddlewareVersion = '0.1.0rc111';

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,
Expand Down
14 changes: 11 additions & 3 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,33 @@ 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);

break;
}
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;
Expand Down
1 change: 1 addition & 0 deletions electron/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
45 changes: 35 additions & 10 deletions frontend/components/Main/MainGasBalance.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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 { useStore } from '@/hooks/useStore';
import { useWallet } from '@/hooks/useWallet';

import { CardSection } from '../styled/CardSection';
Expand All @@ -30,20 +32,43 @@ 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 { isBalanceLoaded, safeBalance } = useBalance();
const { storeState } = useStore();
const { showNotification } = useElectronApi();

const status = useMemo(() => {
if (!safeBalance || safeBalance.ETH === 0) {
return { statusName: 'Empty', StatusComponent: EmptyDot };
const [isLowBalanceNotificationShown, setIsLowBalanceNotificationShown] =
useState(false);

// show notification if balance is too low
useEffect(() => {
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.');
setIsLowBalanceNotificationShown(true);
}

if (safeBalance.ETH < LOW_BALANCE) {
return { statusName: 'Low', StatusComponent: LowDot };
// 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);
}
}, [
isBalanceLoaded,
isLowBalanceNotificationShown,
safeBalance,
showNotification,
storeState?.isInitialFunded,
]);

const status = useMemo(() => {
if (!safeBalance || safeBalance.ETH < LOW_BALANCE) {
return { statusName: 'Too low', StatusComponent: EmptyDot };
}

return { statusName: 'Fine', StatusComponent: FineDot };
Expand Down
22 changes: 16 additions & 6 deletions frontend/components/Main/MainHeader/AgentButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useCallback, useMemo } from 'react';

import { Chain, DeploymentStatus } from '@/client';
import { COLOR } from '@/constants/colors';
import { LOW_BALANCE } from '@/constants/thresholds';
import { useBalance } from '@/hooks/useBalance';
import { useElectronApi } from '@/hooks/useElectronApi';
import { useServices } from '@/hooks/useServices';
Expand All @@ -15,7 +16,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;
Expand Down Expand Up @@ -185,6 +189,15 @@ const AgentNotRunningButton = () => {
]);

const isDeployable = useMemo(() => {
// if the agent is NOT running and the balance is too low,
// user should not be able to start the agent
const isServiceInactive =
serviceStatus === DeploymentStatus.BUILT ||
serviceStatus === DeploymentStatus.STOPPED;
if (isServiceInactive && safeBalance && safeBalance.ETH < LOW_BALANCE) {
return false;
}

if (serviceStatus === DeploymentStatus.DEPLOYED) return false;
if (serviceStatus === DeploymentStatus.DEPLOYING) return false;
if (serviceStatus === DeploymentStatus.STOPPING) return false;
Expand All @@ -211,6 +224,7 @@ const AgentNotRunningButton = () => {
serviceStatus,
storeState?.isInitialFunded,
totalEthBalance,
safeBalance,
]);

const buttonProps: ButtonProps = {
Expand Down Expand Up @@ -258,11 +272,7 @@ export const AgentButton = () => {
return <AgentNotRunningButton />;
}

return (
<Button type="primary" size="large" disabled>
Error, contact us!
</Button>
);
return <CannotStartAgentDueToUnexpectedError />;
}, [
hasInitialLoaded,
serviceStatus,
Expand Down
31 changes: 26 additions & 5 deletions frontend/components/Main/MainHeader/CannotStartAgent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,32 @@ const cannotStartAgentText = (
</Text>
);

const otherPopoverProps: PopoverProps = {
arrow: false,
placement: 'bottomRight',
};

export const CannotStartAgentDueToUnexpectedError = () => (
<Popover
{...otherPopoverProps}
title="Unexpected error"
content={
<div style={{ maxWidth: 340 }}>
<Paragraph>
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.
</Paragraph>

<a href={SUPPORT_URL} target="_blank" rel="noreferrer">
Olas community Discord server {UNICODE_SYMBOLS.EXTERNAL_LINK}
</a>
</div>
}
>
{cannotStartAgentText}
</Popover>
);

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 = () => (
Expand All @@ -27,11 +53,6 @@ const AgentEvictedPopover = () => (
</Popover>
);

const otherPopoverProps: PopoverProps = {
arrow: false,
placement: 'bottomRight',
};

const JoinOlasCommunity = () => (
<div style={{ maxWidth: 340 }}>
<Paragraph>
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/Main/MainHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
Loading
Loading