Skip to content

Commit

Permalink
Asset selection hotfix (#256)
Browse files Browse the repository at this point in the history
* refine asset selector

* dark mode tweaks
  • Loading branch information
qrtp authored Jan 15, 2025
1 parent a2b5faf commit 564cbba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const useStyles = makeStyles()((theme: Theme) => ({
'& > svg': {
width: AVATAR_RESULT_SIZE,
height: AVATAR_RESULT_SIZE,
fill: theme.palette.getContrastText(theme.palette.success.main),
fill: theme.palette.common.white,
padding: theme.spacing(3),
},
},
Expand Down
15 changes: 3 additions & 12 deletions packages/ui-components/src/components/Wallet/SendConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import {makeStyles} from '@unstoppabledomains/ui-kit/styles';

import type {TokenEntry} from '../../lib';
import { useTranslationContext} from '../../lib';
import {useTranslationContext} from '../../lib';
import type {AccountAsset} from '../../lib/types/fireBlocks';
import {
getBlockchainDisplaySymbol,
Expand All @@ -36,21 +36,12 @@ const useStyles = makeStyles()((theme: Theme) => ({
width: '100%',
gap: '7px',
marginBottom: theme.spacing(5),
backgroundColor: theme.palette.primaryShades[100],
color: theme.palette.getContrastText(theme.palette.secondary.light),
backgroundColor: theme.palette.secondary.light,
padding: 12,
borderRadius: 8,
height: '100%',
},
icon: {
fontSize: '60px',
},
subTitlePending: {
marginTop: theme.spacing(1),
color: theme.palette.neutralShades[400],
},
subTitleComplete: {
marginTop: theme.spacing(1),
},
}));

const MAX_DISPLAY_LENGTH = 12;
Expand Down
21 changes: 21 additions & 0 deletions packages/ui-components/src/lib/wallet/asset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,27 @@ describe('selecting asset', () => {
expect(asset?.blockchainAsset.blockchain.id).toBe('POLYGON');
});

it('should select Polygon asset by native token asset', () => {
const asset = getAsset(mockAssets, {
token: {
address: 'mockTokenAddress',
type: TokenType.Native,
symbol: 'MATIC',
name: 'Polygon',
ticker: 'MATIC',
value: 1,
tokenConversionUsd: 1,
balance: 1,
walletAddress: '0x8ee1E1d88EBE2B44eAD162777DE787Ef6A2dC2F2',
walletBlockChainLink: 'mockBlockchainLink',
walletName: 'Polygon',
},
address: '0x8ee1E1d88EBE2B44eAD162777DE787Ef6A2dC2F2',
});
expect(asset).toBeDefined();
expect(asset?.blockchainAsset.blockchain.id).toBe('POLYGON');
});

it('should not return an asset for invalid chain ID', () => {
const asset = getAsset(mockAssets, {
chainId: 9999999999,
Expand Down
8 changes: 3 additions & 5 deletions packages/ui-components/src/lib/wallet/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const getAsset = (
const isToken =
opts.token.type === TokenType.Erc20 ||
opts.token.type === TokenType.Spl;
const tokenAsset =
return (
opts.token.walletName.toLowerCase() ===
a.blockchainAsset.blockchain.name.toLowerCase() &&
[
Expand All @@ -46,10 +46,8 @@ export const getAsset = (
? opts.token.symbol.toLowerCase()
: opts.token.ticker.toLowerCase(),
) &&
a.address.toLowerCase() === opts.token.walletAddress.toLowerCase();
if (tokenAsset) {
return tokenAsset;
}
a.address.toLowerCase() === opts.token.walletAddress.toLowerCase()
);
}

// find by address on default signing assets
Expand Down

0 comments on commit 564cbba

Please sign in to comment.