Skip to content

Commit

Permalink
Merge pull request #162 from InjectiveLabs/f/add_explorer_queries
Browse files Browse the repository at this point in the history
F/add explorer queries
  • Loading branch information
achilleas-kal authored Nov 10, 2022
2 parents 6356c2f + 27660f4 commit 44c75ef
Show file tree
Hide file tree
Showing 13 changed files with 4,356 additions and 904 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ Note that the [sync client](https://github.com/InjectiveLabs/sdk-python/blob/mas


### Changelogs
**0.5.8.8**
* Add grpc_explorer_endpoint in Network
* Add explorer channel and stub

*BREAKING CHANGES*

- Clients using [Custom Network](https://github.com/InjectiveLabs/sdk-python/blob/master/pyinjective/constant.py#L166) must now set grpc_explorer_endpoint during init

**0.5.8.7**
* Add testnet ini metadata
* Fix account pb import
Expand Down
4 changes: 2 additions & 2 deletions examples/exchange_client/explorer_rpc/2_AccountTxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
async def main() -> None:
network = Network.testnet()
client = AsyncClient(network, insecure=False)
address = "inj1cml96vmptgw99syqrrz8az79xer2pcgp0a885r"
type = "injective.exchange.v1beta1.MsgCreateDerivativeLimitOrder"
address = "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex"
type = "cosmos.bank.v1beta1.MsgSend"
account = await client.get_account_txs(address=address, type=type)
print(account)

Expand Down
13 changes: 10 additions & 3 deletions pyinjective/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,20 @@ def __init__(
self.exchange_channel
)
)
self.stubExplorer = explorer_rpc_grpc.InjectiveExplorerRPCStub(
self.exchange_channel
)
self.stubAuction = auction_rpc_grpc.InjectiveAuctionRPCStub(
self.exchange_channel
)

# explorer stubs
self.explorer_channel = (
grpc.aio.insecure_channel(network.grpc_explorer_endpoint)
if (insecure or credentials is None)
else grpc.aio.secure_channel(network.grpc_explorer_endpoint, credentials)
)
self.stubExplorer = explorer_rpc_grpc.InjectiveExplorerRPCStub(
self.explorer_channel
)

# timeout height update routine
self.cron = aiocron.crontab(
"* * * * * */{}".format(DEFAULT_TIMEOUTHEIGHT_SYNC_INTERVAL),
Expand Down
20 changes: 15 additions & 5 deletions pyinjective/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(
tm_websocket_endpoint: str,
grpc_endpoint: str ,
grpc_exchange_endpoint: str ,
grpc_explorer_endpoint: str ,
chain_id: str ,
fee_denom: str ,
env: str
Expand All @@ -74,6 +75,7 @@ def __init__(
self.tm_websocket_endpoint = tm_websocket_endpoint
self.grpc_endpoint = grpc_endpoint
self.grpc_exchange_endpoint = grpc_exchange_endpoint
self.grpc_explorer_endpoint = grpc_explorer_endpoint
self.chain_id = chain_id
self.fee_denom = fee_denom
self.env = env
Expand All @@ -85,6 +87,7 @@ def devnet(cls):
tm_websocket_endpoint='wss://devnet.tm.injective.dev/websocket',
grpc_endpoint='devnet.injective.dev:9900',
grpc_exchange_endpoint='devnet.injective.dev:9910',
grpc_explorer_endpoint='devnet.injective.dev:9911',
chain_id='injective-777',
fee_denom='inj',
env='devnet'
Expand All @@ -97,6 +100,7 @@ def testnet(cls):
tm_websocket_endpoint='wss://k8s.testnet.tm.injective.network/websocket',
grpc_endpoint='k8s.testnet.chain.grpc.injective.network:443',
grpc_exchange_endpoint='k8s.testnet.exchange.grpc.injective.network:443',
grpc_explorer_endpoint='k8s.testnet.explorer.grpc.injective.network:443',
chain_id='injective-888',
fee_denom='inj',
env='testnet'
Expand All @@ -120,22 +124,26 @@ def mainnet(cls, node='k8s'):
tm_websocket_endpoint='wss://k8s.mainnet.tm.injective.network:443/websocket'
grpc_endpoint='k8s.mainnet.chain.grpc.injective.network:443'
grpc_exchange_endpoint='k8s.mainnet.exchange.grpc.injective.network:443'
grpc_explorer_endpoint='k8s.mainnet.explorer.grpc.injective.network:443'
elif node == 'lb':
lcd_endpoint = 'https://k8s.global.mainnet.lcd.injective.network:443'
tm_websocket_endpoint = 'wss://k8s.global.mainnet.tm.injective.network:443/websocket'
grpc_endpoint = 'k8s.global.mainnet.chain.grpc.injective.network:443'
grpc_exchange_endpoint = 'k8s.global.mainnet.exchange.grpc.injective.network:443'
lcd_endpoint = 'https://k8s.global.mainnet.lcd.injective.network:443'
tm_websocket_endpoint = 'wss://k8s.global.mainnet.tm.injective.network:443/websocket'
grpc_endpoint = 'k8s.global.mainnet.chain.grpc.injective.network:443'
grpc_exchange_endpoint = 'k8s.global.mainnet.exchange.grpc.injective.network:443'
grpc_explorer_endpoint = 'k8s.global.mainnet.explorer.grpc.injective.network:443'
else:
lcd_endpoint='https://lcd.injective.network'
tm_websocket_endpoint=f'ws://{node}.injective.network:26657/websocket'
grpc_endpoint=f'{node}.injective.network:9900'
grpc_exchange_endpoint=f'{node}.injective.network:9910'
grpc_explorer_endpoint=f'{node}.injective.network:9911'

return cls(
lcd_endpoint=lcd_endpoint,
tm_websocket_endpoint=tm_websocket_endpoint,
grpc_endpoint=grpc_endpoint,
grpc_exchange_endpoint=grpc_exchange_endpoint,
grpc_explorer_endpoint=grpc_explorer_endpoint,
chain_id='injective-1',
fee_denom='inj',
env='mainnet'
Expand All @@ -148,18 +156,20 @@ def local(cls):
tm_websocket_endpoint='ws://localost:26657/websocket',
grpc_endpoint='localhost:9900',
grpc_exchange_endpoint='localhost:9910',
grpc_explorer_endpoint='localhost:9911',
chain_id='injective-1',
fee_denom='inj',
env='local'
)

@classmethod
def custom(cls, lcd_endpoint, tm_websocket_endpoint, grpc_endpoint, grpc_exchange_endpoint, chain_id, env):
def custom(cls, lcd_endpoint, tm_websocket_endpoint, grpc_endpoint, grpc_exchange_endpoint, grpc_explorer_endpoint, chain_id, env):
return cls(
lcd_endpoint=lcd_endpoint,
tm_websocket_endpoint=tm_websocket_endpoint,
grpc_endpoint=grpc_endpoint,
grpc_exchange_endpoint=grpc_exchange_endpoint,
grpc_explorer_endpoint=grpc_explorer_endpoint,
chain_id=chain_id,
fee_denom='inj',
env=env
Expand Down
Loading

0 comments on commit 44c75ef

Please sign in to comment.