- Consolidated duplicate UndoManagers to single instance - Fixed connection promise to only resolve on 'connected' status - Fixed WebSocketProvider import (WebsocketProvider) - Added proper doc.destroy() cleanup - Renamed isPresenceInitialized property to avoid conflict Co-Authored-By: Paperclip <noreply@paperclip.ing>
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import type { Account } from '../../accounts/types.js'
|
|
import type { Client } from '../../clients/createClient.js'
|
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
import type { ErrorType } from '../../errors/utils.js'
|
|
import type { Chain } from '../../types/chain.js'
|
|
import type { RequestErrorType } from '../../utils/buildRequest.js'
|
|
|
|
export type GetBlobBaseFeeReturnType = bigint
|
|
|
|
export type GetBlobBaseFeeErrorType = RequestErrorType | ErrorType
|
|
|
|
/**
|
|
* Returns the base fee per blob gas in wei.
|
|
*
|
|
* - Docs: https://viem.sh/docs/actions/public/getBlobBaseFee
|
|
* - JSON-RPC Methods: [`eth_blobBaseFee`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blobBaseFee)
|
|
*
|
|
* @param client - Client to use
|
|
* @returns The blob base fee (in wei). {@link GetBlobBaseFeeReturnType}
|
|
*
|
|
* @example
|
|
* import { createPublicClient, http } from 'viem'
|
|
* import { mainnet } from 'viem/chains'
|
|
* import { getBlobBaseFee } from 'viem/public'
|
|
*
|
|
* const client = createPublicClient({
|
|
* chain: mainnet,
|
|
* transport: http(),
|
|
* })
|
|
* const blobBaseFee = await getBlobBaseFee(client)
|
|
*/
|
|
export async function getBlobBaseFee<
|
|
chain extends Chain | undefined,
|
|
account extends Account | undefined,
|
|
>(
|
|
client: Client<Transport, chain, account>,
|
|
): Promise<GetBlobBaseFeeReturnType> {
|
|
const baseFee = await client.request({
|
|
method: 'eth_blobBaseFee',
|
|
})
|
|
return BigInt(baseFee)
|
|
}
|