Skip to content

Commit

Permalink
US-1873: Security - Misleading send transaction UX when sending small…
Browse files Browse the repository at this point in the history
… amounts (#744)

* update abi-enhancer lib

* handle receive small amounts from dapp

* update abi-enhancer

* add less than symbol for small amounts
  • Loading branch information
rodrigoncalves authored Sep 29, 2023
1 parent d521f4f commit 1c56a15
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
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

0 comments on commit 1c56a15

Please sign in to comment.