コード例 #1
0
ファイル: types.py プロジェクト: westonplatter/web3.py
    topic: HexBytes
    topics: Sequence[HexBytes]
    transactionHash: HexBytes
    transactionIndex: int


# syntax b/c "from" keyword not allowed w/ class construction
TxData = TypedDict("TxData", {
    "blockHash": HexBytes,
    "blockNumber": BlockNumber,
    "chainId": int,
    "data": Union[bytes, HexStr],
    "from": ChecksumAddress,
    "gas": Wei,
    "gasPrice": Wei,
    "hash": HexBytes,
    "input": HexStr,
    "nonce": Nonce,
    "r": HexBytes,
    "s": HexBytes,
    "to": ChecksumAddress,
    "transactionIndex": int,
    "v": int,
    "value": Wei,
}, total=False)


# syntax b/c "from" keyword not allowed w/ class construction
TxParams = TypedDict("TxParams", {
    "chainId": int,
    "data": Union[bytes, HexStr],
    # addr or ens
コード例 #2
0
    topics: Sequence[HexBytes]
    transactionHash: HexBytes
    transactionIndex: int


# syntax b/c "from" keyword not allowed w/ class construction
TxData = TypedDict("TxData", {
    "blockHash": HexBytes,
    "blockNumber": BlockNumber,
    "chainId": int,
    "data": Union[bytes, HexStr],
    "from": ChecksumAddress,
    "gas": Wei,
    "gasPrice": Wei,
    "hash": HexBytes,
    "input": HexStr,
    "nonce": Nonce,
    "r": HexBytes,
    "s": HexBytes,
    "to": ChecksumAddress,
    "transactionIndex": int,
    "v": int,
    "value": Wei,
},
                   total=False)

# syntax b/c "from" keyword not allowed w/ class construction
TxParams = TypedDict(
    "TxParams",
    {
        "chainId": int,
コード例 #3
0
ファイル: cache.py プロジェクト: danhper/web3.py
AVG_BLOCK_TIME_UPDATED_AT_KEY: Literal[
    'avg_block_time_updated_at'] = 'avg_block_time_updated_at'


def _is_latest_block_number_request(method: RPCEndpoint, params: Any) -> bool:
    if method != 'eth_getBlockByNumber':
        return False
    elif params[:1] == ['latest']:
        return True
    return False


BlockInfoCache = TypedDict("BlockInfoCache", {
    "avg_block_time": float,
    "avg_block_sample_size": int,
    "avg_block_time_updated_at": float,
    "latest_block": BlockData,
},
                           total=False)


def construct_latest_block_based_cache_middleware(
    cache_class: Callable[..., Dict[Any, Any]],
    rpc_whitelist: Collection[RPCEndpoint] = BLOCK_NUMBER_RPC_WHITELIST,
    average_block_time_sample_size: int = 240,
    default_average_block_time: int = 15,
    should_cache_fn: Callable[[RPCEndpoint, Any, RPCResponse],
                              bool] = _should_cache
) -> Middleware:
    """
    Constructs a middleware which caches responses based on the request
コード例 #4
0
from eth_typing import (
    Address,
    ChecksumAddress,
)
from eth_utils import (
    is_string,
    to_checksum_address,
)

from web3._utils.compat import (
    TypedDict, )
from web3._utils.validation import (
    validate_address, )

IbanOptions = TypedDict("IbanOptions", {
    "institution": str,
    "identifier": str,
})


def pad_left_hex(value: str, num_bytes: int) -> str:
    return value.rjust(num_bytes * 2, '0')


def iso13616Prepare(iban: str) -> str:
    """
    Prepare an IBAN for mod 97 computation by moving the first
    4 chars to the end and transforming the letters to numbers
    (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.

    @method iso13616Prepare
    @param {String} iban the IBAN
コード例 #5
0
ファイル: types.py プロジェクト: lionel-martin/web3.py
)

from web3._utils.compat import (
    TypedDict,
)
from web3.datastructures import (
    NamedElementOnion,
)

Wei = NewType('Wei', int)


# todo: move these to eth_typing once web3 is type hinted
ABIEventParams = TypedDict("ABIEventParams", {
    "name": str,
    "type": str,
    "indexed": bool,
})

ENS = NewType("ENS", str)

ABIEvent = TypedDict("ABIEvent", {
    "type": "event",
    "name": str,
    "inputs": Sequence[ABIEventParams],
    "anonymous": bool,
})


ABIFunctionComponents = TypedDict("ABIFunctionParams", {
    "name": str,
コード例 #6
0
Wei = NewType('Wei', int)
TReturn = TypeVar("TReturn")
TParams = TypeVar("TParams")
TValue = TypeVar("TValue")

Nonce = NewType("Nonce", int)

HexBytes32 = NewType("HexBytes32", HexBytes)
HexStr32 = NewType("HexStr32", HexStr)

_Hash32 = Union[Hash32, HexBytes, HexStr]

# todo: move these to eth_typing once web3 is type hinted
ABIEventParams = TypedDict("ABIEventParams", {
    "name": str,
    "type": str,
    "indexed": bool,
}, total=False)


ABIEvent = TypedDict("ABIEvent", {
    "type": Literal["event"],
    "name": str,
    "inputs": Sequence["ABIEventParams"],
    "anonymous": bool,
}, total=False)


ABIFunctionComponents = TypedDict("ABIFunctionComponents", {
    "name": str,
    "type": str,
コード例 #7
0
ファイル: types.py プロジェクト: SkywalkingZulu/web3.py
    BlockNumber,
    ChecksumAddress,
    Hash32,
    HexStr,
)
from hexbytes import (
    HexBytes, )

from web3._utils.compat import (
    TypedDict, )

# todo: move these to eth_typing once web3 is type hinted

ABIEventParameter = TypedDict("ABIEventParameter", {
    "name": str,
    "type": str,
    "indexed": bool,
})

ABIEvent = TypedDict(
    "ABIEvent", {
        "type": "event",
        "name": str,
        "inputs": Sequence[ABIEventParameter],
        "anonymous": bool,
    })

ABIFunctionComponents = TypedDict(
    "ABIFunctionParameter", {
        "name": str,
        "type": str,
コード例 #8
0
ファイル: types.py プロジェクト: fubuloubu/web3.py
    transactionIndex: int


# syntax b/c "from" keyword not allowed w/ class construction
TxData = TypedDict("TxData", {
    "accessList": AccessList,
    "blockHash": HexBytes,
    "blockNumber": BlockNumber,
    "chainId": int,
    "data": Union[bytes, HexStr],
    "from": ChecksumAddress,
    "gas": int,
    "gasPrice": Wei,
    "maxFeePerGas": Wei,
    "maxPriorityFeePerGas": Wei,
    "hash": HexBytes,
    "input": HexStr,
    "nonce": Nonce,
    "r": HexBytes,
    "s": HexBytes,
    "to": ChecksumAddress,
    "transactionIndex": int,
    "type": Union[int, HexStr],
    "v": int,
    "value": Wei,
},
                   total=False)

# syntax b/c "from" keyword not allowed w/ class construction
TxParams = TypedDict(
    "TxParams",