@@ -6,22 +6,23 @@ type Params = {
6
6
}
7
7
}
8
8
9
- const ALCHEMY_KEY = process . env . NEXT_PRIVATE_ALCHEMY_KEY || ''
10
9
const DRPC_KEY = process . env . NEXT_PRIVATE_DRPC_KEY || ''
10
+ const dRpcUrl = ( chainName : string ) =>
11
+ `https://lb.drpc.org/ogrpc?network=${ chainName } &dkey=${ DRPC_KEY } `
11
12
12
13
const chainToRpcMap : Record < GqlChain , string | undefined > = {
13
- [ GqlChain . Mainnet ] : `https://eth-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
14
- [ GqlChain . Arbitrum ] : `https://arb-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
15
- [ GqlChain . Optimism ] : `https://opt-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
16
- [ GqlChain . Base ] : `https:// base-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
17
- [ GqlChain . Polygon ] : `https:// polygon-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
18
- [ GqlChain . Avalanche ] : `https://avax-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
19
- [ GqlChain . Fantom ] : `https:// fantom-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
20
- [ GqlChain . Sepolia ] : `https://eth- sepolia.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
21
- [ GqlChain . Fraxtal ] : `https://frax-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
22
- [ GqlChain . Gnosis ] : `https://lb.drpc.org/ogrpc?network= gnosis&dkey= ${ DRPC_KEY } ` ,
23
- [ GqlChain . Mode ] : undefined ,
24
- [ GqlChain . Zkevm ] : `https://polygonzkevm-mainnet.g.alchemy.com/v2/ ${ ALCHEMY_KEY } ` ,
14
+ [ GqlChain . Mainnet ] : dRpcUrl ( 'ethereum' ) ,
15
+ [ GqlChain . Arbitrum ] : dRpcUrl ( 'arbitrum' ) ,
16
+ [ GqlChain . Optimism ] : dRpcUrl ( 'optimism' ) ,
17
+ [ GqlChain . Base ] : dRpcUrl ( ' base' ) ,
18
+ [ GqlChain . Polygon ] : dRpcUrl ( ' polygon' ) ,
19
+ [ GqlChain . Avalanche ] : dRpcUrl ( 'avalanche' ) ,
20
+ [ GqlChain . Fantom ] : dRpcUrl ( ' fantom' ) ,
21
+ [ GqlChain . Sepolia ] : dRpcUrl ( ' sepolia' ) ,
22
+ [ GqlChain . Fraxtal ] : dRpcUrl ( 'fraxtal' ) ,
23
+ [ GqlChain . Gnosis ] : dRpcUrl ( ' gnosis' ) ,
24
+ [ GqlChain . Mode ] : dRpcUrl ( 'mode' ) ,
25
+ [ GqlChain . Zkevm ] : dRpcUrl ( 'polygon-zkevm' ) ,
25
26
}
26
27
27
28
function getRpcUrl ( chain : string ) {
@@ -35,11 +36,6 @@ function getRpcUrl(chain: string) {
35
36
}
36
37
37
38
export async function POST ( request : Request , { params : { chain } } : Params ) {
38
- if ( ! ALCHEMY_KEY ) {
39
- return new Response ( JSON . stringify ( { error : 'NEXT_PRIVATE_ALCHEMY_KEY is missing' } ) , {
40
- status : 500 ,
41
- } )
42
- }
43
39
if ( ! DRPC_KEY ) {
44
40
return new Response ( JSON . stringify ( { error : 'NEXT_PRIVATE_DRPC_KEY is missing' } ) , {
45
41
status : 500 ,
0 commit comments