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

Contract migration updates & fixes #285

Merged
merged 99 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 98 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
3c24735
chore: revisit staking flow
jmoreira-valory Jul 17, 2024
e294ad0
chore: updates
jmoreira-valory Jul 17, 2024
4184f20
[no ci] chore: update
jmoreira-valory Jul 19, 2024
3623c03
Merge branch 'main' into fix/onchain_update_flow
jmoreira-valory Jul 26, 2024
e3cb6c0
chore: bump framework
jmoreira-valory Jul 26, 2024
e096a81
chore: fix
jmoreira-valory Jul 26, 2024
6bcd92f
[no ci] chore: update
jmoreira-valory Jul 26, 2024
403aa58
chore: refactor
jmoreira-valory Aug 2, 2024
e481d7a
Merge branch 'main' into fix/onchain_update_flow
jmoreira-valory Aug 2, 2024
0a3da8f
Merge remote-tracking branch 'origin/main' into fix/onchain_update_flow
jmoreira-valory Aug 12, 2024
ca92d60
feat: Add IncentiveProgramStatus enum and update PageState enum
truemiller Aug 12, 2024
c4884ab
chore: update
jmoreira-valory Aug 13, 2024
f78a343
chore: update
jmoreira-valory Aug 13, 2024
11b8dac
chore: can unstake method
jmoreira-valory Aug 13, 2024
410bea2
chore: updates
jmoreira-valory Aug 13, 2024
b4d90a1
feat: Update enum names in PageState.ts and usePageState.ts
truemiller Aug 14, 2024
72c42d5
chore: update service file
jmoreira-valory Aug 14, 2024
e0386fd
feat: add the staking flow
0xArdi Aug 14, 2024
b5162ef
chore: templates
jmoreira-valory Aug 14, 2024
c95d9f8
feat: add support for updates from safe
0xArdi Aug 14, 2024
dfeb6b8
fix: staking flow
jmoreira-valory Aug 14, 2024
06de4ad
Merge branch 'feat/staking-flow' into feat/update-from-safe
jmoreira-valory Aug 14, 2024
1320092
fix: contract
jmoreira-valory Aug 14, 2024
e68221c
fix: signature packaging
0xArdi Aug 14, 2024
39677ed
Merge pull request #280 from valory-xyz/feat/update-from-safe
jmoreira-valory Aug 14, 2024
b3eb5fa
Merge pull request #279 from valory-xyz/feat/staking-flow
jmoreira-valory Aug 14, 2024
52dfe3f
chore: update
jmoreira-valory Aug 14, 2024
d44e262
fix: reuse_multisig
jmoreira-valory Aug 14, 2024
c2afc2e
chore: remove comment
jmoreira-valory Aug 14, 2024
a01ad6d
feat: style contracts
Aug 14, 2024
bf4d196
fix: fund service
jmoreira-valory Aug 14, 2024
cf1fdd7
fix: funding_job
jmoreira-valory Aug 14, 2024
352b07d
feat: update showing contract details ling logic
Aug 14, 2024
647da57
[no ci] chore: minor fixes
jmoreira-valory Aug 14, 2024
e5c7d48
fix: staking flow
jmoreira-valory Aug 14, 2024
c46c86f
feat: add first time deploy
0xArdi Aug 14, 2024
5f1bfd9
fix: allow single message
0xArdi Aug 14, 2024
4f40673
chore: minor fixes
jmoreira-valory Aug 14, 2024
71d3d48
chore: update
jmoreira-valory Aug 14, 2024
515b7c2
chore: update
jmoreira-valory Aug 14, 2024
3b2ea44
chore: update
jmoreira-valory Aug 15, 2024
33f9938
Merge remote-tracking branch 'origin/fix/onchain_update_flow' into fe…
truemiller Aug 15, 2024
d294867
refactor: remove minimumFunding property from GNOSIS chain constant
truemiller Aug 15, 2024
02cd87f
update types
truemiller Aug 15, 2024
52e6346
refactor: gnosis chain id and variable rename
truemiller Aug 15, 2024
9a26d8d
feat: update olas_required_to_stake in service templates
truemiller Aug 15, 2024
2428802
refactor: service template reference refactors
truemiller Aug 15, 2024
316269a
refactor: staking program alert notification section
truemiller Aug 15, 2024
9df9871
chore: delete unused
truemiller Aug 15, 2024
feda974
feat: new staking program alert section
truemiller Aug 15, 2024
8e1a9c4
feat: add staking programs enums and records
truemiller Aug 15, 2024
305526d
refactor: remove and rename irrelevant mocking
truemiller Aug 15, 2024
8174bc7
refactor: logging for electron store and IPC stuff
truemiller Aug 16, 2024
bea9061
fix: electron-store issue
Aug 16, 2024
6cafa98
chore: add minStakingDeposit for n+1 calculation
truemiller Aug 16, 2024
300d18e
refactor: multi staking program refactor to Autonolas service
truemiller Aug 16, 2024
623c660
refactor: plural addresses rename
truemiller Aug 16, 2024
6049239
feat: show new staking program alert conditionally
truemiller Aug 16, 2024
207c7ce
refactor: replace mocked contracts data
truemiller Aug 16, 2024
8bfbf49
refactor: progress on staking contract sections, replacing mocked data
truemiller Aug 16, 2024
50d688b
refactor: use stakingContractMeta in staking contract sections
truemiller Aug 16, 2024
a4020b6
feat: add staking contract meta for hardcode textual data
truemiller Aug 16, 2024
e8132a6
refactor: multicontract support for rewards
truemiller Aug 16, 2024
175c321
feat: extend staking contract info provider with current staking prog…
truemiller Aug 16, 2024
5bdb80f
feat: add context for staking program data; current, default, and upd…
truemiller Aug 16, 2024
154aa72
feat: hook for staking program context
truemiller Aug 16, 2024
04c4f02
feat: staking program provider in _app
truemiller Aug 16, 2024
e23dc35
Merge branch 'feat/contract-migration-ui' of github.com:valory-xyz/ol…
truemiller Aug 16, 2024
65d1dc7
feat: staking program hooks and context
truemiller Aug 16, 2024
99365e8
refactor: main page conditions and modals
truemiller Aug 16, 2024
5de93a4
refactor: staking contract section
truemiller Aug 16, 2024
e9946e8
---
truemiller Aug 16, 2024
d096c6c
refactor: reward provider
truemiller Aug 16, 2024
64a3184
refactor: update chain data types
truemiller Aug 16, 2024
ba68ea0
refactor: fix agent button constants
truemiller Aug 16, 2024
4c9fefa
fix: local deployment
0xArdi Aug 16, 2024
de443c3
refactor: remove migrating button, reset create service null coalesce
truemiller Aug 16, 2024
8fe5fa3
refactor: improve staking program retrieval and error handling
truemiller Aug 16, 2024
d9b29b3
refactor: remove unused code in StakingContractSection
truemiller Aug 16, 2024
e56fa4e
bump: 112
truemiller Aug 16, 2024
9d70c41
fix: release.yml service_version
truemiller Aug 16, 2024
9f2ed5b
refactor: update chain data types
truemiller Aug 16, 2024
e66deda
fix: dynamic olas requirement dependant on staking program
truemiller Aug 16, 2024
8680d1b
fix: migration requirement
truemiller Aug 16, 2024
43b603c
refactor: update minimum OLAS balance requirement for migration
truemiller Aug 16, 2024
3dfebf5
refactor: force rewards availability check to true
truemiller Aug 16, 2024
5a27881
fix: default rewards availiability to true
truemiller Aug 16, 2024
59474d1
fix: trader hash
0xArdi Aug 20, 2024
6824e6f
Merge remote-tracking branch 'origin/feat/contract-migration-ui' into…
jmoreira-valory Aug 20, 2024
4ce058e
chore: isort
jmoreira-valory Aug 20, 2024
8a8e675
fix: update user params
jmoreira-valory Aug 20, 2024
138c553
chore: whitespace
jmoreira-valory Aug 20, 2024
0f9f5dc
bump: rc114
truemiller Aug 20, 2024
daf0f62
Merge remote-tracking branch 'origin/staging' into contract-migration…
truemiller Aug 20, 2024
2e368cb
fix: conflict resolution, electron-store 8.2 pin
truemiller Aug 20, 2024
5b237b9
fix: balance provider type merge conflict resolution
truemiller Aug 20, 2024
bb4104a
fix: custom alert import
truemiller Aug 20, 2024
717714b
fix: gitleaks ignore 2 keys
truemiller Aug 21, 2024
c54ab4b
fix: update trader hash
0xArdi Aug 21, 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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Get trader bin
run: |
trader_version=$(poetry run python -c "import yaml; config = yaml.safe_load(open('templates/trader.yaml')); print(config['trader_version'])")
trader_version=$(poetry run python -c "import yaml; config = yaml.safe_load(open('templates/trader.yaml')); print(config['service_version'])")
echo $trader_version
mkdir dist && curl -L -o dist/aea_bin "https://github.com/valory-xyz/trader/releases/download/${trader_version}/trader_bin_${{ env.OS_ARCH }}"
Expand Down
4 changes: 3 additions & 1 deletion .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ d8149e9b5b7bd6a7ed7bc1039900702f1d4f287b:operate/services/manage.py:generic-api-
99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:406
99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:454
99c0f139b037da2587708212fcf6d0e20786d0ba:operate/services/manage.py:generic-api-key:455
91ec07457f69e9a29f63693ac8ef887e4b5f49f0:operate/services/manage.py:generic-api-key:454
91ec07457f69e9a29f63693ac8ef887e4b5f49f0:operate/services/manage.py:generic-api-key:454
410bea2bd02ff54da69387fe8f3b58793e09f7b0:operate/services/manage.py:generic-api-key:421
410bea2bd02ff54da69387fe8f3b58793e09f7b0:operate/services/manage.py:generic-api-key:422
2 changes: 1 addition & 1 deletion electron/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.0rc111';
const OlasMiddlewareVersion = '0.1.0rc115';

const path = require('path');
const { app } = require('electron');
Expand Down
28 changes: 15 additions & 13 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const HEIGHT = 700;
/**
* Creates the main window
*/
const createMainWindow = () => {
const createMainWindow = async () => {
const width = isDev ? 840 : APP_WIDTH;
mainWindow = new BrowserWindow({
title: 'Pearl',
Expand All @@ -216,12 +216,6 @@ const createMainWindow = () => {

mainWindow.setMenuBarVisibility(true);

if (isDev) {
mainWindow.loadURL(`http://localhost:${appConfig.ports.dev.next}`);
} else {
mainWindow.loadURL(`http://localhost:${appConfig.ports.prod.next}`);
}

ipcMain.on('close-app', () => {
mainWindow.close();
});
Expand Down Expand Up @@ -264,15 +258,23 @@ const createMainWindow = () => {
event.preventDefault();
mainWindow.hide();
});

const storeInitialValues = {
environmentName: process.env.IS_STAGING ? 'staging' : '',
};
setupStoreIpc(ipcMain, mainWindow, storeInitialValues);

try {
logger.electron('Setting up store IPC');
await setupStoreIpc(ipcMain, mainWindow);
} catch (e) {
logger.electron('Store IPC failed:', JSON.stringify(e));
}

if (isDev) {
mainWindow.webContents.openDevTools();
}

if (isDev) {
mainWindow.loadURL(`http://localhost:${appConfig.ports.dev.next}`);
} else {
mainWindow.loadURL(`http://localhost:${appConfig.ports.prod.next}`);
}
};

async function launchDaemon() {
Expand Down Expand Up @@ -494,7 +496,7 @@ ipcMain.on('check', async function (event, _argument) {
}

event.sender.send('response', 'Launching App');
createMainWindow();
await createMainWindow();
createTray();
splashWindow.destroy();
} catch (e) {
Expand Down
38 changes: 18 additions & 20 deletions electron/store.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
const Store = require('electron-store');
// set schema to validate store data
const defaultSchema = {
environmentName: { type: 'string', default: '' },
isInitialFunded: { type: 'boolean', default: false },
const schema = {
isInitialFunded: { type: 'boolean', default: false }, // TODO: reconsider this default, can be problematic if user has already funded prior to implementation
firstStakingRewardAchieved: { type: 'boolean', default: false },
firstRewardNotificationShown: { type: 'boolean', default: false },
agentEvictionAlertShown: { type: 'boolean', default: false },
};

const setupStoreIpc = async (ipcChannel, mainWindow, storeInitialValues) => {
const Store = (await import('electron-store')).default;

// set default values for store
const schema = Object.assign({}, defaultSchema);
Object.keys(schema).forEach((key) => {
if (storeInitialValues[key] !== undefined) {
schema[key].default = storeInitialValues[key];
}
});
environmentName: { type: 'string', default: '' },
currentStakingProgram: { type: 'string', default: '' },
};

/** @type import Store from 'electron-store' */
/**
* Sets up the IPC communication and initializes the Electron store with default values and schema.
* @param {Electron.IpcMain} ipcMain - The IPC channel for communication.
* @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 store = new Store({ schema });

store.onDidAnyChange((data) => {
Expand All @@ -27,11 +25,11 @@ const setupStoreIpc = async (ipcChannel, mainWindow, storeInitialValues) => {
});

// exposed to electron browser window
ipcChannel.handle('store', () => store.store);
ipcChannel.handle('store-get', (_, key) => store.get(key));
ipcChannel.handle('store-set', (_, key, value) => store.set(key, value));
ipcChannel.handle('store-delete', (_, key) => store.delete(key));
ipcChannel.handle('store-clear', (_) => store.clear());
ipcMain.handle('store', () => store.store);
ipcMain.handle('store-get', (_, key) => store.get(key));
ipcMain.handle('store-set', (_, key, value) => store.set(key, value));
ipcMain.handle('store-delete', (_, key) => store.delete(key));
ipcMain.handle('store-clear', (_) => store.clear());
};

module.exports = { setupStoreIpc };
32 changes: 25 additions & 7 deletions frontend/client/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { StakingProgram } from '@/enums/StakingProgram';
import { Address } from '@/types/Address';

import { Chain, DeploymentStatus, Ledger } from './enums';
Expand All @@ -20,36 +21,53 @@ export type ChainData = {
instances?: Address[];
token?: number;
multisig?: Address;
on_chain_state: number;
staked: boolean;
user_params: {
cost_of_bond: number;
fund_requirements: {
agent: number;
safe: number;
};
nft: string;
staking_program_id: StakingProgram;
threshold: number;
use_staking: true;
};
};

export type Service = {
name: string;
hash: string;
keys: ServiceKeys[];
readme?: string;
ledger: LedgerConfig;
chain_data: ChainData;
chain_configs: {
[chainId: number]: {
ledger_config: LedgerConfig;
chain_data: ChainData;
};
};
};

export type ServiceTemplate = {
name: string;
hash: string;
image: string;
description: string;
configuration: ConfigurationTemplate;
service_version: string;
home_chain_id: string;
configurations: { [key: string]: ConfigurationTemplate };
deploy?: boolean;
};

export type ConfigurationTemplate = {
rpc?: string; // added on deployment
staking_program_id?: StakingProgram; // added on deployment
nft: string;
trader_version: string;
rpc?: string; // added by user
agent_id: number;
threshold: number;
use_staking: boolean;
cost_of_bond: number;
olas_cost_of_bond: number;
olas_required_to_stake: number;
monthly_gas_estimate: number;
fund_requirements: FundRequirementsTemplate;
};
Expand Down
5 changes: 5 additions & 0 deletions frontend/components/Alert/AlertTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Typography } from 'antd';

export const AlertTitle = ({ children }: { children: React.ReactNode }) => (
<Typography.Text className="font-weight-600">{children}</Typography.Text>
);
2 changes: 1 addition & 1 deletion frontend/components/Alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const icons = {
error: <ExclamationCircleOutlined />,
};

export const Alert = ({
export const CustomAlert = ({
type,
fullWidth,
...rest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useCallback, useEffect, useState } from 'react';

import { UNICODE_SYMBOLS } from '@/constants/symbols';
import { FAQ_URL, SUPPORT_URL } from '@/constants/urls';
import { PageState } from '@/enums/PageState';
import { Pages } from '@/enums/PageState';
import { useElectronApi } from '@/hooks/useElectronApi';
import { useLogs } from '@/hooks/useLogs';
import { usePageState } from '@/hooks/usePageState';
Expand Down Expand Up @@ -78,7 +78,7 @@ export const HelpAndSupport = () => {
<Button
size="large"
icon={<CloseOutlined />}
onClick={() => goto(PageState.Main)}
onClick={() => goto(Pages.Main)}
/>
}
>
Expand Down
20 changes: 0 additions & 20 deletions frontend/components/Main/MainHeader/constants.ts

This file was deleted.

58 changes: 58 additions & 0 deletions frontend/components/MainPage/MainHeader/FirstRunModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Button, Flex, Modal, Typography } from 'antd';
import Image from 'next/image';
import { FC } from 'react';

import { useServiceTemplates } from '@/hooks/useServiceTemplates';
import { getMinimumStakedAmountRequired } from '@/utils/service';

type FirstRunModalProps = { open: boolean; onClose: () => void };

export const FirstRunModal: FC<FirstRunModalProps> = ({ open, onClose }) => {
const { getServiceTemplates } = useServiceTemplates();

if (!open) return null;

const minimumStakedAmountRequired = getMinimumStakedAmountRequired(
getServiceTemplates()[0],
);

return (
<Modal
open={open}
width={412}
onCancel={onClose}
footer={[
<Button
key="ok"
type="primary"
block
size="large"
className="mt-8"
onClick={onClose}
>
Got it
</Button>,
]}
>
<Flex align="center" justify="center">
<Image
src="/splash-robot-head.png"
width={100}
height={100}
alt="OLAS logo"
/>
</Flex>
<Typography.Title level={5} className="mt-12 text-center">
{`Your agent is running and you've staked ${minimumStakedAmountRequired} OLAS!`}
</Typography.Title>
<Typography.Paragraph>
Your agent is working towards earning rewards.
</Typography.Paragraph>
<Typography.Paragraph>
Pearl is designed to make it easy for you to earn staking rewards every
day. Simply leave the app and agent running in the background for ~1hr a
day.
</Typography.Paragraph>
</Modal>
);
};
Loading
Loading