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

feat: display proper image for src20 tokens #6013

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"@leather.io/bitcoin": "0.17.0",
"@leather.io/constants": "0.13.5",
"@leather.io/crypto": "1.6.14",
"@leather.io/models": "0.24.0",
"@leather.io/models": "0.24.3",
"@leather.io/query": "2.26.10",
"@leather.io/stacks": "1.4.0",
"@leather.io/tokens": "0.12.1",
Expand Down Expand Up @@ -360,6 +360,7 @@
"ts-node": "10.9.2",
"ts-unused-exports": "10.0.1",
"tsconfig-paths-webpack-plugin": "4.1.0",
"type-fest": "4.30.2",
"typescript": "5.4.5",
"vitest": "2.0.5",
"vm-browserify": "1.1.2",
Expand All @@ -370,8 +371,7 @@
"webpack-cli": "5.1.4",
"webpack-dev-server": "4.15.1",
"webpack-hot-middleware": "2.26.1",
"webpack-shell-plugin": "0.5.0",
"type-fest": "4.30.2"
"webpack-shell-plugin": "0.5.0"
},
"resolutions": {
"cross-spawn": "7.0.5",
Expand Down
260 changes: 220 additions & 40 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactNode } from 'react';

import { HeadsetIcon } from '@leather.io/ui';

import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout';
import { CollectibleItemLayout, CollectibleItemLayoutProps } from './collectible-item.layout';
import { CollectiblePlaceholderLayout } from './collectible-placeholder.layout';

interface CollectibleAudioProps extends Omit<CollectibleItemLayoutProps, 'children'> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ReactNode, useState } from 'react';

import { Iframe } from '@app/ui/components/iframe';

import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout';
import { ImageUnavailable } from '../image-unavailable';
import { CollectibleItemLayout, CollectibleItemLayoutProps } from './collectible-item.layout';
import { ImageUnavailable } from './image-unavailable';

interface CollectibleIframeProps extends Omit<CollectibleItemLayoutProps, 'children'> {
icon: ReactNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactNode, useState } from 'react';

import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout';
import { ImageUnavailable } from '../image-unavailable';
import { CollectibleItemLayout, CollectibleItemLayoutProps } from './collectible-item.layout';
import { ImageUnavailable } from './image-unavailable';

interface CollectibleImageProps extends Omit<CollectibleItemLayoutProps, 'children'> {
alt?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from 'leather-styles/jsx';

import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout';
import { CollectibleItemLayout, CollectibleItemLayoutProps } from './collectible-item.layout';

interface CollectibleOtherProps extends Omit<CollectibleItemLayoutProps, 'children'> {
children: React.JSX.Element;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout';
import { CollectibleItemLayout, CollectibleItemLayoutProps } from './collectible-item.layout';
import { CollectibleTextLayout } from './collectible-text.layout';

interface CollectibleTextProps extends Omit<CollectibleItemLayoutProps, 'children'> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { styled } from 'leather-styles/jsx';

import { Eye1ClosedIcon } from '@leather.io/ui';

import { CollectiblePlaceholderLayout } from './_collectible-types/collectible-placeholder.layout';
import { CollectiblePlaceholderLayout } from './collectible-placeholder.layout';

export function ImageUnavailable() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Src20AvatarIcon } from '@leather.io/ui';
import { getAssetDisplayName } from '@leather.io/utils';

import { useManageTokens } from '@app/common/hooks/use-manage-tokens';
import { CollectibleImage } from '@app/components/collectibles/collectible-image';
import { CryptoAssetItem } from '@app/components/crypto-asset-item/crypto-asset-item';
import type { Src20TokenAssetDetails } from '@app/components/loaders/src20-tokens-loader';
import { useIsPrivateMode } from '@app/store/settings/settings.selectors';
Expand Down Expand Up @@ -34,7 +35,17 @@ export function Src20TokenAssetList({
return tokens.map((token, i) => {
const key = `${token.info.id}${i}`;
const captionLeft = getAssetDisplayName(token.info).toUpperCase();
const icon = <Src20AvatarIcon />;
const icon = token.info.deploy_img ? (
<CollectibleImage
alt={token.info.symbol}
icon={<Src20AvatarIcon size="lg" />}
src={token.info.deploy_img}
title={`# ${token.info.id}`}
subtitle={`# ${token.info.symbol}`}
/>
) : (
<Src20AvatarIcon />
);
const titleLeft = token.info.symbol.toUpperCase();
const symbol = token.info.symbol;

Expand Down
2 changes: 1 addition & 1 deletion src/app/features/collectibles/collectibles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { CurrentBitcoinSignerLoader } from '@app/components/loaders/current-bitc
import { CurrentStacksAccountLoader } from '@app/components/loaders/stacks-account-loader';
import { useConfigNftMetadataEnabled } from '@app/query/common/remote-config/remote-config.query';

import { CollectiblesLayout } from '../../components/collectibles/collectible.layout';
import { AddCollectible } from './components/add-collectible';
import { Ordinals } from './components/bitcoin/ordinals';
import { Stamps } from './components/bitcoin/stamps';
import { CollectiblesLayout } from './components/collectible.layout';
import { StacksCryptoAssets } from './components/stacks/stacks-crypto-assets';
import { TaprootBalanceDisplayer } from './components/taproot-balance-displayer';
import { useIsFetchingCollectiblesRelatedQuery } from './hooks/use-is-fetching-collectibles';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PlusIcon } from '@leather.io/ui';
import { RouteUrls } from '@shared/route-urls';
import { analytics } from '@shared/utils/analytics';

import { CollectibleItemLayout } from './collectible-item.layout';
import { CollectibleItemLayout } from '../../../components/collectibles/collectible-item.layout';

export function AddCollectible() {
const navigate = useNavigate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OrdinalAvatarIcon } from '@leather.io/ui';

import { parseJson } from '@app/components/json';

import { CollectibleText } from '../_collectible-types/collectible-text';
import { CollectibleText } from '../../../../components/collectibles/collectible-text';

interface InscriptionTextProps {
contentSrc: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import { useHoverWithChildren } from '@app/common/hooks/use-hover-with-children'
import { openInNewTab } from '@app/common/utils/open-in-new-tab';
import { useDiscardedInscriptions } from '@app/store/settings/settings.selectors';

import { CollectibleAudio } from '../_collectible-types/collectible-audio';
import { CollectibleIframe } from '../_collectible-types/collectible-iframe';
import { CollectibleImage } from '../_collectible-types/collectible-image';
import { CollectibleOther } from '../_collectible-types/collectible-other';
import { CollectibleAudio } from '../../../../components/collectibles/collectible-audio';
import { CollectibleIframe } from '../../../../components/collectibles/collectible-iframe';
import { CollectibleImage } from '../../../../components/collectibles/collectible-image';
import { CollectibleOther } from '../../../../components/collectibles/collectible-other';
import { HighSatValueUtxoWarning } from './high-sat-value-utxo';
import { InscriptionText } from './inscription-text';

Expand Down
2 changes: 1 addition & 1 deletion src/app/features/collectibles/components/bitcoin/stamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Stamp as BitcoinStamp } from '@leather.io/query';
import { openInNewTab } from '@app/common/utils/open-in-new-tab';
import { StampsAvatarIcon } from '@app/ui/components/avatar/stamps-avatar-icon';

import { CollectibleImage } from '../_collectible-types/collectible-image';
import { CollectibleImage } from '../../../../components/collectibles/collectible-image';

const stampChainAssetUrl = 'https://stampchain.io/asset.html?stampNumber=';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import StacksNftBns from '@assets/images/stacks-nft-bns.png';

import { StxAvatarIcon } from '@leather.io/ui';

import { CollectibleItemLayout } from '../collectible-item.layout';
import { CollectibleItemLayout } from '../../../../components/collectibles/collectible-item.layout';

export function StacksBnsName(props: { bnsName: string }) {
const { bnsName } = props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { StxAvatarIcon } from '@leather.io/ui';

import { isValidUrl } from '@shared/utils/validate-url';

import { CollectibleImage } from '../_collectible-types/collectible-image';
import { ImageUnavailable } from '../image-unavailable';
import { CollectibleImage } from '../../../../components/collectibles/collectible-image';
import { ImageUnavailable } from '../../../../components/collectibles/image-unavailable';

interface StacksNonFungibleTokensProps {
metadata: StacksNftMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const SwitchAccountSheet = memo(({ isShowing, onClose }: SwitchAccountShe
borderTop="default"
p="space.05"
>
<Button fullWidth onClick={() => onCreateAccount()}>
<Button fullWidth onClick={() => onCreateAccount()} data-testid="create-account-btn">
Create new account
</Button>
</Flex>
Expand Down
27 changes: 26 additions & 1 deletion tests/page-object-models/onboarding.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ import { RouteUrls } from '@shared/route-urls';

const TEST_ACCOUNT_SECRET_KEY = process.env.TEST_ACCOUNT_SECRET_KEY ?? '';

async function pauseForStateToBeSet() {
return delay(2000);
}

// If default wallet state changes, we'll need to update this
export const testSoftwareAccountDefaultWalletState = {
chains: { stx: { default: { highestAccountIndex: 2, currentAccountIndex: 0 } } },
chains: { stx: { default: { highestAccountIndex: 0, currentAccountIndex: 0 } } },
appPermissions: {
entities: {},
ids: [],
Expand Down Expand Up @@ -318,6 +322,27 @@ export class OnboardingPage {

iterationCounter.increment();
} while (!(await isSignedIn()));

await this.createNewAccount();
await this.createNewAccount();
await this.selectFirstAccount();
await pauseForStateToBeSet();
}

async createNewAccount() {
await this.page.getByTestId('switch-account-trigger').click();
await this.page.getByTestId('switch-account-item-0').isVisible();
const dialog = this.page.getByRole('dialog');
await this.page.getByTestId('create-account-btn').click();
await dialog.waitFor({ state: 'detached' });
}

async selectFirstAccount() {
await this.page.getByTestId('switch-account-trigger').click();
await this.page.getByTestId('switch-account-item-0').isVisible();
const dialog = this.page.getByRole('dialog');
await this.page.getByTestId('switch-account-item-0').click();
await dialog.waitFor({ state: 'detached' });
}

/**
Expand Down
Loading