@reservoir0x/relay-kit-ui
Version:
Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.
41 lines • 1.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const index_js_1 = require("../primitives/index.js");
const ErrorWell = ({ error, hasTxHashes, fromChain }) => {
const renderedErrorMessage = React.useMemo(() => {
if (error && error.response?.data?.message) {
return error.response?.data?.message;
}
if (error?.message?.includes('An internal error was received.') ||
!error?.message) {
return 'Oops! Something went wrong while processing your transaction.';
}
else if (error?.name &&
(error?.message?.includes('does not support chain') ||
error?.message?.match(/Chain \d+ not supported/))) {
return `Your wallet does not support ${fromChain?.displayName ?? 'this chain'}`;
}
if (!hasTxHashes ||
error?.message?.includes('Deposit transaction with hash')) {
return 'Oops, something went wrong while initiating the swap. Your request was not submitted. Please try again.';
}
else if (error?.message?.includes('solver status check')) {
return 'This transaction is taking longer than usual to process. Please visit the transaction page for more details.';
}
else if (error.name === 'TransactionConfirmationError') {
return 'Transaction Failed. Try adjusting slippage or gas limits and try again.';
}
return error?.message;
}, [error?.message, hasTxHashes]);
return ((0, jsx_runtime_1.jsx)(index_js_1.Text, { style: "subtitle1", css: {
my: '4',
textAlign: 'center',
width: '100%',
wordBreak: 'break-word'
}, children: renderedErrorMessage }));
};
exports.default = ErrorWell;
//# sourceMappingURL=ErrorWell.js.map