Handle squid route errors
This commit is contained in:
parent
c5f736d805
commit
534970d475
@ -56,13 +56,8 @@ class AbacusRest implements AbacusRestProtocol {
|
||||
.then(async (response) => {
|
||||
const data = await response.text();
|
||||
|
||||
if (response.ok) {
|
||||
callback(data, response.status);
|
||||
} else {
|
||||
// response not OK, call callback with null data and the status, this includes 400/500 status codes
|
||||
callback(null, response.status);
|
||||
}
|
||||
|
||||
callback(data, response.status);
|
||||
|
||||
try {
|
||||
lastSuccessfulRestRequestByOrigin[new URL(url).origin] = Date.now();
|
||||
} catch {}
|
||||
|
||||
@ -65,6 +65,7 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
chain: chainIdStr,
|
||||
resources,
|
||||
summary,
|
||||
errors: routeErrors,
|
||||
} = useSelector(getTransferInputs, shallowEqual) || {};
|
||||
const chainId = chainIdStr ? parseInt(chainIdStr) : undefined;
|
||||
|
||||
@ -287,6 +288,17 @@ export const DepositForm = ({ onDeposit, onError }: DepositFormProps) => {
|
||||
return parseWalletError({ error, stringGetter }).message;
|
||||
}
|
||||
|
||||
if (routeErrors) {
|
||||
const parsedErrors = JSON.parse(routeErrors);
|
||||
if (parsedErrors?.[0]?.message) {
|
||||
return stringGetter({
|
||||
key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE,
|
||||
params: { ERROR_MESSAGE: parsedErrors?.[0]?.message },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (fromAmount) {
|
||||
if (!chainId) {
|
||||
return stringGetter({ key: STRING_KEYS.MUST_SPECIFY_CHAIN });
|
||||
|
||||
@ -69,6 +69,7 @@ export const WithdrawForm = () => {
|
||||
chain: chainIdStr,
|
||||
address: toAddress,
|
||||
resources,
|
||||
errors: routeErrors,
|
||||
} = useSelector(getTransferInputs, shallowEqual) || {};
|
||||
|
||||
const isValidAddress = toAddress && isAddress(toAddress);
|
||||
@ -281,6 +282,16 @@ export const WithdrawForm = () => {
|
||||
});
|
||||
}
|
||||
|
||||
if (routeErrors) {
|
||||
const parsedErrors = JSON.parse(routeErrors);
|
||||
if (parsedErrors?.[0]?.message) {
|
||||
return stringGetter({
|
||||
key: STRING_KEYS.SOMETHING_WENT_WRONG_WITH_MESSAGE,
|
||||
params: { ERROR_MESSAGE: parsedErrors?.[0]?.message },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!toAddress) return stringGetter({ key: STRING_KEYS.WITHDRAW_MUST_SPECIFY_ADDRESS });
|
||||
|
||||
if (sanctionedAddresses.has(toAddress))
|
||||
@ -303,6 +314,7 @@ export const WithdrawForm = () => {
|
||||
return undefined;
|
||||
}, [
|
||||
error,
|
||||
routeErrors,
|
||||
freeCollateralBN,
|
||||
chainIdStr,
|
||||
debouncedAmountBN,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user