dank_mids package
Subpackages
- dank_mids.brownie_patch package
- Submodules
- dank_mids.brownie_patch.call module
- dank_mids.brownie_patch.contract module
ContractContract.__init__()Contract.balance()Contract.decode_input()Contract.from_abi()Contract.from_ethpm()Contract.from_explorer()Contract.get_method()Contract.get_method_object()Contract.get_solc_version()Contract.info()Contract.remove_deployment()Contract.set_alias()Contract.abiContract.aliasContract.signaturesContract.topics
EventNameLogTopicMethodSignaturepatch_contract()retry_etherscan()
- dank_mids.brownie_patch.overloaded module
- dank_mids.brownie_patch.types module
DankContractCallDankContractCall.__call__()DankContractCall.__init__()DankContractCall.call()DankContractCall.coroutine()DankContractCall.decode_input()DankContractCall.decode_output()DankContractCall.encode_input()DankContractCall.estimate_gas()DankContractCall.info()DankContractCall.map()DankContractCall.transact()DankContractCall.abiDankContractCall.natspecDankContractCall.payableDankContractCall.signature
DankContractTxDankContractTx.__call__()DankContractTx.__init__()DankContractTx.call()DankContractTx.coroutine()DankContractTx.decode_input()DankContractTx.decode_output()DankContractTx.encode_input()DankContractTx.estimate_gas()DankContractTx.info()DankContractTx.map()DankContractTx.transact()DankContractTx.abiDankContractTx.natspecDankContractTx.payableDankContractTx.signature
DankOverloadedMethodDankOverloadedMethod.__call__()DankOverloadedMethod.__getitem__()DankOverloadedMethod.__init__()DankOverloadedMethod.call()DankOverloadedMethod.coroutine()DankOverloadedMethod.decode_input()DankOverloadedMethod.decode_output()DankOverloadedMethod.encode_input()DankOverloadedMethod.info()DankOverloadedMethod.map()DankOverloadedMethod.transact()DankOverloadedMethod.abiDankOverloadedMethod.methodsDankOverloadedMethod.signature
- Module contents
DankContractCallDankContractCall.__call__()DankContractCall.__init__()DankContractCall.call()DankContractCall.coroutine()DankContractCall.decode_input()DankContractCall.decode_output()DankContractCall.encode_input()DankContractCall.estimate_gas()DankContractCall.info()DankContractCall.map()DankContractCall.transact()DankContractCall.abiDankContractCall.natspecDankContractCall.payableDankContractCall.signature
DankContractTxDankContractTx.__call__()DankContractTx.__init__()DankContractTx.call()DankContractTx.coroutine()DankContractTx.decode_input()DankContractTx.decode_output()DankContractTx.encode_input()DankContractTx.estimate_gas()DankContractTx.info()DankContractTx.map()DankContractTx.transact()DankContractTx.abiDankContractTx.natspecDankContractTx.payableDankContractTx.signature
DankOverloadedMethodDankOverloadedMethod.__call__()DankOverloadedMethod.__getitem__()DankOverloadedMethod.__init__()DankOverloadedMethod.call()DankOverloadedMethod.coroutine()DankOverloadedMethod.decode_input()DankOverloadedMethod.decode_output()DankOverloadedMethod.encode_input()DankOverloadedMethod.info()DankOverloadedMethod.map()DankOverloadedMethod.transact()DankOverloadedMethod.abiDankOverloadedMethod.methodsDankOverloadedMethod.natspecDankOverloadedMethod.signature
- dank_mids.helpers package
- Submodules
- dank_mids.helpers.batch_size module
- dank_mids.helpers.future module
DebuggableFutureDebuggableFuture.__init__()DebuggableFuture.__iter__()DebuggableFuture.add_done_callback()DebuggableFuture.cancel()DebuggableFuture.cancelled()DebuggableFuture.done()DebuggableFuture.exception()DebuggableFuture.get_loop()DebuggableFuture.remove_done_callback()DebuggableFuture.result()DebuggableFuture.set_exception()DebuggableFuture.set_result()
error_logger_debug()
- dank_mids.helpers.hashing module
- dank_mids.helpers.lru_cache module
- dank_mids.helpers.method module
- Module contents
DebuggableFutureDebuggableFuture.__init__()DebuggableFuture.__iter__()DebuggableFuture.add_done_callback()DebuggableFuture.cancel()DebuggableFuture.cancelled()DebuggableFuture.done()DebuggableFuture.exception()DebuggableFuture.get_loop()DebuggableFuture.remove_done_callback()DebuggableFuture.result()DebuggableFuture.set_exception()DebuggableFuture.set_result()
gatherish()lru_cache_lite()lru_cache_lite_nonull()make_hashable()setup_dank_w3()setup_dank_w3_from_sync()
- dank_mids.stats package
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
- class dank_mids.eth.DankEth
Bases:
AsyncEth- __init__(w3)
- Parameters:
w3 (AsyncWeb3 | Web3)
- Return type:
None
- attach_methods(methods)
- 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:
- call_munger(transaction, block_identifier=None, state_override=None)
- Parameters:
- 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)
- async estimate_gas(transaction, block_identifier=None)
- 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)
- filter_munger(filter_params=None, filter_id=None)
- 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)
- get_block_munger(block_identifier, full_transactions=False)
- 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_fnand 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:
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.
- async get_raw_transaction(transaction_hash)
- async get_raw_transaction_by_block(block_identifier, index)
- async get_storage_at(account, position, block_identifier=None)
- get_storage_at_munger(account, position, block_identifier=None)
- 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)
- 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.
- async get_transaction_status(transaction_hash)
Retrieves the status of a transaction.
- 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)
- async modify_transaction(transaction_hash, **transaction_params)
- async replace_transaction(transaction_hash, new_transaction)
- async send_raw_transaction(transaction)
- 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)
- async sign(account, data=None, hexstr=None, text=None)
- sign_munger(account, data=None, hexstr=None, text=None)
- 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)
- 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:
Example
>>> traces = await dank_mids.eth.trace_transaction('0x...')
- async wait_for_transaction_receipt(transaction_hash, timeout=120, poll_latency=0.1)
- account = <eth_account.account.Account object>
- 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
- property gas_price: Wei
- 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.
- 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.
- 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
- 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.exceptions module
- exception dank_mids.exceptions.BrownieNotConnectedError
Bases:
RuntimeErrorRuntimeErrorraised when brownie is not connected but needs to be in order to access functionality withindank_mids.brownie_patch.
- exception dank_mids.exceptions.GarbageCollectionError
Bases:
RuntimeErrorException 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:
_AbstractPrioritySemaphoreA semaphore for managing concurrency based on block numbers.
This class extends
_AbstractPrioritySemaphoreto 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:
- 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
- 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
See also
- 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.
See also
- 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:
DictStructChainstack 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:
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.
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:
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)]
- 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']
- 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]
- 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:
DictStructRepresents 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:
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.
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:
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)]
- 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']
- 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]
- 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.
- class dank_mids.types.OverrideParams
Bases:
dictA 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
- class dank_mids.types.PartialRequest
Bases:
DictStructRepresents 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:
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.
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:
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)]
- 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']
- 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]
- class dank_mids.types.PartialResponse
Bases:
DictStructRepresents 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:
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.
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:
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)]
- 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']
- 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]
- property exception: Exception
If the rpc response contains an ‘error’ field, returns a specialized exception for the specified rpc error.
- 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
- dank_mids_added_context: PartialRequest
- class dank_mids.types.Request
Bases:
PartialRequestRepresents 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:
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.
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:
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)]
- 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']
- 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]
- class dank_mids.types.Response
Bases:
PartialResponseRepresents 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:
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.
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:
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)]
- 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']
- 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]
- property exception: Exception
If the rpc response contains an ‘error’ field, returns a specialized exception for the specified rpc error.
- result: Raw
The result of the RPC call, if successful.
- class dank_mids.types.eth_callParams
Bases:
dictA 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
- to: ChecksumAddress
- dank_mids.types.better_decode(data, *, type=None, dec_hook=None, method=None)
- 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:
- 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.
- 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]