Update token and company list schemas - #1693
Merged
Merged
Conversation
… validation and improve error handling
…dling - Implement tests for TokenListItem to ensure token and issuer addresses are converted to checksum format. - Add parameterized tests to validate rejection of invalid token and issuer addresses. - Update existing tests for listing public tokens to include issuer addresses. - Enhance company indexer tests to handle trustee information and validate address checksumming. - Introduce tests for processing token lists with issuer addresses, ensuring they are stored as checksummed addresses.
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
purplesmoke05
marked this pull request as ready for review
November 12, 2025 23:37
YoshihitoAso
approved these changes
Nov 13, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces enhanced validation and schema support for company and token list data by adding trustee information for companies and issuer addresses for tokens. The changes include new Pydantic models for input validation, database schema updates with appropriate constraints, and refactored batch indexers.
Key Changes
- Added trustee-related fields to the
Companymodel with a database check constraint ensuring all-or-nothing population - Added
issuer_addressfield to theTokenListmodel - Introduced Pydantic models (
CompanyListItem,TokenListItem,Trustee) for robust input validation in batch indexers - Updated batch indexers to use Pydantic validation and improved error handling
- Added
python-dotenvdependency for better environment variable management
Reviewed Changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Updated aiomysql from 0.2.0 to 0.3.0 and added python-dotenv dependency |
| pyproject.toml | Added python-dotenv~=1.1.0 dependency and formatting changes |
| migrations/versions/835dd5b51e23_v25_12_0_feature_1692.py | Migration to add trustee fields to company table and issuer_address to token_list table with check constraint |
| app/model/db/company.py | Added trustee fields and check constraint to Company model, updated json() method |
| app/model/db/public_info.py | Added issuer_address field to TokenList model and updated json() method |
| app/model/type/company_list.py | New Pydantic models for CompanyListItem and Trustee with validation |
| app/model/type/token_list.py | New Pydantic model for TokenListItem with address validation |
| app/model/schema/company_info.py | Added trustee field to CompanyInfo schema |
| app/model/schema/public_info.py | Added issuer_address field to TokenBase schema |
| batch/indexer_Company_List.py | Refactored to use CompanyListItem model for validation, added URL check |
| batch/indexer_PublicInfo_TokenList.py | Refactored to use TokenListItem model for validation, added URL check |
| app/utils/company_list.py | Added trustee field support to CompanyList utility |
| app/config.py | Added dotenv loading for environment variables |
| .dockerignore | Added .env to ignore list |
| docs/ibet_wallet_api.yaml | Updated OpenAPI schema with trustee and issuer_address fields |
| tests/** | Updated tests to cover new trustee and issuer_address functionality |
Comments suppressed due to low confidence (3)
batch/indexer_Company_List.py:115
- The additional validation check for required fields (lines 104-115) is redundant. Since
CompanyListItemis a Pydantic model withaddress,corporate_name, andrsa_publickeyas required fields (not Optional), themodel_validatecall at line 99 would have already raised aValidationErrorif any required field was missing or empty. This check adds unnecessary complexity and should be removed.
if (
company_list_item.address
and company_list_item.corporate_name
and company_list_item.rsa_publickey
):
self.__sink_on_company(
db_session=db_session,
company_list_item=company_list_item,
)
else:
LOG.notice(f"Missing required field: index={i}")
continue
migrations/versions/835dd5b51e23_v25_12_0_feature_1692.py:23
- Variable connection is not used.
connection = op.get_bind()
migrations/versions/835dd5b51e23_v25_12_0_feature_1692.py:55
- Variable connection is not used.
connection = op.get_bind()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Description
This pull request introduces enhanced handling and validation for company and token list data, with particular focus on trustee information for companies and issuer addresses for tokens. It refactors the batch indexer scripts to use new Pydantic models for validation, adds new fields and constraints to the database models, and updates serialization and schema definitions to support these changes.
✅ Related Issues
🔄 Changes
Company List and Trustee Enhancements:
trustee_corporate_name,trustee_corporate_number,trustee_corporate_address) to theCompanydatabase model, with a check constraint ensuring all trustee fields are either fully set or all null. [1] [2]Trusteemodel and updated related schemas and utilities to support trustee data, including validation and serialization. [1] [2] [3] [4] [5]batch/indexer_Company_List.pyto use the newCompanyListItemPydantic model for input validation and streamlined database insertion logic, including trustee fields. [1] [2] [3]Token List and Issuer Address Enhancements:
issuer_addressfield to theTokenListdatabase model and related schemas, and updated the token list indexer to use the newTokenListItemmodel for validation and insertion. [1] [2] [3] [4] [5] [6]Validation and Environment Setup:
python-dotenvfor environment variable loading inapp/config.pyand added.envto.dockerignorefor better configuration management. [1] [2]API and Documentation Updates:
trusteefield in company schemas, supporting null values and referencing the newTrusteeschema.These changes collectively improve data consistency, validation, and extensibility for company and token list management.
📌 Checklist