Skip to content

Commit

Permalink
Merge pull request #9 from NillionNetwork/bug/hardcoded-grpc
Browse files Browse the repository at this point in the history
bug: make grpc configurable
  • Loading branch information
oceans404 authored Sep 13, 2024
2 parents fb0554c + 0484a77 commit dedd3bf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
13 changes: 10 additions & 3 deletions nillion_python_helpers/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,27 @@ async def pay_with_quote(
return nillion.PaymentReceipt(quote, submitted_tx.tx_hash)


def create_payments_config(chain_id, payments_endpoint):
def create_payments_config(chain_id, payments_endpoint, scheme="grpc"):
"""
Creates a network configuration for the payments client.
Args:
chain_id: The chain ID of the network.
payments_endpoint: The endpoint URL for the payments service.
payments_endpoint: The http or https endpoint URL for the payments service.
scheme: The scheme to use for the URL. Defaults to "grpc".
Returns:
NetworkConfig: The network configuration object.
"""
if not payments_endpoint.startswith(("http://", "https://")):
print(
"Deprecation warning: payments_endpoint should start with http:// or https://"
)
payments_endpoint = f"http://{payments_endpoint}"

return NetworkConfig(
chain_id=chain_id,
url=f"grpc+http://{payments_endpoint}/",
url=f"{scheme}+{payments_endpoint}/",
fee_minimum_gas_price=0,
fee_denomination="unil",
staking_denomination="unil",
Expand Down
24 changes: 12 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nillion-python-helpers"
version = "0.3.0"
version = "0.3.1"
description = ""
authors = ["José Cabrero-Holgueras <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit dedd3bf

Please sign in to comment.