Skip to content

Commit

Permalink
Update fetch_tokens.py
Browse files Browse the repository at this point in the history
  • Loading branch information
prettyirrelevant authored Jun 8, 2024
1 parent e8ba1a7 commit ff33895
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions backend/bridgebloc/apps/tokens/management/commands/fetch_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ class Command(BaseCommand):
SUPPORTED_COINGECKO_IDS = ('usd-coin', 'dai', 'tether', 'weth')

def handle(self, *args: Any, **options: Any) -> None: # noqa: ARG002
tokens_to_create = []
for coingecko_id in self.SUPPORTED_COINGECKO_IDS:
try:
token_data = self._fetch_mainnet_token_data(coingecko_id)
tokens_to_create.extend(self._extract_tokens(token_data))
except Exception as e: # noqa: BLE001
raise CommandError(f'Error fetching token information for {coingecko_id}: {e}') from e

Token.objects.bulk_create(tokens_to_create, ignore_conflicts=True)
# NOTE: Polygon zkEVM and PoS have been migrated.
# tokens_to_create = []
# for coingecko_id in self.SUPPORTED_COINGECKO_IDS:
# try:
# token_data = self._fetch_mainnet_token_data(coingecko_id)
# tokens_to_create.extend(self._extract_tokens(token_data))
# except Exception as e: # noqa: BLE001
# raise CommandError(f'Error fetching token information for {coingecko_id}: {e}') from e

# Token.objects.bulk_create(tokens_to_create, ignore_conflicts=True)

self._populate_testnet_token_data()

Expand Down

0 comments on commit ff33895

Please sign in to comment.