Skip to content

Commit c0c22c9

Browse files
authored
1 parent 9a9ab5c commit c0c22c9

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

api/app/af_ens/routes.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def get(self, address):
3939
"first_register_time": None,
4040
"first_set_primary_time": None,
4141
}
42-
if address:
42+
try:
4343
address = bytes.fromhex(address[2:])
44-
else:
44+
except Exception:
4545
raise APIError("Invalid Address Format", code=400)
4646

4747
dn = datetime.now()
@@ -97,9 +97,7 @@ def get(self, address):
9797
res["ens_holdings_total"] = len(res["ens_holdings"])
9898
primary_address_row = db.session.query(ENSAddress).filter(ENSAddress.address == address).first()
9999
if primary_address_row:
100-
primary_record = db.session.query(ENSRecord).filter(ENSRecord.name == primary_address_row.name).first()
101-
if primary_record:
102-
res["primary_name"] = primary_record.name
100+
res["primary_name"] = primary_address_row.name
103101
else:
104102
res["primary_name"] = w3.ens.name(w3.to_checksum_address(w3.to_hex(address)))
105103

@@ -147,9 +145,9 @@ def get(self, address):
147145
@af_ens_namespace.route("/v1/aci/<address>/ens/detail")
148146
class ACIEnsDetail(Resource):
149147
def get(self, address):
150-
if address:
148+
try:
151149
address = bytes.fromhex(address[2:])
152-
else:
150+
except Exception:
153151
raise APIError("Invalid Address Format", code=400)
154152

155153
events = []
@@ -194,11 +192,11 @@ def get(self, address):
194192

195193
for r in all_rows:
196194
name = None
197-
if hasattr(r, "node") and r.node:
195+
if hasattr(r, "node") and r.node and r.node in node_name_map:
198196
name = node_name_map[r.node]
199-
elif hasattr(r, "token_id") and r.token_id:
197+
elif hasattr(r, "token_id") and r.token_id and r.token_id in token_id_name_map:
200198
name = token_id_name_map[r.token_id]
201-
elif hasattr(r, "w_token_id") and r.w_token_id:
199+
elif hasattr(r, "w_token_id") and r.w_token_id and r.w_token_id in token_id_name_map:
202200
name = token_id_name_map[r.w_token_id]
203201
base = {
204202
"block_number": r.block_number,

0 commit comments

Comments
 (0)