Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query interchain verifications #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions dragonchain_sdk/dragonchain_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,22 @@ def get_verifications(self, block_id: str, level: Optional[int] = None) -> "requ
return self.request.get("/v1/verifications/{}?level={}".format(block_id, level))
return self.request.get("/v1/verifications/{}".format(block_id))

def query_interchain_transactions(self, block_id: str) -> "request_response":
"""Get all subsequent interchain broadcasts both including and after the L1 block ID

Args:
block_id (str): ID of the block to get verifications for

Raises:
TypeError: with bad parameter type

Returns:
Level 5 verifications
"""
if not isinstance(block_id, str):
raise TypeError('Parameter "block_id" must be of type str.')
return self.request.get("/v1/verifications/interchains/{}".format(block_id))

def get_api_key(self, key_id: str) -> "request_response":
"""Get information about an HMAC API key

Expand Down
9 changes: 9 additions & 0 deletions tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,15 @@ def test_get_smart_contract_object_throws_type_error(self, mock_creds, mock_requ
self.assertRaises(TypeError, self.client.get_smart_contract_object, key=[])
self.assertRaises(TypeError, self.client.get_smart_contract_object, key="MyKey", smart_contract_id=[])

def test_query_interchain_transactions_throws_type_error(self, mock_creds, mock_request):
self.client = dragonchain_sdk.create_client()
self.assertRaises(TypeError, self.client.query_interchain_transactions, 123456789)

def test_query_interchain_transactions_calls_get_with_string(self, mock_creds, mock_request):
self.client = dragonchain_sdk.create_client()
self.client.query_interchain_transactions("123456789")
self.client.request.get.assert_called_once_with("/v1/verifications/interchains/123456789")

@patch.dict(os.environ, {"SMART_CONTRACT_ID": "MyName"})
def test_get_smart_contract_object_reads_env_and_calls_get(self, mock_creds, mock_request):
self.client = dragonchain_sdk.create_client()
Expand Down