-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chain filter defaults to the header (#490)
- Loading branch information
Showing
3 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { getRequestScopeContextValue } from '../context/request-scoped-context'; | ||
import { Chain } from '@prisma/client'; | ||
|
||
const chainIdToChain: { [id: string]: Chain } = { | ||
'1': Chain.MAINNET, | ||
'10': Chain.OPTIMISM, | ||
'100': Chain.GNOSIS, | ||
'137': Chain.POLYGON, | ||
'250': Chain.FANTOM, | ||
'1101': Chain.ZKEVM, | ||
'8453': Chain.BASE, | ||
'42161': Chain.ARBITRUM, | ||
'43114': Chain.AVALANCHE, | ||
} | ||
|
||
/** | ||
* Setup to transition out from the old header-based chainIDs to the new required chain query filters. | ||
* | ||
* @returns The chain of the current request, if any. | ||
*/ | ||
export const headerChain = (): Chain | undefined => { | ||
const chainId = getRequestScopeContextValue<string>('chainId'); | ||
|
||
if (chainId) { | ||
return chainIdToChain[chainId]; | ||
} | ||
|
||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters