Skip to content

Commit

Permalink
fix: use DRPC private url in gnosis (#1135)
Browse files Browse the repository at this point in the history
* fix: use DRPC private url in gnosis
  • Loading branch information
agualis authored Sep 27, 2024
1 parent d0c7f5d commit fd8d87c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ PRIVATE_CURRENCYAPI_KEY=xxx

# For integration tests and rpc proxy routes (optional)
NEXT_PRIVATE_ALCHEMY_KEY=xxx
NEXT_PRIVATE_DRPC_KEY=xxx


1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ env:
NEXT_PUBLIC_BALANCER_API_URL: https://api-v3.balancer.fi/graphql
NEXT_PUBLIC_WALLET_CONNECT_ID: ${{ secrets.NEXT_PUBLIC_WALLET_CONNECT_ID }}
NEXT_PRIVATE_ALCHEMY_KEY: ${{ secrets.PRIVATE_ALCHEMY_KEY }}
NEXT_PRIVATE_DRPC_KEY: ${{ secrets.PRIVATE_DRPC_KEY }}

jobs:
Build:
Expand Down
8 changes: 7 additions & 1 deletion app/api/rpc/[chain]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Params = {
}

const ALCHEMY_KEY = process.env.NEXT_PRIVATE_ALCHEMY_KEY || ''
const DRPC_KEY = process.env.NEXT_PRIVATE_DRPC_KEY || ''

const chainToRpcMap: Record<GqlChain, string | undefined> = {
[GqlChain.Mainnet]: `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
Expand All @@ -18,7 +19,7 @@ const chainToRpcMap: Record<GqlChain, string | undefined> = {
[GqlChain.Fantom]: `https://fantom-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[GqlChain.Sepolia]: `https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[GqlChain.Fraxtal]: `https://frax-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[GqlChain.Gnosis]: `https://gnosis-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[GqlChain.Gnosis]: `https://lb.drpc.org/ogrpc?network=gnosis&dkey=${DRPC_KEY}`,
[GqlChain.Mode]: undefined,
[GqlChain.Zkevm]: `https://polygonzkevm-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
}
Expand All @@ -39,6 +40,11 @@ export async function POST(request: Request, { params: { chain } }: Params) {
status: 500,
})
}
if (!DRPC_KEY) {
return new Response(JSON.stringify({ error: 'NEXT_PRIVATE_DRPC_KEY is missing' }), {
status: 500,
})
}

const rpcUrl = getRpcUrl(chain)
const rpcBody = await request.json()
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/web3/ChainConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const rpcOverrides: Record<GqlChain, string | undefined> = {
[GqlChain.Base]: getPrivateRpcUrl(GqlChain.Base),
[GqlChain.Avalanche]: getPrivateRpcUrl(GqlChain.Avalanche),
[GqlChain.Fantom]: getPrivateRpcUrl(GqlChain.Fantom),
[GqlChain.Gnosis]: 'https://rpc.gnosischain.com', // Temporary fix until we fix an alchemy rpc url issue (Reverted incorrect sender)
[GqlChain.Gnosis]: getPrivateRpcUrl(GqlChain.Gnosis),
[GqlChain.Optimism]: getPrivateRpcUrl(GqlChain.Optimism),
[GqlChain.Polygon]: getPrivateRpcUrl(GqlChain.Polygon),
[GqlChain.Zkevm]: getPrivateRpcUrl(GqlChain.Zkevm),
Expand Down

0 comments on commit fd8d87c

Please sign in to comment.