Skip to content

Commit

Permalink
[DDW-1131] Enable providing stake pool registry cardano-wallet argume…
Browse files Browse the repository at this point in the history
…nt (#1771)

* [DDW-1131] Enable providing stake pool registry cardano-wallet argument

* [DDW-1131] Cardano wallet launcher improvement to accept CARDANO_WALLET_STAKE_POOL_REGISTRY_URL

* [DDW-1131] Improve flow types

* [DDW-1131] Adds CHANGELOG

* [DDW-1131] Stake Pool Tooltip homepage address styles improvement and CARDANO_WALLET_STAKE_POOL_REGISTRY_URL deadalus branch address

* [DDW-1131] Remove unnecessary comments

* [DDW-1131] Add Nightly registry URL

* [DDW-1131] Adds registry URL for QA network

* [DDW-1131] Fix Stake pool URL wrapping
  • Loading branch information
Tomislav Horaček authored and nikolaglumac committed Dec 13, 2019
1 parent 27f30f8 commit 2faf6f9
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog

### Features

- Added stake pool metadata registry for "SelfNode" network ([PR 1771](https://github.com/input-output-hk/daedalus/pull/1771/))
- Added list stake pools API endpoint errors handlers ([PR 1765](https://github.com/input-output-hk/daedalus/pull/1765))
- Added "Terms of use" for the Incentivized Testnet v1 - Rewards network ([PR 1741](https://github.com/input-output-hk/daedalus/pull/1741))
- Updated stake pool ranking logic to use `apparent_performance` from the Api response ([PR 1757](https://github.com/input-output-hk/daedalus/pull/1757))
Expand Down
33 changes: 28 additions & 5 deletions source/main/cardano/CardanoWalletLauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { spawn } from 'child_process';
import { dirname } from 'path';
import type { ChildProcess } from 'child_process';
import { configureJormungandrDeps } from './nodes';
import { STAKE_POOL_REGISTRY_URL } from '../config';
import { environment } from '../environment';
import { NIGHTLY, SELFNODE, QA } from '../../common/types/environment.types';

export type WalletOpts = {
path: string,
Expand All @@ -26,6 +29,15 @@ export async function CardanoWalletLauncher(
path,
walletArgs,
} = walletOpts;
const walletStdio: string[] = ['pipe', 'pipe', 'pipe', 'ipc'];
const nodePath = dirname(nodeBin);
const PATH: string = (process.env.PATH: any);
const envVariables: {
PATH: string,
CARDANO_WALLET_STAKE_POOL_REGISTRY_URL?: string,
} = {
PATH: `${nodePath}:${PATH}`,
};

// This switch statement handles any node specifc
// configuration, prior to spawning the child process
Expand All @@ -37,21 +49,32 @@ export async function CardanoWalletLauncher(
// The selfnode is identified by the unique genesis-block wallet arg
if (walletArgs.findIndex(arg => arg === '--genesis-block') > -1) {
await configureJormungandrDeps(cliBin, stateDir);
Object.assign(envVariables, {
CARDANO_WALLET_STAKE_POOL_REGISTRY_URL:
STAKE_POOL_REGISTRY_URL[SELFNODE],
});
}
if (environment.isIncentivizedTestnetNightly) {
Object.assign(envVariables, {
CARDANO_WALLET_STAKE_POOL_REGISTRY_URL:
STAKE_POOL_REGISTRY_URL[NIGHTLY],
});
}
if (environment.isIncentivizedTestnetQA) {
Object.assign(envVariables, {
CARDANO_WALLET_STAKE_POOL_REGISTRY_URL: STAKE_POOL_REGISTRY_URL[QA],
});
}
break;
default:
break;
}

const walletStdio: string[] = ['pipe', 'pipe', 'pipe', 'ipc'];
const nodePath = dirname(nodeBin);
const PATH: string = (process.env.PATH: any);

const childProcess = spawn(path, walletArgs, {
stdio: walletStdio,
env: {
...process.env,
PATH: `${nodePath}:${PATH}`,
...envVariables,
},
});

Expand Down
10 changes: 10 additions & 0 deletions source/main/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,13 @@ export const DISK_SPACE_CHECK_LONG_INTERVAL = 10 * 60 * 1000; // 10 minutes | un
export const DISK_SPACE_CHECK_MEDIUM_INTERVAL = 60 * 1000; // 1 minute | unit: milliseconds
export const DISK_SPACE_CHECK_SHORT_INTERVAL = isTest ? 2000 : 10 * 1000; // 10 seconds | unit: milliseconds
export const DISK_SPACE_RECOMMENDED_PERCENTAGE = 15; // 15% of the total disk space

// CardanoWallet config
export const STAKE_POOL_REGISTRY_URL = {
selfnode:
'https://github.com/input-output-hk/daedalus/raw/selfnode/test-integration-registry.zip',
nightly:
'https://github.com/piotr-iohk/incentivized-testnet-stakepool-registry/archive/master.zip',
qa:
'https://explorer.qa.jormungandr-testnet.iohkdev.io/stakepool-registry/registry.zip',
};
22 changes: 11 additions & 11 deletions source/renderer/app/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1110,13 +1110,11 @@ export default class AdaApi {
Logger.debug('AdaApi::getStakePools called');
try {
const stakePools: AdaApiStakePools = await getStakePools(this.config);

Logger.debug('AdaApi::getStakePools success');
return (
stakePools
// @API TODO: Filter Stake Pools without metadata, once metadata is present in the API response
// .filter(({ metadata }: AdaApiStakePool) => metadata !== undefined)
.map(_createStakePoolFromServerData)
);
return stakePools
.filter(({ metadata }: AdaApiStakePool) => metadata !== undefined)
.map(_createStakePoolFromServerData);
} catch (error) {
Logger.error('AdaApi::getStakePools error', { error });
throw new GenericApiError();
Expand Down Expand Up @@ -1458,15 +1456,17 @@ const _createStakePoolFromServerData = action(
'AdaApi::_createStakePoolFromServerData',
(stakePool: AdaApiStakePool, index: number) => {
// DATA FROM THE API
const { id, metrics, apparent_performance: performance } = stakePool;
const {
id,
metrics,
apparent_performance: performance,
metadata,
} = stakePool;
let {
controlled_stake: controlledStake,
produced_blocks: producedBlocks,
} = metrics; // eslint-disable-line
const {
// MISSING DATA FROM THE API
// IT IS CONTAINED IN THE DOCS:
metadata,
// MISSING DATA FROM THE API
// NOT CONTAINED IN THE CURRENT API DOCS:
// _cost: cost,
Expand All @@ -1479,7 +1479,7 @@ const _createStakePoolFromServerData = action(
} = stakingStakePoolsMissingApiData[index];
const {
name,
description,
description = '',
ticker,
homepage,
pledge_address: pledgeAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,17 @@ export default class StakePoolTooltip extends Component<Props, State> {
</div>
)}
<div className={styles.description}>{description}</div>
<button
className={styles.homepage}

<span
role="presentation"
aria-hidden
className={styles.homepageAddress}
onClick={() => onOpenExternalLink(homepage)}
>
<span className={styles.homepageContent}>{homepage}</span>
{homepage}
<SVGInline svg={externalLinkIcon} />
</button>
</span>

<dl className={styles.table}>
<dt>{intl.formatMessage(messages.ranking)}</dt>
<dd className={styles.ranking}>
Expand Down Expand Up @@ -516,12 +520,12 @@ export default class StakePoolTooltip extends Component<Props, State> {
*/}
</dl>
<button
className={styles.homepage}
className={styles.pledgeAddress}
onClick={() =>
onOpenExternalLink(getPledgeAddressUrl(pledgeAddress))
}
>
<span className={styles.homepageContent}>
<span className={styles.pledgeAddressContent}>
{intl.formatMessage(messages.pledgeAddressLabel)}
</span>
<SVGInline svg={externalLinkIcon} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,22 @@
text-overflow: ellipsis;
}

.homepage {
.homepageAddress {
@include link(--theme-link-main-color);
border-bottom-color: var(--theme-link-main-color);
font-size: 14px;
line-height: 1.36;
word-break: break-all;
}

.pledgeAddress {
@include link(--theme-link-main-color);
font-size: 14px;
line-height: 1.36;
margin-bottom: 14px;
max-width: 100%;

.homepageContent {
.pledgeAddressContent {
display: inline-block;
max-width: calc(100% - 14px);
overflow: hidden;
Expand All @@ -219,7 +227,7 @@
@extend %regularText;
display: flex;
flex-wrap: wrap;
margin-bottom: 6px;
margin: 18px 0 6px 0;

dt,
dd {
Expand Down

0 comments on commit 2faf6f9

Please sign in to comment.