Skip to content

Commit 44c75ef

Browse files
Merge pull request #162 from InjectiveLabs/f/add_explorer_queries
F/add explorer queries
2 parents 6356c2f + 27660f4 commit 44c75ef

13 files changed

+4356
-904
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ Note that the [sync client](https://github.com/InjectiveLabs/sdk-python/blob/mas
7878

7979

8080
### Changelogs
81+
**0.5.8.8**
82+
* Add grpc_explorer_endpoint in Network
83+
* Add explorer channel and stub
84+
85+
*BREAKING CHANGES*
86+
87+
- Clients using [Custom Network](https://github.com/InjectiveLabs/sdk-python/blob/master/pyinjective/constant.py#L166) must now set grpc_explorer_endpoint during init
88+
8189
**0.5.8.7**
8290
* Add testnet ini metadata
8391
* Fix account pb import

examples/exchange_client/explorer_rpc/2_AccountTxs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
async def main() -> None:
2323
network = Network.testnet()
2424
client = AsyncClient(network, insecure=False)
25-
address = "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r"
26-
type = "injective.exchange.v1beta1.MsgCreateDerivativeLimitOrder"
25+
address = "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex"
26+
type = "cosmos.bank.v1beta1.MsgSend"
2727
account = await client.get_account_txs(address=address, type=type)
2828
print(account)
2929

pyinjective/async_client.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,20 @@ def __init__(
153153
self.exchange_channel
154154
)
155155
)
156-
self.stubExplorer = explorer_rpc_grpc.InjectiveExplorerRPCStub(
157-
self.exchange_channel
158-
)
159156
self.stubAuction = auction_rpc_grpc.InjectiveAuctionRPCStub(
160157
self.exchange_channel
161158
)
162159

160+
# explorer stubs
161+
self.explorer_channel = (
162+
grpc.aio.insecure_channel(network.grpc_explorer_endpoint)
163+
if (insecure or credentials is None)
164+
else grpc.aio.secure_channel(network.grpc_explorer_endpoint, credentials)
165+
)
166+
self.stubExplorer = explorer_rpc_grpc.InjectiveExplorerRPCStub(
167+
self.explorer_channel
168+
)
169+
163170
# timeout height update routine
164171
self.cron = aiocron.crontab(
165172
"* * * * * */{}".format(DEFAULT_TIMEOUTHEIGHT_SYNC_INTERVAL),

pyinjective/constant.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(
6666
tm_websocket_endpoint: str,
6767
grpc_endpoint: str ,
6868
grpc_exchange_endpoint: str ,
69+
grpc_explorer_endpoint: str ,
6970
chain_id: str ,
7071
fee_denom: str ,
7172
env: str
@@ -74,6 +75,7 @@ def __init__(
7475
self.tm_websocket_endpoint = tm_websocket_endpoint
7576
self.grpc_endpoint = grpc_endpoint
7677
self.grpc_exchange_endpoint = grpc_exchange_endpoint
78+
self.grpc_explorer_endpoint = grpc_explorer_endpoint
7779
self.chain_id = chain_id
7880
self.fee_denom = fee_denom
7981
self.env = env
@@ -85,6 +87,7 @@ def devnet(cls):
8587
tm_websocket_endpoint='wss://devnet.tm.injective.dev/websocket',
8688
grpc_endpoint='devnet.injective.dev:9900',
8789
grpc_exchange_endpoint='devnet.injective.dev:9910',
90+
grpc_explorer_endpoint='devnet.injective.dev:9911',
8891
chain_id='injective-777',
8992
fee_denom='inj',
9093
env='devnet'
@@ -97,6 +100,7 @@ def testnet(cls):
97100
tm_websocket_endpoint='wss://k8s.testnet.tm.injective.network/websocket',
98101
grpc_endpoint='k8s.testnet.chain.grpc.injective.network:443',
99102
grpc_exchange_endpoint='k8s.testnet.exchange.grpc.injective.network:443',
103+
grpc_explorer_endpoint='k8s.testnet.explorer.grpc.injective.network:443',
100104
chain_id='injective-888',
101105
fee_denom='inj',
102106
env='testnet'
@@ -120,22 +124,26 @@ def mainnet(cls, node='k8s'):
120124
tm_websocket_endpoint='wss://k8s.mainnet.tm.injective.network:443/websocket'
121125
grpc_endpoint='k8s.mainnet.chain.grpc.injective.network:443'
122126
grpc_exchange_endpoint='k8s.mainnet.exchange.grpc.injective.network:443'
127+
grpc_explorer_endpoint='k8s.mainnet.explorer.grpc.injective.network:443'
123128
elif node == 'lb':
124-
lcd_endpoint = 'https://k8s.global.mainnet.lcd.injective.network:443'
125-
tm_websocket_endpoint = 'wss://k8s.global.mainnet.tm.injective.network:443/websocket'
126-
grpc_endpoint = 'k8s.global.mainnet.chain.grpc.injective.network:443'
127-
grpc_exchange_endpoint = 'k8s.global.mainnet.exchange.grpc.injective.network:443'
129+
lcd_endpoint = 'https://k8s.global.mainnet.lcd.injective.network:443'
130+
tm_websocket_endpoint = 'wss://k8s.global.mainnet.tm.injective.network:443/websocket'
131+
grpc_endpoint = 'k8s.global.mainnet.chain.grpc.injective.network:443'
132+
grpc_exchange_endpoint = 'k8s.global.mainnet.exchange.grpc.injective.network:443'
133+
grpc_explorer_endpoint = 'k8s.global.mainnet.explorer.grpc.injective.network:443'
128134
else:
129135
lcd_endpoint='https://lcd.injective.network'
130136
tm_websocket_endpoint=f'ws://{node}.injective.network:26657/websocket'
131137
grpc_endpoint=f'{node}.injective.network:9900'
132138
grpc_exchange_endpoint=f'{node}.injective.network:9910'
139+
grpc_explorer_endpoint=f'{node}.injective.network:9911'
133140

134141
return cls(
135142
lcd_endpoint=lcd_endpoint,
136143
tm_websocket_endpoint=tm_websocket_endpoint,
137144
grpc_endpoint=grpc_endpoint,
138145
grpc_exchange_endpoint=grpc_exchange_endpoint,
146+
grpc_explorer_endpoint=grpc_explorer_endpoint,
139147
chain_id='injective-1',
140148
fee_denom='inj',
141149
env='mainnet'
@@ -148,18 +156,20 @@ def local(cls):
148156
tm_websocket_endpoint='ws://localost:26657/websocket',
149157
grpc_endpoint='localhost:9900',
150158
grpc_exchange_endpoint='localhost:9910',
159+
grpc_explorer_endpoint='localhost:9911',
151160
chain_id='injective-1',
152161
fee_denom='inj',
153162
env='local'
154163
)
155164

156165
@classmethod
157-
def custom(cls, lcd_endpoint, tm_websocket_endpoint, grpc_endpoint, grpc_exchange_endpoint, chain_id, env):
166+
def custom(cls, lcd_endpoint, tm_websocket_endpoint, grpc_endpoint, grpc_exchange_endpoint, grpc_explorer_endpoint, chain_id, env):
158167
return cls(
159168
lcd_endpoint=lcd_endpoint,
160169
tm_websocket_endpoint=tm_websocket_endpoint,
161170
grpc_endpoint=grpc_endpoint,
162171
grpc_exchange_endpoint=grpc_exchange_endpoint,
172+
grpc_explorer_endpoint=grpc_explorer_endpoint,
163173
chain_id=chain_id,
164174
fee_denom='inj',
165175
env=env

0 commit comments

Comments
 (0)