예제 #1
0
def inputPostFormatter(post):
    """
    Formats the input of a whisper post and converts all values to HEX
    """

    post["ttl"] = from_decimal(post["ttl"])
    post["workToProve"] = from_decimal(post.get("workToProve", 0))
    post["priority"] = from_decimal(post["priority"])

    if not is_array(post.get("topics")):
        post["topics"] = [post["topics"]] if post.get("topics") else []

    post["topics"] = [topic if is_0x_prefixed(topic) else encode_hex(topic)
                      for topic in post["topics"]]

    return post
예제 #2
0
def inputPostFormatter(post):
    """
    Formats the input of a whisper post and converts all values to HEX
    """

    post["ttl"] = from_decimal(post["ttl"])
    post["workToProve"] = from_decimal(post.get("workToProve", 0))
    post["priority"] = from_decimal(post["priority"])

    if not is_list_like(post.get("topics")):
        post["topics"] = [post["topics"]] if post.get("topics") else []

    post["topics"] = [
        topic if is_0x_prefixed(topic) else encode_hex(topic)
        for topic in post["topics"]
    ]

    return post
예제 #3
0
def test_conversion_rount_trip(value):
    intermediate_value = from_decimal(value)
    result_value = to_decimal(intermediate_value)
    error_msg = "Expected: {0!r}, Result: {1!r}, Intermediate: {2!r}".format(
        value,
        result_value,
        intermediate_value,
    )
    assert result_value == value, error_msg
예제 #4
0
def inputTransactionFormatter(options):
    """
    Formats the input of a transaction and converts all values to HEX
    """
    options.setdefault("from", config.defaultAccount)
    options["from"] = inputAddressFormatter(options["from"])

    if options.get("to"):
        options["to"] = inputAddressFormatter(options["to"])

    for key in ("gasPrice", "gas", "value", "nonce"):
        if key in options:
            options[key] = from_decimal(options[key])

    return options
예제 #5
0
def test_from_decimal(value, expected):
    assert from_decimal(value) == expected
예제 #6
0
파일: main.py 프로젝트: maxgillett/web3.py
 def fromDecimal(decimal):
     return from_decimal(decimal)
예제 #7
0
def test_conversion_rount_trip(value):
    intermediate_value = from_decimal(value)
    result_value = to_decimal(intermediate_value)
    assert result_value == value, "Expected: {0!r}, Result: {1!r}, Intermediate: {2!r}".format(value, result_value, intermediate_value)
예제 #8
0
def test_from_decimal(value, expected):
    assert from_decimal(value) == expected
예제 #9
0
def test_conversion_rount_trip(value):
    intermediate_value = from_decimal(value)
    result_value = to_decimal(intermediate_value)
    assert result_value == value