Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jon/swap-success-update #5303

Merged
merged 2 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

## Unreleased

- added: "Transaction Details" button to `SwapSuccessScene`
- added: `WalletRestoreScene`
- added: Button to access the `WalletRestoreScene` on `WalletListScene` if applicable
- added: "Go to Parent Wallet" `WalletListMenuModal` option
- added: Earn Scene
- added: Include wallet creation date in wallet data in log output
- changed: Wording on `SwapSuccessScene`
- changed: `SettingsScene` disables "Restore Wallets" option if there are no wallets to restore
- changed: FIO Home Scene tile replaced with Earn
- changed: Stake Overview Scene `StakingReturnsCard` redesigned
Expand Down
22 changes: 21 additions & 1 deletion src/__tests__/scenes/SwapSuccessScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,27 @@ describe('SwapSuccessSceneComponent', () => {

const renderer = TestRenderer.create(
<FakeProviders initialState={fakeState}>
<SwapSuccessScene {...fakeSceneProps('swapSuccess', undefined)} />
<SwapSuccessScene
{...fakeSceneProps('swapSuccess', {
walletId: fakeCoreWallet.id,
edgeTransaction: {
blockHeight: 0,
currencyCode: 'BTC',
date: 1535752780.947, // 2018-08-31T21:59:40.947Z
isSend: false,
memos: [],
metadata: { name: 'timmy' },
nativeAmount: '12300000',
networkFee: '1',
otherParams: {},
ourReceiveAddresses: ['this is an address'],
signedTx: 'this is a signed tx',
tokenId: null,
txid: 'this is the txid',
walletId: fakeCoreWallet.id
}
})}
/>
</FakeProviders>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ exports[`SwapSuccessSceneComponent should render with loading props 1`] = `
]
}
>
Your exchange has been successfully completed!
Your exchange is being processed!
</Text>
<Text
adjustsFontSizeToFit={true}
Expand Down Expand Up @@ -320,7 +320,7 @@ exports[`SwapSuccessSceneComponent should render with loading props 1`] = `
]
}
>
Exchanges may take a few minutes and up to 24 hours to process.
Processing may take up to 24 hours to complete.
</Text>
</View>
</View>,
Expand Down
5 changes: 4 additions & 1 deletion src/components/scenes/SwapConfirmationScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ export const SwapConfirmationScene = (props: Props) => {
nativeAmount ${networkFee.nativeAmount}
`)

navigation.push('swapSuccess')
navigation.push('swapSuccess', {
edgeTransaction: result.transaction,
walletId: request.fromWallet.id
})

// Dispatch the success action and callback
onApprove()
Expand Down
31 changes: 24 additions & 7 deletions src/components/scenes/SwapSuccessScene.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EdgeTransaction } from 'edge-core-js'
import * as React from 'react'
import { View } from 'react-native'
import ConfettiCannon from 'react-native-confetti-cannon'
Expand All @@ -14,6 +15,11 @@ import { SceneWrapper } from '../common/SceneWrapper'
import { cacheStyles, Theme, useTheme } from '../services/ThemeContext'
import { EdgeText } from '../themed/EdgeText'

export interface SwapSuccessParams {
edgeTransaction: EdgeTransaction
walletId: string
}

interface Props extends EdgeSceneProps<'swapSuccess'> {}

const confettiProps = {
Expand All @@ -23,7 +29,8 @@ const confettiProps = {
}

export const SwapSuccessScene = (props: Props) => {
const { navigation } = props
const { navigation, route } = props
const { edgeTransaction, walletId } = route.params
const theme = useTheme()
const styles = getStyles(theme)

Expand All @@ -33,11 +40,15 @@ export const SwapSuccessScene = (props: Props) => {
const userId = useSelector(state => state.core.account.id)
const disklet = useSelector(state => state.core.disklet)

const done = useHandler(() => {
const handleDone = useHandler(() => {
setShowButton(false)
navigation.navigate('swapTab', { screen: 'swapCreate' })
})

const handleTransactionDetails = useHandler(() => {
navigation.replace('transactionDetails', { edgeTransaction, walletId })
})

useAsyncEffect(
async () => {
const show: boolean = await needToShowConfetti(userId, disklet)
Expand Down Expand Up @@ -65,13 +76,19 @@ export const SwapSuccessScene = (props: Props) => {
<View style={styles.container}>
<EdgeText style={styles.title}>{lstrings.exchange_congratulations}</EdgeText>
<EdgeText style={styles.text} numberOfLines={2}>
{lstrings.exchange_congratulations_msg}
{lstrings.exchange_congratulations_success}
</EdgeText>
<EdgeText style={[styles.text, styles.textInfo]} numberOfLines={3}>
{lstrings.exchange_congratulations_msg_info}
{lstrings.exchange_congratulations_note}
</EdgeText>
<EdgeAnim style={styles.animOverlay} visible={showButton} enter={fadeIn}>
<SceneButtons absolute primary={{ label: lstrings.string_done_cap, onPress: done }} />
<SceneButtons
primary={{ label: lstrings.string_done_cap, onPress: handleDone }}
secondary={{
label: lstrings.transaction_details,
onPress: handleTransactionDetails
}}
/>
</EdgeAnim>
{renderConfetti()}
</View>
Expand All @@ -82,8 +99,8 @@ export const SwapSuccessScene = (props: Props) => {
const getStyles = cacheStyles((theme: Theme) => ({
animOverlay: {
position: 'absolute',
width: '100%',
height: '100%'
height: '100%',
width: '100%'
},
container: {
flexGrow: 1,
Expand Down
5 changes: 3 additions & 2 deletions src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ const strings = {
'The "%1$s" application is requesting full access to your account and all wallets. \n\nOnly accept this login request if you trust this application and where it was downloaded from.',
exchange_failed: 'Exchange Failed',
exchange_congratulations: 'Congratulations!',
exchange_congratulations_msg: 'Your exchange has been successfully completed!',
exchange_congratulations_msg_info: 'Exchanges may take a few minutes and up to 24 hours to process.',
exchange_congratulations_success: 'Your exchange is being processed!',
exchange_congratulations_note: 'Processing may take up to 24 hours to complete.',
no_exchange_amount: 'No Amount Selected',
select_exchange_amount: 'Please enter an amount to exchange',
select_exchange_amount_short: 'Enter an Amount',
Expand Down Expand Up @@ -678,6 +678,7 @@ const strings = {
trade_currency: 'Trade',
trade_s: 'Trade %1$s',
swap_s_to_from_crypto: 'Swap %1$s to/from another crypto',
transaction_details: 'Transaction Details',
transaction_details_category_title: 'Category',
transaction_details_payee: 'Payee',
transaction_details_payer: 'Payer',
Expand Down
5 changes: 3 additions & 2 deletions src/locales/strings/enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
"edge_description_warning": "The \"%1$s\" application is requesting full access to your account and all wallets. \n\nOnly accept this login request if you trust this application and where it was downloaded from.",
"exchange_failed": "Exchange Failed",
"exchange_congratulations": "Congratulations!",
"exchange_congratulations_msg": "Your exchange has been successfully completed!",
"exchange_congratulations_msg_info": "Exchanges may take a few minutes and up to 24 hours to process.",
"exchange_congratulations_success": "Your exchange is being processed!",
"exchange_congratulations_note": "Processing may take up to 24 hours to complete.",
"no_exchange_amount": "No Amount Selected",
"select_exchange_amount": "Please enter an amount to exchange",
"select_exchange_amount_short": "Enter an Amount",
Expand Down Expand Up @@ -610,6 +610,7 @@
"trade_currency": "Trade",
"trade_s": "Trade %1$s",
"swap_s_to_from_crypto": "Swap %1$s to/from another crypto",
"transaction_details": "Transaction Details",
"transaction_details_category_title": "Category",
"transaction_details_payee": "Payee",
"transaction_details_payer": "Payer",
Expand Down
3 changes: 2 additions & 1 deletion src/types/routerTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import type { StakeOverviewParams } from '../components/scenes/Staking/StakeOver
import type { SwapConfirmationParams } from '../components/scenes/SwapConfirmationScene'
import type { SwapCreateParams } from '../components/scenes/SwapCreateScene'
import type { SwapProcessingParams } from '../components/scenes/SwapProcessingScene'
import { SwapSuccessParams } from '../components/scenes/SwapSuccessScene'
import type { SweepPrivateKeyCalculateFeeParams } from '../components/scenes/SweepPrivateKeyCalculateFeeScene'
import type { SweepPrivateKeyCompletionParams } from '../components/scenes/SweepPrivateKeyCompletionScene'
import type { SweepPrivateKeyProcessingParams } from '../components/scenes/SweepPrivateKeyProcessingScene'
Expand Down Expand Up @@ -186,7 +187,7 @@ export type EdgeAppStackParamList = {} & {
stakeOptions: StakeOptionsParams
stakeOverview: StakeOverviewParams
swapSettings: undefined
swapSuccess: undefined
swapSuccess: SwapSuccessParams
sweepPrivateKeyCalculateFee: SweepPrivateKeyCalculateFeeParams
sweepPrivateKeyCompletion: SweepPrivateKeyCompletionParams
sweepPrivateKeyProcessing: SweepPrivateKeyProcessingParams
Expand Down
Loading