Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it more precise about the value of personal_info_not_registered #624

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions app/utils/ledger_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,21 @@ async def __get_personal_info(
# For tokens with require_personal_info_registered = False, search only indexed data.
# If indexed data does not exist, return the default value.

# Issuer cannot have any personal info
if account_address == token_contract.issuer_address:
personal_info_not_registered = False
return (
ContractPersonalInfoType(
key_manager=None,
name=None,
address=None,
postal_code=None,
email=None,
birth=None,
).model_dump(),
personal_info_not_registered,
)

# Search indexed data
_idx_personal_info: IDXPersonalInfo | None = (
await db.scalars(
Expand All @@ -304,7 +319,10 @@ async def __get_personal_info(
.limit(1)
)
).first()
if _idx_personal_info is not None:
if (
_idx_personal_info is not None
and any(_idx_personal_info.personal_info.values()) is not False
):
# Get personal info from DB
personal_info_not_registered = False
return _idx_personal_info.personal_info, personal_info_not_registered
Expand All @@ -315,7 +333,10 @@ async def __get_personal_info(
personal_info = await personal_info_contract.get_info(
account_address, default_value=None
)
personal_info_not_registered = False
if any(personal_info.values()) is False:
personal_info_not_registered = True
else:
personal_info_not_registered = False
else:
# Do not retrieve contract data and return the default value
personal_info = ContractPersonalInfoType().model_dump()
Expand Down
Loading
Loading