-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: WT-2054 Add Loading, Success and Failure screens for transaction (
- Loading branch information
1 parent
39334fb
commit 0195845
Showing
13 changed files
with
317 additions
and
13 deletions.
There are no files selected for viewing
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
74 changes: 74 additions & 0 deletions
74
packages/checkout/widgets-lib/src/components/Transactions/ClaimWithdrawalInProgress.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,74 @@ | ||
import { TransactionResponse } from '@ethersproject/providers'; | ||
import { useContext, useEffect } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { UserJourney, useAnalytics } from 'context/analytics-provider/SegmentAnalyticsProvider'; | ||
import { ViewActions, ViewContext } from 'context/view-context/ViewContext'; | ||
import { BridgeWidgetViews } from 'context/view-context/BridgeViewContextTypes'; | ||
import { LoadingView } from 'views/loading/LoadingView'; | ||
|
||
interface ClaimWithdrawalInProgressProps { | ||
transactionResponse: TransactionResponse; | ||
} | ||
|
||
export function ClaimWithdrawalInProgress({ transactionResponse }: ClaimWithdrawalInProgressProps) { | ||
const { t } = useTranslation(); | ||
const { viewDispatch } = useContext(ViewContext); | ||
|
||
const { page } = useAnalytics(); | ||
|
||
useEffect(() => { | ||
page({ | ||
userJourney: UserJourney.BRIDGE, | ||
screen: 'ClaimWithdrawalInProgress', | ||
}); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (!transactionResponse) return; | ||
|
||
(async () => { | ||
try { | ||
const receipt = await transactionResponse.wait(); | ||
|
||
if (receipt.status === 1) { | ||
viewDispatch({ | ||
payload: { | ||
type: ViewActions.UPDATE_VIEW, | ||
view: { | ||
type: BridgeWidgetViews.CLAIM_WITHDRAWAL_SUCCESS, | ||
transactionHash: receipt.transactionHash, | ||
}, | ||
}, | ||
}); | ||
return; | ||
} | ||
|
||
viewDispatch({ | ||
payload: { | ||
type: ViewActions.UPDATE_VIEW, | ||
view: { | ||
type: BridgeWidgetViews.CLAIM_WITHDRAWAL_FAILURE, | ||
transactionHash: receipt.transactionHash, | ||
reason: 'Transaction failed', | ||
}, | ||
}, | ||
}); | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
viewDispatch({ | ||
payload: { | ||
type: ViewActions.UPDATE_VIEW, | ||
view: { | ||
type: BridgeWidgetViews.CLAIM_WITHDRAWAL_FAILURE, | ||
transactionHash: '', | ||
reason: 'Transaction failed', | ||
}, | ||
}, | ||
}); | ||
} | ||
})(); | ||
}, [transactionResponse]); | ||
|
||
return <LoadingView loadingText={t('views.CLAIM_WITHDRAWAL.IN_PROGRESS.loading.text')} showFooterLogo />; | ||
} |
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
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
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.