Skip to content

Commit fa5e91b

Browse files
committed
(fix) Removed old deprecated functions from Composer and AsyncClient. Removed the deprecation tests no longer required
1 parent 302f09b commit fa5e91b

18 files changed

+583
-4245
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import asyncio
2+
import time
3+
4+
from pyinjective.async_client import AsyncClient
5+
from pyinjective.client.model.pagination import PaginationOption
6+
from pyinjective.core.network import Network
7+
8+
9+
async def main() -> None:
10+
# Select network: local, testnet, mainnet, or custom
11+
network = Network.testnet()
12+
13+
# Initialize client
14+
client = AsyncClient(network)
15+
16+
try:
17+
# Example parameters for fetching contract transactions
18+
address = "inj1ady3s7whq30l4fx8sj3x6muv5mx4dfdlcpv8n7" # Replace with actual contract address
19+
20+
# Optional pagination and filtering parameters
21+
pagination = PaginationOption(
22+
limit=10,
23+
start_time=int((time.time() - 100) * 1000),
24+
end_time=int(time.time() * 1000),
25+
)
26+
27+
# Fetch contract transactions V2
28+
response = await client.fetch_contract_txs_v2(address=address, height=60_000_000, pagination=pagination)
29+
30+
# Print the results
31+
print("Contract Transactions V2:")
32+
print("Total Transactions:", len(response["data"]))
33+
34+
for tx in response["data"]:
35+
print("\nTransaction Details:")
36+
print("ID:", tx["id"])
37+
print("Block Number:", tx["blockNumber"])
38+
print("Timestamp:", tx["blockTimestamp"])
39+
print("Hash:", tx["hash"])
40+
print("Tx Number:", tx["txNumber"])
41+
42+
except Exception as e:
43+
print(f"Error occurred: {e}")
44+
45+
46+
if __name__ == "__main__":
47+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import asyncio
2+
3+
from pyinjective.async_client import AsyncClient
4+
from pyinjective.core.network import Network
5+
6+
7+
async def main():
8+
# Select network: choose between testnet, mainnet, or local
9+
network = Network.testnet()
10+
11+
# Initialize AsyncClient
12+
client = AsyncClient(network)
13+
14+
try:
15+
# Fetch validators
16+
validators = await client.fetch_validators()
17+
18+
# Print validators
19+
print("Validators:")
20+
print(validators)
21+
22+
except Exception as e:
23+
print(f"Error: {e}")
24+
25+
26+
if __name__ == "__main__":
27+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import asyncio
2+
3+
from pyinjective.async_client import AsyncClient
4+
from pyinjective.core.network import Network
5+
6+
7+
async def main():
8+
# Select network: choose between testnet, mainnet, or local
9+
network = Network.testnet()
10+
11+
# Initialize AsyncClient
12+
client = AsyncClient(network)
13+
address = "injvaloper1kk523rsm9pey740cx4plalp40009ncs0wrchfe"
14+
15+
try:
16+
# Fetch validator
17+
validator = await client.fetch_validator(address=address)
18+
19+
# Print validators
20+
print("Validator:")
21+
print(validator)
22+
23+
except Exception as e:
24+
print(f"Error: {e}")
25+
26+
27+
if __name__ == "__main__":
28+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import asyncio
2+
3+
from pyinjective.async_client import AsyncClient
4+
from pyinjective.core.network import Network
5+
6+
7+
async def main():
8+
# Select network: choose between testnet, mainnet, or local
9+
network = Network.testnet()
10+
11+
# Initialize AsyncClient
12+
client = AsyncClient(network)
13+
address = "injvaloper1kk523rsm9pey740cx4plalp40009ncs0wrchfe"
14+
15+
try:
16+
# Fetch validator uptime
17+
uptime = await client.fetch_validator_uptime(address=address)
18+
19+
# Print uptime
20+
print("Validator uptime:")
21+
print(uptime)
22+
23+
except Exception as e:
24+
print(f"Error: {e}")
25+
26+
27+
if __name__ == "__main__":
28+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import asyncio
2+
import logging
3+
4+
from pyinjective.async_client import AsyncClient
5+
from pyinjective.client.model.pagination import PaginationOption
6+
from pyinjective.core.network import Network
7+
8+
9+
async def main() -> None:
10+
# network: Network = Network.testnet()
11+
network: Network = Network.testnet()
12+
client: AsyncClient = AsyncClient(network)
13+
14+
pagination = PaginationOption(
15+
limit=10,
16+
from_number=1000,
17+
to_number=2000,
18+
)
19+
20+
wasm_codes = await client.fetch_wasm_codes(
21+
pagination=pagination,
22+
)
23+
print("Wasm codes:")
24+
print(wasm_codes)
25+
26+
27+
if __name__ == "__main__":
28+
logging.basicConfig(level=logging.INFO)
29+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import asyncio
2+
import logging
3+
4+
from pyinjective.async_client import AsyncClient
5+
from pyinjective.core.network import Network
6+
7+
8+
async def main() -> None:
9+
# network: Network = Network.testnet()
10+
network: Network = Network.testnet()
11+
client: AsyncClient = AsyncClient(network)
12+
13+
code_id = 2008
14+
15+
wasm_code = await client.fetch_wasm_code_by_id(
16+
code_id=code_id,
17+
)
18+
print("Wasm code:")
19+
print(wasm_code)
20+
21+
22+
if __name__ == "__main__":
23+
logging.basicConfig(level=logging.INFO)
24+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import asyncio
2+
import logging
3+
4+
from pyinjective.async_client import AsyncClient
5+
from pyinjective.client.model.pagination import PaginationOption
6+
from pyinjective.core.network import Network
7+
8+
9+
async def main() -> None:
10+
# network: Network = Network.testnet()
11+
network: Network = Network.testnet()
12+
client: AsyncClient = AsyncClient(network)
13+
14+
pagination = PaginationOption(
15+
limit=10,
16+
from_number=1000,
17+
to_number=2000,
18+
)
19+
20+
wasm_contracts = await client.fetch_wasm_contracts(
21+
assets_only=True,
22+
pagination=pagination,
23+
)
24+
print("Wasm contracts:")
25+
print(wasm_contracts)
26+
27+
28+
if __name__ == "__main__":
29+
logging.basicConfig(level=logging.INFO)
30+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import asyncio
2+
import logging
3+
4+
from pyinjective.async_client import AsyncClient
5+
from pyinjective.core.network import Network
6+
7+
8+
async def main() -> None:
9+
# network: Network = Network.testnet()
10+
network: Network = Network.testnet()
11+
client: AsyncClient = AsyncClient(network)
12+
13+
address = "inj1yhz4e7df95908jhs9erl87vdzjkdsc24q7afjf"
14+
15+
wasm_contract = await client.fetch_wasm_contract_by_address(address=address)
16+
print("Wasm contract:")
17+
print(wasm_contract)
18+
19+
20+
if __name__ == "__main__":
21+
logging.basicConfig(level=logging.INFO)
22+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import asyncio
2+
import logging
3+
4+
from pyinjective.async_client import AsyncClient
5+
from pyinjective.core.network import Network
6+
7+
8+
async def main() -> None:
9+
# network: Network = Network.testnet()
10+
network: Network = Network.testnet()
11+
client: AsyncClient = AsyncClient(network)
12+
13+
address = "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex"
14+
15+
balance = await client.fetch_cw20_balance(address=address)
16+
print("Cw20 balance:")
17+
print(balance)
18+
19+
20+
if __name__ == "__main__":
21+
logging.basicConfig(level=logging.INFO)
22+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import asyncio
2+
3+
from pyinjective.async_client import AsyncClient
4+
from pyinjective.core.network import Network
5+
6+
7+
async def main():
8+
# Select network: choose between testnet, mainnet, or local
9+
network = Network.testnet()
10+
11+
# Initialize AsyncClient
12+
client = AsyncClient(network)
13+
14+
try:
15+
# Fetch relayers
16+
validators = await client.fetch_relayers()
17+
18+
# Print relayers
19+
print("Relayers:")
20+
print(validators)
21+
22+
except Exception as e:
23+
print(f"Error: {e}")
24+
25+
26+
if __name__ == "__main__":
27+
asyncio.get_event_loop().run_until_complete(main())

0 commit comments

Comments
 (0)