示例#1
0
def test_arrays():
    assert Array(String()).type_name == 'string[]'
    assert Array(String(), 4).type_name == 'string[4]'

    assert Array(Bytes(17)).type_name == 'bytes17[]'
    assert Array(Bytes(17), 10).type_name == 'bytes17[10]'

    assert Array(Array(Uint(160))).type_name == 'uint160[][]'
示例#2
0
文件: order.py 项目: gnosis/gnosis-py
class Order(EIP712Struct):
    sellToken = Address()
    buyToken = Address()
    receiver = Address()
    sellAmount = Uint(256)
    buyAmount = Uint(256)
    validTo = Uint(32)
    appData = Bytes(32)
    feeAmount = Uint(256)
    kind = String()  # `sell` or `buy`
    partiallyFillable = Boolean()
    sellTokenBalance = String()  # `erc20`, `external` or `internal`
    buyTokenBalance = String()  # `erc20` or `internal`
示例#3
0
class Foo(EIP712Struct):
    s = String()
    u_i = Uint(256)
    s_i = Int(8)
    a = Address()
    b = Boolean()
    bytes_30 = Bytes(30)
    dyn_bytes = Bytes()
    bar = Bar
    arr = Array(Bytes(1))
 class TestStruct(EIP712Struct):
     address = Address()
     boolean = Boolean()
     dyn_bytes = Bytes()
     bytes_1 = Bytes(1)
     bytes_32 = Bytes(32)
     int_32 = Int(32)
     int_256 = Int(256)
     string = String()
     uint_32 = Uint(32)
     uint_256 = Uint(256)
示例#5
0
def test_from_solidity_type():
    assert from_solidity_type('address') == Address()
    assert from_solidity_type('bool') == Boolean()
    assert from_solidity_type('bytes') == Bytes()
    assert from_solidity_type('bytes32') == Bytes(32)
    assert from_solidity_type('int128') == Int(128)
    assert from_solidity_type('string') == String()
    assert from_solidity_type('uint256') == Uint(256)

    assert from_solidity_type('address[]') == Array(Address())
    assert from_solidity_type('address[10]') == Array(Address(), 10)
    assert from_solidity_type('bytes16[32]') == Array(Bytes(16), 32)

    # Sanity check that equivalency is working as expected
    assert from_solidity_type('bytes32') != Bytes(31)
    assert from_solidity_type('bytes16[32]') != Array(Bytes(16), 31)
    assert from_solidity_type('bytes16[32]') != Array(Bytes(), 32)
    assert from_solidity_type('bytes16[32]') != Array(Bytes(8), 32)
 class Person(EIP712Struct):
     name = String()
 class Mail(EIP712Struct):
     source = Person
     dest = Person
     content = String()
 class Person(EIP712Struct):
     name = String()
     addr = Address()
 class Person(EIP712Struct):
     name = String()
     addr = Address()
     numbers = Array(Int(256))
     moreNumbers = Array(Uint(256), 8)
示例#10
0
class Message(EIP712Struct):
    actionType = String()
    timestamp = Uint(256)
    authorizer = Identity
 class A(EIP712Struct):
     s = String()
     c = C
 class MainStruct(EIP712Struct):
     sub_1 = SubStruct
     sub_2 = String()
     sub_3 = SubStruct
 class SubStruct(EIP712Struct):
     s = String()
 class Bar(EIP712Struct):
     s = String()
     f = Foo
 class Foo(EIP712Struct):
     s = String()
     b = Bytes(32)
 class Foo(EIP712Struct):
     s = String()
 class Foo(EIP712Struct):
     s = String()
     i = Int(256)
 class B(EIP712Struct):
     s = String()
 class C(EIP712Struct):
     s = String()
     b = B
示例#20
0
def test_length_str_typing():
    # Ensure that if length is given as a string, it's typecast to int
    assert Array(String(), '5').fixed_length == 5
    assert Bytes('10').length == 10
    assert Int('128').length == 128
    assert Uint('128').length == 128
 class Z(EIP712Struct):
     s = String()
     a = A
示例#22
0
class EIP712Domain(EIP712Struct):
    name = String()
    version = String()
    chainId = Uint(256)
    verifyingContract = Address()