-
Notifications
You must be signed in to change notification settings - Fork 15
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 #831 from alleslabs/feature/cfe-381-bonded-changes…
…-transaction [CFE-381]: Feature - bonded changes transaction
- Loading branch information
Showing
16 changed files
with
480 additions
and
65 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
21 changes: 0 additions & 21 deletions
21
src/lib/pages/validator-details/components/tables/RelatedTransactionsTable.tsx
This file was deleted.
Oops, something went wrong.
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,3 +1,3 @@ | ||
export * from "./ProposedBlocksTable"; | ||
export * from "./RelatedTransactionsTable"; | ||
export * from "./VotedProposalsTable"; | ||
export * from "./related-transactions"; |
66 changes: 66 additions & 0 deletions
66
...-details/components/tables/related-transactions/RelatedTransactionsBondedTokenChanges.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,66 @@ | ||
import { Box, Flex, Text } from "@chakra-ui/react"; | ||
import type { BigSource } from "big.js"; | ||
import type Big from "big.js"; | ||
|
||
import { TokenImageRender } from "lib/components/token"; | ||
import { getUndefinedTokenIcon } from "lib/pages/pools/utils"; | ||
import type { AssetInfos, Coin, Option, Token, U, USD } from "lib/types"; | ||
import { | ||
coinToTokenWithValue, | ||
formatPrice, | ||
formatUTokenWithPrecision, | ||
getTokenLabel, | ||
} from "lib/utils"; | ||
|
||
interface RelatedTransactionsBondedTokenChangesProps { | ||
txHash: string; | ||
coin: Coin; | ||
assetInfos: Option<AssetInfos>; | ||
} | ||
|
||
export const RelatedTransactionsBondedTokenChanges = ({ | ||
txHash, | ||
coin, | ||
assetInfos, | ||
}: RelatedTransactionsBondedTokenChangesProps) => { | ||
const token = coinToTokenWithValue(coin.denom, coin.amount, assetInfos); | ||
const isPositiveAmount = token.amount.gte(0); | ||
const formattedAmount = `${isPositiveAmount ? "+" : "-"}${formatUTokenWithPrecision(token.amount.abs() as U<Token<Big>>, token.precision ?? 0, false, 2)}`; | ||
|
||
return ( | ||
<Flex | ||
gap={2} | ||
key={`${txHash}-${coin.denom}`} | ||
w="100%" | ||
justifyContent={{ base: "start", md: "end" }} | ||
alignItems="center" | ||
> | ||
<Box textAlign={{ base: "left", md: "right" }}> | ||
<Flex alignItems="center" gap={1}> | ||
<Text | ||
fontWeight={700} | ||
color={isPositiveAmount ? "success.main" : "error.main"} | ||
> | ||
{formattedAmount} | ||
</Text> | ||
<Text>{getTokenLabel(token.denom, token.symbol)}</Text> | ||
<TokenImageRender | ||
display={{ base: "block", md: "none" }} | ||
boxSize={4} | ||
logo={token.logo ?? getUndefinedTokenIcon(token.denom)} | ||
/> | ||
</Flex> | ||
<Text variant="body3" color="text.dark"> | ||
{token.value | ||
? `(${formatPrice(token.value.abs() as USD<BigSource>)})` | ||
: "-"} | ||
</Text> | ||
</Box> | ||
<TokenImageRender | ||
display={{ base: "none", md: "block" }} | ||
boxSize={6} | ||
logo={token.logo ?? getUndefinedTokenIcon(token.denom)} | ||
/> | ||
</Flex> | ||
); | ||
}; |
89 changes: 89 additions & 0 deletions
89
...alidator-details/components/tables/related-transactions/RelatedTransactionsMobileCard.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,89 @@ | ||
import { Badge, Box, Flex, Grid, GridItem, Text } from "@chakra-ui/react"; | ||
|
||
import { ExplorerLink } from "lib/components/ExplorerLink"; | ||
import { MobileCardTemplate } from "lib/components/table"; | ||
import type { ValidatorDelegationRelatedTxsResponseItem } from "lib/services/validator"; | ||
import type { AssetInfos, Option } from "lib/types"; | ||
import { dateFromNow, extractMsgType, formatUTC } from "lib/utils"; | ||
|
||
import { RelatedTransactionsBondedTokenChanges } from "./RelatedTransactionsBondedTokenChanges"; | ||
|
||
interface RelatedTransactionsMobileCardProps { | ||
delegationRelatedTx: ValidatorDelegationRelatedTxsResponseItem; | ||
assetInfos: Option<AssetInfos>; | ||
onRowSelect: (txHash: string) => void; | ||
} | ||
|
||
export const RelatedTransactionsMobileCard = ({ | ||
delegationRelatedTx, | ||
assetInfos, | ||
onRowSelect, | ||
}: RelatedTransactionsMobileCardProps) => ( | ||
<MobileCardTemplate | ||
topContent={ | ||
<Flex w="100%" flexDirection="column" gap={2}> | ||
<Grid templateColumns="1fr 1fr" gap={2}> | ||
<GridItem> | ||
<Text variant="body3" color="text.dark" fontWeight={600}> | ||
Transaction Hash | ||
</Text> | ||
<ExplorerLink | ||
value={delegationRelatedTx.txHash.toLocaleUpperCase()} | ||
type="tx_hash" | ||
showCopyOnHover | ||
/> | ||
{delegationRelatedTx.messages.length > 1 && ( | ||
<Badge variant="secondary" ml={2}> | ||
{delegationRelatedTx.messages.length} | ||
</Badge> | ||
)} | ||
</GridItem> | ||
<GridItem> | ||
<Text variant="body3" color="text.dark" fontWeight={600}> | ||
Sender | ||
</Text> | ||
<ExplorerLink | ||
value={delegationRelatedTx.sender} | ||
type="user_address" | ||
showCopyOnHover | ||
/> | ||
</GridItem> | ||
</Grid> | ||
<Box> | ||
<Text variant="body3" color="text.dark" fontWeight={600}> | ||
Action | ||
</Text> | ||
<Text variant="body2" color="white"> | ||
{delegationRelatedTx.messages.length > 1 | ||
? `${delegationRelatedTx.messages.length} Messages` | ||
: extractMsgType(delegationRelatedTx.messages[0].type)} | ||
</Text> | ||
</Box> | ||
<Box> | ||
<Text variant="body3" color="text.dark" fontWeight={600}> | ||
Bonded Token Changes | ||
</Text> | ||
{delegationRelatedTx.tokens.map((token) => ( | ||
<RelatedTransactionsBondedTokenChanges | ||
txHash={delegationRelatedTx.txHash} | ||
coin={token} | ||
assetInfos={assetInfos} | ||
key={delegationRelatedTx.txHash + token.amount + token.denom} | ||
/> | ||
))} | ||
</Box> | ||
</Flex> | ||
} | ||
bottomContent={ | ||
<Box> | ||
<Text variant="body2" color="text.dark"> | ||
{formatUTC(delegationRelatedTx.timestamp)} | ||
</Text> | ||
<Text variant="body3" color="text.disabled"> | ||
{`(${dateFromNow(delegationRelatedTx.timestamp)})`} | ||
</Text> | ||
</Box> | ||
} | ||
onClick={() => onRowSelect(delegationRelatedTx.txHash)} | ||
/> | ||
); |
Oops, something went wrong.