Skip to content

Commit

Permalink
Fix matic endpoint and improve error message
Browse files Browse the repository at this point in the history
Closes #1755
  • Loading branch information
0237h committed Nov 5, 2024
1 parent 08914a8 commit a0d88c1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-shrimps-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

Fix `matic` RPC endpoint and improve error message
8 changes: 5 additions & 3 deletions packages/cli/src/command-helpers/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export const fetchTransactionByHashFromRPC = async (
transactionHash: string,
): Promise<any> => {
let json: any;
const RPCURL = getPublicRPCEndpoint(network);
try {
const RPCURL = getPublicRPCEndpoint(network);
if (!RPCURL) throw new Error(`Unable to fetch RPC URL for ${network}`);
const result = await fetch(String(RPCURL), {
method: 'POST',
Expand All @@ -120,7 +120,9 @@ export const fetchTransactionByHashFromRPC = async (
return json;
} catch (error) {
logger('Failed to fetchTransactionByHashFromRPC: %O', error);
throw new Error('Failed to fetch contract creation transaction');
throw new Error(
`Failed to run \`eth_getTransactionByHash\` on RPC (${RPCURL}) (run with env \`DEBUG=*\` for full error).`,
);
}
};

Expand Down Expand Up @@ -387,7 +389,7 @@ const getPublicRPCEndpoint = (network: string) => {
case 'mainnet':
return 'https://rpc.ankr.com/eth';
case 'matic':
return 'https://rpc-mainnet.maticvigil.com';
return 'https://polygon-rpc.com/';
case 'mbase':
return 'https://rpc.moonbase.moonbeam.network';
case 'mumbai':
Expand Down

0 comments on commit a0d88c1

Please sign in to comment.