-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix swaps tx history #557
Fix swaps tx history #557
Changes from 2 commits
0fb35e3
e7c5f19
bc0b291
288ec1b
ff88521
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,10 +51,11 @@ const TransactionValue = styled.p((props) => ({ | |
interface TxTransfersProps { | ||
transaction: AddressTransactionWithTransfers; | ||
coin: CurrencyTypes; | ||
txFilter: string | null; | ||
} | ||
|
||
export default function TxTransfers(props: TxTransfersProps) { | ||
const { transaction, coin } = props; | ||
const { transaction, coin, txFilter } = props; | ||
const { selectedAccount } = useWalletSelector(); | ||
const { t } = useTranslation('translation', { keyPrefix: 'COIN_DASHBOARD_SCREEN' }); | ||
|
||
|
@@ -75,26 +76,59 @@ export default function TxTransfers(props: TxTransfersProps) { | |
: t('TRANSACTION_SENT'); | ||
return ( | ||
<> | ||
{transaction.stx_transfers.map((stxTransfer) => ( | ||
<TransactionContainer key={nanoid()}> | ||
{renderTransactionIcon(stxTransfer)} | ||
<TransactionInfoContainer> | ||
<TransactionRow> | ||
<TransactionTitleText>{getTokenTransferTitle(stxTransfer)}</TransactionTitleText> | ||
<NumericFormat | ||
value={microstacksToStx(BigNumber(stxTransfer.amount)).toString()} | ||
displayType="text" | ||
thousandSeparator | ||
prefix={selectedAccount?.stxAddress === stxTransfer.recipient ? '' : '-'} | ||
renderText={(value: string) => ( | ||
<TransactionValue>{`${value} ${coin}`}</TransactionValue> | ||
)} | ||
/> | ||
</TransactionRow> | ||
<RecipientAddress>{formatAddress(stxTransfer.recipient as string)}</RecipientAddress> | ||
</TransactionInfoContainer> | ||
</TransactionContainer> | ||
))} | ||
{coin === 'FT' && transaction.ft_transfers | ||
? transaction.ft_transfers.map((ftTransfer) => { | ||
if (ftTransfer.asset_identifier === txFilter) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not filter on the list instead, like |
||
return ( | ||
<TransactionContainer key={nanoid()}> | ||
{renderTransactionIcon(ftTransfer)} | ||
<TransactionInfoContainer> | ||
<TransactionRow> | ||
<TransactionTitleText> | ||
{getTokenTransferTitle(ftTransfer)} | ||
</TransactionTitleText> | ||
<NumericFormat | ||
value={microstacksToStx(BigNumber(ftTransfer.amount)).toString()} | ||
displayType="text" | ||
thousandSeparator | ||
prefix={selectedAccount?.stxAddress === ftTransfer.recipient ? '' : '-'} | ||
renderText={(value: string) => ( | ||
<TransactionValue>{`${value} ${ftTransfer.asset_identifier | ||
.split('::')[1] | ||
.toUpperCase()}`}</TransactionValue> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
)} | ||
/> | ||
</TransactionRow> | ||
<RecipientAddress> | ||
{formatAddress(ftTransfer.recipient as string)} | ||
</RecipientAddress> | ||
</TransactionInfoContainer> | ||
</TransactionContainer> | ||
); | ||
} | ||
}) | ||
: transaction.stx_transfers.map((stxTransfer) => ( | ||
<TransactionContainer key={nanoid()}> | ||
{renderTransactionIcon(stxTransfer)} | ||
<TransactionInfoContainer> | ||
<TransactionRow> | ||
<TransactionTitleText>{getTokenTransferTitle(stxTransfer)}</TransactionTitleText> | ||
<NumericFormat | ||
value={microstacksToStx(BigNumber(stxTransfer.amount)).toString()} | ||
displayType="text" | ||
thousandSeparator | ||
prefix={selectedAccount?.stxAddress === stxTransfer.recipient ? '' : '-'} | ||
renderText={(value: string) => ( | ||
<TransactionValue>{`${value} ${coin}`}</TransactionValue> | ||
)} | ||
/> | ||
</TransactionRow> | ||
<RecipientAddress> | ||
{formatAddress(stxTransfer.recipient as string)} | ||
</RecipientAddress> | ||
</TransactionInfoContainer> | ||
</TransactionContainer> | ||
))} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a lot of duplicated code. could you DRY it up? it looks like only the NumericFormat props change depending on whether it's a stxTransfer or ftTransfer |
||
</> | ||
); | ||
} |
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.
lint error here