Skip to content

Commit 7dcc408

Browse files
committed
merge develop
2 parents 172d780 + 7c93737 commit 7dcc408

File tree

35 files changed

+2712
-971
lines changed

35 files changed

+2712
-971
lines changed

apps/wallet-mobile/.storybook/storybook.requires.js

+18-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/wallet-mobile/src/YoroiApp.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ const Yoroi = () => {
6969
<ReviewTxProvider>
7070
<InitApp />
7171
</ReviewTxProvider>
72+
<ReviewTxProvider>
73+
<InitApp />
74+
</ReviewTxProvider>
7275
</AutomaticWalletOpenerProvider>
7376
</BrowserProvider>
7477
</PoolTransitionProvider>

apps/wallet-mobile/src/features/ReviewTx/common/Divider.tsx apps/wallet-mobile/src/components/Divider/Divider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {SpacingSize, useTheme} from '@yoroi/theme'
22
import * as React from 'react'
33
import {StyleSheet, View} from 'react-native'
44

5-
import {Space} from '../../../components/Space/Space'
5+
import {Space} from '../Space/Space'
66

77
export const Divider = ({verticalSpace = 'none'}: {verticalSpace?: SpacingSize}) => {
88
const {styles} = useStyles()

apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/Overview/OverviewTab.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {useSelectedWallet} from '../../../../WalletManager/common/hooks/useSelec
1313
import {useWalletManager} from '../../../../WalletManager/context/WalletManagerProvider'
1414
import {Accordion} from '../../../common/Accordion'
1515
import {CopiableText} from '../../../common/CopiableText'
16-
import {Divider} from '../../../common/Divider'
16+
import {Divider} from '../../../../../components/Divider/Divider'
1717
import {useAddressType} from '../../../common/hooks/useAddressType'
1818
import {useStrings} from '../../../common/hooks/useStrings'
1919
import {ReviewTxState} from '../../../common/ReviewTxProvider'

apps/wallet-mobile/src/features/ReviewTx/useCases/ReviewTxScreen/UTxOs/UTxOsTab.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {StyleSheet, Text, View} from 'react-native'
55
import {Space} from '../../../../../components/Space/Space'
66
import {Accordion} from '../../../common/Accordion'
77
import {CopiableText} from '../../../common/CopiableText'
8-
import {Divider} from '../../../common/Divider'
8+
import {Divider} from '../../../../../components/Divider/Divider'
99
import {useStrings} from '../../../common/hooks/useStrings'
1010
import {TokenItem} from '../../../common/TokenItem'
1111
import {FormattedInput, FormattedInputs, FormattedOutput, FormattedOutputs, FormattedTx} from '../../../common/types'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import {defineMessages, useIntl} from 'react-intl'
2+
3+
export const useStrings = () => {
4+
const intl = useIntl()
5+
return {
6+
lockedAsCollateral: intl.formatMessage(messages.lockedAsCollateral),
7+
removeCollateral: intl.formatMessage(messages.removeCollateral),
8+
collateralSpent: intl.formatMessage(messages.collateralSpent),
9+
generateCollateral: intl.formatMessage(messages.generateCollateral),
10+
notEnoughFundsAlertTitle: intl.formatMessage(messages.notEnoughFundsAlertTitle),
11+
notEnoughFundsAlertMessage: intl.formatMessage(messages.notEnoughFundsAlertMessage),
12+
notEnoughFundsAlertOK: intl.formatMessage(messages.notEnoughFundsAlertOK),
13+
collateralInfoModalLabel: intl.formatMessage(messages.collateralInfoModalLabel),
14+
collateralInfoModalTitle: intl.formatMessage(messages.collateralInfoModalTitle),
15+
collateralInfoModalText: intl.formatMessage(messages.collateralInfoModalText),
16+
initialCollateralInfoModalTitle: intl.formatMessage(messages.initialCollateralInfoModalTitle),
17+
initialCollateralInfoModalText: intl.formatMessage(messages.initialCollateralInfoModalText),
18+
initialCollateralInfoModalButton: intl.formatMessage(messages.initialCollateralInfoModalButton),
19+
}
20+
}
21+
22+
const messages = defineMessages({
23+
lockedAsCollateral: {
24+
id: 'components.settings.collateral.lockedAsCollateral',
25+
defaultMessage: '!!!Locked as collateral',
26+
},
27+
removeCollateral: {
28+
id: 'components.settings.collateral.removeCollateral',
29+
defaultMessage: '!!!If you want to return the amount locked as collateral to your balance press the remove icon',
30+
},
31+
collateralSpent: {
32+
id: 'components.settings.collateral.collateralSpent',
33+
defaultMessage: '!!!Your collateral is gone, please generate new collateral',
34+
},
35+
generateCollateral: {
36+
id: 'components.settings.collateral.generateCollateral',
37+
defaultMessage: '!!!Generate collateral',
38+
},
39+
notEnoughFundsAlertTitle: {
40+
id: 'components.settings.collateral.notEnoughFundsAlertTitle',
41+
defaultMessage: '!!!Not enough funds',
42+
},
43+
notEnoughFundsAlertMessage: {
44+
id: 'components.settings.collateral.notEnoughFundsAlertMessage',
45+
defaultMessage: '!!!We could not find enough funds in this wallet to create collateral.',
46+
},
47+
notEnoughFundsAlertOK: {
48+
id: 'components.settings.collateral.notEnoughFundsAlertOK',
49+
defaultMessage: '!!!OK',
50+
},
51+
collateralInfoModalLabel: {
52+
id: 'components.settings.collateral.collateralInfoModalLabel',
53+
defaultMessage: '!!!Collateral creation',
54+
},
55+
collateralInfoModalTitle: {
56+
id: 'components.settings.collateral.collateralInfoModalTitle',
57+
defaultMessage: '!!!What is collateral?',
58+
},
59+
collateralInfoModalText: {
60+
id: 'components.settings.collateral.collateralInfoModalText',
61+
defaultMessage:
62+
'!!!The collateral mechanism is an important feature that has been designed to ensure successful smart contract execution. It is used to guarantee that Cardano nodes are compensated for their work in case phase-2 validation fails.',
63+
},
64+
initialCollateralInfoModalTitle: {
65+
id: 'components.settings.collateral.initialCollateralInfoModalTitle',
66+
defaultMessage: '!!!Collateral creation',
67+
},
68+
initialCollateralInfoModalText: {
69+
id: 'components.settings.collateral.initialCollateralInfoModalText',
70+
defaultMessage:
71+
'!!!The collateral mechanism is designed to ensure smart contracts on Cardano execute successfully. It guarantees that nodes are compensated for their work if a contract fails during validation.',
72+
},
73+
initialCollateralInfoModalButton: {
74+
id: 'components.settings.collateral.initialCollateralInfoModalButton',
75+
defaultMessage: '!!!Add collateral',
76+
},
77+
})

apps/wallet-mobile/src/features/Settings/useCases/changeWalletSettings/ManageCollateral/ManageCollateralScreen.tsx

+69
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
TouchableOpacity,
1111
TouchableOpacityProps,
1212
useWindowDimensions,
13+
useWindowDimensions,
1314
View,
1415
ViewProps,
1516
} from 'react-native'
@@ -39,6 +40,7 @@ import {useSelectedWallet} from '../../../../WalletManager/common/hooks/useSelec
3940
import {CollateralInfoModal} from './CollateralInfoModal'
4041
import {createCollateralEntry} from './helpers'
4142
import {InitialCollateralInfoModal} from './InitialCollateralInfoModal'
43+
import {InitialCollateralInfoModal} from './InitialCollateralInfoModal'
4244
import {useNavigateTo} from './navigation'
4345
import {useStrings} from './strings'
4446

@@ -49,15 +51,19 @@ export const ManageCollateralScreen = () => {
4951
meta: {addressMode},
5052
} = useSelectedWallet()
5153
const screenHeight = useWindowDimensions().height
54+
const screenHeight = useWindowDimensions().height
5255
const {amount, collateralId, utxo} = useCollateralInfo(wallet)
5356
const hasCollateral = collateralId !== '' && utxo !== undefined
5457
const didSpend = collateralId !== '' && utxo === undefined
5558
const navigateTo = useNavigateTo()
5659
const {openModal} = useModal()
60+
const {openModal} = useModal()
5761
const strings = useStrings()
5862
const balances = useBalances(wallet)
5963
const {navigateToTxReview} = useWalletNavigation()
6064
const {unsignedTxChanged, onSuccessChanged, onErrorChanged, operationsChanged} = useReviewTx()
65+
const {navigateToTxReview} = useWalletNavigation()
66+
const {unsignedTxChanged, onSuccessChanged, onErrorChanged, operationsChanged} = useReviewTx()
6167
const lockedAmount = asQuantity(wallet.primaryBreakdown.lockedAsStorageCost.toString())
6268

6369
const params = useUnsafeParams<SettingsStackRoutes['manage-collateral']>()
@@ -88,6 +94,16 @@ export const ManageCollateralScreen = () => {
8894
navigateTo.failedTx()
8995
}
9096

97+
const onSuccess = (signedTx: YoroiSignedTx) => {
98+
navigateTo.submittedTx()
99+
const collateralId = `${signedTx.signedTx.id}:0`
100+
setCollateralId(collateralId)
101+
}
102+
103+
const onError = () => {
104+
navigateTo.failedTx()
105+
}
106+
91107
const createCollateralTransaction = () => {
92108
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
93109

@@ -98,6 +114,11 @@ export const ManageCollateralScreen = () => {
98114
onSuccessChanged(onSuccess)
99115
onErrorChanged(onError)
100116
navigateToTxReview()
117+
unsignedTxChanged(yoroiUnsignedTx)
118+
operationsChanged([<Operation key="0" />])
119+
onSuccessChanged(onSuccess)
120+
onErrorChanged(onError)
121+
navigateToTxReview()
101122
},
102123
})
103124
}
@@ -137,6 +158,14 @@ export const ManageCollateralScreen = () => {
137158
)
138159
}
139160

161+
const handleCollateralInfoModal = () => {
162+
openModal(
163+
strings.initialCollateralInfoModalTitle,
164+
<InitialCollateralInfoModal onConfirm={handleGenerateCollateral} />,
165+
Math.min(screenHeight * 0.9, 650),
166+
)
167+
}
168+
140169
const shouldShowPrimaryButton = !hasCollateral || didSpend
141170
const shouldShowBackButton = !shouldShowPrimaryButton && !!params?.backButton
142171

@@ -183,6 +212,7 @@ export const ManageCollateralScreen = () => {
183212
<Button
184213
title={strings.generateCollateral}
185214
onPress={handleCollateralInfoModal}
215+
onPress={handleCollateralInfoModal}
186216
shelleyTheme
187217
disabled={isLoading}
188218
/>
@@ -261,20 +291,49 @@ const Operation = () => {
261291
)
262292
}
263293

294+
const Operation = () => {
295+
const {styles, colors} = useStyles()
296+
const strings = useStrings()
297+
const {openModal} = useModal()
298+
299+
const handleOnPressInfo = () => {
300+
openModal(strings.collateralInfoModalTitle, <CollateralInfoModal />, 500)
301+
}
302+
303+
return (
304+
<View style={styles.operation}>
305+
<Text style={styles.operationText}>{strings.collateralInfoModalLabel}</Text>
306+
307+
<Space width="xs" />
308+
309+
<TouchableOpacity onPress={handleOnPressInfo}>
310+
<Info size={24} color={colors.iconColor} />
311+
</TouchableOpacity>
312+
</View>
313+
)
314+
}
315+
264316
const useStyles = () => {
317+
const {color, atoms} = useTheme()
265318
const {color, atoms} = useTheme()
266319
const styles = StyleSheet.create({
267320
safeAreaView: {
268321
backgroundColor: color.bg_color_max,
269322
...atoms.flex_1,
270323
...atoms.px_lg,
324+
...atoms.flex_1,
325+
...atoms.px_lg,
271326
},
272327
amountItem: {
273328
...atoms.flex_row,
274329
...atoms.justify_between,
275330
...atoms.align_center,
331+
...atoms.flex_row,
332+
...atoms.justify_between,
333+
...atoms.align_center,
276334
},
277335
heading: {
336+
...atoms.flex_1,
278337
...atoms.flex_1,
279338
alignSelf: 'center',
280339
},
@@ -286,11 +345,21 @@ const useStyles = () => {
286345
...atoms.body_2_md_regular,
287346
color: color.text_gray_medium,
288347
},
348+
operation: {
349+
...atoms.flex_row,
350+
...atoms.align_center,
351+
},
352+
operationText: {
353+
...atoms.body_2_md_regular,
354+
color: color.text_gray_medium,
355+
},
289356
})
290357

291358
const colors = {
292359
iconColor: color.gray_900,
360+
iconColor: color.gray_900,
293361
}
294362

295363
return {styles, colors} as const
364+
return {styles, colors} as const
296365
}

apps/wallet-mobile/src/features/Swap/common/navigation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const useNavigateTo = () => {
1414
selectSellToken: () => swapNavigation.navigate('swap-select-sell-token'),
1515
startSwap: () => swapNavigation.navigate('swap-start-swap', {screen: 'token-swap'}),
1616
confirmTx: () => swapNavigation.navigate('swap-confirm-tx'),
17+
reviewSwap: () => swapNavigation.navigate('swap-review'),
1718
submittedTx: (txId: string) => swapNavigation.navigate('swap-submitted-tx', {txId}),
1819
failedTx: () => swapNavigation.navigate('swap-failed-tx'),
1920
swapOpenOrders: () =>

0 commit comments

Comments
 (0)