0xa5::coin_info
Defines the CoinInfo
type which allows to store information about a coin:
either derived from CoinMetadata
or manually provided.
CoinInfo
from_info
from_metadata
name
symbol
decimals
metadata
use 0x1::ascii;
use 0x1::option;
use 0x1::string;
use 0x2::coin;
CoinInfo
struct CoinInfo<T> has store
name: string::String
symbol: ascii::String
decimals: u8
metadata: option::Option<coin::CoinMetadata<T>>
from_info
Create a new coin info from the given name, symbol and decimals.
public fun from_info<T>(name: string::String, symbol: ascii::String, decimals: u8): coin_info::CoinInfo<T>
public fun from_info<T>(
name: String,
symbol: ascii::String,
decimals: u8,
): CoinInfo<T> {
CoinInfo {
name,
symbol,
decimals,
metadata: option::none(),
}
}
from_metadata
Create a new coin info from the given CoinMetadata
object.
public fun from_metadata<T>(metadata: coin::CoinMetadata<T>): coin_info::CoinInfo<T>
public fun from_metadata<T>(metadata: CoinMetadata<T>): CoinInfo<T> {
CoinInfo {
name: metadata.get_name(),
symbol: metadata.get_symbol(),
decimals: metadata.get_decimals(),
metadata: option::some(metadata),
}
}
name
public fun name<T>(self: &coin_info::CoinInfo<T>): string::String
symbol
public fun symbol<T>(self: &coin_info::CoinInfo<T>): ascii::String
public fun symbol<T>(self: &CoinInfo<T>): ascii::String {
self.symbol
}
decimals
public fun decimals<T>(self: &coin_info::CoinInfo<T>): u8
metadata
public fun metadata<T>(self: &coin_info::CoinInfo<T>): &option::Option<coin::CoinMetadata<T>>