From a0d88c1307bc486d8b094d38f726365be8ff25b1 Mon Sep 17 00:00:00 2001 From: Etienne Donneger Date: Tue, 5 Nov 2024 09:54:36 -0500 Subject: [PATCH] Fix `matic` endpoint and improve error message Closes #1755 --- .changeset/pretty-shrimps-kick.md | 5 +++++ packages/cli/src/command-helpers/abi.ts | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changeset/pretty-shrimps-kick.md diff --git a/.changeset/pretty-shrimps-kick.md b/.changeset/pretty-shrimps-kick.md new file mode 100644 index 000000000..7063adcc6 --- /dev/null +++ b/.changeset/pretty-shrimps-kick.md @@ -0,0 +1,5 @@ +--- +'@graphprotocol/graph-cli': patch +--- + +Fix `matic` RPC endpoint and improve error message diff --git a/packages/cli/src/command-helpers/abi.ts b/packages/cli/src/command-helpers/abi.ts index 8c17884eb..3bef67bc5 100644 --- a/packages/cli/src/command-helpers/abi.ts +++ b/packages/cli/src/command-helpers/abi.ts @@ -100,8 +100,8 @@ export const fetchTransactionByHashFromRPC = async ( transactionHash: string, ): Promise => { 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', @@ -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).`, + ); } }; @@ -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':