-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'display-tx' into 'dev'
complete transaction page See merge request ergo/minotaur/minotaur-wallet!36
- Loading branch information
Showing
13 changed files
with
222 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged | ||
#npx lint-staged |
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { openTxInBrowser } from '@/action/tx'; | ||
import ErgAmount from '@/components/amounts-display/ErgAmount'; | ||
import IssuedBurntTokenAmount from '@/components/token-amount/IssuedBurntTokenAmount'; | ||
import useIssuedAndBurntTokens from '@/hooks/useIssuedAndBurntTokens'; | ||
import useTxValues from '@/hooks/useTxValues'; | ||
import TxAssetDetail from '@/pages/wallet-page/transaction/TxAssetDetail'; | ||
import { StateWallet } from '@/store/reducer/wallet'; | ||
import { getValueColor } from '@/utils/functions'; | ||
import { OpenInNew } from '@mui/icons-material'; | ||
import { IconButton, Stack, Typography } from '@mui/material'; | ||
import React from 'react'; | ||
import * as wasm from 'ergo-lib-wasm-browser'; | ||
|
||
interface TxDisplayPropsType { | ||
wallet: StateWallet; | ||
tx: wasm.Transaction | wasm.UnsignedTransaction; | ||
boxes: Array<wasm.ErgoBox>; | ||
date?: string; | ||
} | ||
|
||
const TxDisplay = ({ tx, boxes, wallet, date }: TxDisplayPropsType) => { | ||
const txId = tx.id().to_str(); | ||
const issuedAndBurnt = useIssuedAndBurntTokens(tx, boxes); | ||
const { txValues } = useTxValues(tx, boxes, wallet); | ||
const openTx = () => openTxInBrowser(wallet.networkType, txId ?? ''); | ||
return ( | ||
<React.Fragment> | ||
<Typography | ||
fontSize="2rem" | ||
textAlign="center" | ||
color={getValueColor(-txValues.total)} | ||
mb={2} | ||
> | ||
<ErgAmount | ||
amount={txValues.total > 0 ? txValues.total : -txValues.total} | ||
/> | ||
<Typography component="span" ml={1}> | ||
ERG | ||
</Typography> | ||
</Typography> | ||
{date ? ( | ||
<React.Fragment> | ||
<Typography variant="body2" color="textSecondary"> | ||
Received on | ||
</Typography> | ||
<Typography mb={2}>{date}</Typography> | ||
</React.Fragment> | ||
) : null} | ||
<div> | ||
<Typography variant="body2" color="textSecondary"> | ||
Transaction Id | ||
</Typography> | ||
<Typography mb={2} sx={{ overflowWrap: 'anywhere' }} onClick={openTx}> | ||
{txId} | ||
<IconButton size="small"> | ||
<OpenInNew /> | ||
</IconButton> | ||
</Typography> | ||
</div> | ||
{Object.entries(txValues.tokens).map((item) => ( | ||
<TxAssetDetail | ||
amount={-item[1]} | ||
id={item[0]} | ||
networkType={wallet.networkType} | ||
key={item[0]} | ||
/> | ||
))} | ||
{issuedAndBurnt.burnt.length > 0 ? ( | ||
<React.Fragment> | ||
<Typography variant="body2" color="textSecondary" mt={2}> | ||
Burnt tokens | ||
</Typography> | ||
<Stack sx={{ mb: 2, mt: 1 }} gap={0.5}> | ||
{issuedAndBurnt.burnt.map((item) => ( | ||
<IssuedBurntTokenAmount | ||
key={item.tokenId} | ||
tokenId={item.tokenId} | ||
amount={item.amount} | ||
networkType={wallet.networkType} | ||
color={'error'} | ||
/> | ||
))} | ||
</Stack> | ||
</React.Fragment> | ||
) : null} | ||
{issuedAndBurnt.issued.length > 0 ? ( | ||
<React.Fragment> | ||
<Typography variant="body2" color="textSecondary" mt={2}> | ||
Issued tokens | ||
</Typography> | ||
<Stack sx={{ mb: 2, mt: 1 }} gap={0.5}> | ||
{issuedAndBurnt.issued.map((item) => ( | ||
<IssuedBurntTokenAmount | ||
key={item.tokenId} | ||
tokenId={item.tokenId} | ||
amount={item.amount} | ||
networkType={wallet.networkType} | ||
color={'success'} | ||
/> | ||
))} | ||
</Stack> | ||
</React.Fragment> | ||
) : null} | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default TxDisplay; |
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
44 changes: 44 additions & 0 deletions
44
apps/wallet/src/pages/wallet-page/transaction/TxAssetDetail.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,44 @@ | ||
import TokenAmountDisplay from '@/components/amounts-display/TokenAmountDisplay'; | ||
import DisplayId from '@/components/display-id/DisplayId'; | ||
import useAssetDetail from '@/hooks/useAssetDetail'; | ||
import { getValueColor } from '@/utils/functions'; | ||
import { Avatar, Box, Typography } from '@mui/material'; | ||
import React from 'react'; | ||
|
||
interface TxAssetDetailPropsType { | ||
id: string; | ||
amount: bigint; | ||
networkType: string; | ||
} | ||
const TxAssetDetail = (props: TxAssetDetailPropsType) => { | ||
const details = useAssetDetail(props.id, props.networkType); | ||
if (props.amount === 0n) return null; | ||
const color = getValueColor(props.amount); | ||
return ( | ||
<React.Fragment> | ||
<Box sx={{ float: 'left', mr: 2 }}> | ||
{details.logo ? ( | ||
<Avatar alt={details.name}> | ||
<details.logo /> | ||
</Avatar> | ||
) : ( | ||
<Avatar alt={details.name} src="/" /> | ||
)} | ||
</Box> | ||
<Box display="flex"> | ||
<Typography sx={{ flexGrow: 1 }}>{details.name}</Typography> | ||
<Typography color={color}> | ||
{props.amount > 0 ? '+' : ''} | ||
<TokenAmountDisplay amount={props.amount} decimal={details.decimal} /> | ||
</Typography> | ||
</Box> | ||
<DisplayId | ||
variant="body2" | ||
color={color} | ||
id={props.amount > 0 ? 'Received' : 'Sent'} | ||
/> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default TxAssetDetail; |
58 changes: 35 additions & 23 deletions
58
apps/wallet/src/pages/wallet-page/transaction/WalletTransactionDetail.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
Oops, something went wrong.