pub struct EvmToken {
pub address: String,
pub symbol: String,
pub name: String,
pub decimals: u8,
pub chain_id: u64,
}Expand description
Token information for ERC20 and native tokens
Fields§
§address: StringContract address (0x0 for native token)
symbol: StringToken symbol (e.g., “USDC”, “ETH”)
name: StringToken name (e.g., “USD Coin”, “Ethereum”)
decimals: u8Number of decimal places
chain_id: u64Chain ID where this token exists
Implementations§
Source§impl EvmToken
impl EvmToken
Sourcepub fn new(
address: &str,
symbol: String,
name: String,
decimals: u8,
chain_id: u64,
) -> Result<EvmToken, EvmCommonError>
pub fn new( address: &str, symbol: String, name: String, decimals: u8, chain_id: u64, ) -> Result<EvmToken, EvmCommonError>
Create new EVM token with validation
Sourcepub fn contract_address(&self) -> Result<Option<Address>, EvmCommonError>
pub fn contract_address(&self) -> Result<Option<Address>, EvmCommonError>
Get contract address as Alloy Address (for non-native tokens)
Sourcepub fn format_amount(&self, raw_amount: Uint<256, 4>) -> String
pub fn format_amount(&self, raw_amount: Uint<256, 4>) -> String
Convert amount from smallest unit to human-readable format
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EvmToken
impl<'de> Deserialize<'de> for EvmToken
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EvmToken, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EvmToken, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for EvmToken
impl JsonSchema for EvmToken
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Serialize for EvmToken
impl Serialize for EvmToken
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for EvmToken
impl RefUnwindSafe for EvmToken
impl Send for EvmToken
impl Sync for EvmToken
impl Unpin for EvmToken
impl UnsafeUnpin for EvmToken
impl UnwindSafe for EvmToken
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
Mutably borrows from an owned value. Read more
impl<'de, T> BorrowedRpcObject<'de> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
Converts
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> ⓘ
Converts
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