-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat(extension): LW-9178 collateral output in tx activity details #844
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5472186
feat(ui): create info bar component
renanvalentin 7d914ad
fix(ui): add zIndex property to tooltip
renanvalentin 2e91695
feat(core): add collateral tooltip and info bar
renanvalentin c7ee6fb
feat(extension): display collateral info on activity details
renanvalentin 8247c03
refactor(extension): use wallet state
renanvalentin b4e5508
refactor(extension): reduce argument scope
renanvalentin 11e41b3
refactor(extension): move ternary operation to variable declaration
renanvalentin ef4a35b
refactor(core): rename tooltip function
renanvalentin 48184ef
refactor(ui): remove unused variable
renanvalentin b6dfeb4
refactor(core): ignore spendable activity status
renanvalentin 1210a21
feat(extension): display collateral balance
renanvalentin 20f0b36
refactor(extension): move phase 2 validation func to utils
renanvalentin b038bdb
Merge remote-tracking branch 'upstream/main' into lw-9178-cip40
renanvalentin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe it would be good to have a dedicated tooltip's text for review and error?
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.
There's a status bar below the collateral when phase 2 fails.