Skip to content

feat: use Pactus Python packages for RPC connections #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions examples/example_get_consensus_info.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

def main() -> None:
# Creating a gRPC channel
channel = grpc.insecure_channel("testnet1.pactus.org:50052")
channel = grpc.insecure_channel("bootstrap1.pactus.org:50051")

# Creating a stub from channel
stub = BlockchainStub(channel)

# Initialize a request and call get blockchain info method
req = GetBlockchainInfoRequest()
blockchain_info = stub.GetBlockchainInfo(req)
res = stub.GetBlockchainInfo(req)

print(f"Blockchain info:\n{blockchain_info}")
print(f"Blockchain info:\n{res}")


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def main() -> None:
req = GetNodeInfoRequest()
res = stub.GetNodeInfo(req)

print(f"Node info Response:\n{res.reachability}")
print(f"Node info:\n{res}")


if __name__ == "__main__":
Expand Down
16 changes: 16 additions & 0 deletions examples/example_jsonrpc_get_blockchain_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pactus_jsonrpc.client import PactusOpenRPCClient
import pactus_jsonrpc.client
import asyncio


async def main() -> None:
pactus_jsonrpc.client.CLIENT_URL = "https://testnet1.pactus.org/jsonrpc"
client = PactusOpenRPCClient([])

res = await client.pactus.blockchain.get_blockchain_info()

print(f"Blockchain info:\n{res}")


if __name__ == "__main__":
asyncio.run(main())
16 changes: 16 additions & 0 deletions examples/example_jsonrpc_get_node_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pactus_jsonrpc.client import PactusOpenRPCClient
import pactus_jsonrpc.client
import asyncio


async def main() -> None:
pactus_jsonrpc.client.CLIENT_URL = "https://testnet1.pactus.org/jsonrpc"
client = PactusOpenRPCClient([])

res = await client.pactus.network.get_node_info()

print(f"Node info:\n{res}")


if __name__ == "__main__":
asyncio.run(main())
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools >= 42.0.0"]
build-backend = "setuptools.build_meta"
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
packages=find_packages(),
license="MIT",
install_requires=[
"pactus_grpc",
"pactus-grpc>=1.7.4",
"pactus-jsonrpc>=1.7.4",
"ripemd-hash",
"grpcio",
"grpcio-tools",
Expand Down
Loading