Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Pyband: Implemented get_price_symbols to client module #2883

Merged
merged 6 commits into from
Nov 18, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@

### Helpers

- (feat) [\#2883](https://github.com/bandprotocol/bandchain/pull/2883) pyband: Implemented get_price_symbols to client module

### MISC
12 changes: 11 additions & 1 deletion helpers/pyband/pyband/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from dacite import from_dict
from .wallet import Address
from typing import List
from .data import (
Account,
Block,
Expand Down Expand Up @@ -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,
},
)
26 changes: 25 additions & 1 deletion helpers/pyband/tests/client/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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",
]