Skip to content

Commit

Permalink
Merge pull request #9 from JaminPeng/main
Browse files Browse the repository at this point in the history
get_address_history support sort_flag
  • Loading branch information
caixiao-QA committed Jul 19, 2022
2 parents de92b4d + 454a550 commit 615bb7d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ client.verify_valid_address("ETH", "0x05325e6f9d1f0437bd78a72c2ae084fbb8c039ee")

#### Get Address History List
```python
client.get_address_history("ETH",0, 10)
from cobo_custody.model.enums import SortFlagEnum
client.get_address_history("ETH",0, 10, sort_flag=SortFlagEnum.DESCENDING)
```
<details>
<summary>View Response</summary>
Expand Down
5 changes: 3 additions & 2 deletions cobo_custody/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from cobo_custody.error.api_error import ApiError
from cobo_custody.signer.api_signer import ApiSigner
from cobo_custody.signer.local_signer import verify_ecdsa_signature
from cobo_custody.model.enums import SortFlagEnum


class Client(object):
Expand Down Expand Up @@ -122,9 +123,9 @@ def batch_verify_deposit_address(self, coin: str, addresses: str) -> ApiResponse
def verify_valid_address(self, coin: str, address: str) -> ApiResponse:
return self.request("GET", "/v1/custody/is_valid_address/", {"coin": coin, "address": address})

def get_address_history(self, coin: str, page_index=None, page_length=None) -> ApiResponse:
def get_address_history(self, coin: str, page_index=None, page_length=None, sort_flag=SortFlagEnum.DESCENDING) -> ApiResponse:
return self.request("GET", "/v1/custody/address_history/", {
"coin": coin, "page_index": page_index, "page_length": page_length})
"coin": coin, "page_index": page_index, "page_length": page_length, "sort_flag": sort_flag.value})

# loop alliance
def check_loop_address_details(self, coin: str, address: str, memo: str = None) -> ApiResponse:
Expand Down
Empty file added cobo_custody/model/__init__.py
Empty file.
Binary file not shown.
Binary file added cobo_custody/model/__pycache__/enums.cpython-37.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions cobo_custody/model/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import IntEnum


class SortFlagEnum(IntEnum):
DESCENDING = 0
ASCENDING = 1
12 changes: 12 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import unittest
from cobo_custody.client import Client
from cobo_custody.model.enums import SortFlagEnum
from cobo_custody.signer.local_signer import LocalSigner
from parameterized import param, parameterized
import sys
Expand Down Expand Up @@ -215,6 +216,17 @@ def test_get_invalid_address_history_with_invalid_page(self, coin, page_index, p
# Coin BTTB not supported, please add it on admin web.
self.assertEqual(response.exception.errorCode, 1011)

@parameterized.expand(
[
param(coin="BTC", page_index=0, page_length=10, sort_flag=SortFlagEnum.ASCENDING),
]
)
def test_get_address_history_with_sort(self, coin, page_index, page_length, sort_flag):
response = self.client.get_address_history(
coin=coin, page_index=page_index, page_length=page_length, sort_flag=sort_flag)
self.assertTrue(response.success)
self.assertTrue(len(response.result) > 0)

@parameterized.expand(
[
param(coin="BTC", memo=False),
Expand Down

0 comments on commit 615bb7d

Please sign in to comment.