Skip to content

Commit

Permalink
Merge pull request #399 from BoostryJP/feature/#390
Browse files Browse the repository at this point in the history
feat: Improve output when transfers are approved/cancelled and event data in sync
  • Loading branch information
YoshihitoAso committed Oct 4, 2022
2 parents 7c1a108 + eed0f50 commit 5e443f5
Show file tree
Hide file tree
Showing 17 changed files with 1,410 additions and 428 deletions.
5 changes: 4 additions & 1 deletion app/model/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@
Notification,
NotificationType
)
from .transfer_appoval_history import TransferApprovalHistory
from .transfer_appoval_history import (
TransferApprovalHistory,
TransferApprovalOperationType
)
from .tx_management import TransactionLock
from .utxo import UTXO, UTXOBlockNumber
from .scheduled_events import (
Expand Down
11 changes: 6 additions & 5 deletions app/model/db/idx_transfer_approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
BigInteger
)

import config
from .base import Base


Expand All @@ -36,11 +37,11 @@ class IDXTransferApproval(Base):
# Sequence Id
id = Column(BigInteger, primary_key=True, autoincrement=True)
# Token Address
token_address = Column(String(42), index=True)
token_address = Column(String(42), index=True, nullable=False)
# Exchange Address (value is set if the event is from exchange)
exchange_address = Column(String(42), index=True)
# Application Id (escrow id is set if the event is from exchange)
application_id = Column(BigInteger, index=True)
exchange_address = Column(String(42), index=True, nullable=False, default=config.ZERO_ADDRESS)
# Application ID (escrow id is set if the event is from exchange)
application_id = Column(BigInteger, index=True, nullable=False)
# Transfer From
from_address = Column(String(42))
# Transfer To
Expand Down Expand Up @@ -69,7 +70,7 @@ def json(self):
"application_id": self.application_id,
"from_address": self.from_address,
"to_address": self.to_address,
"value": self.value,
"amount": self.amount,
"application_datetime": self.application_datetime,
"application_blocktimestamp": self.application_blocktimestamp,
"approval_datetime": self.approval_datetime,
Expand Down
24 changes: 15 additions & 9 deletions app/model/db/transfer_appoval_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,41 @@
SPDX-License-Identifier: Apache-2.0
"""
from enum import Enum

from sqlalchemy import (
BigInteger,
Column,
Integer,
String
)

from .base import Base


class TransferApprovalHistory(Base):
"""Token Transfer Approval History"""
"""Token Transfer Approval Operation History"""
__tablename__ = 'transfer_approval_history'

# Sequence Id
id = Column(BigInteger, primary_key=True, autoincrement=True)
# Token Address
token_address = Column(String(42), index=True)
token_address = Column(String(42), index=True, nullable=False)
# Exchange Address (value is set if the event is from exchange)
exchange_address = Column(String(42), index=True)
# Application Id (escrow id is set if the event is from exchange)
application_id = Column(BigInteger, index=True)
# Result (Success:1, Fail:2)
result = Column(Integer)
exchange_address = Column(String(42), index=True, nullable=False)
# Application ID (escrow id is set if the event is from exchange)
application_id = Column(BigInteger, index=True, nullable=False)
# Operation Type: TransferApprovalOperationType
operation_type = Column(String(20), index=True, nullable=False)

def json(self):
return {
"token_address": self.token_address,
"exchange_address": self.exchange_address,
"application_id": self.application_id,
"result": self.result,
"operation_type": self.operation_type,
}


class TransferApprovalOperationType(str, Enum):
APPROVE = "approve"
CANCEL = "cancel"
2 changes: 1 addition & 1 deletion app/model/schema/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TransferApprovalTokenResponse(BaseModel):
"""transfer approval token data"""
id: int
token_address: str
exchange_address: Optional[str]
exchange_address: str
application_id: int
from_address: str
to_address: str
Expand Down

0 comments on commit 5e443f5

Please sign in to comment.