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

feat: Add batch redeem/issue token API and Notification for batch redeem/issue #374

Merged
merged 2 commits into from
Aug 24, 2022

Conversation

purplesmoke05
Copy link
Member

@purplesmoke05 purplesmoke05 commented Aug 24, 2022

Additional implementation for #331.
(Previous PR are #351 and #372)

Changes

  • Add API for referencing issue/redeem batch uploads list.

    • GET: /bond/tokens/{token_address}/additional_issue/batch
    • GET: /bond/tokens/{token_address}/redeem/batch
    • GET: /share/tokens/{token_address}/additional_issue/batch
    • GET: /share/tokens/{token_address}/redeem/batch
  • Add Notification Type for issue/redeem batch process.

    • BatchIssueProcessed
  • Refactoring of API Notification to define metainfo schema.(I/F not changed)

    • スクリーンショット 2022-08-24 10 44 05
  • Refactoring of API to reference processing status of personal_info batch.(“created” field added)

    • POST: /bond/tokens/{token_address}/personal_info/batch
    • POST: /share/tokens/{token_address}/personal_info/batch

  • 追加発行/償還バッチ一覧のAPIを追加。
  • 追加発行/償還バッチの通知タイプを追加。
  • 通知APIにMetainfoのスキーマ定義を追加。
  • PersonalInfo更新バッチの参照APIにcreated属性を追加。

Comment on lines +37 to +73
class IssueErrorMetainfo(BaseModel):
token_address: str
token_type: TokenType
arguments: dict


############################
# RESPONSE
############################
class BulkTransferErrorMetainfo(BaseModel):
upload_id: str
token_type: TokenType
error_transfer_id: list[int]

class NotificationsListResponse(BaseModel):
"""Notifications List schema (Response)"""

class ScheduleEventErrorMetainfo(BaseModel):
scheduled_event_id: int
token_type: TokenType


class TransferApprovalInfoMetaInfo(BaseModel):
id: int
token_address: str


class CreateLedgerInfoMetaInfo(BaseModel):
token_address: str
token_type: TokenType
ledger_id: int


class BatchRegisterPersonalInfoErrorMetainfo(BaseModel):
upload_id: str
error_registration_id: list[int]


class BatchIssueRedeemProcessedMetainfo(BaseModel):
category: BatchIssueRedeemProcessingCategory
upload_id: str
error_data_id: list[int]
Copy link
Member Author

Choose a reason for hiding this comment

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

Add notification types so as to make clear what will be set to metainfo.

Comment on lines +84 to +182

class BulkTransferErrorNotification(Notification):
notice_type: str = NotificationType.BULK_TRANSFER_ERROR
notice_code: conint(ge=0, le=2)
metainfo: BulkTransferErrorMetainfo

class Config:
@staticmethod
def schema_extra(schema: Dict[str, Any], _) -> None:
notice_code_schema = schema["properties"]["notice_code"]
notice_code_schema["description"] = " - 0: Issuer does not exist\n" \
" - 1: Could not get the private key of the issuer\n" \
" - 2: Failed to send transaction\n" \
"\n" \
"notice_type: BatchRegisterPersonalInfoError\n" \
" - 0: Issuer does not exist\n" \
" - 1: Failed to send transaction\n" \
"\n" \
"notice_type: ScheduleEventError\n" \
" - 0: Issuer does not exist\n" \



class ScheduleEventErrorNotification(Notification):
notice_type: str = NotificationType.SCHEDULE_EVENT_ERROR
notice_code: conint(ge=0, le=2)
metainfo: ScheduleEventErrorMetainfo

class Config:
@staticmethod
def schema_extra(schema: Dict[str, Any], _) -> None:
notice_code_schema = schema["properties"]["notice_code"]
notice_code_schema["description"] = " - 0: Issuer does not exist\n" \
" - 1: Could not get the private key of the issuer\n" \
" - 2: Failed to send transaction\n" \
"\n" \
"notice_type: TransferApprovalInfo\n" \
" - 0: Apply for transfer\n" \



class TransferApprovalInfoNotification(Notification):
notice_type: str = NotificationType.TRANSFER_APPROVAL_INFO
notice_code: conint(ge=0, le=3)
metainfo: TransferApprovalInfoMetaInfo

class Config:
@staticmethod
def schema_extra(schema: Dict[str, Any], _) -> None:
notice_code_schema = schema["properties"]["notice_code"]
notice_code_schema["description"] = " - 0: Apply for transfer\n" \
" - 1: Cancel transfer\n" \
" - 2: Approve transfer\n" \
" - 3: Escrow finished (Only occurs in security token escrow)\n" \
"\n" \
"notice_type: CreateLedgerInfo\n" \
" - 0: Created ledger info successfully\n" \
" - 3: Escrow finished (Only occurs in security token escrow)\n"


class CreateLedgerInfoNotification(Notification):
notice_type: str = NotificationType.CREATE_LEDGER_INFO
notice_code: conint(ge=0, le=0)
metainfo: CreateLedgerInfoMetaInfo

class Config:
@staticmethod
def schema_extra(schema: Dict[str, Any], _) -> None:
notice_code_schema = schema["properties"]["notice_code"]
notice_code_schema["description"] = " - 0: Created ledger info successfully\n"


class BatchRegisterPersonalInfoErrorNotification(Notification):
notice_type: str = NotificationType.BATCH_REGISTER_PERSONAL_INFO_ERROR
notice_code: conint(ge=0, le=1)
metainfo: BatchRegisterPersonalInfoErrorMetainfo

class Config:
@staticmethod
def schema_extra(schema: Dict[str, Any], _) -> None:
notice_code_schema = schema["properties"]["notice_code"]
notice_code_schema["description"] = "notice_type: BatchRegisterPersonalInfoError\n" \
" - 0: Issuer does not exist\n" \
" - 1: Failed to send transaction\n"


class BatchIssueRedeemProcessedNotification(Notification):
notice_type: str = NotificationType.BATCH_ISSUE_REDEEM_PROCESSED
notice_code: conint(ge=0, le=3)
metainfo: BatchIssueRedeemProcessedMetainfo

class Config:
@staticmethod
def schema_extra(schema: Dict[str, Any], _) -> None:
notice_code_schema = schema["properties"]["notice_code"]
notice_code_schema["description"] = "notice_type: BatchIssueRedeemProcessed\n" \
" - 0: All records successfully processed\n" \
" - 1: Issuer does not exist\n" \
" - 2: Failed to decode keyfile\n" \
" - 3: Some records are failed to send transaction"
Copy link
Member Author

Choose a reason for hiding this comment

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

Currently notice code schema description is too long because it's described in Notification model.
So I split notification into each type.

API doc view example is shown in PR top.

Comment on lines +504 to +506
sort_order: int = Query(1, ge=0, le=1, description="0:asc, 1:desc (created)"),
offset: Optional[int] = Query(None),
limit: Optional[int] = Query(None),
Copy link
Member Author

Choose a reason for hiding this comment

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

  • sort_order / offset / limit are added.
  • applied "created" field to sort item
    • default sort_order is desc.

Comment on lines +46 to +50
notice_type: BatchIssueRedeemProcessed
- 0: All records successfully processed
- 1: Issuer does not exist
- 2: Failed to decode keyfile
- 3: Some records are failed to send transaction
Copy link
Member Author

Choose a reason for hiding this comment

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

Added BatchIssueRedeemProcessed .

@YoshihitoAso YoshihitoAso merged commit 4fc4ee5 into dev-22.9 Aug 24, 2022
@purplesmoke05 purplesmoke05 deleted the feature/batch-issue-redeem-notification branch August 25, 2022 00:20
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.

2 participants