Пример #1
0
    def cast_return_data(self, outputs):
        if len(self.output_types) != 1:
            try:
                return decode_multi(self.output_types, outputs)
            except AssertionError:
                raise EmptyDataError("call to {0} unexpectedly returned no data".format(self))
        output_type = self.output_types[0]

        try:
            return decode_single(output_type, outputs)
        except AssertionError:
            raise EmptyDataError("call to {0} unexpectedly returned no data".format(self))
Пример #2
0
 def get_log_data(self, log_entry, indexed=False):
     values = self.cast_return_data(log_entry['data'], raw=True)
     event_data = {
         output['name']: value for output, value in zip(self.outputs, values)
     }
     if indexed:
         for idx, _input in enumerate(self.inputs):
             if _input['indexed']:
                 event_data[_input['name']] = decode_single(
                     _input['type'],
                     log_entry['topics'][idx + 1],
                 )
     return event_data
Пример #3
0
    def cast_return_data(self, outputs):
        if len(self.output_types) != 1:
            try:
                return decode_multi(self.output_types, outputs)
            except AssertionError:
                raise EmptyDataError(
                    "call to {0} unexpectedly returned no data".format(self))
        output_type = self.output_types[0]

        try:
            return decode_single(output_type, outputs)
        except AssertionError:
            raise EmptyDataError(
                "call to {0} unexpectedly returned no data".format(self))
Пример #4
0
def test_decode_bool(input, expected):
    output = decode_single('bool', input)
    assert output == expected
Пример #5
0
def test_decode_uint256(input, expected):
    output = decode_single('uint256', input)
    assert output == expected
Пример #6
0
def test_raises_on_empty_data(_type):
    with pytest.raises(AssertionError):
        decode_single(_type, '0x')
Пример #7
0
def test_decode_address(input, expected):
    output = decode_single('address', input)
    assert output == expected
Пример #8
0
def test_decode_address(input, expected):
    output = decode_single('address', input)
    assert output == expected
Пример #9
0
def test_decode_bytes():
    input = '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000024b0f07e44616263646162636461626364616263646162636461626364616263646162636400000000000000000000000000000000000000000000000000000000'
    output = decode_single('bytes', input)
    assert output == '\xb0\xf0~Dabcdabcdabcdabcdabcdabcdabcdabcd'
Пример #10
0
def test_raises_on_empty_data(_type):
    with pytest.raises(AssertionError):
        decode_single(_type, '0x')
Пример #11
0
def test_decode_bool(input, expected):
    output = decode_single('bool', input)
    assert output == expected
Пример #12
0
def test_decode_uint256(input, expected):
    output = decode_single('uint256', input)
    assert output == expected
Пример #13
0
    def cast_return_data(self, outputs):
        if len(self.output_types) != 1:
            return decode_multi(self.output_types, outputs)
        output_type = self.output_types[0]

        return decode_single(output_type, outputs)
Пример #14
0
def test_decode_bytes32(input, expected):
    output = decode_single('bytes32', input)
    assert output == expected
Пример #15
0
def test_decode_bytes32(input, expected):
    output = decode_single('bytes32', input)
    assert output == expected
Пример #16
0
def test_decode_bytes():
    input = '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000024b0f07e44616263646162636461626364616263646162636461626364616263646162636400000000000000000000000000000000000000000000000000000000'
    output = decode_single('bytes', input)
    assert output == '\xb0\xf0~Dabcdabcdabcdabcdabcdabcdabcdabcd'
Пример #17
0
    def cast_return_data(self, outputs):
        if len(self.output_types) != 1:
            return decode_multi(self.output_types, outputs)
        output_type = self.output_types[0]

        return decode_single(output_type, outputs)