-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(swap): Allow cancellation of an open order (#2683)
- Loading branch information
Showing
40 changed files
with
1,731 additions
and
647 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...llet-mobile/src/features/Send/useCases/StartMultiTokenTx/InputReceiver/ResolveAddress.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
.../features/Swap/common/ConfirmWithSpendingPassword/ConfirmWithSpendingPassword.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {storiesOf} from '@storybook/react-native' | ||
import React from 'react' | ||
import {StyleSheet, View} from 'react-native' | ||
|
||
import {ConfirmWithSpendingPassword} from './ConfirmWithSpendingPassword' | ||
|
||
storiesOf('ConfirmWithSpendingPassword', module) | ||
.addDecorator((story) => <View style={styles.container}>{story()}</View>) | ||
.add('Initial', () => <ConfirmWithSpendingPassword />) | ||
.add('Loading', () => <ConfirmWithSpendingPassword isLoading />) | ||
.add('Error', () => <ConfirmWithSpendingPassword error={new Error('Example error')} />) | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
padding: 16, | ||
}, | ||
}) |
85 changes: 85 additions & 0 deletions
85
...bile/src/features/Swap/common/ConfirmWithSpendingPassword/ConfirmWithSpendingPassword.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from 'react' | ||
import {ActivityIndicator, StyleSheet, TextInput as RNTextInput, View} from 'react-native' | ||
|
||
import {Button, Spacer, Text, TextInput} from '../../../../components' | ||
import {debugWalletInfo, features} from '../../../../features' | ||
import {COLORS} from '../../../../theme' | ||
import {WrongPassword} from '../../../../yoroi-wallets/cardano/errors' | ||
import {useStrings} from '../../common/strings' | ||
|
||
type Props = { | ||
onSubmit?: (spendingPassword: string) => void | ||
isLoading?: boolean | ||
error?: Error | ||
} | ||
|
||
export const ConfirmWithSpendingPassword = ({onSubmit, isLoading, error}: Props) => { | ||
const spendingPasswordRef = React.useRef<RNTextInput>(null) | ||
const [spendingPassword, setSpendingPassword] = React.useState( | ||
features.prefillWalletInfo ? debugWalletInfo.PASSWORD : '', | ||
) | ||
const strings = useStrings() | ||
|
||
return ( | ||
<> | ||
<Text style={styles.modalText}>{strings.enterSpendingPassword}</Text> | ||
|
||
<TextInput | ||
secureTextEntry | ||
ref={spendingPasswordRef} | ||
enablesReturnKeyAutomatically | ||
placeholder={strings.spendingPassword} | ||
value={spendingPassword} | ||
onChangeText={setSpendingPassword} | ||
autoComplete="off" | ||
/> | ||
|
||
{error != null && ( | ||
<View> | ||
<Text style={styles.errorMessage} numberOfLines={3}> | ||
{getErrorMessage(error, strings)} | ||
</Text> | ||
</View> | ||
)} | ||
|
||
<Spacer fill /> | ||
|
||
<Button testID="swapButton" shelleyTheme title={strings.sign} onPress={() => onSubmit?.(spendingPassword)} /> | ||
|
||
{isLoading && ( | ||
<View style={styles.loading}> | ||
<ActivityIndicator size="large" color="black" /> | ||
</View> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
const getErrorMessage = (error: unknown, strings: Record<'wrongPasswordMessage' | 'error', string>) => { | ||
if (error instanceof WrongPassword) { | ||
return strings.wrongPasswordMessage | ||
} | ||
if (error instanceof Error) { | ||
return error.message | ||
} | ||
|
||
return strings.error | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
modalText: { | ||
paddingHorizontal: 70, | ||
textAlign: 'center', | ||
paddingBottom: 8, | ||
}, | ||
errorMessage: { | ||
color: COLORS.ERROR_TEXT_COLOR, | ||
}, | ||
loading: { | ||
position: 'absolute', | ||
height: '100%', | ||
width: '100%', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}) |
1 change: 1 addition & 0 deletions
1
apps/wallet-mobile/src/features/Swap/common/ConfirmWithSpendingPassword/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {ConfirmWithSpendingPassword} from './ConfirmWithSpendingPassword' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.