Skip to content

Commit 5ca69e4

Browse files
committed
(feat) Synchronized dev branch with master after releasing v1.5.4
2 parents 1b00ad8 + 6a9c390 commit 5ca69e4

File tree

348 files changed

+1040
-947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

348 files changed

+1040
-947
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@ All notable changes to this project will be documented in this file.
1414
### Changed
1515
- Refactored cookies management logic to use all gRPC calls' responses to update the current cookies
1616

17+
## [1.5.4] - 2024-07-03
18+
### Changed
19+
- Fixed all import statements in pyinjective.proto modules to make them explicit
20+
21+
## [1.4.4] - 2024-07-03
22+
### Changed
23+
- Fixed all import statements in pyinjective.proto modules to make them explicit
24+
25+
## [1.5.3] - 2024-06-12
26+
### Changed
27+
- Changed parameter `key` from the PaginationOption class.
28+
- Fixed an error when using the next page key in PaginationOption, causing incorrect pagination responses.
29+
1730
## [1.4.3] - 2024-06-06
1831
### Changed
1932
- Fixed `protobuf` dependency version to "<5" to for the v1.4 branch, because newer versions require a code refactoring (done in v1.5)
20-
+ Fixed `protobuf` dependency version to "<5" for the v1.4 branch because newer versions require a code refactoring (done in v1.5)
33+
- Fixed `protobuf` dependency version to "<5" for the v1.4 branch because newer versions require a code refactoring (done in v1.5)
2134

2235
## [1.5.2] - 2024-05-10
2336
### Changed

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@ all:
33
gen: gen-client
44

55
gen-client: clone-all copy-proto
6+
mkdir -p ./pyinjective/proto
67
@for dir in $(shell find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq); do \
7-
mkdir -p ./pyinjective/$${dir}; \
88
python3 -m grpc_tools.protoc \
9-
-I proto \
9+
--proto_path=./proto \
1010
--python_out=./pyinjective/proto \
1111
--grpc_python_out=./pyinjective/proto \
1212
$$(find ./$${dir} -type f -name '*.proto'); \
13-
done; \
13+
done
1414
rm -rf proto
1515
$(call clean_repos)
16-
echo "import os\nimport sys\n\nsys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))" > pyinjective/proto/__init__.py
16+
touch pyinjective/proto/__init__.py
17+
$(MAKE) fix-proto-imports
18+
19+
PROTO_MODULES := cosmwasm exchange gogoproto cosmos_proto cosmos testpb ibc amino tendermint injective
20+
fix-proto-imports:
21+
@for module in $(PROTO_MODULES); do \
22+
find ./pyinjective/proto -type f -name "*.py" -exec sed -i "" -e "s/from $${module}/from pyinjective.proto.$${module}/g" {} \; ; \
23+
done
24+
@find ./pyinjective/proto -type f -name "*.py" -exec sed -i "" -e "s/from google.api/from pyinjective.proto.google.api/g" {} \;
1725

1826
define clean_repos
1927
rm -Rf cosmos-sdk
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import asyncio
2+
3+
from pyinjective.async_client import AsyncClient
4+
from pyinjective.client.model.pagination import PaginationOption
5+
from pyinjective.core.network import Network
6+
7+
8+
async def main() -> None:
9+
network = Network.testnet()
10+
client = AsyncClient(network)
11+
pagination = PaginationOption(
12+
limit=10,
13+
count_total=True,
14+
)
15+
first_result = await client.fetch_total_supply(
16+
pagination=pagination,
17+
)
18+
print(f"First result:\n{first_result}")
19+
20+
next_page_key = first_result["pagination"]["nextKey"]
21+
22+
for i in range(5):
23+
if next_page_key == "":
24+
break
25+
26+
next_request_pagination = PaginationOption(
27+
limit=pagination.limit,
28+
count_total=pagination.count_total,
29+
encoded_page_key=next_page_key,
30+
)
31+
32+
next_result = await client.fetch_total_supply(
33+
pagination=next_request_pagination,
34+
)
35+
print(f"Page {i+2} result:\n{next_result}")
36+
37+
next_page_key = next_result["pagination"]["nextKey"]
38+
39+
40+
if __name__ == "__main__":
41+
asyncio.get_event_loop().run_until_complete(main())

poetry.lock

Lines changed: 90 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyinjective/async_client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import base64
32
import time
43
from copy import deepcopy
54
from decimal import Decimal
@@ -3228,11 +3227,10 @@ async def initialize_tokens_from_chain_denoms(self):
32283227
next_key = query_result.get("pagination", {}).get("nextKey", "")
32293228

32303229
while next_key != "":
3231-
query_result = await self.fetch_denoms_metadata(pagination=PaginationOption(key=next_key))
3230+
query_result = await self.fetch_denoms_metadata(pagination=PaginationOption(encoded_page_key=next_key))
32323231

32333232
all_denoms_metadata.extend(query_result.get("metadatas", []))
3234-
result_next_key = query_result.get("pagination", {}).get("nextKey", "")
3235-
next_key = base64.b64decode(result_next_key).decode()
3233+
next_key = query_result.get("pagination", {}).get("nextKey", "")
32363234

32373235
for token_metadata in all_denoms_metadata:
32383236
symbol = token_metadata["symbol"]

pyinjective/client/model/pagination.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import base64
12
from typing import Optional
23

34
from pyinjective.proto.cosmos.base.query.v1beta1 import pagination_pb2 as pagination_pb
@@ -6,7 +7,7 @@
67
class PaginationOption:
78
def __init__(
89
self,
9-
key: Optional[str] = None,
10+
encoded_page_key: Optional[str] = None,
1011
skip: Optional[int] = None,
1112
limit: Optional[int] = None,
1213
start_time: Optional[int] = None,
@@ -17,7 +18,7 @@ def __init__(
1718
to_number: Optional[int] = None,
1819
):
1920
super().__init__()
20-
self.key = key
21+
self.encoded_page_key = encoded_page_key
2122
self.skip = skip
2223
self.limit = limit
2324
self.start_time = start_time
@@ -30,8 +31,9 @@ def __init__(
3031
def create_pagination_request(self) -> pagination_pb.PageRequest:
3132
page_request = pagination_pb.PageRequest()
3233

33-
if self.key is not None:
34-
page_request.key = self.key.encode()
34+
if self.encoded_page_key is not None and self.encoded_page_key != "":
35+
page_key = base64.b64decode(self.encoded_page_key)
36+
page_request.key = page_key
3537
if self.skip is not None:
3638
page_request.offset = self.skip
3739
if self.limit is not None:

pyinjective/proto/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
import os
2-
import sys
3-
4-
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))

pyinjective/proto/cosmos/app/runtime/v1alpha1/module_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyinjective/proto/cosmos/app/v1alpha1/query_pb2.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyinjective/proto/cosmos/app/v1alpha1/query_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""Client and server classes corresponding to protobuf-defined services."""
33
import grpc
44

5-
from cosmos.app.v1alpha1 import query_pb2 as cosmos_dot_app_dot_v1alpha1_dot_query__pb2
5+
from pyinjective.proto.cosmos.app.v1alpha1 import query_pb2 as cosmos_dot_app_dot_v1alpha1_dot_query__pb2
66

77

88
class QueryStub(object):

0 commit comments

Comments
 (0)