Skip to content

Commit 0abb4a8

Browse files
committed
feat: add GetTx Tendermint
1 parent c9622d5 commit 0abb4a8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

37_GetTx.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2021 Injective Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Injective Exchange API client for Python. Example only."""
15+
16+
import asyncio
17+
import logging
18+
19+
from pyinjective.async_client import AsyncClient
20+
from pyinjective.constant import Network
21+
22+
async def main() -> None:
23+
network = Network.testnet()
24+
client = AsyncClient(network, insecure=False)
25+
tx_hash = "7746BC12EB82B4D59D036FBFF2F67BDCA6F62A20B3DBC25661707DD61D4DC1B7"
26+
tx_logs = await client.get_tx(tx_hash=tx_hash)
27+
print(tx_logs)
28+
29+
if __name__ == '__main__':
30+
logging.basicConfig(level=logging.INFO)
31+
asyncio.get_event_loop().run_until_complete(main())

pyinjective/async_client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
query_pb2_grpc as tendermint_query_grpc,
1515
query_pb2 as tendermint_query,
1616
)
17+
1718
from .proto.cosmos.auth.v1beta1 import (
1819
query_pb2_grpc as auth_query_grpc,
1920
query_pb2 as auth_query,
@@ -142,6 +143,12 @@ def __init__(
142143
start=True
143144
)
144145

146+
async def get_tx(self, tx_hash):
147+
return await self.stubTx.GetTx(
148+
tx_service.GetTxRequest(
149+
hash=tx_hash )
150+
)
151+
145152
async def close_exchange_channel(self):
146153
await self.exchange_channel.close()
147154

0 commit comments

Comments
 (0)