def handle(self, *args, **options): w3 = get_web3() chain = Chain.make(chain_id=int(w3.net.version)) EthereumToken.ETH(chain=chain) erc20_token_addresses = [ to_checksum_address(t) for t in TRACKED_TOKENS if t != EthereumToken.NULL_ADDRESS ] for token_address in erc20_token_addresses: logger.info(f"Checking token {token_address}...") try: token_data = get_token_information(w3=w3, address=token_address) EthereumToken.make(address=token_address, chain=chain, **token_data) except OverflowError: logger.error( f"{token_address} is not a valid address or not ERC20-compliant" ) except Exception as exc: logger.exception( f"Failed to load token data for {token_address}", exc_info=exc)
def handle(self, *args, **options): for token_address in TRACKED_TOKENS: logger.info(f"Checking token {token_address}...") try: EthereumToken.make(to_checksum_address(token_address)) except OverflowError: logger.error(f"{token_address} is not a valid address or not ERC20-compliant") except Exception as exc: logger.exception(f"Failed to load token data for {token_address}", exc_info=exc)
def sync_token_networks(client: RaidenClient, w3: Web3): logger.info("Updating Token Networks") chain_id = int(w3.net.version) known_tokens = client.raiden.token_networks.values_list("token__address", flat=True) for token_address in client.get_token_addresses(): if token_address in known_tokens: continue logger.info(f"Getting information about token on {token_address}") token = EthereumToken.make(token_address, chain_id) token_network_registry_contract = get_token_network_registry_contract(w3) token_network = models.TokenNetwork.make(token, token_network_registry_contract) client.raiden.token_networks.add(token_network)