Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/cozy-poets-go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@human-protocol/sdk": major
"@human-protocol/python-sdk": major
---

Updated KV Store utils in sdk to return empty string in case no value in subgraph instead of throwing and error
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get(
address: str,
key: str,
options: Optional[SubgraphOptions] = None,
) -> Optional[str]:
) -> str:
"""Get the value of a specific key for an address.

Queries the subgraph for a specific key-value pair associated with an address.
Expand Down Expand Up @@ -181,7 +181,7 @@ def get(
or "kvstores" not in kvstore_data["data"]
or len(kvstore_data["data"]["kvstores"]) == 0
):
return None
return ""

return kvstore_data["data"]["kvstores"][0]["value"]

Expand Down Expand Up @@ -232,12 +232,12 @@ def get_file_url_and_verify_hash(
raise KVStoreClientError(f"Invalid address: {address}")

url = KVStoreUtils.get(chain_id, address, key, options=options)
if url is None:
if url == "":
raise KVStoreClientError("No URL found for the given address and key")

hash = KVStoreUtils.get(chain_id, address, key + "_hash", options=options)

if hash is None:
if hash == "":
raise KVStoreClientError("No hash found for the given address and url")

content = requests.get(url).text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_get_empty_value(self, mock_function):

result = KVStoreUtils.get(ChainId.LOCALHOST, address, key)

self.assertIsNone(result)
self.assertEqual(result, "")

mock_function.assert_called_once_with(
NETWORKS[ChainId.LOCALHOST],
Expand Down
Loading