Skip to content

Commit

Permalink
refactor: created enums for the wizard steps related to send flow (#1350
Browse files Browse the repository at this point in the history
)

* refactor: created enums for the wizard steps related to send flow

* refactor: moved WizardStepsSend to separate files after renaming it
  • Loading branch information
AntonioVentilii-DFINITY authored May 27, 2024
1 parent 489bc14 commit 25e3383
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/frontend/src/eth/components/send/SendTokenModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { replacePlaceholders } from '$lib/utils/i18n.utils';
import type { Erc20Token } from '$eth/types/erc20';
import { ethereumToken } from '$eth/derived/token.derived';
import { WizardStepsSend } from '$lib/enums/wizard-steps';
/**
* Props
Expand Down Expand Up @@ -73,7 +74,7 @@
bind:currentStep
bind:this={modal}
on:nnsClose={close}
disablePointerEvents={currentStep?.name === 'Sending'}
disablePointerEvents={currentStep?.name === WizardStepsSend.SENDING}
>
<svelte:fragment slot="title">{currentStep?.title ?? ''}</svelte:fragment>

Expand Down
9 changes: 5 additions & 4 deletions src/frontend/src/eth/components/send/SendTokenWizard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import { shouldSendWithApproval } from '$eth/utils/send.utils';
import { toCkErc20HelperContractAddress } from '$icp-eth/utils/cketh.utils';
import type { Token } from '$lib/types/token';
import { WizardStepsSend } from '$lib/enums/wizard-steps';
export let currentStep: WizardStep | undefined;
export let formCancelAction: 'back' | 'close' = 'close';
Expand Down Expand Up @@ -204,12 +205,12 @@
bind:this={feeContext}
{amount}
{destination}
observe={currentStep?.name !== 'Sending'}
observe={currentStep?.name !== WizardStepsSend.SENDING}
{sourceNetwork}
{targetNetwork}
{nativeEthereumToken}
>
{#if currentStep?.name === 'Review'}
{#if currentStep?.name === WizardStepsSend.REVIEW}
<SendReview
on:icBack
on:icSend={send}
Expand All @@ -219,12 +220,12 @@
{targetNetwork}
{destinationEditable}
/>
{:else if currentStep?.name === 'Sending'}
{:else if currentStep?.name === WizardStepsSend.SENDING}
<InProgressWizard
progressStep={sendProgressStep}
steps={sendSteps({ i18n: $i18n, sendWithApproval })}
/>
{:else if currentStep?.name === 'Send'}
{:else if currentStep?.name === WizardStepsSend.SEND}
<SendForm
on:icNext
on:icClose={close}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import { shouldSendWithApproval } from '$eth/utils/send.utils';
import { ckErc20HelperContractAddress } from '$icp-eth/derived/cketh.derived';
import { isErc20TransactionApprove } from '$eth/utils/transactions.utils';
import { WizardStepsSend } from '$lib/enums/wizard-steps';
export let request: Web3WalletTypes.SessionRequest;
export let firstTransaction: WalletConnectEthSendTransactionParams;
Expand Down Expand Up @@ -98,11 +99,11 @@
const steps: WizardSteps = [
{
name: 'Review',
name: WizardStepsSend.REVIEW,
title: $i18n.send.text.review
},
{
name: 'Sending',
name: WizardStepsSend.SENDING,
title: $i18n.send.text.sending
}
];
Expand Down Expand Up @@ -169,12 +170,12 @@
<FeeContext
amount={amount.toString()}
{destination}
observe={currentStep?.name !== 'Sending'}
observe={currentStep?.name !== WizardStepsSend.SENDING}
{sourceNetwork}
nativeEthereumToken={$ethereumToken}
>
<CkEthLoader nativeTokenId={$sendTokenId}>
{#if currentStep?.name === 'Sending'}
{#if currentStep?.name === WizardStepsSend.SENDING}
<SendProgress
progressStep={sendProgressStep}
steps={walletConnectSendSteps({ i18n: $i18n, sendWithApproval })}
Expand Down
7 changes: 4 additions & 3 deletions src/frontend/src/eth/config/send.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { WizardStepsSend } from '$lib/enums/wizard-steps';
import type { WizardSteps } from '@dfinity/gix-components';

export const sendWizardSteps = (i18n: I18n): WizardSteps => [
{
name: 'Send',
name: WizardStepsSend.SEND,
title: i18n.send.text.send
},
{
name: 'Review',
name: WizardStepsSend.REVIEW,
title: i18n.send.text.review
},
{
name: 'Sending',
name: WizardStepsSend.SENDING,
title: i18n.send.text.sending
}
];
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
toCkEthHelperContractAddress
} from '$icp-eth/utils/cketh.utils';
import { ckEthMinterInfoStore } from '$icp-eth/stores/cketh.store';
import { WizardStepsSend } from '$lib/enums/wizard-steps';
/**
* Props
Expand Down Expand Up @@ -65,7 +66,7 @@
bind:currentStep
bind:this={modal}
on:nnsClose={close}
disablePointerEvents={currentStep?.name === 'Sending'}
disablePointerEvents={currentStep?.name === WizardStepsSend.SENDING}
>
<svelte:fragment slot="title">{currentStep?.title ?? ''}</svelte:fragment>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
toCkEthHelperContractAddress
} from '$icp-eth/utils/cketh.utils';
import { ckEthMinterInfoStore } from '$icp-eth/stores/cketh.store';
import { WizardStepsSend } from '$lib/enums/wizard-steps';
/**
* Props
Expand Down Expand Up @@ -81,7 +82,7 @@
bind:currentStep
bind:this={modal}
on:nnsClose={close}
disablePointerEvents={currentStep?.name === 'Sending'}
disablePointerEvents={currentStep?.name === WizardStepsSend.SENDING}
>
<svelte:fragment slot="title">{currentStep?.title ?? ''}</svelte:fragment>

Expand Down
13 changes: 7 additions & 6 deletions src/frontend/src/icp/components/send/IcSendModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
initEthereumFeeStore,
type EthereumFeeContext as EthereumFeeContextType
} from '$icp/stores/ethereum-fee.store';
import { WizardStepsSend } from '$lib/enums/wizard-steps';
/**
* Props
Expand Down Expand Up @@ -130,7 +131,7 @@
let steps: WizardSteps;
$: steps = [
{
name: 'Send',
name: WizardStepsSend.SEND,
title: isNetworkIdBTC(networkId)
? $i18n.convert.text.convert_to_btc
: isNetworkIdEthereum(networkId)
Expand All @@ -140,11 +141,11 @@
: $i18n.send.text.send
},
{
name: 'Review',
name: WizardStepsSend.REVIEW,
title: $i18n.send.text.review
},
{
name: 'Sending',
name: WizardStepsSend.SENDING,
title: $i18n.send.text.sending
}
];
Expand Down Expand Up @@ -185,15 +186,15 @@
bind:currentStep
bind:this={modal}
on:nnsClose={close}
disablePointerEvents={currentStep?.name === 'Sending'}
disablePointerEvents={currentStep?.name === WizardStepsSend.SENDING}
>
<svelte:fragment slot="title">{currentStep?.title ?? ''}</svelte:fragment>

<EthereumFeeContext {networkId}>
<BitcoinFeeContext {amount} {networkId}>
{#if currentStep?.name === 'Review'}
{#if currentStep?.name === WizardStepsSend.REVIEW}
<IcSendReview on:icBack={modal.back} on:icSend={send} {destination} {amount} {networkId} />
{:else if currentStep?.name === 'Sending'}
{:else if currentStep?.name === WizardStepsSend.SENDING}
<IcSendProgress bind:sendProgressStep {networkId} />
{:else}
<IcSendForm
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/src/lib/enums/wizard-steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum WizardStepsSend {
SEND = 'Send',
REVIEW = 'Review',
SENDING = 'Sending'
}

0 comments on commit 25e3383

Please sign in to comment.