Skip to content
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

US-1873: Security - Misleading send transaction UX when sending small amounts #744

Merged
merged 4 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@reduxjs/toolkit": "^1.9.0",
"@rsksmart/rif-id-mnemonic": "^0.1.1",
"@rsksmart/rif-relay-light-sdk": "^1.0.12",
"@rsksmart/rif-wallet-abi-enhancer": "^1.0.5",
"@rsksmart/rif-wallet-abi-enhancer": "^1.0.7",
"@rsksmart/rif-wallet-adapters": "^1.0.0",
"@rsksmart/rif-wallet-bitcoin": "^1.2.0",
"@rsksmart/rif-wallet-core": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/token/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const TokenBalance = ({
{'<'}
</Typography>
)}
<DollarIcon size={16} color={sharedColors.subTitle} />
<DollarIcon size={16} color={sharedColors.labelLight} />
</>
)}
{!isNaN(Number(secondValue?.balance)) && (
Expand Down
5 changes: 1 addition & 4 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ export const roundBalance = (num: number, decimalPlaces?: number) => {
}

export const displayRoundBalance = (num: number): string => {
let rounded = roundBalance(num, 4)
if (!rounded) {
rounded = roundBalance(num, 8)
}
const rounded = roundBalance(num, 4) || roundBalance(num, 8)
return rounded.toString()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ export const TransactionSummaryComponent = ({
</View>
</View>
<View style={styles.dollarAmountWrapper}>
{usdValue.symbol === '<' && (
<Typography type="body1" color={sharedColors.labelLight}>
{'<'}
</Typography>
)}
<DollarIcon size={14} color={sharedColors.labelLight} />
<Typography
type={'body2'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,19 @@ export const ReviewTransactionContainer = ({
// get usd values
const tokenUsd = convertToUSD(Number(value), tokenQuote)
const feeUsd = convertToUSD(Number(feeValue), feeQuote)
const isAmountSmall = !Number(tokenUsd) && !!Number(value)

return {
transaction: {
tokenValue: {
balance: value.toString(),
symbolType: 'icon',
symbol: symbol || feeSymbol,
symbolType: 'icon',
balance: value.toString(),
},
usdValue: {
balance: tokenUsd,
symbol: isAmountSmall ? '<' : '$',
symbolType: 'usd',
symbol: '$',
balance: isAmountSmall ? '0.01' : tokenUsd,
},
fee: {
tokenValue: feeValue,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2045,10 +2045,10 @@
"@rsksmart/rif-wallet-token" "*"
axios "^0.27.2"

"@rsksmart/rif-wallet-abi-enhancer@^1.0.5":
version "1.0.5"
resolved "https://npm.pkg.github.com/download/@rsksmart/rif-wallet-abi-enhancer/1.0.5/1b438b530e1a136b308352cbf80221cea6930d06#1b438b530e1a136b308352cbf80221cea6930d06"
integrity sha512-XbnOlNCyXA7O7tgoXF4SAg0nHMFQC7QYmtENFgFFsxcetx9kawu5DuQFHLHbvcj8+QFvWKkXQL/Dt24vf4//0A==
"@rsksmart/rif-wallet-abi-enhancer@^1.0.7":
version "1.0.7"
resolved "https://npm.pkg.github.com/download/@rsksmart/rif-wallet-abi-enhancer/1.0.7/c33b6fe6903427dbadafd9dbeb1472f0e1b1ea15#c33b6fe6903427dbadafd9dbeb1472f0e1b1ea15"
integrity sha512-hw+ZuPlPGvOcpzwqX6dNj4qNdfefiZCSYMF2wcwFXD/IsoeE0ZYFWD7xkvgfb8nDcCRBPdlj0ALwxkoTuW7qWA==
dependencies:
"@ethersproject/abi" "^5.7.0"
"@ethersproject/abstract-provider" "^5.7.0"
Expand Down
Loading