Handled unicode code points that can't be stored in Postgres

Also applied MOONSTREAM_SPIRE_API_URL configuration to mooncrawl
reporter so that we can report to non-production Spire APIs.
pull/283/head
Neeraj Kashyap 2021-09-25 08:51:03 -07:00
rodzic 4bf2b5311d
commit 126090ab54
2 zmienionych plików z 17 dodań i 2 usunięć

Wyświetl plik

@ -302,13 +302,24 @@ def label_erc721_addresses(
for address, id in address_ids:
try:
contract_info = get_erc721_contract_info(w3, address)
# Postgres cannot store the following unicode code point in a string: \u0000
# Therefore, we replace that code point with the empty string to avoid errors:
# https://stackoverflow.com/a/31672314
contract_name = contract_info.name.replace("\\u0000", "").replace(
"\x00", ""
)
contract_symbol = contract_info.symbol.replace("\\u0000", "").replace(
"\x00", ""
)
labels.append(
EthereumLabel(
address_id=id,
label=NFT_LABEL,
label_data={
"name": contract_info.name,
"symbol": contract_info.symbol,
"name": contract_name,
"symbol": contract_symbol,
},
)
)

Wyświetl plik

@ -1,3 +1,4 @@
import os
import uuid
from humbug.consent import HumbugConsent
@ -8,6 +9,8 @@ from .settings import HUMBUG_REPORTER_CRAWLERS_TOKEN
session_id = str(uuid.uuid4())
client_id = "moonstream-crawlers"
spire_url = os.environ.get("MOONSTREAM_SPIRE_API_URL")
reporter = HumbugReporter(
name="moonstream-crawlers",
consent=HumbugConsent(True),
@ -15,4 +18,5 @@ reporter = HumbugReporter(
session_id=session_id,
bugout_token=HUMBUG_REPORTER_CRAWLERS_TOKEN,
tags=[],
url=spire_url,
)