-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Snedashkovsky/add_contract_query
Add contract query
- Loading branch information
Showing
5 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .execution import execute_contract | ||
from .instantiate import instantiate_contract | ||
from .execution import execute_contract | ||
from .query import query_contract |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import json | ||
import requests | ||
|
||
from base64 import b64encode | ||
|
||
|
||
def query_contract( | ||
contract_address: str, | ||
query: dict, | ||
node_lcd_url: str, | ||
display_query_url: bool = False) -> dict: | ||
""" | ||
Query contract | ||
:param contract_address: contract address | ||
:param query: contract query | ||
:param node_lcd_url: node lcd url | ||
:param display_query_url: display a query url or not | ||
:return: query result | ||
""" | ||
_query_msg = b64encode(json.dumps(query).encode("utf-8")).decode("utf-8") | ||
_query = f'{node_lcd_url}/cosmwasm/wasm/v1/contract/{contract_address}/smart/{_query_msg}' | ||
if display_query_url: | ||
print(_query) | ||
return requests.get(_query).json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters