-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extension): LW-9178 collateral output in tx activity details (#844)
* feat(ui): create info bar component * fix(ui): add zIndex property to tooltip * feat(core): add collateral tooltip and info bar * feat(extension): display collateral info on activity details * refactor(extension): use wallet state * refactor(extension): reduce argument scope * refactor(extension): move ternary operation to variable declaration * refactor(core): rename tooltip function * refactor(ui): remove unused variable * refactor(core): ignore spendable activity status * feat(extension): display collateral balance * refactor(extension): move phase 2 validation func to utils
- Loading branch information
1 parent
57138c6
commit 2db23bf
Showing
21 changed files
with
407 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Wallet } from '@lace/cardano'; | ||
|
||
export const hasPhase2ValidationFailed = ( | ||
tx: Wallet.TxInFlight | Wallet.Cardano.HydratedTx | Wallet.Cardano.Tx | ||
): boolean => 'inputSource' in tx && tx.inputSource === Wallet.Cardano.InputSource.collaterals; |
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: 42 additions & 8 deletions
50
packages/core/src/ui/components/ActivityDetail/Collateral.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,21 +1,55 @@ | ||
import React from 'react'; | ||
import { useTranslate } from '@src/ui/hooks'; | ||
import { TransactionSummary } from '@lace/ui'; | ||
import { Box, TransactionSummary, InfoBar } from '@lace/ui'; | ||
import { ReactComponent as InfoIcon } from '@lace/icons/dist/InfoComponent'; | ||
|
||
export enum CollateralStatus { | ||
REVIEW = 'review', | ||
SUCCESS = 'success', | ||
ERROR = 'error', | ||
NONE = 'none' | ||
} | ||
|
||
export interface Props { | ||
collateral: string; | ||
amountTransformer: (amount: string) => string; | ||
coinSymbol: string; | ||
status?: CollateralStatus; | ||
} | ||
export const Collateral = ({ collateral, amountTransformer, coinSymbol }: Props): React.ReactElement => { | ||
|
||
export const Collateral = ({ | ||
collateral, | ||
amountTransformer, | ||
coinSymbol, | ||
status = CollateralStatus.REVIEW | ||
}: Props): React.ReactElement => { | ||
const { t } = useTranslate(); | ||
|
||
const getTooltipText = (): string => { | ||
switch (status) { | ||
case 'review': | ||
case 'error': | ||
return t('package.core.activityDetails.collateral.tooltip.info'); | ||
case 'success': | ||
return t('package.core.activityDetails.collateral.tooltip.success'); | ||
} | ||
|
||
return ''; | ||
}; | ||
|
||
return ( | ||
<TransactionSummary.Amount | ||
amount={`${collateral} ${coinSymbol}`} | ||
fiatPrice={amountTransformer(collateral)} | ||
label={t('package.core.activityDetails.collateral')} | ||
tooltip={t('package.core.activityDetails.collateralInfo')} | ||
/> | ||
<> | ||
<TransactionSummary.Amount | ||
amount={`${collateral} ${coinSymbol}`} | ||
fiatPrice={amountTransformer(collateral)} | ||
label={t('package.core.activityDetails.collateral.label')} | ||
tooltip={getTooltipText()} | ||
/> | ||
{status === CollateralStatus.ERROR && ( | ||
<Box mt="$32"> | ||
<InfoBar icon={<InfoIcon />} message={t('package.core.activityDetails.collateral.error')} /> | ||
</Box> | ||
)} | ||
</> | ||
); | ||
}; |
Oops, something went wrong.