diff --git a/CHANGELOG_UNRELEASED.md b/CHANGELOG_UNRELEASED.md index 3e291cad0a..c579721768 100644 --- a/CHANGELOG_UNRELEASED.md +++ b/CHANGELOG_UNRELEASED.md @@ -28,4 +28,6 @@ ### Helpers +- (feat) [\#2883](https://github.com/bandprotocol/bandchain/pull/2883) pyband: Implemented get_price_symbols to client module + ### MISC diff --git a/helpers/pyband/pyband/client.py b/helpers/pyband/pyband/client.py index 24366261cf..8d28cef8d2 100644 --- a/helpers/pyband/pyband/client.py +++ b/helpers/pyband/pyband/client.py @@ -2,6 +2,7 @@ from dacite import from_dict from .wallet import Address +from typing import List from .data import ( Account, Block, @@ -126,5 +127,14 @@ def get_latest_request(self, oid: int, calldata: bytes, min_count: int, ask_coun config=DACITE_CONFIG, ) - def get_reporters(self, validator: str) -> list: + def get_reporters(self, validator: str) -> List[str]: return self._get_result("/oracle/reporters/{}".format(validator)) + + def get_price_symbols(self, min_count: int, ask_count: int) -> List[str]: + return self._get_result( + "/oracle/price_symbols", + params={ + "min_count": min_count, + "ask_count": ask_count, + }, + ) diff --git a/helpers/pyband/tests/client/client_test.py b/helpers/pyband/tests/client/client_test.py index 469efb6228..c1aaa9646f 100644 --- a/helpers/pyband/tests/client/client_test.py +++ b/helpers/pyband/tests/client/client_test.py @@ -23,7 +23,7 @@ ) from pyband.utils import parse_datetime -TEST_RPC = "https://api-mock.bandprotocol.com/rest/" +TEST_RPC = "https://api-mock.bandprotocol.com/rest" client = Client(TEST_RPC) @@ -638,3 +638,27 @@ def test_get_reporters(requests_mock): "band15pm9scujgkpwpy2xa2j53tvs9ylunjn0g73a9s", "band1cehe3sxk7f4rmvwdf6lxh3zexen7fn02zyltwy", ] + + +def test_get_price_symbols(requests_mock): + requests_mock.register_uri( + "GET", + "{}/oracle/price_symbols?min_count=3&ask_count=4".format(TEST_RPC), + json={ + "height": "2951872", + "result": [ + "2KEY", + "ABYSS", + "ADA", + "AKRO", + ], + }, + status_code=200, + ) + + assert client.get_price_symbols(3, 4) == [ + "2KEY", + "ABYSS", + "ADA", + "AKRO", + ]