Ejemplo n.º 1
0
    def json_dict_to_receipt_log(self, json_dict):
        receipt_log = EthReceiptLog()

        receipt_log.log_index = hex_to_dec(json_dict.get('logIndex'))
        receipt_log.transaction_hash = json_dict.get('transactionHash')
        receipt_log.transaction_index = hex_to_dec(json_dict.get('transactionIndex'))
        receipt_log.block_hash = json_dict.get('blockHash')
        receipt_log.block_number = hex_to_dec(json_dict.get('blockNumber'))
        receipt_log.address = json_dict.get('address')
        receipt_log.data = json_dict.get('data')
        receipt_log.topics = json_dict.get('topics')

        return receipt_log
def test_extract_transfer_from_receipt_log():
    log = EthReceiptLog()
    log.address = '0x25c6413359059694A7FCa8e599Ae39Ce1C944Da2'
    log.block_number = 1061946
    log.data = '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18'
    log.log_index = 0
    log.topics = ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
                  '0x000000000000000000000000e9eeaec75883f0e389a78e2260bfac1776df2f1d',
                  '0x0000000000000000000000000000000000000000000000000000000000000000']
    log.transaction_hash = '0xd62a74c7b04e8e0539398f6ba6a5eb11ad8aa862e77f0af718f0fad19b0b0480'

    token_transfer = token_transfer_extractor.extract_transfer_from_log(log)

    assert token_transfer.token_address == '0x25c6413359059694a7fca8e599ae39ce1c944da2'
    assert token_transfer.from_address == '0xe9eeaec75883f0e389a78e2260bfac1776df2f1d'
    assert token_transfer.to_address == '0x0000000000000000000000000000000000000000'
    assert token_transfer.value == 115792089237316195423570985008687907853269984665640564039457584007913129638936
    assert token_transfer.transaction_hash == '0xd62a74c7b04e8e0539398f6ba6a5eb11ad8aa862e77f0af718f0fad19b0b0480'
    assert token_transfer.block_number == 1061946
Ejemplo n.º 3
0
    def web3_dict_to_receipt_log(self, dict):

        receipt_log = EthReceiptLog()

        receipt_log.log_index = dict.get('logIndex', None)

        transaction_hash = dict.get('transactionHash', None)
        if transaction_hash is not None:
            transaction_hash = transaction_hash.hex()
        receipt_log.transaction_hash = transaction_hash

        block_hash = dict.get('blockHash', None)
        if block_hash is not None:
            block_hash = block_hash.hex()
        receipt_log.block_hash = block_hash

        receipt_log.block_number = dict.get('blockNumber', None)
        receipt_log.address = dict.get('address', None)
        receipt_log.data = dict.get('data', None)

        if 'topics' in dict:
            receipt_log.topics = [topic.hex() for topic in dict['topics']]

        return receipt_log
Ejemplo n.º 4
0
    def dict_to_receipt_log(self, dict):
        receipt_log = EthReceiptLog()

        receipt_log.log_index = dict.get('log_index')
        receipt_log.transaction_hash = dict.get('transaction_hash')
        receipt_log.transaction_index = dict.get('transaction_index')
        receipt_log.block_hash = dict.get('block_hash')
        receipt_log.block_number = dict.get('block_number')
        receipt_log.address = dict.get('address')
        receipt_log.data = dict.get('data')

        topics = dict.get('topics')
        if isinstance(topics, str):
            if len(topics.strip()) == 0:
                receipt_log.topics = []
            else:
                receipt_log.topics = topics.strip().split(',')
        else:
            receipt_log.topics = topics

        return receipt_log