pub struct DydxGrpcClient { /* private fields */ }Expand description
gRPC client for dYdX v4 protocol operations.
This client handles:
- Transaction signing and broadcasting.
- Account query operations.
- Order placement and management via Cosmos SDK messages.
- Connection management and automatic failover to fallback nodes.
Implementations§
Source§impl DydxGrpcClient
impl DydxGrpcClient
Sourcepub async fn new(grpc_url: String) -> Result<Self, DydxError>
pub async fn new(grpc_url: String) -> Result<Self, DydxError>
Create a new gRPC client with a single URL.
§Errors
Returns an error if the gRPC connection cannot be established.
Sourcepub async fn new_with_fallback(
grpc_urls: &[impl AsRef<str>],
) -> Result<Self, DydxError>
pub async fn new_with_fallback( grpc_urls: &[impl AsRef<str>], ) -> Result<Self, DydxError>
Create a new gRPC client with fallback support.
Attempts to connect to each URL in the provided list until a successful connection is established. This is useful for DEX environments where nodes can fail and fallback options are needed.
§Errors
Returns an error if none of the provided URLs can establish a connection.
Sourcepub async fn reconnect_with_fallback(
&mut self,
grpc_urls: &[impl AsRef<str>],
) -> Result<(), DydxError>
pub async fn reconnect_with_fallback( &mut self, grpc_urls: &[impl AsRef<str>], ) -> Result<(), DydxError>
Reconnect to a different gRPC node from the fallback list.
Attempts to establish a new connection to each URL in the provided list until successful. This is useful when the current node fails and you need to failover to a different validator node.
§Errors
Returns an error if none of the provided URLs can establish a connection.
Sourcepub fn current_url(&self) -> &str
pub fn current_url(&self) -> &str
Get the currently connected gRPC node URL.
Sourcepub fn channel(&self) -> &Channel
pub fn channel(&self) -> &Channel
Get the underlying gRPC channel.
This can be used to create custom gRPC service clients.
Sourcepub async fn query_address(
&mut self,
address: &str,
) -> Result<(u64, u64), Error>
pub async fn query_address( &mut self, address: &str, ) -> Result<(u64, u64), Error>
Query account information for a given address.
Returns the account number and sequence number needed for transaction signing.
§Errors
Returns an error if the query fails or the account does not exist.
Sourcepub async fn get_account(&mut self, address: &str) -> Result<BaseAccount, Error>
pub async fn get_account(&mut self, address: &str) -> Result<BaseAccount, Error>
Query for an account by its address.
§Errors
Returns an error if the query fails or the account does not exist.
Sourcepub async fn get_account_balances(
&mut self,
address: &str,
) -> Result<Vec<Coin>, Error>
pub async fn get_account_balances( &mut self, address: &str, ) -> Result<Vec<Coin>, Error>
Query for account balances by address for all denominations.
§Errors
Returns an error if the query fails.
Sourcepub async fn get_node_info(&mut self) -> Result<GetNodeInfoResponse, Error>
pub async fn get_node_info(&mut self) -> Result<GetNodeInfoResponse, Error>
Sourcepub async fn latest_block(&mut self) -> Result<Block, Error>
pub async fn latest_block(&mut self) -> Result<Block, Error>
Sourcepub async fn latest_block_height(&mut self) -> Result<Height, Error>
pub async fn latest_block_height(&mut self) -> Result<Height, Error>
Sourcepub async fn get_subaccount(
&mut self,
address: &str,
number: u32,
) -> Result<SubaccountInfo, Error>
pub async fn get_subaccount( &mut self, address: &str, number: u32, ) -> Result<SubaccountInfo, Error>
Trait Implementations§
Source§impl Clone for DydxGrpcClient
impl Clone for DydxGrpcClient
Source§fn clone(&self) -> DydxGrpcClient
fn clone(&self) -> DydxGrpcClient
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for DydxGrpcClient
impl !RefUnwindSafe for DydxGrpcClient
impl Send for DydxGrpcClient
impl Sync for DydxGrpcClient
impl Unpin for DydxGrpcClient
impl !UnwindSafe for DydxGrpcClient
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].