-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove rpcs #220
Remove rpcs #220
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
import { CHAIN_CONFIGS, CHAIN } from 'utils/chains/configs'; | ||
import { ethers } from 'ethers'; | ||
|
||
export const dynamic = 'force-dynamic'; // defaults to auto | ||
|
||
export async function GET(request: NextRequest) { | ||
const { searchParams } = request.nextUrl; | ||
let chainId = Number(searchParams.get('chainId') || ''); | ||
|
||
if (!chainId) { | ||
return NextResponse.json({ error: 'Invalid chainId' }, { status: 400 }); | ||
} | ||
|
||
let chainRpc = ''; | ||
for (const chain of Object.keys(CHAIN_CONFIGS)) { | ||
const chainName = chain as CHAIN; | ||
const chainVals = CHAIN_CONFIGS[chainName]; | ||
if (chainId === chainVals.id) { | ||
chainRpc = chainVals.rpc; | ||
break; | ||
} | ||
} | ||
|
||
if (!chainRpc) { | ||
return NextResponse.json({ error: 'Chain not found' }, { status: 404 }); | ||
} | ||
|
||
const provider = new ethers.JsonRpcProvider(chainRpc) | ||
const feeData = await provider.getFeeData(); | ||
|
||
return NextResponse.json(feeData, { status: 200 }); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ let baseDispatcher = process.env.DISPATCHER_ADDRESS_BASE!; | |
let opClientName = process.env.OPTIMISM_CLIENT_NAME!; | ||
let baseClientName = process.env.BASE_CLIENT_NAME!; | ||
|
||
let optimismRPC = process.env.OPTIMISM_RPC || 'https://opt-sepolia.g.alchemy.com/v2/jKvLhhXvtnWdNeZrKst0demxnwJcYH1o'; | ||
let baseRPC = process.env.BASE_RPC || 'https://base-sepolia.g.alchemy.com/v2/776dC6qT-NTtupdnxlUJuXGbUIKWWhLe'; | ||
let optimismRPC = process.env.OPTIMISM_RPC!; | ||
let baseRPC = process.env.BASE_RPC!; | ||
Comment on lines
+12
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential risk of runtime errors due to non-null assertions. The use of the non-null assertion operator ( Consider adding error handling or documentation to ensure that these variables are set before deployment. Consider adding runtime checks or fallback mechanisms. The direct use of Consider implementing runtime checks or fallback mechanisms within the |
||
|
||
export const CHAIN_CONFIGS: { | ||
[key in CHAIN]: Chain; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the type issue and approve the changes.
The function
calcTxFunding
has been updated to use a chain ID and fetch fee data from an API, aligning with the PR's objectives. However, the type 'Number' should be corrected to 'number' for consistency with TypeScript best practices.Apply this diff to correct the type issue:
Committable suggestion
Tools
Biome