-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from InjectiveLabs/feat/add_missing_explorer_…
…endpoints Feat/add missing explorer endpoints
- Loading branch information
Showing
21 changed files
with
951 additions
and
4,687 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
examples/exchange_client/explorer_rpc/11_GetContractsTxsV2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import asyncio | ||
import time | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.client.model.pagination import PaginationOption | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main() -> None: | ||
# Select network: local, testnet, mainnet, or custom | ||
network = Network.testnet() | ||
|
||
# Initialize client | ||
client = AsyncClient(network) | ||
|
||
try: | ||
# Example parameters for fetching contract transactions | ||
address = "inj1ady3s7whq30l4fx8sj3x6muv5mx4dfdlcpv8n7" # Replace with actual contract address | ||
|
||
# Optional pagination and filtering parameters | ||
pagination = PaginationOption( | ||
limit=10, | ||
start_time=int((time.time() - 100) * 1000), | ||
end_time=int(time.time() * 1000), | ||
) | ||
|
||
# Fetch contract transactions V2 | ||
response = await client.fetch_contract_txs_v2(address=address, height=60_000_000, pagination=pagination) | ||
|
||
# Print the results | ||
print("Contract Transactions V2:") | ||
print("Total Transactions:", len(response["data"])) | ||
|
||
for tx in response["data"]: | ||
print("\nTransaction Details:") | ||
print("ID:", tx["id"]) | ||
print("Block Number:", tx["blockNumber"]) | ||
print("Timestamp:", tx["blockTimestamp"]) | ||
print("Hash:", tx["hash"]) | ||
print("Tx Number:", tx["txNumber"]) | ||
|
||
except Exception as e: | ||
print(f"Error occurred: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import asyncio | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main(): | ||
# Select network: choose between testnet, mainnet, or local | ||
network = Network.testnet() | ||
|
||
# Initialize AsyncClient | ||
client = AsyncClient(network) | ||
|
||
try: | ||
# Fetch validators | ||
validators = await client.fetch_validators() | ||
|
||
# Print validators | ||
print("Validators:") | ||
print(validators) | ||
|
||
except Exception as e: | ||
print(f"Error: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import asyncio | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main(): | ||
# Select network: choose between testnet, mainnet, or local | ||
network = Network.testnet() | ||
|
||
# Initialize AsyncClient | ||
client = AsyncClient(network) | ||
address = "injvaloper1kk523rsm9pey740cx4plalp40009ncs0wrchfe" | ||
|
||
try: | ||
# Fetch validator | ||
validator = await client.fetch_validator(address=address) | ||
|
||
# Print validators | ||
print("Validator:") | ||
print(validator) | ||
|
||
except Exception as e: | ||
print(f"Error: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
28 changes: 28 additions & 0 deletions
28
examples/exchange_client/explorer_rpc/14_GetValidatorUptime.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import asyncio | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main(): | ||
# Select network: choose between testnet, mainnet, or local | ||
network = Network.testnet() | ||
|
||
# Initialize AsyncClient | ||
client = AsyncClient(network) | ||
address = "injvaloper1kk523rsm9pey740cx4plalp40009ncs0wrchfe" | ||
|
||
try: | ||
# Fetch validator uptime | ||
uptime = await client.fetch_validator_uptime(address=address) | ||
|
||
# Print uptime | ||
print("Validator uptime:") | ||
print(uptime) | ||
|
||
except Exception as e: | ||
print(f"Error: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import asyncio | ||
import logging | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.client.model.pagination import PaginationOption | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main() -> None: | ||
# network: Network = Network.testnet() | ||
network: Network = Network.testnet() | ||
client: AsyncClient = AsyncClient(network) | ||
|
||
pagination = PaginationOption( | ||
limit=10, | ||
from_number=1000, | ||
to_number=2000, | ||
) | ||
|
||
wasm_codes = await client.fetch_wasm_codes( | ||
pagination=pagination, | ||
) | ||
print("Wasm codes:") | ||
print(wasm_codes) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
asyncio.get_event_loop().run_until_complete(main()) |
24 changes: 24 additions & 0 deletions
24
examples/exchange_client/explorer_rpc/16_GetWasmCodeById.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import asyncio | ||
import logging | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main() -> None: | ||
# network: Network = Network.testnet() | ||
network: Network = Network.testnet() | ||
client: AsyncClient = AsyncClient(network) | ||
|
||
code_id = 2008 | ||
|
||
wasm_code = await client.fetch_wasm_code_by_id( | ||
code_id=code_id, | ||
) | ||
print("Wasm code:") | ||
print(wasm_code) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
asyncio.get_event_loop().run_until_complete(main()) |
30 changes: 30 additions & 0 deletions
30
examples/exchange_client/explorer_rpc/17_GetWasmContracts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import asyncio | ||
import logging | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.client.model.pagination import PaginationOption | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main() -> None: | ||
# network: Network = Network.testnet() | ||
network: Network = Network.testnet() | ||
client: AsyncClient = AsyncClient(network) | ||
|
||
pagination = PaginationOption( | ||
limit=10, | ||
from_number=1000, | ||
to_number=2000, | ||
) | ||
|
||
wasm_contracts = await client.fetch_wasm_contracts( | ||
assets_only=True, | ||
pagination=pagination, | ||
) | ||
print("Wasm contracts:") | ||
print(wasm_contracts) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
asyncio.get_event_loop().run_until_complete(main()) |
22 changes: 22 additions & 0 deletions
22
examples/exchange_client/explorer_rpc/18_GetWasmContractByAddress.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import asyncio | ||
import logging | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main() -> None: | ||
# network: Network = Network.testnet() | ||
network: Network = Network.testnet() | ||
client: AsyncClient = AsyncClient(network) | ||
|
||
address = "inj1yhz4e7df95908jhs9erl87vdzjkdsc24q7afjf" | ||
|
||
wasm_contract = await client.fetch_wasm_contract_by_address(address=address) | ||
print("Wasm contract:") | ||
print(wasm_contract) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
asyncio.get_event_loop().run_until_complete(main()) |
22 changes: 22 additions & 0 deletions
22
examples/exchange_client/explorer_rpc/19_GetCw20Balance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import asyncio | ||
import logging | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main() -> None: | ||
# network: Network = Network.testnet() | ||
network: Network = Network.testnet() | ||
client: AsyncClient = AsyncClient(network) | ||
|
||
address = "inj1phd706jqzd9wznkk5hgsfkrc8jqxv0kmlj0kex" | ||
|
||
balance = await client.fetch_cw20_balance(address=address) | ||
print("Cw20 balance:") | ||
print(balance) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
asyncio.get_event_loop().run_until_complete(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import asyncio | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main(): | ||
# Select network: choose between testnet, mainnet, or local | ||
network = Network.testnet() | ||
|
||
# Initialize AsyncClient | ||
client = AsyncClient(network) | ||
|
||
try: | ||
# Fetch relayers | ||
validators = await client.fetch_relayers() | ||
|
||
# Print relayers | ||
print("Relayers:") | ||
print(validators) | ||
|
||
except Exception as e: | ||
print(f"Error: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.get_event_loop().run_until_complete(main()) |
25 changes: 25 additions & 0 deletions
25
examples/exchange_client/explorer_rpc/21_GetBankTransfers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import asyncio | ||
import json | ||
import logging | ||
|
||
from pyinjective.async_client import AsyncClient | ||
from pyinjective.client.model.pagination import PaginationOption | ||
from pyinjective.core.network import Network | ||
|
||
|
||
async def main() -> None: | ||
# network: Network = Network.testnet() | ||
network: Network = Network.testnet() | ||
client: AsyncClient = AsyncClient(network) | ||
|
||
pagination = PaginationOption(limit=5) | ||
senders = ["inj17xpfvakm2amg962yls6f84z3kell8c5l6s5ye9"] | ||
|
||
bank_transfers = await client.fetch_bank_transfers(senders=senders, pagination=pagination) | ||
print("Bank transfers:") | ||
print(json.dumps(bank_transfers, indent=2)) | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
asyncio.get_event_loop().run_until_complete(main()) |
Oops, something went wrong.