-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5047 from leather-wallet/release/friday-brc-20-fix
Release/friday brc 20 fix
- Loading branch information
Showing
17 changed files
with
226 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
src/app/features/asset-list/components/stacks-asset-list.tsx
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
src/app/features/asset-list/components/stacks-balance-list-item.layout.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { TooltipProvider } from '@radix-ui/react-tooltip'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import BigNumber from 'bignumber.js'; | ||
|
||
import { StacksBalanceListItemLayout } from './stacks-balance-list-item.layout'; | ||
|
||
const meta: Meta<typeof StacksBalanceListItemLayout> = { | ||
component: StacksBalanceListItemLayout, | ||
tags: ['autodocs'], | ||
title: 'Feature/StacksBalanceListItem', | ||
argTypes: {}, | ||
parameters: {}, | ||
decorators: [ | ||
Story => ( | ||
<TooltipProvider> | ||
<Story /> | ||
</TooltipProvider> | ||
), | ||
], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof StacksBalanceListItemLayout>; | ||
|
||
const symbol = 'STX'; | ||
|
||
export const StacksBalanceItem: Story = { | ||
args: { | ||
address: 'ST1PQHQKV0YX2K1Z0V2VQZGZGZGZGZGZGZGZGZGZG', | ||
stxEffectiveBalance: { | ||
balance: { decimals: 8, amount: new BigNumber(100000000000), symbol }, | ||
blockchain: 'stacks', | ||
type: 'crypto-currency', | ||
asset: { | ||
decimals: 8, | ||
hasMemo: true, | ||
name: 'Stacks', | ||
symbol, | ||
} as const, | ||
}, | ||
stxEffectiveUsdBalance: '$100,000', | ||
}, | ||
}; | ||
|
||
export const StacksBalanceItemWithLockedBalance: Story = { | ||
args: { | ||
address: 'ST1PQHQKV0YX2K1Z0V2VQZGZGZGZGZGZGZGZGZGZG', | ||
stxEffectiveBalance: { | ||
balance: { decimals: 8, amount: new BigNumber(100000000000), symbol }, | ||
blockchain: 'stacks', | ||
type: 'crypto-currency', | ||
asset: { | ||
decimals: 8, | ||
hasMemo: true, | ||
name: 'Stacks', | ||
symbol, | ||
} as const, | ||
}, | ||
stxEffectiveUsdBalance: '$100,000', | ||
stxUsdLockedBalance: '$1,000', | ||
stxLockedBalance: { decimals: 8, amount: new BigNumber(1000000000), symbol }, | ||
}, | ||
}; |
49 changes: 49 additions & 0 deletions
49
src/app/features/asset-list/components/stacks-balance-list-item.layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { styled } from 'leather-styles/jsx'; | ||
|
||
import type { StacksCryptoCurrencyAssetBalance } from '@shared/models/crypto-asset-balance.model'; | ||
import type { Money } from '@shared/models/money.model'; | ||
|
||
import { ftDecimals } from '@app/common/stacks-utils'; | ||
import { CryptoCurrencyAssetItemLayout } from '@app/components/crypto-assets/crypto-currency-asset/crypto-currency-asset-item.layout'; | ||
import { StxAvatarIcon } from '@app/ui/components/avatar/stx-avatar-icon'; | ||
import { BulletOperator } from '@app/ui/components/bullet-separator/bullet-separator'; | ||
import { Caption } from '@app/ui/components/typography/caption'; | ||
|
||
interface StacksBalanceListItemLayoutProps { | ||
address: string; | ||
stxEffectiveBalance: StacksCryptoCurrencyAssetBalance; | ||
stxEffectiveUsdBalance?: string; | ||
stxLockedBalance?: Money; | ||
stxUsdLockedBalance?: string; | ||
} | ||
export function StacksBalanceListItemLayout(props: StacksBalanceListItemLayoutProps) { | ||
const { | ||
address, | ||
stxEffectiveBalance, | ||
stxEffectiveUsdBalance, | ||
stxLockedBalance, | ||
stxUsdLockedBalance, | ||
} = props; | ||
|
||
const stxAdditionalBalanceInfo = stxLockedBalance?.amount.isGreaterThan(0) ? ( | ||
<styled.span> | ||
<BulletOperator ml="space.01" mr="space.02" /> | ||
{ftDecimals(stxLockedBalance.amount, stxLockedBalance.decimals || 0)} locked | ||
</styled.span> | ||
) : undefined; | ||
|
||
const stxAdditionalUsdBalanceInfo = stxLockedBalance?.amount.isGreaterThan(0) ? ( | ||
<Caption>{stxUsdLockedBalance} locked</Caption> | ||
) : undefined; | ||
|
||
return ( | ||
<CryptoCurrencyAssetItemLayout | ||
assetBalance={stxEffectiveBalance} | ||
usdBalance={stxEffectiveUsdBalance} | ||
address={address} | ||
additionalBalanceInfo={stxAdditionalBalanceInfo} | ||
additionalUsdBalanceInfo={stxAdditionalUsdBalanceInfo} | ||
icon={<StxAvatarIcon />} | ||
/> | ||
); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/app/features/asset-list/components/stacks-balance-list-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useStxBalance } from '@app/common/hooks/balance/stx/use-stx-balance'; | ||
|
||
import { StacksBalanceListItemLayout } from './stacks-balance-list-item.layout'; | ||
|
||
interface StacksBalanceListItemProps { | ||
address: string; | ||
} | ||
export function StacksBalanceListItem({ address }: StacksBalanceListItemProps) { | ||
const balaceDetails = useStxBalance(); | ||
return <StacksBalanceListItemLayout address={address} {...balaceDetails} />; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/app/features/asset-list/components/stacks-fungible-token-asset-list.layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Stack } from 'leather-styles/jsx'; | ||
|
||
import type { StacksFungibleTokenAssetBalance } from '@shared/models/crypto-asset-balance.model'; | ||
|
||
import { StacksFungibleTokenAssetItemLayout } from '@app/components/crypto-assets/stacks/fungible-token-asset/stacks-fungible-token-asset-item.layout'; | ||
|
||
interface StacksFungibleTokenAssetListLayoutProps { | ||
assetBalances: StacksFungibleTokenAssetBalance[]; | ||
} | ||
export function StacksFungibleTokenAssetListLayout({ | ||
assetBalances, | ||
}: StacksFungibleTokenAssetListLayoutProps) { | ||
if (assetBalances.length === 0) return null; | ||
return ( | ||
<Stack> | ||
{assetBalances.map(assetBalance => ( | ||
<StacksFungibleTokenAssetItemLayout | ||
assetBalance={assetBalance} | ||
key={assetBalance.asset.contractId} | ||
/> | ||
))} | ||
</Stack> | ||
); | ||
} |
23 changes: 6 additions & 17 deletions
23
src/app/features/asset-list/components/stacks-fungible-token-asset-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
import { Stack } from 'leather-styles/jsx'; | ||
import { useStacksFungibleTokenAssetBalancesWithMetadata } from '@app/query/stacks/balance/stacks-ft-balances.hooks'; | ||
|
||
import type { StacksFungibleTokenAssetBalance } from '@shared/models/crypto-asset-balance.model'; | ||
|
||
import { StacksFungibleTokenAssetItemLayout } from '@app/components/crypto-assets/stacks/fungible-token-asset/stacks-fungible-token-asset-item.layout'; | ||
import { StacksFungibleTokenAssetListLayout } from './stacks-fungible-token-asset-list.layout'; | ||
|
||
interface StacksFungibleTokenAssetListProps { | ||
assetBalances: StacksFungibleTokenAssetBalance[]; | ||
address: string; | ||
} | ||
export function StacksFungibleTokenAssetList({ assetBalances }: StacksFungibleTokenAssetListProps) { | ||
if (assetBalances.length === 0) return null; | ||
return ( | ||
<Stack> | ||
{assetBalances.map(assetBalance => ( | ||
<StacksFungibleTokenAssetItemLayout | ||
assetBalance={assetBalance} | ||
key={assetBalance.asset.contractId} | ||
/> | ||
))} | ||
</Stack> | ||
); | ||
export function StacksFungibleTokenAssetList({ address }: StacksFungibleTokenAssetListProps) { | ||
const stacksFtAssetBalances = useStacksFungibleTokenAssetBalancesWithMetadata(address); | ||
return <StacksFungibleTokenAssetListLayout assetBalances={stacksFtAssetBalances} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.