saepenatus
Version:
Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, mul
29 lines (27 loc) • 636 B
text/typescript
import { ChainId, RequestEndpoint } from './types.js'
export function getRequestUrl({
chainId,
endpoint,
apiKey
}: {
chainId: ChainId
endpoint: RequestEndpoint
apiKey?: string
}): { url: string; headers: { authorization?: string } } {
switch (endpoint) {
case 'blockPrices':
return {
url: `https://api.blocknative.com/gasprices/blockprices?chainid=${parseInt(
chainId,
16
)}`,
headers: apiKey
? {
authorization: apiKey
}
: {}
}
default:
throw new Error(`Unrecognized request endpoint: ${endpoint}`)
}
}