Skip to content

Commit

Permalink
Merge branch 'main' of github.com:immutable/ts-immutable-sdk into fea…
Browse files Browse the repository at this point in the history
…t/checkout-widget-sample-app
  • Loading branch information
jwhardwick committed Oct 17, 2024
2 parents edd6211 + 00ab696 commit ee4b8e4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 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',
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,22 @@ export function AddFunds({
};

const setSelectedRouteData = (route: RouteData | undefined) => {
track({
userJourney: UserJourney.ADD_FUNDS,
screen: 'InputScreen',
control: 'RoutesMenu',
controlType: 'MenuItem',
extras: {
toTokenAddress: route?.amountData.toToken.address,
toTokenChainId: route?.amountData.toToken.chainId,
fromTokenAddress: route?.amountData.fromToken.address,
fromTokenChainId: route?.amountData.fromToken.chainId,
toAmount: route?.amountData.toAmount,
fromAmount: route?.amountData.fromAmount,
},
});
if (route) {
track({
userJourney: UserJourney.ADD_FUNDS,
screen: 'InputScreen',
control: 'RoutesMenu',
controlType: 'MenuItem',
extras: {
toTokenAddress: route.amountData.toToken.address,
toTokenChainId: route.amountData.toToken.chainId,
fromTokenAddress: route.amountData.fromToken.address,
fromTokenChainId: route.amountData.fromToken.chainId,
toAmount: route.amountData.toAmount,
fromAmount: route.amountData.fromAmount,
},
});
}

addFundsDispatch({
payload: {
Expand Down

0 comments on commit ee4b8e4

Please sign in to comment.