Skip to content

Commit

Permalink
Merge branch 'develop' into us-2150
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoncalves committed Apr 18, 2024
2 parents 3fbc202 + 61cede3 commit 49ce1d8
Show file tree
Hide file tree
Showing 28 changed files with 358 additions and 297 deletions.
10 changes: 5 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ We are committed to conduct our security process in a professional and civil man

## Responsible Disclosure

For all security related issues, RIF Wallet has two main points of contact. Reach us at <security@iovlabs.org> or refer to our [Bug Bounty Program](https://www.iovlabs.org/bug-bounty-program). **Do not open up a GitHub issue if the bug is a security vulnerability**
For all security related issues, RIF Wallet has two main points of contact. Reach us at <security@rootstocklabs.com> or refer to our [Bug Bounty Program](https://www.rootstocklabs.com/bug-bounty-program). **Do not open up a GitHub issue if the bug is a security vulnerability**

**Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/rsksmart/rif-wallet/issues).

## Vulnerability Handling

### Response Time

RSK will make a best effort to meet the following response times for reported vulnerabilities:
RootstockLabs will make a best effort to meet the following response times for reported vulnerabilities:

* Time to first response (from report submit) - 24 hours
* Time to triage (from report submit) - 2 business days
* Time to first response (from report submit) - 5 business days
* Time to triage (from report submit) - 7 business days
* Time to bounty (from triage) - 15 business days

We’ll try to keep you informed about our progress throughout the process.
Expand All @@ -25,7 +25,7 @@ We’ll try to keep you informed about our progress throughout the process.
* Follow HackerOne's [disclosure guidelines](https://www.hackerone.com/disclosure-guidelines).
* Public disclosure of a vulnerability makes it ineligible for a bounty.

For more information check RSK bounty program policy at [HackerOne](https://hackerone.com/iovlabs)
For more information check RootstockLabs bounty program policy at [HackerOne](https://hackerone.com/rootstocklabs)

## Public Keys

Expand Down
2 changes: 2 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true

VisionCamera_enableCodeScanner=true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"react-native-ssl-public-key-pinning": "^1.1.3",
"react-native-svg": "13.4.0",
"react-native-vector-icons": "^10.0.3",
"react-native-vision-camera": "^3.9.0",
"react-native-vision-camera": "^3.9.1",
"react-redux": "^8.0.5",
"readable-stream": "1.0.33",
"redux-persist": "^6.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/BasicRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface BasicRowProps {
amount?: string
status?: StatusTextProps['status']
error?: string
usdAmount?: number
usdAmount?: string
style?: StyleProp<ViewStyle>
symbol?: string
}
Expand Down Expand Up @@ -110,14 +110,14 @@ export const BasicRow = ({
)}
</View>
<View style={styles.usdAmountView}>
{usdAmount !== undefined && (
{usdAmount && (
<Typography
accessibilityLabel={`usdAmount-${index}`}
type="labelLight"
numberOfLines={1}
ellipsizeMode="tail"
style={styles.usdText}>
{!usdAmount && '< '}${usdAmount ? usdAmount.toFixed(2) : '0.01'}
{usdAmount}
</Typography>
)}
</View>
Expand Down
14 changes: 8 additions & 6 deletions src/components/QRCodeScanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface QRCodeScannerProps {
}

export const QRCodeScanner = ({ onClose, onCodeRead }: QRCodeScannerProps) => {
const [barcode, setBarcode] = useState<Code | null>(null)
const codeScanner = useCodeScanner({
codeTypes: ['qr', 'ean-13'],
onCodeScanned: codes => {
Expand All @@ -34,10 +35,9 @@ export const QRCodeScanner = ({ onClose, onCodeRead }: QRCodeScannerProps) => {
},
})
const { t } = useTranslation()
const device = useCameraDevice('back')
const [barcode, setBarcode] = useState<Code | null>(null)
const dispatch = useAppDispatch()
const isFocused = useIsFocused()
const dispatch = useAppDispatch()
const device = useCameraDevice('back')

useCheckCameraPermissions({ t, isFocused })

Expand All @@ -63,10 +63,12 @@ export const QRCodeScanner = ({ onClose, onCodeRead }: QRCodeScannerProps) => {
</View>
) : (
<Camera
isActive={isFocused}
device={device}
style={StyleSheet.absoluteFill}
torch="off"
device={device}
isActive={true}
photo={false}
video={false}
audio={false}
codeScanner={codeScanner}
/>
)}
Expand Down
31 changes: 11 additions & 20 deletions src/components/token/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import { ContactCard } from 'screens/contacts/components'
import { TokenImage, TokenSymbol } from 'screens/home/TokenImage'
import { noop, sharedColors, sharedStyles, testIDs } from 'shared/constants'
import { ContactWithAddressRequired } from 'shared/types'
import { castStyle, formatTokenValues } from 'shared/utils'
import { castStyle, formatTokenValue, formatFiatValue } from 'shared/utils'

import { DollarIcon } from '../icons/DollarIcon'
import { EyeIcon } from '../icons/EyeIcon'

export interface CurrencyValue {
symbol: TokenSymbol | string
symbolType: 'usd' | 'icon'
balance: string
balance: number | string
}

interface Props {
Expand Down Expand Up @@ -70,8 +70,8 @@ export const TokenBalance = ({
firstValue.symbol?.toUpperCase() === 'TRIF'

const firstValueBalance = editable
? firstValue.balance
: formatTokenValues(firstValue.balance)
? firstValue.balance.toString()
: formatTokenValue(firstValue.balance)

const onCopyAddress = useCallback(() => {
if (contact) {
Expand Down Expand Up @@ -106,7 +106,7 @@ export const TokenBalance = ({
)}
<TextInput
onChangeText={handleAmountChange}
value={hide ? '\u002A\u002A\u002A\u002A' : firstValueBalance}
value={hide ? '\u002A\u002A\u002A\u002A\u002A' : firstValueBalance}
keyboardType="numeric"
accessibilityLabel={'Amount.Input'}
placeholder="0"
Expand All @@ -123,23 +123,13 @@ export const TokenBalance = ({
<TokenImage symbol={secondValue.symbol} />
</View>
)}
{secondValue?.symbolType === 'usd' && (
<>
{secondValue.symbol === '<' && (
<Typography type="body1" style={styles.secondValue}>
{'<'}
</Typography>
)}
<DollarIcon size={16} color={sharedColors.text.label} />
</>
)}
{!isNaN(Number(secondValue?.balance)) && (
{secondValue && (
<Typography type="body1" style={styles.secondValue}>
{hide
? '\u002A\u002A\u002A\u002A\u002A\u002A'
: secondValue
? formatTokenValues(secondValue.balance)
: ''}
? '\u002A\u002A\u002A\u002A\u002A'
: secondValue.symbolType === 'usd'
? formatFiatValue(secondValue.balance)
: formatTokenValue(secondValue.balance)}
</Typography>
)}
{error && (
Expand Down Expand Up @@ -235,6 +225,7 @@ const styles = StyleSheet.create({
borderRadius: 10,
width: 20,
height: 20,
marginRight: 4,
}),
secondValue: castStyle.text({
color: sharedColors.text.label,
Expand Down
4 changes: 2 additions & 2 deletions src/core/Core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Core = () => {
const topColor = useAppSelector(selectTopColor)
const setGlobalError = useSetGlobalError()
const isOffline = useIsOffline()
const { active } = useStateSubscription()
const { active, unlocked } = useStateSubscription()
const { wallet, initializeWallet } = useContext(WalletContext)

const unlockAppFn = useCallback(async () => {
Expand All @@ -62,7 +62,7 @@ export const Core = () => {
<WalletConnect2Provider wallet={wallet}>
<>
<RootNavigationComponent />
{requests.length !== 0 && wallet && (
{requests.length !== 0 && wallet && unlocked && (
<RequestHandler
wallet={wallet}
request={requests[0]}
Expand Down
5 changes: 5 additions & 0 deletions src/core/hooks/useStateSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
setPreviouslyUnlocked,
setUnlocked as setIsUnlocked,
unlockApp,
closeRequest,
setFullscreen,
} from 'store/slices/settingsSlice'
import { useAppDispatch, useAppSelector } from 'store/storeUtils'
import { SocketsEvents, socketsEvents } from 'src/subscriptions/rifSockets'
Expand Down Expand Up @@ -52,6 +54,9 @@ export const useStateSubscription = () => {

setUnlocked(false)
dispatch(setPreviouslyUnlocked(true))
// request needs to be reset when gracePeriod is over
dispatch(closeRequest())
dispatch(setFullscreen(false))
//reset wallet state
setWallet(null)
setWalletIsDeployed(null)
Expand Down
2 changes: 2 additions & 0 deletions src/redux/slices/settingsSlice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
import { addressToUse, Wallet } from 'shared/wallet'
import { createAppWallet, loadAppWallet } from 'shared/utils'
import { MMKVStorage } from 'storage/MMKVStorage'
import { deleteWCSessions } from 'screens/walletConnect/walletConnect2.utils'

import {
Bitcoin,
Expand Down Expand Up @@ -346,6 +347,7 @@ export const resetApp = createAsyncThunk(
thunkAPI.dispatch(setKeysExist(false))
resetMainStorage()
resetReduxStorage()
deleteWCSessions()
return 'deleted'
} catch (err) {
return thunkAPI.rejectWithValue(err)
Expand Down
2 changes: 1 addition & 1 deletion src/redux/slices/transactionsSlice/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface IBitcoinTransaction {

export interface TokenFeeValueObject {
tokenValue: string
usdValue: string
usdValue: number | string
symbol?: TokenSymbol | string
}

Expand Down
84 changes: 40 additions & 44 deletions src/screens/activity/ActivityRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next'
import { StyleProp, ViewStyle } from 'react-native'
import { ZERO_ADDRESS } from '@rsksmart/rif-relay-light-sdk'

import { roundBalance, shortAddress } from 'lib/utils'
import { shortAddress } from 'lib/utils'

import { isMyAddress } from 'components/address/lib'
import { StatusEnum } from 'components/BasicRow'
Expand All @@ -15,7 +15,9 @@ import { ActivityMainScreenProps } from 'shared/types'
import { useAppSelector } from 'store/storeUtils'
import { getContactByAddress } from 'store/slices/contactsSlice'
import { ActivityRowPresentationObject } from 'store/slices/transactionsSlice'
import { formatTokenValue, formatFiatValue } from 'shared/utils'
import { Wallet, useWallet } from 'shared/wallet'
import { TransactionStatus } from 'store/shared/types'

const getStatus = (status: string) => {
switch (status) {
Expand Down Expand Up @@ -53,7 +55,7 @@ export const ActivityBasicRow = ({
timeHumanFormatted,
from = '',
to = '',
price,
price: usdValue,
id,
} = activityDetails
const { address: walletAddress } = useWallet()
Expand All @@ -76,68 +78,62 @@ export const ActivityBasicRow = ({
label = t('wallet_deployment_label')
}

// USD Balance
const usdBalance = roundBalance(price, 2)
const txSummary: TransactionSummaryScreenProps = useMemo(() => {
const totalUsd = isNaN(usdValue) ? '' : usdValue + Number(fee.usdValue)
const feeUsd = isNaN(+fee.usdValue) ? '' : fee.usdValue
const usdAmount = isNaN(usdValue) ? '' : usdValue

const txSummary: TransactionSummaryScreenProps = useMemo(
() => ({
const totalToken =
symbol === fee.symbol
? Number(value) + Number(fee.tokenValue)
: Number(value)

return {
transaction: {
tokenValue: {
symbol,
symbolType: 'icon',
balance: value,
},
usdValue: {
symbol: usdBalance ? '$' : '<',
symbol: '$',
symbolType: 'usd',
balance: usdBalance ? usdBalance : '0.01',
balance: usdAmount,
},
totalToken:
symbol === fee.symbol
? Number(value) + Number(fee.tokenValue)
: Number(value),
totalUsd: Number(value) + Number(fee.usdValue),
status,
fee: {
...fee,
symbol: fee.symbol || symbol,
usdValue: fee.usdValue,
tokenValue: fee.tokenValue,
usdValue: feeUsd,
},
totalToken,
totalUsd,
status: status.toUpperCase() as TransactionStatus,
amIReceiver,
from,
to,
time: timeHumanFormatted,
hashId: id,
},
contact: contact || { address },
}),
[
address,
amIReceiver,
contact,
fee,
from,
to,
status,
symbol,
timeHumanFormatted,
usdBalance,
value,
id,
],
)

const amount = useMemo(() => {
if (symbol.startsWith('BTC')) {
return value
}
const num = Number(value)
let rounded = roundBalance(num, 4)
if (!rounded) {
rounded = roundBalance(num, 8)
}
return rounded.toString()
}, [value, symbol])
}, [
fee,
symbol,
value,
usdValue,
status,
amIReceiver,
from,
to,
timeHumanFormatted,
id,
contact,
address,
])

const amount = symbol.startsWith('BTC') ? value : formatTokenValue(value)
const isUnknownToken = !usdValue && Number(value) > 0
const usdAmount = isUnknownToken ? '' : formatFiatValue(usdValue)

const handlePress = useCallback(() => {
if (txSummary) {
Expand All @@ -158,7 +154,7 @@ export const ActivityBasicRow = ({
status={getStatus(status)}
avatar={{ name: 'A' }}
secondaryLabel={timeHumanFormatted}
usdAmount={price === 0 ? undefined : usdBalance}
usdAmount={usdAmount}
contact={contact}
/>
</AppTouchable>
Expand Down
Loading

0 comments on commit 49ce1d8

Please sign in to comment.