Skip to content

Commit

Permalink
add pool icon
Browse files Browse the repository at this point in the history
  • Loading branch information
SorinC6 committed Apr 17, 2024
1 parent 583ebf5 commit 700179b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
7 changes: 1 addition & 6 deletions package.json
Expand Up @@ -8,12 +8,7 @@
"translations:purge": "lerna run translations:purge -- stream",
"archive:src": "func() { git rev-parse HEAD > COMMIT && git rev-parse --abbrev-ref HEAD > BRANCH && git archive --format zip --add-file COMMIT --add-file BRANCH -o $1 HEAD && rm COMMIT BRANCH; }; func"
},
"husky": {
"hooks": {
"pre-push": ". check-all.sh",
"post-checkout": "npm run translations:purge"
}
},

"devDependencies": {
"concurrently": "^7.0.0",
"husky": "4.3.8",
Expand Down
5 changes: 3 additions & 2 deletions packages/yoroi-extension/app/containers/wallet/Wallet.js
Expand Up @@ -130,7 +130,7 @@ class Wallet extends Component<AllProps> {
if (publicDeriver == null) {
throw new Error(`${nameof(Wallet)} no public deriver. Should never happen`);
}

const currentPool = this.props.stores.delegation.getDelegatedPoolId(publicDeriver);
const poolTransition = stores.delegation.checkPoolTransition(publicDeriver);
const isFirstSync = stores.wallets.firstSyncWalletId === selectedWallet.getPublicDeriverId();
const spendableBalance = this.props.stores.transactions.balance;
Expand All @@ -149,7 +149,7 @@ class Wallet extends Component<AllProps> {
}))}
onItemClick={route => actions.router.goToRoute.trigger({ route })}
isActiveItem={route => this.props.stores.app.currentRoute.startsWith(route)}
locationId='wallet'
locationId="wallet"
/>
);

Expand Down Expand Up @@ -225,6 +225,7 @@ class Wallet extends Component<AllProps> {
this.props.stores.delegation.setPoolTransitionConfig({ show: 'idle' });
}}
poolTransition={poolTransition}
currentPoolId={currentPool ?? ''}
onUpdatePool={() => {
this.props.stores.delegation.setPoolTransitionConfig({
show: 'idle',
Expand Down
Expand Up @@ -27,13 +27,15 @@ type Props = {|
onClose: () => void,
poolTransition?: PoolTransition | null,
onUpdatePool: () => void,
currentPoolId?: string,
intl: $npm$ReactIntl$IntlFormat,
|};

export const PoolTransitionDialog = ({
onClose,
poolTransition,
onUpdatePool,
currentPoolId,
intl,
}: Props): React$Node => {
const { currentPool, suggestedPool } = poolTransition || {};
Expand All @@ -55,6 +57,7 @@ export const PoolTransitionDialog = ({
roa={currentPool?.roa}
fee={currentPool?.share}
deadlineMilliseconds={poolTransition?.deadlineMilliseconds}
poolHash={currentPoolId}
intl={intl}
/>
<Typography variant="body1" fontWeight="500">
Expand All @@ -65,6 +68,7 @@ export const PoolTransitionDialog = ({
poolName={suggestedPool?.name}
roa={suggestedPool?.roa}
fee={suggestedPool?.share}
poolHash={suggestedPool?.id}
suggestedPool
intl={intl}
/>
Expand Down
Expand Up @@ -7,6 +7,7 @@ import { ReactComponent as WarningSvg } from '../../../../assets/images/revamp/i
import { ReactComponent as EmurgoSvg } from '../../../../assets/images/emurgo-logo-small.svg';
import type { $npm$ReactIntl$IntlFormat } from 'react-intl';
import { messages } from './dialog-messages';
import { toSvg } from 'jdenticon';

type Props = {|
label: string,
Expand All @@ -15,6 +16,7 @@ type Props = {|
fee?: string,
deadlineMilliseconds?: number,
suggestedPool?: boolean,
poolHash?: string,
intl: $npm$ReactIntl$IntlFormat,
|};

Expand All @@ -26,14 +28,21 @@ export const StakePoolCard = ({
deadlineMilliseconds,
suggestedPool = false,
intl,
poolHash,
}: Props): React$Node => {
const avatarSource = toSvg(poolHash, 36, { padding: 0 });
const avatarGenerated = `data:image/svg+xml;utf8,${encodeURIComponent(avatarSource)}`;
return (
<CustomCard suggestedPool={suggestedPool}>
<Typography variant="body1" fontWeight={500} mb={2}>
{label}
</Typography>
<Stack direction="row" gap={1}>
<EmurgoSvg />
<Box
sx={{ width: '24px', height: '24px', borderRadius: '50%', display: 'inline-block' }}
component="img"
src={avatarGenerated}
/>
<Typography variant="body1" fontWeight={400}>
{poolName}
</Typography>
Expand Down
Expand Up @@ -14,7 +14,6 @@ import type { ActionsMap } from '../../actions/index';
import type { StoresMap } from '../index';
import type { PoolInfo } from '@emurgo/yoroi-lib';
import { MultiToken } from '../../api/common/lib/MultiToken';
import { PoolTransitionDialog } from '../../containers/wallet/dialogs/pool-transition/PoolTransitionDialog';
import { maybe } from '../../coreUtils';
import type {
GetDelegatedBalanceFunc,
Expand Down

0 comments on commit 700179b

Please sign in to comment.