Skip to content

Commit

Permalink
fix(config): log warning for http(s) node URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
samtin0x committed Sep 30, 2024
1 parent 42dcbaf commit 60e719a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions v4-client-py-v2/documentation/network_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ To connect to the mainnet, use the `make_mainnet` function:
from dydx_v4_client.network import make_mainnet

NETWORK = make_mainnet(
node_url="dydx-ops-grpc.kingnodes.com:443", # No 'https://' prefix
rest_indexer="https://indexer.v4.dydx.exchange",
websocket_indexer="wss://indexer.v4.dydx.exchange/v4/ws"
node_url="NODE_URL", # No 'https://' prefix
rest_indexer="REST_INDEXER",
websocket_indexer="WEBSOCKET_INDEXER"
)
```

Note the above are just an example of the mainnet endpoints. Always use the most recent endpoints from our [network resources documentation](https://docs.dydx.exchange/infrastructure_providers-network/resources#networks-repositories).
> Note the above are just an example of the mainnet endpoints. Always use the most recent endpoints from our [network resources documentation](https://docs.dydx.exchange/infrastructure_providers-network/resources#indexer-endpoints).
⚠️ **Important:** When specifying `node_url`, do not include the `https://` prefix. This is a common mistake that can cause connection issues.

Expand Down
9 changes: 9 additions & 0 deletions v4-client-py-v2/dydx_v4_client/network.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import logging
from dataclasses import dataclass
from functools import partial

import grpc
from grpc import insecure_channel

logger = logging.getLogger(__name__)

secure_channel = partial(
grpc.secure_channel, credentials=grpc.ssl_channel_credentials()
)
Expand All @@ -27,6 +30,12 @@ class Network:
def make_config(
make_channel, make_node, rest_indexer: str, websocket_indexer: str, node_url: str
):
if node_url.startswith("http://") or node_url.startswith("https://"):
logger.warning(
"Node URL should not contain http(s)://. Stripping the prefix. In the future, consider providing the URL without the http(s) prefix."
)
node_url = node_url.split("://", 1)[1]

return Network(
rest_indexer,
websocket_indexer,
Expand Down

0 comments on commit 60e719a

Please sign in to comment.