Skip to content

Commit

Permalink
[!] fix Network enum
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongFuze committed Nov 9, 2024
1 parent 55002cc commit 5a684bc
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 39 deletions.
14 changes: 10 additions & 4 deletions src/resolver/basenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-09-06 15:40:40
LastEditors: Zella Zhong
LastEditTime: 2024-11-07 20:29:35
LastEditTime: 2024-11-10 07:27:15
FilePath: /data_service/src/resolver/basenames.py
Description:
'''
Expand Down Expand Up @@ -370,10 +370,14 @@ def convert_cache_to_identity_record(cache_value):
return None

# Convert resolved_address list of dictionaries to list of Address instances
resolved_address = [Address(**address) for address in cache_value.get("resolved_address", [])]
resolved_address = []
for record in cache_value.get("resolved_address", []):
resolved_address.append(Address(network=Network[record["network"]], address=record["address"]))

# Convert owner_address list of dictionaries to list of Address instances
owner_address = [Address(**address) for address in cache_value.get("owner_address", [])]
owner_address = []
for record in cache_value.get("owner_address", []):
owner_address.append(Address(network=Network[record["network"]], address=record["address"]))

platform_str = cache_value.get("platform", None)
platform = Platform(platform_str) if platform_str else None
Expand All @@ -385,7 +389,9 @@ def convert_cache_to_identity_record(cache_value):
profile_data = cache_value.get("profile", None)
profile = None
if profile_data:
addresses = [Address(**addr) for addr in profile_data.get("addresses", [])]
addresses = []
for record in cache_value.get("addresses", []):
addresses.append(Address(network=Network[record["network"]], address=record["address"]))
profile_platform_str = profile_data.get("platform", None)
profile_platform = Platform(profile_platform_str) if profile_platform_str else None

Expand Down
14 changes: 10 additions & 4 deletions src/resolver/ensname.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 18:32:53
LastEditors: Zella Zhong
LastEditTime: 2024-11-07 16:12:34
LastEditTime: 2024-11-10 07:28:12
FilePath: /data_service/src/resolver/ensname.py
Description:
'''
Expand Down Expand Up @@ -391,10 +391,14 @@ def convert_cache_to_identity_record(cache_value):
return None

# Convert resolved_address list of dictionaries to list of Address instances
resolved_address = [Address(**address) for address in cache_value.get("resolved_address", [])]
resolved_address = []
for record in cache_value.get("resolved_address", []):
resolved_address.append(Address(network=Network[record["network"]], address=record["address"]))

# Convert owner_address list of dictionaries to list of Address instances
owner_address = [Address(**address) for address in cache_value.get("owner_address", [])]
owner_address = []
for record in cache_value.get("owner_address", []):
owner_address.append(Address(network=Network[record["network"]], address=record["address"]))

platform_str = cache_value.get("platform", None)
platform = Platform(platform_str) if platform_str else None
Expand All @@ -406,7 +410,9 @@ def convert_cache_to_identity_record(cache_value):
profile_data = cache_value.get("profile", None)
profile = None
if profile_data:
addresses = [Address(**addr) for addr in profile_data.get("addresses", [])]
addresses = []
for record in cache_value.get("addresses", []):
addresses.append(Address(network=Network[record["network"]], address=record["address"]))
profile_platform_str = profile_data.get("platform", None)
profile_platform = Platform(profile_platform_str) if profile_platform_str else None

Expand Down
16 changes: 11 additions & 5 deletions src/resolver/ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 18:41:34
LastEditors: Zella Zhong
LastEditTime: 2024-11-09 23:38:30
LastEditTime: 2024-11-10 07:28:36
FilePath: /data_service/src/resolver/ethereum.py
Description:
'''
Expand Down Expand Up @@ -374,10 +374,14 @@ def convert_cache_to_identity_record(cache_value):
return None

# Convert resolved_address list of dictionaries to list of Address instances
resolved_address = [Address(**address) for address in cache_value.get("resolved_address", [])]
resolved_address = []
for record in cache_value.get("resolved_address", []):
resolved_address.append(Address(network=Network[record["network"]], address=record["address"]))

# Convert owner_address list of dictionaries to list of Address instances
owner_address = [Address(**address) for address in cache_value.get("owner_address", [])]
owner_address = []
for record in cache_value.get("owner_address", []):
owner_address.append(Address(network=Network[record["network"]], address=record["address"]))

platform_str = cache_value.get("platform", None)
platform = Platform(platform_str) if platform_str else None
Expand All @@ -389,7 +393,9 @@ def convert_cache_to_identity_record(cache_value):
profile_data = cache_value.get("profile", None)
profile = None
if profile_data:
addresses = [Address(**addr) for addr in profile_data.get("addresses", [])]
addresses = []
for record in cache_value.get("addresses", []):
addresses.append(Address(network=Network[record["network"]], address=record["address"]))
profile_platform_str = profile_data.get("platform", None)
profile_platform = Platform(profile_platform_str) if profile_platform_str else None

Expand Down Expand Up @@ -422,7 +428,7 @@ def convert_cache_to_identity_record(cache_value):
addresses=addresses,
social=social,
)

expired_at_str = cache_value.get("expired_at")
updated_at_str = cache_value.get("updated_at")

Expand Down
19 changes: 13 additions & 6 deletions src/resolver/farcaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 21:38:55
LastEditors: Zella Zhong
LastEditTime: 2024-11-10 05:04:28
LastEditTime: 2024-11-10 07:28:57
FilePath: /data_service/src/resolver/farcaster.py
Description:
'''
Expand Down Expand Up @@ -464,10 +464,14 @@ def convert_cache_to_identity_record(cache_value):
return None

# Convert resolved_address list of dictionaries to list of Address instances
resolved_address = [Address(**address) for address in cache_value.get("resolved_address", [])]
resolved_address = []
for record in cache_value.get("resolved_address", []):
resolved_address.append(Address(network=Network[record["network"]], address=record["address"]))

# Convert owner_address list of dictionaries to list of Address instances
owner_address = [Address(**address) for address in cache_value.get("owner_address", [])]
owner_address = []
for record in cache_value.get("owner_address", []):
owner_address.append(Address(network=Network[record["network"]], address=record["address"]))

platform_str = cache_value.get("platform", None)
platform = Platform(platform_str) if platform_str else None
Expand All @@ -479,7 +483,9 @@ def convert_cache_to_identity_record(cache_value):
profile_data = cache_value.get("profile", None)
profile = None
if profile_data:
addresses = [Address(**addr) for addr in profile_data.get("addresses", [])]
addresses = []
for record in cache_value.get("addresses", []):
addresses.append(Address(network=Network[record["network"]], address=record["address"]))
profile_platform_str = profile_data.get("platform", None)
profile_platform = Platform(profile_platform_str) if profile_platform_str else None

Expand Down Expand Up @@ -512,7 +518,7 @@ def convert_cache_to_identity_record(cache_value):
addresses=addresses,
social=social,
)

expired_at_str = cache_value.get("expired_at")
updated_at_str = cache_value.get("updated_at")

Expand Down Expand Up @@ -1100,7 +1106,8 @@ async def batch_query_profile_by_query_ids_db(query_ids):
for fid in result_fids:
profile_record: FarcasterProfile = profile_dict.get(fid, None)
fname = profile_record.fname
network = profile_record.network
network_str = profile_record.network
network = Network[network_str]
address = profile_record.address
if fname is None:
continue
Expand Down
16 changes: 11 additions & 5 deletions src/resolver/lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-07 01:31:36
LastEditors: Zella Zhong
LastEditTime: 2024-11-10 05:01:13
LastEditTime: 2024-11-10 07:29:35
FilePath: /data_service/src/resolver/lens.py
Description:
'''
Expand Down Expand Up @@ -442,10 +442,14 @@ def convert_cache_to_identity_record(cache_value):
return None

# Convert resolved_address list of dictionaries to list of Address instances
resolved_address = [Address(**address) for address in cache_value.get("resolved_address", [])]
resolved_address = []
for record in cache_value.get("resolved_address", []):
resolved_address.append(Address(network=Network[record["network"]], address=record["address"]))

# Convert owner_address list of dictionaries to list of Address instances
owner_address = [Address(**address) for address in cache_value.get("owner_address", [])]
owner_address = []
for record in cache_value.get("owner_address", []):
owner_address.append(Address(network=Network[record["network"]], address=record["address"]))

platform_str = cache_value.get("platform", None)
platform = Platform(platform_str) if platform_str else None
Expand All @@ -457,7 +461,9 @@ def convert_cache_to_identity_record(cache_value):
profile_data = cache_value.get("profile", None)
profile = None
if profile_data:
addresses = [Address(**addr) for addr in profile_data.get("addresses", [])]
addresses = []
for record in cache_value.get("addresses", []):
addresses.append(Address(network=Network[record["network"]], address=record["address"]))
profile_platform_str = profile_data.get("platform", None)
profile_platform = Platform(profile_platform_str) if profile_platform_str else None

Expand Down Expand Up @@ -490,7 +496,7 @@ def convert_cache_to_identity_record(cache_value):
addresses=addresses,
social=social,
)

expired_at_str = cache_value.get("expired_at")
updated_at_str = cache_value.get("updated_at")

Expand Down
16 changes: 11 additions & 5 deletions src/resolver/solana.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-07 23:11:29
LastEditors: Zella Zhong
LastEditTime: 2024-11-08 00:04:04
LastEditTime: 2024-11-10 07:29:59
FilePath: /data_service/src/resolver/solana.py
Description:
'''
Expand Down Expand Up @@ -80,10 +80,14 @@ def convert_cache_to_identity_record(cache_value):
return None

# Convert resolved_address list of dictionaries to list of Address instances
resolved_address = [Address(**address) for address in cache_value.get("resolved_address", [])]
resolved_address = []
for record in cache_value.get("resolved_address", []):
resolved_address.append(Address(network=Network[record["network"]], address=record["address"]))

# Convert owner_address list of dictionaries to list of Address instances
owner_address = [Address(**address) for address in cache_value.get("owner_address", [])]
owner_address = []
for record in cache_value.get("owner_address", []):
owner_address.append(Address(network=Network[record["network"]], address=record["address"]))

platform_str = cache_value.get("platform", None)
platform = Platform(platform_str) if platform_str else None
Expand All @@ -95,7 +99,9 @@ def convert_cache_to_identity_record(cache_value):
profile_data = cache_value.get("profile", None)
profile = None
if profile_data:
addresses = [Address(**addr) for addr in profile_data.get("addresses", [])]
addresses = []
for record in cache_value.get("addresses", []):
addresses.append(Address(network=Network[record["network"]], address=record["address"]))
profile_platform_str = profile_data.get("platform", None)
profile_platform = Platform(profile_platform_str) if profile_platform_str else None

Expand Down Expand Up @@ -128,7 +134,7 @@ def convert_cache_to_identity_record(cache_value):
addresses=addresses,
social=social,
)

expired_at_str = cache_value.get("expired_at")
updated_at_str = cache_value.get("updated_at")

Expand Down
29 changes: 20 additions & 9 deletions src/resolver/unstoppabledomains.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-24 17:34:05
LastEditors: Zella Zhong
LastEditTime: 2024-11-10 04:43:17
LastEditTime: 2024-11-10 07:30:13
FilePath: /data_service/src/resolver/unstoppabledomains.py
Description:
'''
Expand Down Expand Up @@ -94,10 +94,14 @@ def convert_cache_to_identity_record(cache_value):
return None

# Convert resolved_address list of dictionaries to list of Address instances
resolved_address = [Address(**address) for address in cache_value.get("resolved_address", [])]
resolved_address = []
for record in cache_value.get("resolved_address", []):
resolved_address.append(Address(network=Network[record["network"]], address=record["address"]))

# Convert owner_address list of dictionaries to list of Address instances
owner_address = [Address(**address) for address in cache_value.get("owner_address", [])]
owner_address = []
for record in cache_value.get("owner_address", []):
owner_address.append(Address(network=Network[record["network"]], address=record["address"]))

platform_str = cache_value.get("platform", None)
platform = Platform(platform_str) if platform_str else None
Expand All @@ -109,7 +113,9 @@ def convert_cache_to_identity_record(cache_value):
profile_data = cache_value.get("profile", None)
profile = None
if profile_data:
addresses = [Address(**addr) for addr in profile_data.get("addresses", [])]
addresses = []
for record in cache_value.get("addresses", []):
addresses.append(Address(network=Network[record["network"]], address=record["address"]))
profile_platform_str = profile_data.get("platform", None)
profile_platform = Platform(profile_platform_str) if profile_platform_str else None

Expand Down Expand Up @@ -988,11 +994,12 @@ async def save_unstoppabledomains_profile_to_db(domains):
# Add a graph_id to the non-existent owner
for owner_unique_id in owner_unique_ids:
if owner_unique_id not in address_unique_mapping_graph_id:
_platform, _address = owner_unique_id.split(",")
address_unique_mapping_graph_id[owner_unique_id] = {
"graph_id": str(uuid.uuid4()),
"updated_nanosecond": get_unix_microseconds(),
"platform": Platform.ethereum.value,
"identity": owner_address.removeprefix(f"{Platform.ethereum.value},")
"platform": _platform,
"identity": _address
}

graph_id_upsert_sql = """
Expand Down Expand Up @@ -1043,7 +1050,7 @@ async def save_unstoppabledomains_profile_to_db(domains):
resolved_records = EXCLUDED.resolved_records,
social = EXCLUDED.social,
update_time = EXCLUDED.update_time;
"""
"""

vertices = []
edges = []
Expand Down Expand Up @@ -1080,7 +1087,7 @@ async def save_unstoppabledomains_profile_to_db(domains):
# unstoppabledomains owner_address always equals to resolved_address
resolved_address = domain.get('resolved_address', None)
is_primary = domain.get('is_primary', False)
reverse_address = domain.get('reverse_address', False)
reverse_address = domain.get('reverse_address', None)

owner_unique_id = f"{Platform.ethereum.value},{owner_address}"
if owner_unique_id in address_unique_mapping_graph_id:
Expand Down Expand Up @@ -1197,7 +1204,7 @@ async def save_unstoppabledomains_profile_to_db(domains):
# logging.info("Delete all unstoppabledomains %s from graphdb successfully.", domain_unique_ids)

await upsert_graph(vertices, edges)
logging.info("Upsert all unstoppabledomains from graphdb successfully.")
logging.info("Upsert all unstoppabledomains to graphdb successfully.")

except Exception as ex:
logging.exception(ex)
Expand Down Expand Up @@ -1280,6 +1287,8 @@ async def query_unstoppabledomains_profile_by_ids_cache(info, identities, requir
if record.is_primary == True:
one = record
break
if not one:
return []
return [one]
else:
return identity_records
Expand Down Expand Up @@ -1323,6 +1332,8 @@ async def query_unstoppabledomains_profile_by_ids_cache(info, identities, requir
if record.is_primary == True:
one = record
break
if not one:
return []
return [one]
else:
return identity_records
2 changes: 1 addition & 1 deletion src/scalar/identity_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Author: Zella Zhong
Date: 2024-10-06 17:59:57
LastEditors: Zella Zhong
LastEditTime: 2024-11-08 00:15:59
LastEditTime: 2024-11-10 05:45:57
FilePath: /data_service/src/scalar/identity_record.py
Description:
'''
Expand Down

0 comments on commit 5a684bc

Please sign in to comment.