Skip to content

Conversation

@Royc30ne
Copy link
Contributor

@Royc30ne Royc30ne commented Dec 7, 2025

Description:

  • Adds a public constructor to allow providing an explicit WebSocket PubSub URL: DriftClient::new_with_ws_url(...).
  • Keeps the existing DriftClient::new(...) for backward compatibility; it now delegates to the explicit constructor to reuse validation/initialization logic.
  • Adds DriftClientBackend::new_with_ws_url (and internal new_with_explicit_ws_url) to initialize the backend with a custom wss://host:port endpoint.
  • Validates both RPC and WS URLs early with get_http_url / get_ws_url to fail fast on malformed endpoints.
  • Updates relevant docs/comments in crates/src/lib.rs.

Why: Some users need to connect to a custom/hosted Ws PubSub endpoint (e.g. private relay or proxy) rather than deriving from the RPC URL. Exposing an explicit WS constructor makes that supported while preserving the default behavior for existing callers.

Files changed:

  • crates/src/lib.rs (public API + backend constructors and docs)

Migration:

  • No breaking changes. Existing code using DriftClient::new(...) continues to work.
  • To use a custom WS endpoint, call:
    DriftClient::new_with_ws_url(context, rpc_client, wallet, "wss://host:port").await?;

Testing: Verified compilation and local tests.

@jordy25519
Copy link
Collaborator

hi @Royc30ne needs a format but changes look ok to me apart from that

@Royc30ne
Copy link
Contributor Author

Royc30ne commented Dec 8, 2025

@jordy25519 ran cargo fmt and pushed the updated formatting. Let me know if anything else needs tweaking!

@jordy25519 jordy25519 merged commit 9c0abc5 into drift-labs:main Dec 9, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants