Skip to content

Commit

Permalink
Merge pull request #126 from InjectiveLabs/f/add_get_tx_tendermint
Browse files Browse the repository at this point in the history
F/release0.5.7.0
  • Loading branch information
achilleas-kal authored Jul 6, 2022
2 parents c9622d5 + 386959a commit eadd9d4
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 317 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ Note that the [sync client](https://github.com/InjectiveLabs/sdk-python/blob/mas


### Changelogs
**0.5.7.0**
* Add GetTxRequest Tendermint
* Re-gen ini files

**0.5.6.9**
* Add MsgExternalTransfer to the composer
* Add support for Binary Options
Expand Down
31 changes: 31 additions & 0 deletions examples/chain_client/37_GetTx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2021 Injective Labs
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Injective Exchange API client for Python. Example only."""

import asyncio
import logging

from pyinjective.async_client import AsyncClient
from pyinjective.constant import Network

async def main() -> None:
network = Network.testnet()
client = AsyncClient(network, insecure=False)
tx_hash = "7746BC12EB82B4D59D036FBFF2F67BDCA6F62A20B3DBC25661707DD61D4DC1B7"
tx_logs = await client.get_tx(tx_hash=tx_hash)
print(tx_logs)

if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
asyncio.get_event_loop().run_until_complete(main())
8 changes: 7 additions & 1 deletion pyinjective/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
query_pb2_grpc as tendermint_query_grpc,
query_pb2 as tendermint_query,
)

from .proto.cosmos.auth.v1beta1 import (
query_pb2_grpc as auth_query_grpc,
query_pb2 as auth_query,
Expand Down Expand Up @@ -142,6 +143,12 @@ def __init__(
start=True
)

async def get_tx(self, tx_hash):
return await self.stubTx.GetTx(
tx_service.GetTxRequest(
hash=tx_hash )
)

async def close_exchange_channel(self):
await self.exchange_channel.close()

Expand Down Expand Up @@ -797,4 +804,3 @@ async def get_binary_options_markets(self, **kwargs):
async def get_binary_options_market(self, market_id: str):
req = derivative_exchange_rpc_pb.BinaryOptionsMarketRequest(market_id=market_id)
return await self.stubDerivativeExchange.BinaryOptionsMarket(req)

Loading

0 comments on commit eadd9d4

Please sign in to comment.