pub struct DydxCredential {
pub address: String,
pub authenticator_ids: Vec<u64>,
/* private fields */
}Expand description
dYdX wallet credentials for signing blockchain transactions.
Uses secp256k1 for signing as per Cosmos SDK specifications.
§Security
The underlying SigningKey from cosmrs (backed by k256) securely zeroizes
private key material from memory on drop.
Fields§
§address: StringBech32-encoded account address (e.g., dydx1…).
authenticator_ids: Vec<u64>Optional authenticator IDs for permissioned key trading.
Implementations§
Source§impl DydxCredential
impl DydxCredential
Sourcepub fn from_private_key(
private_key_hex: &str,
authenticator_ids: Vec<u64>,
) -> Result<Self>
pub fn from_private_key( private_key_hex: &str, authenticator_ids: Vec<u64>, ) -> Result<Self>
Creates a new DydxCredential from a raw private key.
§Errors
Returns an error if private key is invalid.
Sourcepub fn from_env(
is_testnet: bool,
authenticator_ids: Vec<u64>,
) -> Result<Option<Self>>
pub fn from_env( is_testnet: bool, authenticator_ids: Vec<u64>, ) -> Result<Option<Self>>
Creates a DydxCredential from environment variables.
Checks for private key: DYDX_PRIVATE_KEY / DYDX_TESTNET_PRIVATE_KEY
Returns None if no environment variable is set.
§Errors
Returns an error if a credential is set but invalid.
Sourcepub fn resolve(
private_key: Option<String>,
is_testnet: bool,
authenticator_ids: Vec<u64>,
) -> Result<Option<Self>>
pub fn resolve( private_key: Option<String>, is_testnet: bool, authenticator_ids: Vec<u64>, ) -> Result<Option<Self>>
Resolves a DydxCredential from config values or environment variables.
Priority:
private_keyconfig valueDYDX_PRIVATE_KEY/DYDX_TESTNET_PRIVATE_KEYenv var
Returns None if no credential is available.
§Errors
Returns an error if a credential is provided but invalid.
Sourcepub fn account_id(&self) -> Result<AccountId>
pub fn account_id(&self) -> Result<AccountId>
Returns the account ID for this credential.
§Errors
Returns an error if the address cannot be parsed as a valid account ID.
Sourcepub fn sign(&self, sign_doc: &SignDoc) -> Result<Vec<u8>>
pub fn sign(&self, sign_doc: &SignDoc) -> Result<Vec<u8>>
Signs a transaction SignDoc.
This produces the signature bytes that will be included in the transaction.
§Errors
Returns an error if SignDoc serialization or signing fails.
Sourcepub fn sign_bytes(&self, message: &[u8]) -> Result<Vec<u8>>
pub fn sign_bytes(&self, message: &[u8]) -> Result<Vec<u8>>
Signs raw message bytes.
Used for custom signing operations outside of standard transaction flow.
§Errors
Returns an error if signing fails.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Returns the public key for this credential.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DydxCredential
impl !RefUnwindSafe for DydxCredential
impl Send for DydxCredential
impl Sync for DydxCredential
impl Unpin for DydxCredential
impl UnsafeUnpin for DydxCredential
impl !UnwindSafe for DydxCredential
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§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].