(self, explorer_url, address)
| 17861 | return ", ".join([f"{k}:{v}" for k, v in sorted(peer_map.items(), key=lambda x: x[1], reverse=True)[:top_n]]) |
| 17862 | |
| 17863 | def _evm_token_metadata(self, explorer_url, address): |
| 17864 | out = {"Token metadata": "N/A"} |
| 17865 | try: |
| 17866 | r = requests.get( |
| 17867 | f"https://{explorer_url}/api?module=account&action=tokentx&address={address}&page=1&offset=60&sort=desc", |
| 17868 | timeout=8 |
| 17869 | ) |
| 17870 | if r.status_code != 200: |
| 17871 | return out |
| 17872 | data = self._safe_response_json(r) |
| 17873 | if not isinstance(data, dict) or data.get("status") != "1": |
| 17874 | return out |
| 17875 | tokens = {} |
| 17876 | for item in data.get("result", []): |
| 17877 | sym = item.get("tokenSymbol") or item.get("tokenName") or "Unknown" |
| 17878 | name = item.get("tokenName") or "" |
| 17879 | dec = item.get("tokenDecimal") or "" |
| 17880 | tokens[sym] = {"name": name, "dec": dec} |
| 17881 | if tokens: |
| 17882 | out["Token metadata"] = ", ".join([f"{k} ({v['name']})" for k, v in list(tokens.items())[:15]]) |
| 17883 | except Exception: |
| 17884 | pass |
| 17885 | return out |
| 17886 | |
| 17887 | def get_crypto_data(self, address, name, ticker): |
| 17888 | """ |
no test coverage detected