Skip to content

Update token and company list schemas - #1693

Merged
purplesmoke05 merged 5 commits into
dev-25.12from
feature/#1692
Nov 13, 2025
Merged

Update token and company list schemas#1693
purplesmoke05 merged 5 commits into
dev-25.12from
feature/#1692

Conversation

@purplesmoke05

@purplesmoke05 purplesmoke05 commented Nov 12, 2025

Copy link
Copy Markdown
Member

📌 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:

  • Added trustee-related fields (trustee_corporate_name, trustee_corporate_number, trustee_corporate_address) to the Company database model, with a check constraint ensuring all trustee fields are either fully set or all null. [1] [2]
  • Introduced the Trustee model and updated related schemas and utilities to support trustee data, including validation and serialization. [1] [2] [3] [4] [5]
  • Refactored batch/indexer_Company_List.py to use the new CompanyListItem Pydantic model for input validation and streamlined database insertion logic, including trustee fields. [1] [2] [3]

Token List and Issuer Address Enhancements:

  • Added issuer_address field to the TokenList database model and related schemas, and updated the token list indexer to use the new TokenListItem model for validation and insertion. [1] [2] [3] [4] [5] [6]

Validation and Environment Setup:

  • Batch indexers now use Pydantic models for robust validation and log warnings when URLs are not set, improving error handling and data integrity. [1] [2]
  • Introduced python-dotenv for environment variable loading in app/config.py and added .env to .dockerignore for better configuration management. [1] [2]

API and Documentation Updates:

  • Updated OpenAPI documentation to include the new trustee field in company schemas, supporting null values and referencing the new Trustee schema.

These changes collectively improve data consistency, validation, and extensibility for company and token list management.

📌 Checklist

  • I have added tests where necessary.
  • I have updated the documentation where necessary.

…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.
@github-actions

github-actions Bot commented Nov 12, 2025

Copy link
Copy Markdown

Coverage

Coverage Report •
FileStmtsMissCoverMissing
app
   config.py101595%60–61, 65, 136, 177
app/model/db
   company.py25292%52, 79
   public_info.py32196%91
app/model/schema
   company_info.py370100% 
   public_info.py470100% 
app/model/type
   __init__.py20100% 
   company_list.py240100% 
   token_list.py16193%41
app/utils
   company_list.py76988%64–66, 77, 106–107, 130, 134, 146
batch
   indexer_Company_List.py972673%62–63, 114–115, 118–120, 147–150, 152–159, 161–163, 167–170
   indexer_PublicInfo_TokenList.py912473%63–64, 108–110, 131–134, 136–143, 145–147, 151–154
tests/app
   company_info_ListAllCompanies_test.py4060100% 
   company_info_ListAllCompanyTokens_test.py1900100% 
   company_info_RetrieveCompanyInfo_test.py1420100% 
   public_info_ListAllPublicListedTokens_test.py2610100% 
tests/app/model/type
   test_company_list.py150100% 
   test_token_list.py150100% 
tests/batch
   indexer_Company_List_test.py5560100% 
   indexer_PublicInfo_TokenList_test.py2780100% 
TOTAL45545159096% 

Tests Skipped Failures Errors Time
1529 0 💤 0 ❌ 0 🔥 12m 39s ⏱️

@purplesmoke05
purplesmoke05 marked this pull request as ready for review November 12, 2025 23:37
@YoshihitoAso
YoshihitoAso requested a review from Copilot November 13, 2025 01:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Company model with a database check constraint ensuring all-or-nothing population
  • Added issuer_address field to the TokenList model
  • 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-dotenv dependency 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 CompanyListItem is a Pydantic model with address, corporate_name, and rsa_publickey as required fields (not Optional), the model_validate call at line 99 would have already raised a ValidationError if 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.

Comment thread app/model/type/company_list.py Outdated
Comment thread migrations/versions/835dd5b51e23_v25_12_0_feature_1692.py
Comment thread migrations/versions/835dd5b51e23_v25_12_0_feature_1692.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@purplesmoke05
purplesmoke05 merged commit b8dd4b4 into dev-25.12 Nov 13, 2025
11 checks passed
@purplesmoke05
purplesmoke05 deleted the feature/#1692 branch November 13, 2025 03:07
@purplesmoke05 purplesmoke05 changed the title Update token and company list schema Update token and company list schemas Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support updated schemas for Token List / Company List

3 participants