Esempio n. 1
0
File: relay.py Progetto: JTpku/relay
 def get_ethindex_db_for_unw_eth(self, address: str):
     """return an EthindexDB instance
     This is being used from relay.api to query for events.
     """
     return ethindex_db.EthindexDB(
         ethindex_db.connect(""),
         address=address,
         standard_event_types=unw_eth_events.standard_event_types,
         event_builders=unw_eth_events.event_builders,
         from_to_types=unw_eth_events.from_to_types,
     )
Esempio n. 2
0
File: relay.py Progetto: JTpku/relay
    def get_user_events(
        self,
        user_address: str,
        event_type: str = None,
        from_block: int = 0,
        contract_type: ContractTypes = None,
    ) -> List[BlockchainEvent]:
        """
        Get all events of users for user_address.
        Filter with from_block, event_type and contract_type
        """
        assert is_checksum_address(user_address)
        event_types: Optional[List[str]]
        if event_type:
            event_types = [event_type]
        else:
            event_types = None

        address_to_contract_types: Dict[str, str] = {}

        if contract_type == ContractTypes.CURRENCY_NETWORK or contract_type is None:
            for address in self.network_addresses:
                address_to_contract_types[
                    address] = ContractTypes.CURRENCY_NETWORK.value
        if contract_type == ContractTypes.EXCHANGE or contract_type is None:
            for address in self.exchange_addresses:
                address_to_contract_types[
                    address] = ContractTypes.EXCHANGE.value
        if contract_type == ContractTypes.TOKEN or contract_type is None:
            for address in self.token_addresses:
                address_to_contract_types[address] = ContractTypes.TOKEN.value
        if contract_type == ContractTypes.UNWETH or contract_type is None:
            for address in self.unw_eth_addresses:
                address_to_contract_types[address] = ContractTypes.UNWETH.value

        ethindex = ethindex_db.EthindexDB(
            ethindex_db.connect(""),
            standard_event_types=all_standard_event_types,
            event_builders=all_event_builders,
            from_to_types=all_from_to_types,
            address_to_contract_types=address_to_contract_types,
        )
        return ethindex.get_all_contract_events(
            event_types,
            user_address=user_address,
            from_block=from_block,
        )