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: Improve output when transfers are approved/cancelled and event data in sync #399

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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