Skip to content

Commit

Permalink
[chore] Add status Property to Trade (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
John-peterson-coinbase authored Sep 25, 2024
1 parent 6d18e53 commit e17b200
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions cdp/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ def to_amount(self) -> Decimal:
"""
return Decimal(self._model.to_amount) / Decimal(10) ** self._model.to_asset.decimals

@property
def status(self) -> str:
"""Get the status.
Returns:
str: The status.
"""
return self.transaction.status

@property
def transaction(self) -> Transaction:
"""Get the trade transaction."""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_broadcast_trade(mock_api_clients, trade_factory):
broadcast_trade_request=ANY,
)
assert isinstance(response, Trade)
assert response.transaction.status.value == "broadcast"
assert response.status.value == "broadcast"
broadcast_trade_request = mock_broadcast.call_args[1]["broadcast_trade_request"]
assert broadcast_trade_request.signed_payload == trade.transaction.signature
assert (
Expand Down Expand Up @@ -224,7 +224,7 @@ def test_wait_for_trade(mock_time, mock_sleep, mock_api_clients, trade_factory):

result = pending_trade.wait(interval_seconds=0.2, timeout_seconds=1)

assert result.transaction.status.value == "complete"
assert result.status.value == "complete"
mock_get_trade.assert_called_with(
wallet_id=pending_trade.wallet_id,
address_id=pending_trade.address_id,
Expand Down

0 comments on commit e17b200

Please sign in to comment.