Skip to content

Commit

Permalink
Merge pull request #104 from subquery/chore/add-more-error-capture
Browse files Browse the repository at this point in the history
chore: add more error capture
  • Loading branch information
HuberTRoy authored Apr 16, 2024
2 parents 6fccafe + a8dcf57 commit b275718
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ REACT_APP_VESTING_SUBQL=https://api.subquery.network/sq/subquery/mainnet-vesting
REACT_APP_AUTH_URL=https://auth.subquery.network
REACT_APP_CHALLENGE_URL=https://airdrop-challenge-api.subquery.network
GENERATE_SOURCEMAP=false
REACT_APP_SUBQUERY_OFFICIAL_BASE_RPC=https://gateway.subquery.network/rpc/base
REACT_APP_SUBQUERY_OFFICIAL_ETH_RPC=https://gateway.subquery.network/rpc/eth
REACT_APP_SUBQUERY_OFFICIAL_BASE_RPC=https://base.rpc.subquery.network/public
REACT_APP_SUBQUERY_OFFICIAL_ETH_RPC=https://ethereum.rpc.subquery.network/public
20 changes: 19 additions & 1 deletion src/components/L2Vesting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BsWallet2 } from 'react-icons/bs';
import { FaRegCheckCircle } from 'react-icons/fa';
import { TfiArrowTopRight } from 'react-icons/tfi';
import { formatEther } from '@ethersproject/units';
import { captureException } from '@sentry/react';
import { Spinner, SubqlProvider, Typography } from '@subql/components';
import mainnetJSON from '@subql/contract-sdk/publish/mainnet.json';
import testnetJSON from '@subql/contract-sdk/publish/testnet.json';
Expand Down Expand Up @@ -444,7 +445,24 @@ const L2Vesting: FC<IProps> = () => {
<Spinner />
</div>
),
error: (e) => <Typography>No Seekers Vesting available</Typography>,
error: (e) => {
try {
captureException('Seekers Vesting load error', {
extra: {
account,
error: e
}
});
openNotificationWithIcon({
type: NotificationType.ERROR,
title: 'An error occurred getting your seekers tokens',
description: 'An error occurred getting your seekers tokens'
});
} catch (err) {
// capture by sentry
}
return <Typography>An error occurred getting your seekers tokens</Typography>;
},
data: () => (
<div className={styles.vesting}>
<Typography variant="h6" weight={500}>
Expand Down
8 changes: 4 additions & 4 deletions src/conf/rainbowConf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const supportedChains =
...base,
rpcUrls: {
default: {
http: [process.env.REACT_APP_SUBQUERY_OFFICIAL_BASE_RPC]
http: [base.rpcUrls.default.http]
},
public: {
http: [process.env.REACT_APP_SUBQUERY_OFFICIAL_BASE_RPC]
http: [base.rpcUrls.default.http]
},
fallback: {
http: base.rpcUrls.default.http
Expand All @@ -40,10 +40,10 @@ const supportedChains =
...mainnet,
rpcUrls: {
default: {
http: [process.env.REACT_APP_SUBQUERY_OFFICIAL_ETH_RPC]
http: [mainnet.rpcUrls.default.http]
},
public: {
http: [process.env.REACT_APP_SUBQUERY_OFFICIAL_ETH_RPC]
http: [mainnet.rpcUrls.default.http]
},
fallback: {
http: mainnet.rpcUrls.default.http
Expand Down
15 changes: 7 additions & 8 deletions src/hooks/useContracts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { HttpTransport } from 'viem';
import { base, baseSepolia, mainnet, sepolia } from 'viem/chains';
import { PublicClient, useNetwork, usePublicClient, useWalletClient, WalletClient } from 'wagmi';

const fetchUrls: { [key in number]: string } = {
[base.id]: base.rpcUrls.public.http[0] || process.env.REACT_APP_SUBQUERY_OFFICIAL_BASE_RPC,
[mainnet.id]: mainnet.rpcUrls.public.http[0] || process.env.REACT_APP_SUBQUERY_OFFICIAL_ETH_RPC
};

export function publicClientToProvider(publicClient: PublicClient) {
const { chain, transport } = publicClient;

Expand All @@ -19,10 +24,7 @@ export function publicClientToProvider(publicClient: PublicClient) {
ensAddress: chain.contracts?.ensRegistry?.address
};

const fetchUrl = {
[base.id]: process.env.REACT_APP_SUBQUERY_OFFICIAL_BASE_RPC,
[mainnet.id]: process.env.REACT_APP_SUBQUERY_OFFICIAL_ETH_RPC
}[chain.id];
const fetchUrl = fetchUrls[chain.id];

if (transport.type === 'fallback') {
return new providers.FallbackProvider(
Expand Down Expand Up @@ -53,10 +55,7 @@ export function walletClientToSignerAndProvider(walletClient: WalletClient) {
...transport,
async request(request, ...rest) {
try {
const fetchUrl = {
[base.id]: process.env.REACT_APP_SUBQUERY_OFFICIAL_BASE_RPC,
[mainnet.id]: process.env.REACT_APP_SUBQUERY_OFFICIAL_ETH_RPC
}[chain.id];
const fetchUrl = fetchUrls[chain.id];

if (fetchUrl) {
requestId += 1;
Expand Down

0 comments on commit b275718

Please sign in to comment.