Skip to content

Commit

Permalink
fixes(release 4.25.0) (#3071)
Browse files Browse the repository at this point in the history
  • Loading branch information
SorinC6 authored Feb 7, 2024
1 parent b4d059c commit bd3e7c8
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 135 deletions.
42 changes: 42 additions & 0 deletions apps/wallet-mobile/src/components/Warning/Warning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {useTheme} from '@yoroi/theme'
import React from 'react'
import {StyleSheet, Text, View} from 'react-native'

import {Icon} from '../Icon'
import {Spacer} from '../Spacer'

type Props = {content: string}

export const Warning = ({content}: Props) => {
const {styles, colors} = useStyles()

return (
<View style={styles.notice}>
<Icon.Info size={30} color={colors.yellow} />

<Spacer height={8} />

<Text style={styles.text}>{content}</Text>
</View>
)
}

const useStyles = () => {
const {theme} = useTheme()
const {color, typography} = theme
const styles = StyleSheet.create({
notice: {
backgroundColor: color.yellow[100],
padding: 12,
},
text: {
...typography['body-2-regular'],
},
})

const colors = {
yellow: color.yellow[500],
}

return {colors, styles}
}
1 change: 1 addition & 0 deletions apps/wallet-mobile/src/components/Warning/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Warning'
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {useTokenInfo} from '../../../yoroi-wallets/hooks'
import {Amounts, Quantities} from '../../../yoroi-wallets/utils'
import {useStrings} from './useStrings'

const MIN_ADA_LIMIT = 100000000

export const useRampOnOff = () => React.useContext(RampOnOffContext)

export const RampOnOffProvider = ({
Expand Down Expand Up @@ -65,7 +67,7 @@ export const RampOnOffProvider = ({
const isNotEnoughBalance = new BigNumber(state.amount.value).isGreaterThan(new BigNumber(amountBalance))

React.useEffect(() => {
actions.canExchangeChanged(state.amount.value !== 0 && state.amount.error === undefined)
actions.canExchangeChanged(state.amount.value >= MIN_ADA_LIMIT && state.amount.error === undefined)
}, [actions, state.amount.error, state.amount.value])

// amount input errors
Expand All @@ -76,6 +78,11 @@ export const RampOnOffProvider = ({
return
}

if (state.amount.value > 0 && state.amount.value < MIN_ADA_LIMIT && state.orderType === 'buy') {
actions.amountErrorChanged(strings.minAdaRequired)
return
}

if (
(!Quantities.isZero(amountBalance) && !isNotEnoughBalance && state.amount.isTouched) ||
state.orderType === 'buy'
Expand All @@ -92,6 +99,8 @@ export const RampOnOffProvider = ({
state.orderType,
strings.notEnoughBalance,
clearErrors,
state.amount.value,
strings.minAdaRequired,
])

const context = React.useMemo(
Expand Down
10 changes: 10 additions & 0 deletions apps/wallet-mobile/src/features/RampOnOff/common/useStrings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ export const useStrings = () => {
fiatAmountYouGet: intl.formatMessage(messages.fiatAmountYouGet),
goToTransactions: intl.formatMessage(messages.goToTransactions),
notEnoughBalance: intl.formatMessage(messages.notEnoughBalance),
minAdaRequired: intl.formatMessage(messages.minAdaRequired),
proceed: intl.formatMessage(messages.proceed),
provider: intl.formatMessage(messages.provider),
providerFee: intl.formatMessage(messages.providerFee),
rampOnOffTitle: intl.formatMessage(messages.rampOnOffTitle),
sellCrypto: intl.formatMessage(messages.sellCrypto),
significant: intl.formatMessage(messages.significant),
sellCurrencyWarning: intl.formatMessage(messages.sellCurrencyWarning),
title: intl.formatMessage(messages.title),
getFirstCrypto: intl.formatMessage(messages.getFirstCrypto),
ourTrustedPartners: intl.formatMessage(messages.ourTrustedPartners),
Expand Down Expand Up @@ -85,6 +87,14 @@ export const messages = Object.freeze(
id: 'swap.swapScreen.notEnoughBalance',
defaultMessage: '!!!Not Enough Balannce',
},
minAdaRequired: {
id: 'rampOnOff.createRampOnOff.minAdaRequired',
defaultMessage: '!!!Minimum required is 100 ADA',
},
sellCurrencyWarning: {
id: 'rampOnOff.createRampOnOff.sellCurrencyWarning',
defaultMessage: '!!!You can currently sell only to USD using ACH.',
},
congrats: {
id: 'rampOnOff.resultRampOnOff.congrats',
defaultMessage: '!!!Congrats🎉 Your ADA will come in a few minutes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import * as React from 'react'
import {Linking, StyleSheet, useWindowDimensions, View} from 'react-native'
import {ScrollView} from 'react-native-gesture-handler'

import {Button, KeyboardAvoidingView} from '../../../../components'
import {Button, KeyboardAvoidingView, Spacer} from '../../../../components'
import {Warning} from '../../../../components/Warning'
import {RAMP_ON_OFF_PATH, SCHEME_URL} from '../../../../legacy/config'
import env from '../../../../legacy/env'
import {useMetrics} from '../../../../metrics/metricsManager'
Expand Down Expand Up @@ -89,6 +90,10 @@ export const CreateExchange = () => {

<ShowProviderFee />

<Spacer height={16} />

{orderType === 'sell' && <Warning content={strings.sellCurrencyWarning} />}

<ShowDisclaimer />
</View>
</ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import {isNameServer, nameServerName} from '@yoroi/resolver'
import {Resolver} from '@yoroi/types'
import * as React from 'react'
import {ReactNode} from 'react'
import {Animated, StyleSheet, Text as RNText, View} from 'react-native'
import {Animated, StyleSheet} from 'react-native'

import {Icon} from '../../../../../components/Icon'
import {Spacer} from '../../../../../components/Spacer/Spacer'
import {Text} from '../../../../../components/Text'
import {Warning} from '../../../../../components/Warning'
import {ButtonGroup} from '../../../common/ButtonGroup/ButtonGroup'
import {useSend} from '../../../common/SendContext'
import {useStrings} from '../../../common/strings'

export const SelectNameServer = () => {
const strings = useStrings()
const {targets, selectedTargetIndex, nameServerSelectedChanged} = useSend()
const receiver = targets[selectedTargetIndex].receiver
const {addressRecords} = receiver
Expand Down Expand Up @@ -58,7 +59,7 @@ export const SelectNameServer = () => {
<>
<Spacer height={16} />

<ShowManyAddressWarning />
<Warning content={String(strings.manyNameServersWarning(bold))} />
</>
)}
</>
Expand All @@ -67,20 +68,6 @@ export const SelectNameServer = () => {
)
}

export const ShowManyAddressWarning = () => {
const strings = useStrings()

return (
<View style={styles.notice}>
<Icon.Info size={30} color="#ECBA09" />

<Spacer height={8} />

<RNText style={styles.text}>{strings.manyNameServersWarning(bold)}</RNText>
</View>
)
}

const toAddressRecordsEntries = (addressRecords: Resolver.Receiver['addressRecords']) =>
Object.entries(addressRecords ?? {}).reduce((acc, [key, value]) => {
if (isNameServer(key)) {
Expand All @@ -92,16 +79,6 @@ const toAddressRecordsEntries = (addressRecords: Resolver.Receiver['addressRecor
const bold = {b: (text: ReactNode) => <Text style={styles.bold}>{text}</Text>}

const styles = StyleSheet.create({
notice: {
backgroundColor: '#FDF7E2',
padding: 12,
},
text: {
fontSize: 14,
lineHeight: 22,
fontWeight: '400',
fontFamily: 'Rubik-Regular',
},
bold: {
fontWeight: '500',
fontFamily: 'Rubik-Medium',
Expand Down
6 changes: 4 additions & 2 deletions apps/wallet-mobile/src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@
"global.sign": "sign",
"global.signTransaction": "Sign transaction",
"global.spendingPassword": "Spending Password",
"global.exchange": "Exchange",
"global.exchange": "Buy/Sell",
"global.staking.epochLabel": "Epoch",
"global.staking.stakePoolHash": "Stake pool hash",
"global.staking.stakePoolName": "Stake pool name",
Expand Down Expand Up @@ -882,7 +882,9 @@
"rampOnOff.createRampOnOff.providerFee": "Provider Fee",
"rampOnOff.createRampOnOff.provider": "Provider",
"rampOnOff.createRampOnOff.banxa": "Banxa",
"rampOnOff.rampOnOffScreen.rampOnOffTitle": "Exchange ADA",
"rampOnOff.createRampOnOff.minAdaRequired": "Minimum required is 100 ADA",
"rampOnOff.createRampOnOff.sellCurrencyWarning": "You can currently sell only to USD using ACH.",
"rampOnOff.rampOnOffScreen.rampOnOffTitle": "Buy/Sell ADA",
"rampOnOff.resultRampOnOff.congrats": "Congrats! 🎉 Your transaction is now in progress. You should be receiving funds soon.",
"rampOnOff.resultRampOnOff.cryptoAmountYouGet": "ADA amount you get",
"rampOnOff.resultRampOnOff.fiatAmountYouGet": "Fiat amount you sell",
Expand Down
Loading

0 comments on commit bd3e7c8

Please sign in to comment.