Skip to content

Commit

Permalink
feat: merge staging
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Sep 27, 2024
2 parents 8380f49 + a471109 commit 4e4bb39
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 51 deletions.
40 changes: 18 additions & 22 deletions electron/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ const process = require('process');
const axios = require('axios');
const { spawnSync } = require('child_process');
const { logger } = require('./logger');
const { execSync} = require('child_process');
const { execSync } = require('child_process');
const { paths } = require('./constants');
const homedir = os.homedir();
/**
* current version of the pearl release
* - 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.0rc143';
const OlasMiddlewareVersion = '0.1.0rc145';

const path = require('path');
const { app } = require('electron');
Expand Down Expand Up @@ -55,18 +55,16 @@ const TendermintUrls = {
},
};


function execSyncExitCode(cmd) {
try {
execSync(cmd);
return 0;
}
catch (error) {
logger.electron(error.status); // Might be 127 in your example.
} catch (error) {
logger.electron(error.status); // Might be 127 in your example.
logger.electron(error.message); // Holds the message you typically want.
logger.electron(error.stderr.toString()); // Holds the stderr output. Use `.toString()`.
logger.electron(error.stdout.toString()); // Holds the stdout output. Use `.toString()`.
return error.status;
logger.electron(error.stderr.toString()); // Holds the stderr output. Use `.toString()`.
logger.electron(error.stdout.toString()); // Holds the stdout output. Use `.toString()`.
return error.status;
}
}

Expand Down Expand Up @@ -94,7 +92,6 @@ function runCmdUnix(command, options) {
logger.electron(`===== stderr ===== \n${output.stderr}`);
}


function runSudoUnix(command, options) {
let bin = getBinPath(command);
if (!bin) {
Expand Down Expand Up @@ -132,7 +129,7 @@ function isTendermintInstalledUnix() {
function isTendermintInstalledWindows() {
return true;
//always installed cause bundled in
return execSyncExitCode('tendermint --help') === 0;
return execSyncExitCode('tendermint --help') === 0;
}

async function downloadFile(url, dest) {
Expand Down Expand Up @@ -171,24 +168,23 @@ async function installTendermintWindows() {
logger.electron(`Installing tendermint binary`);
try {
execSync('tar -xvf tendermint.tar.gz');
} catch (error){
logger.electron(error.status); // Might be 127 in your example.
} catch (error) {
logger.electron(error.status); // Might be 127 in your example.
logger.electron(error.message); // Holds the message you typically want.
logger.electron(error.stderr.toString()); // Holds the stderr output. Use `.toString()`.
logger.electron(error.stdout.toString()); // Holds the stdout output. Use `.toString()`.
logger.electron(error.stderr.toString()); // Holds the stderr output. Use `.toString()`.
logger.electron(error.stdout.toString()); // Holds the stdout output. Use `.toString()`.
}

const bin_dir = homedir + "//AppData//Local//Microsoft//WindowsApps//"
const bin_dir = homedir + '//AppData//Local//Microsoft//WindowsApps//';
if (!Env.CI) {
if (!fs.existsSync(bin_dir)) {
fs.mkdirSync(bin_dir, {recursive: true});
fs.mkdirSync(bin_dir, { recursive: true });
}
fs.copyFileSync("tendermint.exe", bin_dir + "tendermint.exe");
fs.copyFileSync('tendermint.exe', bin_dir + 'tendermint.exe');
}
process.chdir(cwd);
}


async function installTendermintUnix() {
logger.electron(`Installing tendermint for ${os.platform()}-${process.arch}`);
const cwd = process.cwd();
Expand Down Expand Up @@ -259,14 +255,14 @@ async function setupUbuntu(ipcChannel) {
}
}



async function setupWindows(ipcChannel) {
logger.electron('Creating required directories');
await createDirectory(`${paths.dotOperateDirectory}`);
await createDirectory(`${paths.tempDir}`);

logger.electron('Checking tendermint installation: ' + isTendermintInstalledWindows());
logger.electron(
'Checking tendermint installation: ' + isTendermintInstalledWindows(),
);
if (!isTendermintInstalledWindows()) {
ipcChannel.send('response', 'Installing tendermint');
logger.electron('Installing tendermint');
Expand Down
15 changes: 13 additions & 2 deletions frontend/components/YourWalletPage/Titles.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { Flex, Typography } from 'antd';

import { InfoTooltip } from '@/components/InfoTooltip';
import { Address } from '@/types/Address';

import { AddressLink } from '../AddressLink';

const { Paragraph, Text, Title } = Typography;

export const SignerTitle = () => (
type SignerTitleProps = { signerText: string; signerAddress?: Address };

export const SignerTitle = ({
signerText,
signerAddress,
}: SignerTitleProps) => (
<>
Signer&nbsp;
<InfoTooltip>
Expand All @@ -17,7 +25,10 @@ export const SignerTitle = () => (
This setup enables features like the backup wallet.
</Paragraph>
<Paragraph className="text-sm m-0">
Note: Signer’s XDAI balance is included in wallet XDAI balances.
<Flex gap={4} vertical>
<Text className="text-sm">{signerText}</Text>
<AddressLink address={signerAddress} />
</Flex>
</Paragraph>
</InfoTooltip>
</>
Expand Down
45 changes: 29 additions & 16 deletions frontend/components/YourWalletPage/YourAgent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Card, Flex, Typography } from 'antd';
import { Card, Flex, Skeleton, Typography } from 'antd';
import Image from 'next/image';
import { useMemo } from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -78,30 +78,39 @@ const ServiceAndNftDetails = () => {
};

export const YourAgentWallet = () => {
const { agentSafeBalance, agentEoaBalance } = useBalance();
const { accruedServiceStakingRewards } = useReward();
const { isBalanceLoaded, agentSafeBalance, agentEoaBalance } = useBalance();
const {
availableRewardsForEpochEth,
isEligibleForRewards,
accruedServiceStakingRewards,
} = useReward();
const {
instanceAddress: agentEoaAddress,
multisigAddress: agentSafeAddress,
} = useAddress();

const reward = useMemo(() => {
if (!isBalanceLoaded) return <Skeleton.Input size="small" active />;
if (!isEligibleForRewards) return 'Not yet earned';
return `~${balanceFormat(availableRewardsForEpochEth, 2)} OLAS`;
}, [isBalanceLoaded, isEligibleForRewards, availableRewardsForEpochEth]);

const olasBalances = useMemo(() => {
return [
{
title: 'Claimed rewards',
value: balanceFormat(agentSafeBalance?.OLAS ?? 0, 2),
value: `${balanceFormat(agentSafeBalance?.OLAS, 2)} OLAS`,
},
{
title: 'Unclaimed rewards',
value: balanceFormat(accruedServiceStakingRewards ?? 0, 2),
value: `${balanceFormat(accruedServiceStakingRewards, 2)} OLAS`,
},
{
title: 'Current epoch rewards',
value: reward,
},
];
}, [agentSafeBalance?.OLAS, accruedServiceStakingRewards]);

const agentXdaiBalance = useMemo(
() => (agentSafeBalance?.ETH ?? 0) + (agentEoaBalance?.ETH ?? 0),
[agentSafeBalance?.ETH, agentEoaBalance?.ETH],
);
}, [agentSafeBalance?.OLAS, accruedServiceStakingRewards, reward]);

return (
<Card>
Expand All @@ -128,7 +137,7 @@ export const YourAgentWallet = () => {
list={olasBalances.map((item) => ({
left: item.title,
leftClassName: 'text-light text-sm',
right: `${item.value} OLAS`,
right: item.value,
}))}
parentStyle={infoBreakdownParentStyle}
/>
Expand All @@ -140,7 +149,7 @@ export const YourAgentWallet = () => {
{
left: <XdaiTitle />,
leftClassName: 'text-light text-sm',
right: `${balanceFormat(agentXdaiBalance, 2)} XDAI`,
right: `${balanceFormat(agentSafeBalance?.ETH, 2)} XDAI`,
},
]}
parentStyle={infoBreakdownParentStyle}
Expand All @@ -151,10 +160,14 @@ export const YourAgentWallet = () => {
<InfoBreakdownList
list={[
{
left: <SignerTitle />,
left: (
<SignerTitle
signerText="Agent’s wallet signer address:"
signerAddress={agentEoaAddress}
/>
),
leftClassName: 'text-light text-sm',
right: <AddressLink address={agentEoaAddress} />,
rightClassName: 'font-normal',
right: `${balanceFormat(agentEoaBalance?.ETH, 2)} XDAI`,
},
]}
parentStyle={infoBreakdownParentStyle}
Expand Down
19 changes: 10 additions & 9 deletions frontend/components/YourWalletPage/YourWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ const OlasBalance = () => {
};

const XdaiBalance = () => {
const { safeBalance, eoaBalance } = useBalance();
const totalXdaiBalance = useMemo(
() => (safeBalance?.ETH ?? 0) + (eoaBalance?.ETH ?? 0),
[safeBalance?.ETH, eoaBalance?.ETH],
);
const { safeBalance } = useBalance();

return (
<Flex vertical gap={8}>
Expand All @@ -97,7 +93,7 @@ const XdaiBalance = () => {
{
left: <Text strong>XDAI</Text>,
leftClassName: 'text-light',
right: `${balanceFormat(totalXdaiBalance, 2)} XDAI`,
right: `${balanceFormat(safeBalance?.ETH, 2)} XDAI`,
},
]}
parentStyle={infoBreakdownParentStyle}
Expand All @@ -108,16 +104,21 @@ const XdaiBalance = () => {

const Signer = () => {
const { masterEoaAddress } = useWallet();
const { eoaBalance } = useBalance();

return (
<Flex vertical gap={8}>
<InfoBreakdownList
list={[
{
left: <SignerTitle />,
left: (
<SignerTitle
signerText="Your wallet signer address:"
signerAddress={masterEoaAddress}
/>
),
leftClassName: 'text-light',
right: <AddressLink address={masterEoaAddress} />,
rightClassName: 'font-normal',
right: `${balanceFormat(eoaBalance?.ETH, 2)} XDAI`,
},
]}
parentStyle={infoBreakdownParentStyle}
Expand Down
5 changes: 5 additions & 0 deletions frontend/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ button, input, select, textarea, .ant-input-suffix {
color: #4D596A !important;
}

// font color
.text-light {
color: #4D596A !important;
}

.pointer {
cursor: pointer;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
"download-binaries": "sh download_binaries.sh",
"build:pearl": "sh build_pearl.sh"
},
"version": "0.1.0-rc143"
"version": "0.1.0-rc145"
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "olas-operate-middleware"
version = "0.1.0-rc143"
version = "0.1.0-rc145"
description = ""
authors = ["David Vilela <[email protected]>", "Viraj Patel <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 4e4bb39

Please sign in to comment.