diff --git a/README.md b/README.md index 5b9c461..c779170 100644 --- a/README.md +++ b/README.md @@ -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) ```
View Response diff --git a/cobo_custody/client/client.py b/cobo_custody/client/client.py index 6fb207e..4f17da1 100644 --- a/cobo_custody/client/client.py +++ b/cobo_custody/client/client.py @@ -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): @@ -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: diff --git a/cobo_custody/model/__init__.py b/cobo_custody/model/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cobo_custody/model/__pycache__/__init__.cpython-37.pyc b/cobo_custody/model/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..af67927 Binary files /dev/null and b/cobo_custody/model/__pycache__/__init__.cpython-37.pyc differ diff --git a/cobo_custody/model/__pycache__/enums.cpython-37.pyc b/cobo_custody/model/__pycache__/enums.cpython-37.pyc new file mode 100644 index 0000000..da34458 Binary files /dev/null and b/cobo_custody/model/__pycache__/enums.cpython-37.pyc differ diff --git a/cobo_custody/model/enums.py b/cobo_custody/model/enums.py new file mode 100644 index 0000000..949d14b --- /dev/null +++ b/cobo_custody/model/enums.py @@ -0,0 +1,6 @@ +from enum import IntEnum + + +class SortFlagEnum(IntEnum): + DESCENDING = 0 + ASCENDING = 1 diff --git a/test.py b/test.py index 668dd77..d049c19 100644 --- a/test.py +++ b/test.py @@ -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 @@ -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),