Esempio n. 1
0
File: relay.py Progetto: JTpku/relay
    def get_trustline_events(
        self,
        network_address: str,
        user_address: str,
        counterparty_address: str,
        type: str = None,
        from_block: int = 0,
    ):
        if type is None:
            event_types = None
        else:
            event_types = [type]

        ethindex = ethindex_db.CurrencyNetworkEthindexDB(
            ethindex_db.connect(""),
            address=network_address,
            standard_event_types=currency_network_events.trustline_event_types,
            event_builders=currency_network_events.event_builders,
            from_to_types=currency_network_events.from_to_types,
        )

        events = ethindex.get_trustline_events(
            network_address,
            user_address,
            counterparty_address,
            event_types,
            from_block=from_block,
        )
        return events
Esempio n. 2
0
def make_ethindex_db(network_address, conn):
    return ethindex_db.CurrencyNetworkEthindexDB(
        conn,
        address=network_address,
        standard_event_types=currency_network_events.standard_event_types,
        event_builders=all_event_builders,
        from_to_types=currency_network_events.from_to_types,
        address_to_contract_types={
            network_address: ContractTypes.CURRENCY_NETWORK.value
        },
    )
Esempio n. 3
0
File: relay.py Progetto: JTpku/relay
 def get_ethindex_db_for_currency_network(
     self,
     network_address: Optional[str] = None
 ) -> ethindex_db.CurrencyNetworkEthindexDB:
     """return an EthindexDB instance.
     This is being used from relay.api to query for events.
     """
     return ethindex_db.CurrencyNetworkEthindexDB(
         ethindex_db.connect(""),
         address=network_address,
         standard_event_types=currency_network_events.standard_event_types,
         event_builders=currency_network_events.event_builders,
         from_to_types=currency_network_events.from_to_types,
     )
Esempio n. 4
0
def make_ethindex_db(network_address, postgres_port):
    conn = psycopg2.connect(
        cursor_factory=psycopg2.extras.RealDictCursor,
        database=POSTGRES_DATABASE,
        user=POSTGRES_USER,
        password=POSTGRES_PASSWORD,
        port=postgres_port,
    )
    return ethindex_db.CurrencyNetworkEthindexDB(
        conn,
        address=network_address,
        standard_event_types=currency_network_events.standard_event_types,
        event_builders=currency_network_events.event_builders,
        from_to_types=currency_network_events.from_to_types,
    )
Esempio n. 5
0
    def get_ethindex_db_for_currency_network(
        self, network_address: Optional[str] = None
    ) -> ethindex_db.CurrencyNetworkEthindexDB:
        """return an EthindexDB instance.
        This is being used from relay.api to query for events.
        """
        address_to_contract_types: Dict[str, str] = {}
        for address in self.network_addresses:
            address_to_contract_types[address] = ContractTypes.CURRENCY_NETWORK.value

        return ethindex_db.CurrencyNetworkEthindexDB(
            ethindex_db.connect(""),
            address=network_address,
            standard_event_types=currency_network_events.standard_event_types,
            event_builders=all_event_builders,
            from_to_types=currency_network_events.from_to_types,
            address_to_contract_types=address_to_contract_types,
        )