Skip to content

Commit

Permalink
Fix/error handling bridge (#2223)
Browse files Browse the repository at this point in the history
Co-authored-by: miguelmtzinf <miguelmtz.mail@gmail.com>
  • Loading branch information
foodaka and miguelmtzinf authored Oct 22, 2024
1 parent 438635f commit fe9d368
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/components/transactions/Bridge/BridgeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ const testnetConfig: Config[] = [
sourceChainId: ChainId.sepolia,
lockReleaseTokenPool: '0x7768248E1Ff75612c18324bad06bb393c1206980',
chainSelector: '16015286601757825753',
router: '0x11c008349c41fb5c78e544397fb4613605ec1a74',
router: '0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59',
tokenOracle: '0x98458D6A99489F15e6eB5aFa67ACFAcf6F211051', // mock oracle
wrappedNativeOracle: AaveV3Sepolia.ASSETS.WETH.ORACLE,
subgraphUrl: 'https://api.studio.thegraph.com/query/75867/gho-ccip-sepolia/version/latest',
destinations: [
{
destinationChainId: ChainId.arbitrum_sepolia,
onRamp: '0x1f41c443cf68750d5c195e2ea7051521d981fc77',
onRamp: '0xBc09627e58989Ba8F1eDA775e486467d2A00944F',
},
],
feeTokens: [
Expand Down Expand Up @@ -179,14 +179,14 @@ const testnetConfig: Config[] = [
sourceChainId: ChainId.arbitrum_sepolia,
burnMintTokenPool: '0x3eC2b6F818B72442fc36561e9F930DD2b60957D2',
chainSelector: '3478487238524512106',
router: '0x22356aec4cf05ec0ec63daa576c6b2ce1dc64701',
tokenOracle: '0x2a9C5afB0d0e4BAb2BCdaE109EC4b0c4Be15a165', // mock oracle
router: '0x2a9C5afB0d0e4BAb2BCdaE109EC4b0c4Be15a165',
tokenOracle: '0x1f885520b7BD528E46b390040F12E753Dce43004', // mock oracle
wrappedNativeOracle: AaveV3ArbitrumSepolia.ASSETS.WETH.ORACLE,
subgraphUrl: 'https://api.studio.thegraph.com/query/75867/gho-ccip-arb-sepolia/version/latest',
destinations: [
{
destinationChainId: ChainId.sepolia,
onRamp: '0xc1ebd046a4086142479be3fc16a4791e2022909a',
onRamp: '0x64d78F20aD987c7D52FdCB8FB0777bD00de53210',
},
],
feeTokens: [
Expand Down
9 changes: 9 additions & 0 deletions src/components/transactions/Bridge/BridgeModalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const BridgeModalContent = () => {
bridgeFeeFormatted,
loading: loadingBridgeMessage,
latestAnswer: bridgeFeeUSD,
error: txErrorBridgeMessage,
} = useGetBridgeMessage({
sourceChainId: sourceNetworkObj.chainId,
destinationChainId: destinationNetworkObj?.chainId || 0,
Expand Down Expand Up @@ -608,6 +609,14 @@ export const BridgeModalContent = () => {
</TxModalDetails>
{txError && <GasEstimationError txError={txError} />}

{txErrorBridgeMessage && (
<Warning severity="error" sx={{ mt: 4 }} icon={false}>
<Typography variant="caption">
<Trans>Something went wrong fetching bridge message, please try again later.</Trans>
</Typography>
</Warning>
)}

{/* {bridgeLimitExceeded && (
<Warning severity="error" sx={{ mt: 4 }} icon={false}>
<Typography variant="caption">
Expand Down
3 changes: 3 additions & 0 deletions src/components/transactions/Bridge/useGetBridgeMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const useGetBridgeMessage = ({
const [bridgeFeeFormatted, setBridgeFeeFormatted] = useState('');
const [latestAnswer, setLatestAnswer] = useState('');
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | undefined>();

const debounced = useMemo(() => {
return debounce(async () => {
Expand Down Expand Up @@ -138,6 +139,7 @@ export const useGetBridgeMessage = ({
setBridgeFeeFormatted(formatEther(fees));
setBridgeFee(fees.toString());
} catch (e) {
setError(e.message);
console.error(e);
} finally {
setLoading(false);
Expand Down Expand Up @@ -167,5 +169,6 @@ export const useGetBridgeMessage = ({
bridgeFeeFormatted,
loading,
latestAnswer,
error,
};
};
2 changes: 1 addition & 1 deletion src/locales/en/messages.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,10 @@ msgstr "Some migrated assets will not be used as collateral due to enabled isola
msgid "Something went wrong"
msgstr "Something went wrong"

#: src/components/transactions/Bridge/BridgeModalContent.tsx
msgid "Something went wrong fetching bridge message, please try again later."
msgstr "Something went wrong fetching bridge message, please try again later."

#: pages/500.page.tsx
msgid "Sorry, an unexpected error happened. In the meantime you may try reloading the page, or come back later."
msgstr "Sorry, an unexpected error happened. In the meantime you may try reloading the page, or come back later."
Expand Down

2 comments on commit fe9d368

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.