Skip to content

Commit

Permalink
chore: rename modal-named arguments/variables related to SendConfirma…
Browse files Browse the repository at this point in the history
…tion (#6454)

### Description
This PR is related to some renames caused by removal of a modal version
of `SendConfirmation` screeen. The following changes are applied:
- rename `Screens.SendConfirmationModal` to
`Screens.SendConfirmationFromExternal`
- rename `fromModal` to `fromExternal` arguments/variables in files
related to the Send flow

### Test plan
No extra tests needed, all the existing tests work as intended

### Related issues
Relates to RET-1295

### Backwards compatibility
Yes

### Network scalability

If a new NetworkId and/or Network are added in the future, the changes
in this PR will:

- [x] Continue to work without code changes, OR trigger a compilation
error (guaranteeing we find it when a new network is added)
  • Loading branch information
sviderock authored Jan 27, 2025
1 parent dcac9cf commit 9bed0b9
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/fiatExchanges/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe(watchBidaliPaymentRequests, () => {
.dispatch(sendPaymentSuccess({ amount, tokenId: expectedTokenId }))
.run()

expect(navigate).toHaveBeenCalledWith(Screens.SendConfirmationModal, {
expect(navigate).toHaveBeenCalledWith(Screens.SendConfirmationFromExternal, {
origin: SendOrigin.Bidali,
transactionData: {
inputAmount: amount,
Expand Down Expand Up @@ -162,7 +162,7 @@ describe(watchBidaliPaymentRequests, () => {
.dispatch(activeScreenChanged(Screens.BidaliScreen))
.run()

expect(navigate).toHaveBeenCalledWith(Screens.SendConfirmationModal, {
expect(navigate).toHaveBeenCalledWith(Screens.SendConfirmationFromExternal, {
origin: SendOrigin.Bidali,
transactionData: {
inputAmount: amount,
Expand Down
2 changes: 1 addition & 1 deletion src/fiatExchanges/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function* bidaliPaymentRequest({
tokenAmount: new BigNumber(amount),
}

navigate(Screens.SendConfirmationModal, {
navigate(Screens.SendConfirmationFromExternal, {
transactionData,
origin: SendOrigin.Bidali,
isFromScan: false,
Expand Down
2 changes: 1 addition & 1 deletion src/navigator/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ const modalAnimatedScreens = (Navigator: typeof Stack) => (
options={SelectCountry.navigationOptions as NativeStackNavigationOptions}
/>
<Navigator.Screen
name={Screens.SendConfirmationModal}
name={Screens.SendConfirmationFromExternal}
component={SendConfirmation}
options={sendConfirmationScreenNavOptions as NativeStackNavigationOptions}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/navigator/Screens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export enum Screens {
SelectProvider = 'SelectProvider',
SendSelectRecipient = 'SendSelectRecipient',
SendConfirmation = 'SendConfirmation',
SendConfirmationModal = 'SendConfirmationModal',
SendConfirmationFromExternal = 'SendConfirmationFromExternal',
SendEnterAmount = 'SendEnterAmount',
SignInWithEmail = 'SignInWithEmail',
Simplex = 'Simplex',
Expand Down
2 changes: 1 addition & 1 deletion src/navigator/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export type StackParamList = {
}
| undefined
[Screens.SendConfirmation]: SendConfirmationParams
[Screens.SendConfirmationModal]: SendConfirmationParams
[Screens.SendConfirmationFromExternal]: SendConfirmationParams
[Screens.SendEnterAmount]: SendEnterAmountParams
[Screens.JumpstartEnterAmount]: undefined
[Screens.JumpstartSendConfirmation]: {
Expand Down
2 changes: 1 addition & 1 deletion src/send/SendConfirmation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const mockPrepareTransactionsResultPossible: PreparedTransactionsPossible = {

type ScreenProps = NativeStackScreenProps<
StackParamList,
Screens.SendConfirmation | Screens.SendConfirmationModal
Screens.SendConfirmation | Screens.SendConfirmationFromExternal
>

describe('SendConfirmation', () => {
Expand Down
7 changes: 3 additions & 4 deletions src/send/SendConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { walletAddressSelector } from 'src/web3/selectors'

type Props = NativeStackScreenProps<
StackParamList,
Screens.SendConfirmation | Screens.SendConfirmationModal
Screens.SendConfirmation | Screens.SendConfirmationFromExternal
>

const DEBOUNCE_TIME_MS = 250
Expand All @@ -65,7 +65,7 @@ export default function SendConfirmation(props: Props) {
prepareTransactionLoading,
} = usePrepareSendTransactions()

const fromModal = props.route.name === Screens.SendConfirmationModal
const fromExternal = props.route.name === Screens.SendConfirmationFromExternal
const tokenInfo = useTokenInfo(tokenId)
const isSending = useSelector(isSendingSelector)
const localCurrencyCode = useSelector(getLocalCurrencyCode)
Expand Down Expand Up @@ -139,8 +139,7 @@ export default function SendConfirmation(props: Props) {
tokenId,
usdAmount,
recipient,
// TODO rename "fromModal" in all related files to "fromExternal"
fromModal,
fromExternal,
getSerializablePreparedTransaction(preparedTransaction)
)
)
Expand Down
6 changes: 3 additions & 3 deletions src/send/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface SendPaymentAction {
tokenId: string
usdAmount: BigNumber | null
recipient: Recipient
fromModal: boolean
fromExternal: boolean
preparedTransaction: SerializableTransactionRequest
}

Expand Down Expand Up @@ -108,15 +108,15 @@ export const sendPayment = (
tokenId: string,
usdAmount: BigNumber | null,
recipient: Recipient,
fromModal: boolean,
fromExternal: boolean,
preparedTransaction: SerializableTransactionRequest
): SendPaymentAction => ({
type: Actions.SEND_PAYMENT,
amount,
tokenId,
usdAmount,
recipient,
fromModal,
fromExternal,
preparedTransaction,
})

Expand Down
10 changes: 5 additions & 5 deletions src/send/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe(sendPaymentSaga, () => {
tokenId: mockCusdTokenId,
usdAmount: amount,
recipient: mockQRCodeRecipient,
fromModal: false,
fromExternal: false,
preparedTransaction: {
from: '0xfrom',
to: '0xto',
Expand Down Expand Up @@ -118,18 +118,18 @@ describe(sendPaymentSaga, () => {
it.each([
{
testSuffix: 'navigates home when not initiated from modal',
fromModal: false,
fromExternal: false,
navigateFn: navigateHome,
},
{
testSuffix: 'navigates back when initiated from modal',
fromModal: true,
fromExternal: true,
navigateFn: navigateBack,
},
])(
'sends a payment successfully with viem and $testSuffix',
async ({ fromModal, navigateFn }) => {
await expectSaga(sendPaymentSaga, { ...sendAction, fromModal })
async ({ fromExternal, navigateFn }) => {
await expectSaga(sendPaymentSaga, { ...sendAction, fromExternal })
.withState(createMockStore({}).getState())
.provide(createDefaultProviders())
.call(getViemWallet, networkConfig.viemChain.celo, false)
Expand Down
4 changes: 2 additions & 2 deletions src/send/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function* sendPaymentSaga({
tokenId,
usdAmount,
recipient,
fromModal,
fromExternal,
preparedTransaction: serializablePreparedTransaction,
}: SendPaymentAction) {
try {
Expand Down Expand Up @@ -123,7 +123,7 @@ export function* sendPaymentSaga({
})
}

if (fromModal) {
if (fromExternal) {
navigateBack()
} else {
navigateHome()
Expand Down
4 changes: 2 additions & 2 deletions test/RootStateSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3755,7 +3755,7 @@
"SelectLocalCurrency",
"SelectProvider",
"SendConfirmation",
"SendConfirmationModal",
"SendConfirmationFromExternal",
"SendEnterAmount",
"SendSelectRecipient",
"SettingsMenu",
Expand Down Expand Up @@ -6073,7 +6073,7 @@
"SelectLocalCurrency",
"SelectProvider",
"SendConfirmation",
"SendConfirmationModal",
"SendConfirmationFromExternal",
"SendEnterAmount",
"SendSelectRecipient",
"SettingsMenu",
Expand Down

0 comments on commit 9bed0b9

Please # to comment.