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

Refine transfer data schema to classify transfer data derived from Unlock events #713

Merged
merged 6 commits into from
Oct 31, 2024

Conversation

purplesmoke05
Copy link
Member

Close #700

DB

  • Added new message column with index to idx_transfer table, separate from existing JSON data field

API

  • Detailed transfer data schema on Transfer List API to classify transfer data derived from Unlock events
class TransferBase(BaseModel):
    transaction_hash: str
    token_address: str
    from_address: str
    from_address_personal_information: Optional[PersonalInfo] = Field(...)
    to_address: str
    to_address_personal_information: Optional[PersonalInfo] = Field(...)
    amount: int
    block_timestamp: str

class Transfer(TransferBase):
    source_event: Literal[TransferSourceEventType.Transfer] = Field(
        description="Source Event"
    )
    data: None = Field(description="Event data")

class UnlockData(BaseModel):
    message: Literal[
        "garnishment",
        "inheritance",
        "force_unlock",
    ]

class UnlockTransfer(TransferBase):
    source_event: Literal[TransferSourceEventType.Unlock] = Field(
        description="Source Event"
    )
    data: UnlockData | dict = Field(description="Event data")
  • Added GET query to /{bond or share}/transfers/{token_address} for searching by message field.

Batch

  • Fixed to store message column when saving Transfer records.

@purplesmoke05 purplesmoke05 marked this pull request as ready for review October 30, 2024 01:55
Copy link

github-actions bot commented Oct 30, 2024

Coverage

Coverage Report •
FileStmtsMissCoverMissing
app/model/db
   __init__.py320100% 
   idx_transfer.py280100% 
app/model/schema
   __init__.py200100% 
   transfer.py1320100% 
app/routers/issuer
   bond.py11331199%717, 1129, 2124, 2336, 2500, 2791, 2799, 3740–3743
   position.py182199%353
   settlement_issuer.py1561093%170, 298, 300, 436, 438, 446, 454, 462, 573–574
   share.py11191199%684, 1096, 2052, 2264, 2428, 2728, 2736, 3676–3679
app/routers/misc
   settlement_agent.py165298%221, 323
batch
   indexer_transfer.py1512086%79–80, 85–87, 212, 225–226, 254, 271–272, 294–296, 325–326, 332–335
tests/app
   test_bond_transfers_ListBondTokenTransferHistory.py8930100% 
   test_positions_ForceUnlock.py2730100% 
   test_share_transfers_ListShareTokenTransferHistory.py8930100% 
tests/app/model/blockchain
   test_token_IbetShare.py15720100% 
   test_token_IbetStraightBond.py15970100% 
tests/batch
   test_indexer_transfer.py6440100% 
TOTAL76268124898% 

Tests Skipped Failures Errors Time
1953 0 💤 0 ❌ 0 🔥 24m 6s ⏱️

Comment on lines 38 to 44
class UnlockData(BaseModel):
message: Literal[
"garnishment",
"inheritance",
"force_unlock",
]

Copy link
Member

Choose a reason for hiding this comment

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

Since there may be cases in the future where it is necessary to parse messages for events other than UnLock, I thought it would be better to use a structure name such as "DataMessage".

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed the schema to DataMessage for future reusability d5509f1

@YoshihitoAso YoshihitoAso merged commit 827e68f into dev-24.12 Oct 31, 2024
8 checks passed
@YoshihitoAso YoshihitoAso deleted the feature/#700 branch October 31, 2024 01:29
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] Classify unlock event type based on data field of the event log
2 participants