Skip to content

Commit 80c97ff

Browse files
author
abel
committed
(feat) Regenerated proto files based on Injective Core with support for chain streams
1 parent c8d68eb commit 80c97ff

File tree

276 files changed

+7060
-6155
lines changed

Some content is hidden

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

276 files changed

+7060
-6155
lines changed

pyinjective/async_client.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@
5757
injective_portfolio_rpc_pb2 as portfolio_rpc_pb,
5858
injective_portfolio_rpc_pb2_grpc as portfolio_rpc_grpc,
5959
)
60-
6160
from .proto.injective.types.v1beta1 import (
6261
account_pb2
6362
)
63+
from pyinjective.proto.injective.stream.v1beta1 import query_pb2 as chain_stream_query
64+
from pyinjective.proto.injective.stream.v1beta1 import query_pb2_grpc as stream_rpc_grpc
6465

6566
from .core.network import Network
6667
from .utils.logger import LoggerProvider
@@ -145,6 +146,13 @@ def __init__(
145146
self.explorer_channel
146147
)
147148

149+
self.chain_stream_channel = (
150+
grpc.aio.secure_channel(network.chain_stream_endpoint, credentials)
151+
if (network.use_secure_connection and credentials is not None)
152+
else grpc.aio.insecure_channel(network.chain_stream_endpoint)
153+
)
154+
self.chain_stream_stub = stream_rpc_grpc.StreamStub(channel=self.chain_stream_channel)
155+
148156
# timeout height update routine
149157
self.cron = aiocron.crontab(
150158
"* * * * * */{}".format(DEFAULT_TIMEOUTHEIGHT_SYNC_INTERVAL),
@@ -928,6 +936,20 @@ async def stream_account_portfolio(self, account_address: str, **kwargs):
928936
)
929937
return self.stubPortfolio.StreamAccountPortfolio(request=req, metadata=metadata)
930938

939+
async def chain_stream(
940+
self,
941+
bank_balances_filter: Optional[chain_stream_query.BankBalancesFilter] = None,
942+
subaccount_deposits_filter: Optional[chain_stream_query.SubaccountDepositsFilter] = None
943+
):
944+
945+
request = chain_stream_query.StreamRequest(
946+
bank_balances_filter=bank_balances_filter,
947+
subaccount_deposits_filter=subaccount_deposits_filter)
948+
metadata = await self.network.chain_metadata(
949+
metadata_query_provider=self._chain_cookie_metadata_requestor
950+
)
951+
return self.chain_stream_stub.Stream(request=request, metadata=metadata)
952+
931953
async def composer(self):
932954
return Composer(
933955
network=self.network.string(),

pyinjective/composer.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from pyinjective.proto.cosmos.base.v1beta1 import coin_pb2 as cosmos_dot_base_dot_v1beta1_dot_coin__pb2
3535

3636
from .proto.cosmwasm.wasm.v1 import tx_pb2 as wasm_tx_pb
37+
from pyinjective.proto.injective.stream.v1beta1 import query_pb2 as chain_stream_query
3738

3839
from .constant import ADDITIONAL_CHAIN_FORMAT_DECIMALS, INJ_DENOM
3940
from typing import Dict, List, Optional
@@ -901,6 +902,14 @@ def MsgVote(
901902
proposal_id=proposal_id, voter=voter, option=option
902903
)
903904

905+
def chain_stream_bank_balances_filter(self, accounts: List[str]) -> chain_stream_query.BankBalancesFilter:
906+
return chain_stream_query.BankBalancesFilter(accounts=accounts)
907+
908+
def chain_stream_subaccount_deposits_filter(
909+
self, subaccount_ids: List[str]
910+
) -> chain_stream_query.SubaccountDepositsFilter:
911+
return chain_stream_query.SubaccountDepositsFilter(subaccount_ids=subaccount_ids)
912+
904913
# data field format: [request-msg-header][raw-byte-msg-response]
905914
# you need to figure out this magic prefix number to trim request-msg-header off the data
906915
# this method handles only exchange responses

pyinjective/core/network.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def __init__(
172172
grpc_endpoint: str,
173173
grpc_exchange_endpoint: str,
174174
grpc_explorer_endpoint: str,
175+
chain_stream_endpoint: str,
175176
chain_id: str,
176177
fee_denom: str,
177178
env: str,
@@ -183,6 +184,7 @@ def __init__(
183184
self.grpc_endpoint = grpc_endpoint
184185
self.grpc_exchange_endpoint = grpc_exchange_endpoint
185186
self.grpc_explorer_endpoint = grpc_explorer_endpoint
187+
self.chain_stream_endpoint = chain_stream_endpoint
186188
self.chain_id = chain_id
187189
self.fee_denom = fee_denom
188190
self.env = env
@@ -197,6 +199,7 @@ def devnet(cls):
197199
grpc_endpoint="devnet.injective.dev:9900",
198200
grpc_exchange_endpoint="devnet.injective.dev:9910",
199201
grpc_explorer_endpoint="devnet.injective.dev:9911",
202+
chain_stream_endpoint="devnet.injective.dev:9999",
200203
chain_id="injective-777",
201204
fee_denom="inj",
202205
env="devnet",
@@ -218,6 +221,7 @@ def testnet(cls, node="lb"):
218221
grpc_endpoint = "testnet.sentry.chain.grpc.injective.network:443"
219222
grpc_exchange_endpoint = "testnet.sentry.exchange.grpc.injective.network:443"
220223
grpc_explorer_endpoint = "testnet.sentry.explorer.grpc.injective.network:443"
224+
chain_stream_endpoint = "testnet.sentry.chain.stream.injective.network:443"
221225
cookie_assistant = BareMetalLoadBalancedCookieAssistant()
222226
use_secure_connection = True
223227
else:
@@ -226,6 +230,7 @@ def testnet(cls, node="lb"):
226230
grpc_endpoint = "testnet.chain.grpc.injective.network"
227231
grpc_exchange_endpoint = "testnet.exchange.grpc.injective.network"
228232
grpc_explorer_endpoint = "testnet.explorer.grpc.injective.network"
233+
chain_stream_endpoint = "testnet.chain.stream.injective.network"
229234
cookie_assistant = DisabledCookieAssistant()
230235
use_secure_connection = True
231236

@@ -235,6 +240,7 @@ def testnet(cls, node="lb"):
235240
grpc_endpoint=grpc_endpoint,
236241
grpc_exchange_endpoint=grpc_exchange_endpoint,
237242
grpc_explorer_endpoint=grpc_explorer_endpoint,
243+
chain_stream_endpoint=chain_stream_endpoint,
238244
chain_id="injective-888",
239245
fee_denom="inj",
240246
env="testnet",
@@ -260,6 +266,7 @@ def mainnet(cls, node="lb"):
260266
grpc_endpoint = "sentry.chain.grpc.injective.network:443"
261267
grpc_exchange_endpoint = "sentry.exchange.grpc.injective.network:443"
262268
grpc_explorer_endpoint = "sentry.explorer.grpc.injective.network:443"
269+
chain_stream_endpoint = "sentry.chain.stream.injective.network:443"
263270
cookie_assistant = BareMetalLoadBalancedCookieAssistant()
264271
use_secure_connection = True
265272
elif node == "lb_k8s":
@@ -268,6 +275,7 @@ def mainnet(cls, node="lb"):
268275
grpc_endpoint = "k8s.global.mainnet.chain.grpc.injective.network:443"
269276
grpc_exchange_endpoint = "k8s.global.mainnet.exchange.grpc.injective.network:443"
270277
grpc_explorer_endpoint = "k8s.global.mainnet.explorer.grpc.injective.network:443"
278+
chain_stream_endpoint = "k8s.global.mainnet.chain.stream.injective.network:443"
271279
cookie_assistant = KubernetesLoadBalancedCookieAssistant()
272280
use_secure_connection = True
273281
else:
@@ -276,6 +284,7 @@ def mainnet(cls, node="lb"):
276284
grpc_endpoint = f"{node}.injective.network:9900"
277285
grpc_exchange_endpoint = f"{node}.injective.network:9910"
278286
grpc_explorer_endpoint = f"{node}.injective.network:9911"
287+
chain_stream_endpoint = f"{node}.injective.network:9999"
279288
cookie_assistant = DisabledCookieAssistant()
280289
use_secure_connection = False
281290

@@ -285,6 +294,7 @@ def mainnet(cls, node="lb"):
285294
grpc_endpoint=grpc_endpoint,
286295
grpc_exchange_endpoint=grpc_exchange_endpoint,
287296
grpc_explorer_endpoint=grpc_explorer_endpoint,
297+
chain_stream_endpoint=chain_stream_endpoint,
288298
chain_id="injective-1",
289299
fee_denom="inj",
290300
env="mainnet",
@@ -300,6 +310,7 @@ def local(cls):
300310
grpc_endpoint="localhost:9900",
301311
grpc_exchange_endpoint="localhost:9910",
302312
grpc_explorer_endpoint="localhost:9911",
313+
chain_stream_endpoint="localhost:9999",
303314
chain_id="injective-1",
304315
fee_denom="inj",
305316
env="local",
@@ -315,6 +326,7 @@ def custom(
315326
grpc_endpoint,
316327
grpc_exchange_endpoint,
317328
grpc_explorer_endpoint,
329+
chain_stream_endpoint,
318330
chain_id,
319331
env,
320332
cookie_assistant: Optional[CookieAssistant] = None,
@@ -327,6 +339,7 @@ def custom(
327339
grpc_endpoint=grpc_endpoint,
328340
grpc_exchange_endpoint=grpc_exchange_endpoint,
329341
grpc_explorer_endpoint=grpc_explorer_endpoint,
342+
chain_stream_endpoint=chain_stream_endpoint,
330343
chain_id=chain_id,
331344
fee_denom="inj",
332345
env=env,

pyinjective/proto/amino/amino_pb2.py

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

pyinjective/proto/capability/v1/capability_pb2.py

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

pyinjective/proto/capability/v1/genesis_pb2.py

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

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

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

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

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

0 commit comments

Comments
 (0)