Skip to content

Commit

Permalink
refactor: remove brc20 send flow code
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Sep 3, 2024
1 parent 6b9566a commit f253bf5
Show file tree
Hide file tree
Showing 21 changed files with 10 additions and 1,094 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"@leather.io/constants": "0.9.1",
"@leather.io/crypto": "1.4.2",
"@leather.io/models": "0.13.0",
"@leather.io/query": "2.7.0",
"@leather.io/query": "2.7.1",
"@leather.io/stacks": "1.0.2",
"@leather.io/tokens": "0.9.0",
"@leather.io/ui": "1.16.0",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/common/hooks/use-stacks-explorer-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';

import { openInNewTab } from '../utils/open-in-new-tab';

export interface HandleOpenStacksTxLinkArgs {
interface HandleOpenStacksTxLinkArgs {
searchParams?: URLSearchParams;
txid: string;
}
Expand Down
11 changes: 0 additions & 11 deletions src/app/common/validation/forms/amount-validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,3 @@ export function stacksFungibleTokenAmountValidator(balance: Money) {
},
});
}

export function tokenAmountValidator(balance: Money) {
const { amount } = balance;
return amountValidator().test({
message: formatInsufficientBalanceError(balance, sum => sum.amount.toString()),
test(value) {
if (!isNumber(value) || !amount) return false;
return new BigNumber(value).isLessThanOrEqualTo(amount);
},
});
}
12 changes: 0 additions & 12 deletions src/app/components/status-pending.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions src/app/components/status-ready.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { useNavigate } from 'react-router-dom';

import { CryptoAssetSelectors } from '@tests/selectors/crypto-asset.selectors';
import { Stack } from 'leather-styles/jsx';

import type { Brc20CryptoAssetInfo, CryptoAssetBalance, MarketData } from '@leather.io/models';
import { Brc20AvatarIcon } from '@leather.io/ui';

import { RouteUrls } from '@shared/route-urls';

import { convertAssetBalanceToFiat } from '@app/common/asset-utils';
import { CryptoAssetItemLayout } from '@app/components/crypto-asset-item/crypto-asset-item.layout';
import type { AssetListVariant } from '@app/features/asset-list/asset-list';
Expand All @@ -32,24 +28,8 @@ function getBrc20TokenFiatBalance(token: Brc20TokenAssetDetails) {
});
}

export function Brc20TokenAssetList({ tokens, variant }: Brc20TokenAssetListProps) {
const navigate = useNavigate();
const { balance, isLoading } = useCurrentBtcCryptoAssetBalanceNativeSegwit();

const hasPositiveBtcBalanceForFees =
variant === 'interactive' && balance.availableBalance.amount.isGreaterThan(0);

function navigateToBrc20SendForm(token: Brc20TokenAssetDetails) {
const { balance, holderAddress, info, marketData } = token;
navigate(RouteUrls.SendBrc20SendForm.replace(':ticker', info.symbol), {
state: {
balance: balance.availableBalance,
holderAddress,
marketData,
ticker: info.symbol,
},
});
}
export function Brc20TokenAssetList({ tokens }: Brc20TokenAssetListProps) {
const { isLoading } = useCurrentBtcCryptoAssetBalanceNativeSegwit();

if (!tokens.length) return null;
return (
Expand All @@ -61,9 +41,6 @@ export function Brc20TokenAssetList({ tokens, variant }: Brc20TokenAssetListProp
icon={<Brc20AvatarIcon />}
isLoading={isLoading}
key={token.info.symbol}
onSelectAsset={
hasPositiveBtcBalanceForFees ? () => navigateToBrc20SendForm(token) : undefined
}
titleLeft={token.info.symbol}
fiatBalance={getBrc20TokenFiatBalance(token)}
/>
Expand Down
133 changes: 0 additions & 133 deletions src/app/features/pending-brc-20-transfers/pending-brc-20-transfers.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/app/pages/home/components/assets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import { Stack } from 'leather-styles/jsx';

import { AssetList } from '@app/features/asset-list/asset-list';
import { Collectibles } from '@app/features/collectibles/collectibles';
import { PendingBrc20TransferList } from '@app/features/pending-brc-20-transfers/pending-brc-20-transfers';

export function Assets() {
return (
<Stack data-testid={HomePageSelectors.AssetList}>
<AssetList />
<PendingBrc20TransferList />
<Collectibles />
<Outlet />
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { InfoCardRow, InfoCardSeparator } from '@app/components/info-card/info-c
import { InscriptionPreview } from '@app/components/inscription-preview-card/components/inscription-preview';
import { Card } from '@app/components/layout';
import { useCurrentNativeSegwitUtxos } from '@app/query/bitcoin/address/utxos-by-address.hooks';
import { useAppDispatch } from '@app/store';
import { inscriptionSent } from '@app/store/ordinals/ordinals.slice';

import { InscriptionPreviewCard } from '../../../components/inscription-preview-card/inscription-preview-card';
import { useSendInscriptionState } from './components/send-inscription-container';
Expand All @@ -33,7 +31,6 @@ function useSendInscriptionReviewState() {

export function SendInscriptionReview() {
const navigate = useNavigate();
const dispatch = useAppDispatch();
const { arrivesIn, signedTx, recipient, feeRowValue } = useSendInscriptionReviewState();

const { inscription } = useSendInscriptionState();
Expand All @@ -47,8 +44,6 @@ export function SendInscriptionReview() {
async onSuccess(txid: string) {
void analytics.track('broadcast_ordinal_transaction');
await filteredUtxosQuery.refetch();
// Might be a BRC-20 transfer, so we want to remove it from the pending
dispatch(inscriptionSent({ inscriptionId: inscription.id }));
navigate(`/${RouteUrls.SendOrdinalInscription}/${RouteUrls.SendOrdinalInscriptionSent}`, {
state: {
inscription,
Expand Down
Loading

0 comments on commit f253bf5

Please sign in to comment.