Skip to content

Commit

Permalink
fix: ledger locked stx, ref #4539
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf committed Dec 19, 2023
1 parent 1836adf commit 5c89eea
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 47 deletions.
12 changes: 9 additions & 3 deletions src/app/components/loaders/stacks-account-loader.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ReactNode } from 'react';

import { useCurrentAccountIndex } from '@app/store/accounts/account';
import {
useCurrentStacksAccount,
Expand All @@ -6,11 +8,15 @@ import {
import { StacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.models';

interface CurrentStacksAccountLoaderProps {
children(data: StacksAccount): React.ReactNode;
children(data: StacksAccount): ReactNode;
fallback?: ReactNode;
}
export function CurrentStacksAccountLoader({ children }: CurrentStacksAccountLoaderProps) {
export function CurrentStacksAccountLoader({
children,
fallback,
}: CurrentStacksAccountLoaderProps) {
const currentAccount = useCurrentStacksAccount();
if (!currentAccount) return null;
if (!currentAccount) return fallback ? fallback : null;
return children(currentAccount);
}

Expand Down
15 changes: 5 additions & 10 deletions src/app/features/asset-list/asset-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { BtcIcon } from '@app/ui/components/icons/btc-icon';

import { Collectibles } from '../collectibles/collectibles';
import { PendingBrc20TransferList } from '../pending-brc-20-transfers/pending-brc-20-transfers';
import { AddStacksLedgerKeysItem } from './components/add-stacks-ledger-keys-item';
import { BitcoinFungibleTokenAssetList } from './components/bitcoin-fungible-tokens-asset-list';
import { ConnectLedgerAssetBtn } from './components/connect-ledger-asset-button';
import { StacksBalanceItem } from './components/stacks-balance-item';
import { StacksLedgerAssetsList } from './components/stacks-ledger-assets';
import { StacksAssetList } from './components/stacks-asset-list';

export function AssetsList() {
const hasBitcoinLedgerKeys = useHasBitcoinLedgerKeychain();
Expand Down Expand Up @@ -61,14 +61,9 @@ export function AssetsList() {
ledger: null,
})}

{whenWallet({
software: (
<CurrentStacksAccountLoader>
{account => <StacksBalanceItem account={account} />}
</CurrentStacksAccountLoader>
),
ledger: <StacksLedgerAssetsList />,
})}
<CurrentStacksAccountLoader fallback={<AddStacksLedgerKeysItem />}>
{account => <StacksAssetList account={account} />}
</CurrentStacksAccountLoader>

{whenWallet({
software: (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import BigNumber from 'bignumber.js';

import { CryptoCurrencyAssetItem } from '@app/components/crypto-assets/crypto-currency-asset/crypto-currency-asset-item';
import { StxAvatar } from '@app/components/crypto-assets/stacks/components/stx-avatar';
import { createStacksCryptoCurrencyAssetTypeWrapper } from '@app/query/stacks/balance/stacks-ft-balances.utils';

import { ConnectLedgerAssetBtn } from './connect-ledger-asset-button';

export function AddStacksLedgerKeysItem() {
return (
<CryptoCurrencyAssetItem
assetBalance={createStacksCryptoCurrencyAssetTypeWrapper(new BigNumber(0))}
icon={<StxAvatar />}
rightElement={<ConnectLedgerAssetBtn chain="stacks" />}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { Caption } from '@app/ui/components/typography/caption';

import { StacksFungibleTokenAssetList } from './stacks-fungible-token-asset-list';

interface StacksBalanceItemProps {
interface StacksAssetListProps {
account: StacksAccount;
}
export function StacksBalanceItem({ account }: StacksBalanceItemProps) {
export function StacksAssetList({ account }: StacksAssetListProps) {
const stacksFtAssetBalances = useStacksFungibleTokenAssetBalancesAnchoredWithMetadata(
account.address
);
Expand Down
30 changes: 0 additions & 30 deletions src/app/features/asset-list/components/stacks-ledger-assets.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function makeNonFungibleTokenHoldingsQuery(
};
}

export default function useGetNonFungibleTokenHoldingsQuery(address: string) {
export function useGetNonFungibleTokenHoldingsQuery(address: string) {
const client = useStacksClientUnanchored();
const network = useCurrentNetworkState();
const limiter = useHiroApiRateLimiter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useTokenMetadataClient } from '@app/store/common/api-clients.hooks';
import { RateLimiter, useHiroApiRateLimiter } from '../../rate-limiter';
import { TokenMetadataClient } from '../../token-metadata-client';
import { NftAssetResponse } from '../token-metadata.utils';
import useGetNonFungibleTokenHoldingsQuery from './non-fungible-token-holdings.query';
import { useGetNonFungibleTokenHoldingsQuery } from './non-fungible-token-holdings.query';

const queryOptions = {
refetchOnWindowFocus: false,
Expand Down

0 comments on commit 5c89eea

Please sign in to comment.