dank_mids package

Subpackages

Submodules

dank_mids.ENVIRONMENT_VARIABLES module

dank_mids.constants module

dank_mids.controller module

dank_mids.eth module

class dank_mids.eth.CallOverrideParams

Bases: dict

__getitem__()

x.__getitem__(y) <==> x[y]

__init__(*args, **kwargs)
__iter__()

Implement iter(self).

clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
balance: Wei | None
code: bytes | HexStr | None
nonce: int | None
state: Dict[HexStr, HexStr] | None
stateDiff: Dict[HexStr, HexStr] | None
class dank_mids.eth.DankEth

Bases: AsyncEth

__init__(w3)
Parameters:

w3 (AsyncWeb3 | Web3)

Return type:

None

attach_methods(methods)
Parameters:

methods (Dict[str, Method[Callable[[...], Any]]])

Return type:

None

block_id_munger(account, block_identifier=None)
Parameters:
  • account (Address | ChecksumAddress | ENS)

  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int | None)

Return type:

Tuple[Address | ChecksumAddress | ENS, Literal[‘latest’, ‘earliest’, ‘pending’, ‘safe’, ‘finalized’] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int]

async call(transaction, block_identifier=None, state_override=None, ccip_read_enabled=None)
Parameters:
  • transaction (TxParams)

  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int | None)

  • state_override (Dict[ChecksumAddress, CallOverrideParams] | None)

  • ccip_read_enabled (bool | None)

Return type:

HexBytes

call_munger(transaction, block_identifier=None, state_override=None)
Parameters:
  • transaction (TxParams)

  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int | None)

  • state_override (Dict[ChecksumAddress, CallOverrideParams] | None)

Return type:

Tuple[TxParams, Literal[‘latest’, ‘earliest’, ‘pending’, ‘safe’, ‘finalized’] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int] | ~typing.Tuple[~web3.types.TxParams, ~typing.Literal[‘latest’, ‘earliest’, ‘pending’, ‘safe’, ‘finalized’] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int, ~typing.Dict[~eth_typing.evm.ChecksumAddress, ~web3.types.CallOverrideParams]]

contract(address=None, **kwargs)
Parameters:
  • address (Address | ChecksumAddress | ENS | None)

  • kwargs (Any)

Return type:

Type[AsyncContract] | AsyncContract

async estimate_gas(transaction, block_identifier=None)
Parameters:
  • transaction (TxParams)

  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int | None)

Return type:

int

estimate_gas_munger(transaction, block_identifier=None)
Parameters:
  • transaction (TxParams)

  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int | None)

Return type:

Sequence[TxParams | Literal[‘latest’, ‘earliest’, ‘pending’, ‘safe’, ‘finalized’] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int]

async fee_history(block_count, newest_block, reward_percentiles=None)
Parameters:
  • block_count (int)

  • newest_block (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber)

  • reward_percentiles (List[float] | None)

Return type:

FeeHistory

filter_munger(filter_params=None, filter_id=None)
Parameters:
  • filter_params (str | FilterParams | None)

  • filter_id (HexStr | None)

Return type:

List[FilterParams] | List[HexStr] | List[str]

generate_gas_price(transaction_params=None)
Parameters:

transaction_params (TxParams | None)

Return type:

Wei | None

async get_balance(account, block_identifier=None)
Parameters:
  • account (ChecksumAddress)

  • block_identifier (BlockNumber | None)

async get_block(block_identifier, full_transactions=False)
Parameters:
  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int)

  • full_transactions (bool)

Return type:

BlockData

get_block_munger(block_identifier, full_transactions=False)
Parameters:
  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int)

  • full_transactions (bool)

Return type:

Tuple[Literal[‘latest’, ‘earliest’, ‘pending’, ‘safe’, ‘finalized’] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int, bool]

async get_block_number()

Method object for web3 module methods

Calls to the Method go through these steps:

1. input munging - includes normalization, parameter checking, early parameter formatting. Any processing on the input parameters that need to happen before json_rpc method string selection occurs.

A note about mungers: The first (root) munger should reflect the desired

api function arguments. In other words, if the api function wants to behave as: get_balance(account, block_identifier=None), the root munger should accept these same arguments, with the addition of the module as the first argument e.g.:

``` def get_balance_root_munger(module, account, block_identifier=None):

if block_identifier is None:

block_identifier = DEFAULT_BLOCK

return module, [account, block_identifier]

```

all mungers should return an argument list.

if no munger is provided, a default munger expecting no method arguments will be used.

2. method selection - The json_rpc_method argument can be method string or a function that returns a method string. If a callable is provided the processed method inputs are passed to the method selection function, and the returned method string is used.

3. request and response formatters are set - formatters are retrieved using the json rpc method string.

4. After the parameter processing from steps 1-3 the request is made using the calling function returned by the module attribute retrieve_caller_fn and the response formatters are applied to the output.

Return type:

BlockNumber

async get_block_timestamp(block_identifier)

Retrieves only the timestamp from a specific block.

This method skips decoding the rest of the Block response data.

Parameters:

block_identifier (int) – The block number from which to retrieve the timestamp.

Return type:

UnixTimestamp

Example

>>> print(await dank_mids.eth.get_block_timestamp(12345678))
async get_code(account, block_identifier=None)
Parameters:
  • account (ChecksumAddress)

  • block_identifier (BlockNumber | None)

async get_logs(*args, decode_to=tuple[evmspec.structs.log.Log, ...], decode_hook=<function _decode_hook>, **kwargs)

Fetches logs and decodes them into the specified format.

Parameters:
  • *args – Additional positional arguments.

  • decode_to (Type[T]) – The class to which logs should be decoded.

  • decode_hook (Callable[[Type[T], Any], T] | None) – Hook function to assist in decoding.

  • **kwargs – Additional keyword arguments.

Return type:

T

async get_raw_transaction(transaction_hash)
Parameters:

transaction_hash (Hash32 | HexBytes | HexStr)

Return type:

HexBytes

async get_raw_transaction_by_block(block_identifier, index)
Parameters:
  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int)

  • index (int)

Return type:

HexBytes

async get_storage_at(account, position, block_identifier=None)
Parameters:
  • account (Address | ChecksumAddress | ENS)

  • position (int)

  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int | None)

Return type:

HexBytes

get_storage_at_munger(account, position, block_identifier=None)
Parameters:
  • account (Address | ChecksumAddress | ENS)

  • position (int)

  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int | None)

Return type:

Tuple[Address | ChecksumAddress | ENS, int, Literal[‘latest’, ‘earliest’, ‘pending’, ‘safe’, ‘finalized’] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int]

async get_transaction(transaction_hash)

Retrieves a transaction by its hash and attempts to decode it.

Parameters:

transaction_hash (HexStr) – The hash of the transaction to retrieve.

Raises:

ValidationError – If the transaction cannot be decoded into either Transaction or TransactionRLP format.

Return type:

TransactionLegacy | Transaction2930 | Transaction1559 | Transaction4844 | Transaction7702 | TransactionRLP

async get_transaction_by_block(block_identifier, index)
Parameters:
  • block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int)

  • index (int)

Return type:

TxData

async get_transaction_count(account, block_identifier=None)
Parameters:
  • account (ChecksumAddress)

  • block_identifier (BlockNumber | None)

async get_transaction_receipt(*args, decode_to=<class 'evmspec.structs.receipt.TransactionReceipt'>, decode_hook=<function _decode_hook>, **kwargs)

Fetches the transaction receipt and decodes it into the specified format.

Parameters:
  • *args – Additional positional arguments.

  • decode_to (Type[T]) – The class to which the receipt should be decoded.

  • decode_hook (Callable[[Type[T], Any], T] | None) – Hook function to assist in decoding.

  • **kwargs – Additional keyword arguments.

Return type:

T

async get_transaction_status(transaction_hash)

Retrieves the status of a transaction.

Parameters:

transaction_hash (str) – The hash of the transaction to query.

Returns:

The status of the transaction.

Return type:

Status

async get_transactions(block_identifier: int | HexStr) List[TransactionLegacy | Transaction2930 | Transaction1559 | Transaction4844 | Transaction7702]
async get_transactions(block_identifier: int | HexStr, hashes_only: Literal[True]) List[TransactionHash]
async get_transactions(block_identifier: int | HexStr, hashes_only: Literal[False]) List[TransactionLegacy | Transaction2930 | Transaction1559 | Transaction4844 | Transaction7702]

Retrieves only the transactions from a specific block.

This method skips decoding the rest of the Block response data.

Parameters:
  • block_identifier – The block number or hash from which to retrieve the transactions.

  • hashes_only – If True, only transaction hashes will be returned.

Example

>>> [print(tx.hash) for tx in await dank_mids.eth.get_transactions(12345678)]
async get_uncle_count(block_identifier)
Parameters:

block_identifier (Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | ~eth_typing.evm.BlockNumber | ~eth_typing.evm.Hash32 | ~eth_typing.encoding.HexStr | ~hexbytes.main.HexBytes | int)

Return type:

int

icap_namereg()
Return type:

NoReturn

async modify_transaction(transaction_hash, **transaction_params)
Parameters:
  • transaction_hash (Hash32 | HexBytes | HexStr)

  • transaction_params (Any)

Return type:

HexBytes

namereg()
Return type:

NoReturn

async replace_transaction(transaction_hash, new_transaction)
Parameters:
  • transaction_hash (Hash32 | HexBytes | HexStr)

  • new_transaction (TxParams)

Return type:

HexBytes

async send_raw_transaction(transaction)
Parameters:

transaction (HexStr | bytes)

Return type:

HexBytes

async send_transaction(transaction)
Parameters:

transaction (TxParams)

Return type:

HexBytes

send_transaction_munger(transaction)
Parameters:

transaction (TxParams)

Return type:

Tuple[TxParams]

set_contract_factory(contract_factory)
Parameters:

contract_factory (Type[AsyncContract | AsyncContractCaller])

Return type:

None

set_gas_price_strategy(gas_price_strategy)
Parameters:

gas_price_strategy (Callable[[Web3, TxParams], Wei] | Callable[[AsyncWeb3, TxParams], Wei] | None)

Return type:

None

async sign(account, data=None, hexstr=None, text=None)
Parameters:
  • account (Address | ChecksumAddress | ENS)

  • data (int | bytes | None)

  • hexstr (HexStr | None)

  • text (str | None)

Return type:

HexStr

sign_munger(account, data=None, hexstr=None, text=None)
Parameters:
  • account (Address | ChecksumAddress | ENS)

  • data (int | bytes | None)

  • hexstr (HexStr | None)

  • text (str | None)

Return type:

Tuple[Address | ChecksumAddress | ENS, HexStr]

async sign_transaction(transaction)
Parameters:

transaction (TxParams)

Return type:

SignedTx

async sign_typed_data(account, data)
Parameters:
  • account (Address | ChecksumAddress | ENS)

  • data (str)

Return type:

HexStr

async subscribe(subscription_type, subscription_arg=None)
Parameters:
  • subscription_type (Literal['newHeads', 'logs', 'newPendingTransactions', 'syncing'])

  • subscription_arg (LogsSubscriptionArg | bool | None)

Return type:

HexStr

async trace_filter(filter_params, decode_to=typing.List[typing.Union[evmspec.structs.trace.call.Trace, evmspec.structs.trace.create.Trace, evmspec.structs.trace.reward.Trace, evmspec.structs.trace.suicide.Trace]], decode_hook=<function _decode_hook>)

Returns all traces matching a filter. If the decoding to the specified type fails, the method logs problematic traces and re-raises the exception as a diagnostic aid.

Parameters:
  • filter_params (TraceFilterParams) – The parameters defining the traces to filter.

  • decode_to (Type[T]) – The class to which traces should be decoded.

  • decode_hook (Callable[[Type[T], Any], T] | None) – Hook function to assist in decoding.

Raises:

ValidationError – If a trace cannot be decoded.

Return type:

T

async trace_transaction(transaction_hash)

Returns all traces produced by a transaction.

Parameters:

transaction_hash (str) – The hash of the transaction to trace.

Return type:

List[Trace | Trace | Trace | Trace]

Example

>>> traces = await dank_mids.eth.trace_transaction('0x...')
async uninstall_filter(filter_id)
Parameters:

filter_id (HexStr)

Return type:

bool

async unsubscribe(subscription_id)
Parameters:

subscription_id (HexStr)

Return type:

bool

async wait_for_transaction_receipt(transaction_hash, timeout=120, poll_latency=0.1)
Parameters:
Return type:

TxReceipt

account = <eth_account.account.Account object>
property accounts: Tuple[ChecksumAddress]
property block_number: BlockNumber
chain_id
property codec: ABICodec
property coinbase: ChecksumAddress
property default_account: ChecksumAddress | Empty
property default_block: Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | BlockNumber | Hash32 | HexStr | HexBytes | int
filter: Method[Callable[[str | FilterParams | HexStr | None], Awaitable[AsyncFilter]]]
property gas_price: Wei
get_block_transaction_count: Method[Callable[[BlockIdentifier], Awaitable[int]]]
get_filter_changes

Custom method class to bypass web3py’s default result formatters.

This class processes parameters, makes conditional adjustments to the parameters, and selects specific methods to call based on those parameters. It bypasses the standard result formatters by applying a no-operation formatter, effectively returning responses as-is or using predefined formatters based on the RPC call.

get_filter_logs

Custom method class to bypass web3py’s default result formatters.

This class processes parameters, makes conditional adjustments to the parameters, and selects specific methods to call based on those parameters. It bypasses the standard result formatters by applying a no-operation formatter, effectively returning responses as-is or using predefined formatters based on the RPC call.

property hashrate: int
is_async = True
property max_priority_fee: Wei

Try to use eth_maxPriorityFeePerGas but, since this is not part of the spec and is only supported by some clients, fall back to an eth_feeHistory calculation with min and max caps.

meth

Custom method class to bypass web3py’s default result formatters.

This class processes parameters, makes conditional adjustments to the parameters, and selects specific methods to call based on those parameters. It bypasses the standard result formatters by applying a no-operation formatter, effectively returning responses as-is or using predefined formatters based on the RPC call.

property mining: bool
property syncing: SyncStatus | bool
w3: AsyncWeb3
class dank_mids.eth.TraceFilterParams

Bases: TypedDict

__getitem__()

x.__getitem__(y) <==> x[y]

__init__(*args, **kwargs)
__iter__()

Implement iter(self).

clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
after: int
count: int
fromAddress: Sequence[Address | ChecksumAddress | ENS]
fromBlock: Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | BlockNumber | Hash32 | HexStr | HexBytes | int
toAddress: Sequence[Address | ChecksumAddress | ENS]
toBlock: Literal['latest', 'earliest', 'pending', 'safe', 'finalized'] | BlockNumber | Hash32 | HexStr | HexBytes | int
dank_mids.eth.decode_timestamped(self, buf)

Deserialize an object from JSON.

Parameters:

buf (bytes-like or str) – The message to decode.

Returns:

obj – The deserialized object.

Return type:

Any

dank_mids.eth.decode_tiny_block(self, buf)

Deserialize an object from JSON.

Parameters:

buf (bytes-like or str) – The message to decode.

Returns:

obj – The deserialized object.

Return type:

Any

dank_mids.eth.decode_transaction(self, buf)

Deserialize an object from JSON.

Parameters:

buf (bytes-like or str) – The message to decode.

Returns:

obj – The deserialized object.

Return type:

Any

dank_mids.eth.decode_transaction_rlp(self, buf)

Deserialize an object from JSON.

Parameters:

buf (bytes-like or str) – The message to decode.

Returns:

obj – The deserialized object.

Return type:

Any

dank_mids.exceptions module

exception dank_mids.exceptions.BrownieNotConnectedError

Bases: RuntimeError

RuntimeError raised when brownie is not connected but needs to be in order to access functionality within dank_mids.brownie_patch.

__init__(obj_name)

Initializes a new BrownieNotConnectedError.

Params:

obj_name: The name of the object the user attempted to access, which requires brownie to be connected.

Parameters:

obj_name (str)

exception dank_mids.exceptions.GarbageCollectionError

Bases: RuntimeError

Exception raised when an object is garbage collected prematurely.

exception dank_mids.exceptions.Revert

Bases: ValueError

dank_mids.lock module

dank_mids.logging module

class dank_mids.logging.CLogger

Bases: Logger

__init__(*args, **kwargs)
addFilter(filter)

Add the specified filter to this handler.

addHandler(hdlr)

Add the specified handler to this logger.

callHandlers(record)

Pass a record to all relevant handlers.

Loop through all handlers for this logger and its parents in the logger hierarchy. If no handler was found, output a one-off error message to sys.stderr. Stop searching up the hierarchy whenever a logger with the “propagate” attribute set to zero is found - that will be the last logger whose handlers are called.

critical(msg, *args, **kwargs)

Log ‘msg % args’ with severity ‘CRITICAL’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.critical(“Houston, we have a %s”, “major disaster”, exc_info=1)

debug(msg, *args, **kwargs)

Log ‘msg % args’ with severity ‘DEBUG’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.debug(“Houston, we have a %s”, “thorny problem”, exc_info=1)

error(msg, *args, **kwargs)

Log ‘msg % args’ with severity ‘ERROR’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.error(“Houston, we have a %s”, “major problem”, exc_info=1)

exception(msg, *args, exc_info=True, **kwargs)

Convenience method for logging an ERROR with exception information.

fatal(msg, *args, **kwargs)

Don’t use this method, use critical() instead.

filter(record)

Determine if a record is loggable by consulting all the filters.

The default is to allow the record to be logged; any filter can veto this and the record is then dropped. Returns a zero value if a record is to be dropped, else non-zero.

Changed in version 3.2: Allow filters to be just callables.

findCaller(stack_info=False, stacklevel=1)

Find the stack frame of the caller so that we can note the source file name, line number and function name.

getChild(suffix)

Get a logger which is a descendant to this one.

This is a convenience method, such that

logging.getLogger(‘abc’).getChild(‘def.ghi’)

is the same as

logging.getLogger(‘abc.def.ghi’)

It’s useful, for example, when the parent logger is named using __name__ rather than a literal string.

getEffectiveLevel()

Get the effective level for this logger.

Loop through this logger and its parents in the logger hierarchy, looking for a non-zero logging level. Return the first one found.

handle(record)

Call the handlers for the specified record.

This method is used for unpickled records received from a socket, as well as those created locally. Logger-level filtering is applied.

hasHandlers()

See if this logger has any handlers configured.

Loop through all handlers for this logger and its parents in the logger hierarchy. Return True if a handler was found, else False. Stop searching up the hierarchy whenever a logger with the “propagate” attribute set to zero is found - that will be the last logger which is checked for the existence of handlers.

info(msg, *args, **kwargs)

Log ‘msg % args’ with severity ‘INFO’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.info(“Houston, we have a %s”, “interesting problem”, exc_info=1)

isEnabledFor(level)

Is this logger enabled for level ‘level’?

log(level, msg, *args, **kwargs)

Log ‘msg % args’ with the integer severity ‘level’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.log(level, “We have a %s”, “mysterious problem”, exc_info=1)

makeRecord(name, level, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)

A factory method which can be overridden in subclasses to create specialized LogRecords.

removeFilter(filter)

Remove the specified filter from this handler.

removeHandler(hdlr)

Remove the specified handler from this logger.

setLevel(level)

Set the logging level of this logger. level must be an int or a str.

warn(msg, *args, **kwargs)
warning(msg, *args, **kwargs)

Log ‘msg % args’ with severity ‘WARNING’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.warning(“Houston, we have a %s”, “bit of a problem”, exc_info=1)

disabled
handlers
level
manager = <logging.Manager object>
name
parent
propagate
root = <RootLogger root (WARNING)>
dank_mids.logging.get_c_logger(name)
dank_mids.logging.use_c_logger_class()

dank_mids.middleware module

dank_mids.semaphores module

class dank_mids.semaphores.BlockSemaphore

Bases: _AbstractPrioritySemaphore

A semaphore for managing concurrency based on block numbers.

This class extends _AbstractPrioritySemaphore to provide block-specific concurrency control.

Parameters:
  • value – The initial value of the semaphore.

  • name – An optional name for the semaphore.

See also

_BlockSemaphoreContextManager: The context manager used by this semaphore.

__call__(self, fn: CoroFn[P, T]) CoroFn[P, T]

Decorator method to wrap coroutine functions with the semaphore.

This allows rewriting the pattern of acquiring a semaphore within a coroutine using a decorator.

Example

semaphore = Semaphore(5)

@semaphore async def limited():

return 1

__getitem__(self, priority: PT | None) '_AbstractPrioritySemaphoreContextManager[PT]'

Gets the context manager for a given priority.

Parameters:
  • priority – The priority for which to get the context manager. If None, uses the top priority.

  • block (int | HexStr | Literal['latest', None])

Returns:

The context manager associated with the given priority.

Return type:

_BlockSemaphoreContextManager

Examples

>>> semaphore = _AbstractPrioritySemaphore(5)
>>> context_manager = semaphore[priority]
__init__(value=1, *, name=None)

Initializes the priority semaphore.

Parameters:
  • value – The initial capacity of the semaphore.

  • name – An optional name for the semaphore, used for debugging.

Return type:

None

Examples

>>> semaphore = _AbstractPrioritySemaphore(5, name="test_semaphore")
acquire(self)

Acquires the semaphore with the top priority.

This method overrides Semaphore.acquire() to handle priority-based logic.

Examples

>>> semaphore = _AbstractPrioritySemaphore(5)
>>> await semaphore.acquire()
decorate(self, fn: CoroFn[P, T]) CoroFn[P, T]

Wrap a coroutine function to ensure it runs with the semaphore.

Example

semaphore = Semaphore(5)

@semaphore async def limited():

return 1

Parameters:

fn (Callable[[~P], Awaitable[T]])

Return type:

Callable[[~P], Awaitable[T]]

locked(self) bool

Checks if the semaphore is locked.

Returns:

True if the semaphore cannot be acquired immediately, False otherwise.

Examples

>>> semaphore = _AbstractPrioritySemaphore(5)
>>> semaphore.locked()
release(self) void

Release a semaphore, incrementing the internal counter by one.

When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine.

debug_logs_enabled

bool

Checks if debug logging is enabled for the logger.

Examples

>>> class MyClass(_LoggerMixin):
...     pass
...
>>> instance = MyClass()
>>> instance.debug_logs_enabled
False
Type:

_LoggerMixin.debug_logs_enabled

logger

Logger

Provides a logger instance specific to the class using this mixin.

The logger ID is constructed from the module and class name, and optionally includes an instance name if available.

Examples

>>> class MyClass(_LoggerMixin):
...     _name = "example"
...
>>> instance = MyClass()
>>> logger = instance.logger
>>> logger.name
'module_name.MyClass.example'
>>> class AnotherClass(_LoggerMixin):
...     pass
...
>>> another_instance = AnotherClass()
>>> another_logger = another_instance.logger
>>> another_logger.name
'module_name.AnotherClass'

Note

Replace module_name with the actual module name where the class is defined.

Type:

_LoggerMixin.logger

name

str

Type:

Semaphore.name

dank_mids.types module

class dank_mids.types.BlockId

A type representing the identifier for a specific block in the blockchain.

alias of str

class dank_mids.types.ChainstackRateLimitContext

Bases: DictStruct

Chainstack doesn’t use status code 429 for rate limiting, they attach one of these objects to a 200 response.

__getitem__(attr)

Lookup an attribute value via dictionary-style access.

Parameters:

attr (str) – The name of the attribute to access.

Raises:

KeyError – If the provided key is not a member of the struct.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s['field1']
'value'
>>> s['field2']
Traceback (most recent call last):
    ...
KeyError: ('field2', MyStruct(field1='value'))
__iter__()

Iterate through the keys of the Struct.

Yields:

Struct key.

Return type:

Iterator[str]

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(iter(s))
['field1', 'field2']
get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

logger: ClassVar = <CLogger dank_mids.chainstack (WARNING)>
property try_again_in: float

Calculates the time to wait before retrying the request.

Returns:

The number of seconds to wait before retrying.

Raises:

NotImplementedError – If the time string is in an unrecognized format.

class dank_mids.types.Error

Bases: DictStruct

Represents an error in a JSON-RPC response.

__getitem__(attr)

Lookup an attribute value via dictionary-style access.

Parameters:

attr (str) – The name of the attribute to access.

Raises:

KeyError – If the provided key is not a member of the struct.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s['field1']
'value'
>>> s['field2']
Traceback (most recent call last):
    ...
KeyError: ('field2', MyStruct(field1='value'))
__iter__()

Iterate through the keys of the Struct.

Yields:

Struct key.

Return type:

Iterator[str]

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(iter(s))
['field1', 'field2']
get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

to_dict(*, context: None = None) RPCError
to_dict(*, context: PartialRequest) RPCErrorWithContext
values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

code: int

The error code.

data: str | ChainstackRateLimitContext | None

Additional error data, if any.

EVM specs say it should be a string, but some providers will return a dictionary here with even more context.

message: str

The error message.

class dank_mids.types.OverrideParams

Bases: dict

A typed dictionary representing override parameters.

__getitem__()

x.__getitem__(y) <==> x[y]

__init__(*args, **kwargs)
__iter__()

Implement iter(self).

clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
code: str
class dank_mids.types.PartialRequest

Bases: DictStruct

Represents a partial JSON-RPC request.

While technially part of a request, we can successfully make requests to many nodes without including the jsonrpc field.

This class leaves off the jsonrpc field reduce encoding burden and web traffic.

This works with many but not all nodes.

__getitem__(attr)

Lookup an attribute value via dictionary-style access.

Parameters:

attr (str) – The name of the attribute to access.

Raises:

KeyError – If the provided key is not a member of the struct.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s['field1']
'value'
>>> s['field2']
Traceback (most recent call last):
    ...
KeyError: ('field2', MyStruct(field1='value'))
__iter__()

Iterate through the keys of the Struct.

Yields:

Struct key.

Return type:

Iterator[str]

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(iter(s))
['field1', 'field2']
get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property data: bytes
id: str | int

The request identifier.

method: str

The RPC method to be called.

params: list | None

The parameters for the RPC method call.

class dank_mids.types.PartialResponse

Bases: DictStruct

Represents a partial JSON-RPC response.

We use these to more efficiently decode responses from the node.

__getitem__(attr)

Lookup an attribute value via dictionary-style access.

Parameters:

attr (str) – The name of the attribute to access.

Raises:

KeyError – If the provided key is not a member of the struct.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s['field1']
'value'
>>> s['field2']
Traceback (most recent call last):
    ...
KeyError: ('field2', MyStruct(field1='value'))
__iter__()

Iterate through the keys of the Struct.

Yields:

Struct key.

Return type:

Iterator[str]

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(iter(s))
['field1', 'field2']
decode_result(method=None, *, caller=None)
Parameters:

method (RPCEndpoint | None)

Return type:

HexBytes | Wei | uint | ChainId | BlockNumber | AttributeDict | str

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

to_dict(method=None)

Returns a complete dictionary representation of this response Struct.

Parameters:

method (RPCEndpoint | None)

Return type:

RPCResponse

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

error: Error | None

The error object, if the call failed.

property exception: Exception

If the rpc response contains an ‘error’ field, returns a specialized exception for the specified rpc error.

property payload_too_large: bool
result: Raw

The result of the RPC call, if successful.

class dank_mids.types.RPCErrorWithContext

Bases: RPCError

__getitem__()

x.__getitem__(y) <==> x[y]

__init__(*args, **kwargs)
__iter__()

Implement iter(self).

clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
code: int
dank_mids_added_context: PartialRequest
data: NotRequired[str]
message: str
class dank_mids.types.Request

Bases: PartialRequest

Represents a complete JSON-RPC request.

Inherits from PartialRequest and adds the JSON-RPC version.

__getitem__(attr)

Lookup an attribute value via dictionary-style access.

Parameters:

attr (str) – The name of the attribute to access.

Raises:

KeyError – If the provided key is not a member of the struct.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s['field1']
'value'
>>> s['field2']
Traceback (most recent call last):
    ...
KeyError: ('field2', MyStruct(field1='value'))
__iter__()

Iterate through the keys of the Struct.

Yields:

Struct key.

Return type:

Iterator[str]

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(iter(s))
['field1', 'field2']
get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

property data: bytes
id: str | int

The request identifier.

jsonrpc: Literal['2.0']

The JSON-RPC version, always set to “2.0”.

method: str

The RPC method to be called.

params: list | None

The parameters for the RPC method call.

class dank_mids.types.Response

Bases: PartialResponse

Represents a complete JSON-RPC response.

Inherits from PartialResponse and adds the response identifier and JSON-RPC version.

__getitem__(attr)

Lookup an attribute value via dictionary-style access.

Parameters:

attr (str) – The name of the attribute to access.

Raises:

KeyError – If the provided key is not a member of the struct.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s['field1']
'value'
>>> s['field2']
Traceback (most recent call last):
    ...
KeyError: ('field2', MyStruct(field1='value'))
__iter__()

Iterate through the keys of the Struct.

Yields:

Struct key.

Return type:

Iterator[str]

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(iter(s))
['field1', 'field2']
decode_result(method=None, *, caller=None)
Parameters:

method (RPCEndpoint | None)

Return type:

HexBytes | Wei | uint | ChainId | BlockNumber | AttributeDict | str

get(key, default=None)

Get the value associated with a key, or a default value if the key is not present.

Parameters:
  • key (str) – The key to look up.

  • default (optional) – The value to return if the key is not present.

Return type:

Any

Example

>>> class MyStruct(DictStruct):
...     field1: str
>>> s = MyStruct(field1="value")
>>> s.get('field1')
'value'
>>> s.get('field2', 'default')
'default'
items()

Returns an iterator over the struct’s field name and value pairs.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.items())
[('field1', 'value'), ('field2', 42)]
Return type:

Iterator[Tuple[str, Any]]

keys()

Returns an iterator over the field names of the struct.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.keys())
['field1', 'field2']
Return type:

Iterator[str]

to_dict(method=None)

Returns a complete dictionary representation of this response Struct.

Parameters:

method (RPCEndpoint | None)

Return type:

RPCResponse

values()

Returns an iterator over the struct’s field values.

Example

>>> class MyStruct(DictStruct):
...     field1: str
...     field2: int
>>> s = MyStruct(field1="value", field2=42)
>>> list(s.values())
['value', 42]
Return type:

Iterator[Any]

error: Error | None

The error object, if the call failed.

property exception: Exception

If the rpc response contains an ‘error’ field, returns a specialized exception for the specified rpc error.

id: str | int | None

The response identifier, matching the request.

jsonrpc: Literal['2.0']

The JSON-RPC version, always set to “2.0”.

property payload_too_large: bool
result: Raw

The result of the RPC call, if successful.

class dank_mids.types.eth_callParams

Bases: dict

A typed dictionary representing the parameters for an eth_call.

See also

web3.eth.Eth.call(): Web3’s method to perform a call without creating a transaction.

__getitem__()

x.__getitem__(y) <==> x[y]

__init__(*args, **kwargs)
__iter__()

Implement iter(self).

clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
data: str
to: ChecksumAddress
dank_mids.types.better_decode(data, *, type=None, dec_hook=None, method=None)
Parameters:
Return type:

T

dank_mids.types.decode_nested_dict(self, buf)

Deserialize an object from JSON.

Parameters:

buf (bytes-like or str) – The message to decode.

Returns:

obj – The deserialized object.

Return type:

Any

dank_mids.types.decode_string(self, buf)

Deserialize an object from JSON.

Parameters:

buf (bytes-like or str) – The message to decode.

Returns:

obj – The deserialized object.

Return type:

Any

dank_mids.types.encode(self, obj)

Serialize an object to bytes.

Parameters:

obj (Any) – The object to serialize.

Returns:

data – The serialized object.

Return type:

bytes

dank_mids.types.AsyncMiddleware

A type alias for asynchronous middleware functions.

alias of Callable[[RPCEndpoint, Any], Coroutine[Any, Any, RPCResponse]]

dank_mids.types.BatchId

A type representing the identifier for a batch of operations, which can be either an integer or a string.

alias of int | str

dank_mids.types.JsonrpcParams

A list of parameters for JSON-RPC calls, which should be eth_callParams, BlockId, and OverrideParams, in that order.

alias of List[eth_callParams | BlockId | OverrideParams]

dank_mids.types.Multicalls

A dictionary mapping BlockId to Multicall objects.

See also

dank_mids._requests.Multicall: The Multicall class used in this mapping.

alias of Dict[BlockId, Multicall]

Module contents