Skip to content

Commit

Permalink
[NO CHANGELOG] [Add Funds Widget] Display error when environment is n…
Browse files Browse the repository at this point in the history
…ot set to prod (#2323)
  • Loading branch information
jiyounglee authored Oct 17, 2024
1 parent 5b321fa commit 00ab696
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ export default function AddFundsWidget({
checkout.config.environment ?? Environment.SANDBOX,
);

useEffect(() => {
if (config.environment !== Environment.PRODUCTION) {
showErrorHandover(AddFundsErrorTypes.ENVIRONMENT_ERROR);
}
}, [config]);

useEffect(() => {
const isInvalidToTokenAddress = toTokenAddress && !isValidAddress(toTokenAddress);
const isInvalidToAmount = toAmount && !amountInputValidation(toAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ export const useError = (environment: Environment) => {
secondaryButtonText: 'Close',
onSecondaryButtonClick: goBackToAddFundsView,
},
[AddFundsErrorTypes.ENVIRONMENT_ERROR]: {
headingText: 'Unsupported environment',
subHeadingText: 'This is only supported in production environment.',
secondaryButtonText: 'Close',
onSecondaryButtonClick: closeWidget,
},
};

const getErrorConfig = (errorType: AddFundsErrorTypes) => errorConfig[errorType];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ export enum AddFundsErrorTypes {
WALLET_REJECTED = 'WALLET_REJECTED',
WALLET_REJECTED_NO_FUNDS = 'WALLET_REJECTED_NO_FUNDS',
WALLET_POPUP_BLOCKED = 'WALLET_POPUP_BLOCKED',
ENVIRONMENT_ERROR = 'ENVIRONMENT_ERROR',
}

0 comments on commit 00ab696

Please sign in to comment.