-
Notifications
You must be signed in to change notification settings - Fork 17
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 #636 from alleslabs/feat/cfe-24-api-v1-balances
[after #634] feat: api v1 balances
- Loading branch information
Showing
43 changed files
with
617 additions
and
1,095 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,77 @@ | ||
import type { FlexProps } from "@chakra-ui/react"; | ||
import { Badge, Flex, Text } from "@chakra-ui/react"; | ||
import { isUndefined } from "lodash"; | ||
|
||
import { Copier } from "../copy"; | ||
import { Tooltip } from "../Tooltip"; | ||
import type { BalanceWithAssetInfo, Token, U, USD } from "lib/types"; | ||
import type { TokenWithValue } from "lib/types"; | ||
import { | ||
calAssetValueWithPrecision, | ||
formatPrice, | ||
formatUTokenWithPrecision, | ||
getTokenLabel, | ||
} from "lib/utils"; | ||
|
||
import { TokenImageRender } from "./TokenImageRender"; | ||
|
||
interface TokenCardProps extends FlexProps { | ||
userBalance: BalanceWithAssetInfo; | ||
token: TokenWithValue; | ||
amptrackSection?: string; | ||
} | ||
|
||
export const TokenCard = ({ | ||
userBalance, | ||
token, | ||
amptrackSection, | ||
...cardProps | ||
}: TokenCardProps) => { | ||
const { symbol, price, amount, precision, id } = userBalance.balance; | ||
const priceExist = price !== undefined; | ||
return ( | ||
<Tooltip label={`Token ID: ${id}`} maxW="240px" textAlign="center"> | ||
}: TokenCardProps) => ( | ||
<Tooltip label={`Token ID: ${token.denom}`} maxW="240px" textAlign="center"> | ||
<Flex | ||
className="copier-wrapper" | ||
direction="column" | ||
minH="101px" | ||
gap={2} | ||
p={3} | ||
background="gray.900" | ||
borderRadius="8px" | ||
{...cardProps} | ||
> | ||
<Flex | ||
className="copier-wrapper" | ||
direction="column" | ||
minH="101px" | ||
gap={2} | ||
p={3} | ||
background="gray.900" | ||
borderRadius="8px" | ||
{...cardProps} | ||
gap={1} | ||
alignItems="center" | ||
borderBottom="1px solid" | ||
borderBottomColor="gray.700" | ||
pb={2} | ||
> | ||
<Flex | ||
gap={1} | ||
alignItems="center" | ||
borderBottom="1px solid" | ||
borderBottomColor="gray.700" | ||
pb={2} | ||
> | ||
<TokenImageRender | ||
logo={userBalance.logo ?? userBalance.assetInfo?.logo} | ||
alt={symbol} | ||
boxSize={6} | ||
/> | ||
<Text | ||
variant="body2" | ||
className="ellipsis" | ||
maxW="91" | ||
fontWeight="bold" | ||
> | ||
{symbol} | ||
</Text> | ||
<Badge variant="gray" ml={2}> | ||
{priceExist ? formatPrice(price as USD<number>) : "N/A"} | ||
</Badge> | ||
<Copier | ||
type={priceExist ? "supported_asset" : "unsupported_asset"} | ||
value={id} | ||
copyLabel="Token ID Copied!" | ||
display={{ base: "flex", md: "none" }} | ||
ml={1} | ||
amptrackSection={amptrackSection} | ||
/> | ||
</Flex> | ||
<TokenImageRender | ||
logo={token.logo} | ||
alt={getTokenLabel(token.denom, token.symbol)} | ||
boxSize={6} | ||
/> | ||
<Text variant="body2" className="ellipsis" maxW="91" fontWeight="bold"> | ||
{token.symbol} | ||
</Text> | ||
<Badge variant="gray" ml={2}> | ||
{!isUndefined(token.price) ? formatPrice(token.price) : "N/A"} | ||
</Badge> | ||
<Copier | ||
type={ | ||
!isUndefined(token.price) ? "supported_asset" : "unsupported_asset" | ||
} | ||
value={token.denom} | ||
copyLabel="Token ID Copied!" | ||
display={{ base: "flex", md: "none" }} | ||
ml={1} | ||
amptrackSection={amptrackSection} | ||
/> | ||
</Flex> | ||
|
||
<Flex direction="column"> | ||
<Text fontWeight={700} variant="body2"> | ||
{formatUTokenWithPrecision(amount as U<Token>, precision, false)} | ||
</Text> | ||
<Text variant="body3" color="text.dark"> | ||
{priceExist | ||
? `(${formatPrice( | ||
calAssetValueWithPrecision(userBalance.balance) | ||
)})` | ||
: "N/A"} | ||
</Text> | ||
</Flex> | ||
<Flex direction="column"> | ||
<Text fontWeight={700} variant="body2"> | ||
{formatUTokenWithPrecision(token.amount, token.precision ?? 0, false)} | ||
</Text> | ||
<Text variant="body3" color="text.dark"> | ||
{!isUndefined(token.value) ? `(${formatPrice(token.value)})` : "N/A"} | ||
</Text> | ||
</Flex> | ||
</Tooltip> | ||
); | ||
}; | ||
</Flex> | ||
</Tooltip> | ||
); |
48 changes: 48 additions & 0 deletions
48
src/lib/pages/account-details/components/asset/AssetCta.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,48 @@ | ||
import { Button, Flex } from "@chakra-ui/react"; | ||
|
||
import { trackUseViewJSON } from "lib/amplitude"; | ||
import { CustomIcon } from "lib/components/icon"; | ||
import { UnsupportedTokensModal } from "lib/components/modal"; | ||
import { useOpenAssetTab } from "lib/hooks"; | ||
import type { Addr, TokenWithValue } from "lib/types"; | ||
|
||
interface AssetCtaProps { | ||
unsupportedAssets: TokenWithValue[]; | ||
totalAsset: number; | ||
address: Addr; | ||
} | ||
|
||
export const AssetCta = ({ | ||
unsupportedAssets, | ||
totalAsset, | ||
address, | ||
}: AssetCtaProps) => { | ||
const openAssetTab = useOpenAssetTab(); | ||
|
||
return ( | ||
<Flex | ||
w={{ base: "full", md: "auto" }} | ||
justify="center" | ||
mb={{ base: 4, md: 0 }} | ||
> | ||
{totalAsset > 0 && ( | ||
<Button | ||
variant="ghost-gray" | ||
size="sm" | ||
rightIcon={<CustomIcon name="launch" boxSize={3} color="text.dark" />} | ||
onClick={() => { | ||
trackUseViewJSON("account_details_page_assets"); | ||
openAssetTab(address); | ||
}} | ||
> | ||
View in JSON | ||
</Button> | ||
)} | ||
<UnsupportedTokensModal | ||
unsupportedAssets={unsupportedAssets} | ||
address={address} | ||
addressType="user_address" | ||
/> | ||
</Flex> | ||
); | ||
}; |
Oops, something went wrong.
97e3330
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
celatone-frontend-staging – ./
celatone-frontend-staging.vercel.app
celatone-frontend-staging-alleslabs.vercel.app
celatone-frontend-staging-git-develop-alleslabs.vercel.app
dev.celat.one
97e3330
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
osmosis-celatone-frontend-staging – ./
osmosis-celatone-frontend-staging-git-develop-alleslabs.vercel.app
osmosis-celatone-frontend-staging-alleslabs.vercel.app
osmosis-celatone-frontend-staging.vercel.app
staging.osmoscan.io
osmosis-staging.celat.one
celatone-staging.osmosis.zone