pub fn _name(
    name_key: StorageKey<StorageMap<AssetId, StorageString>>,
    asset: AssetId,
) -> Option<String> 
Expand description

Returns the name of the asset, such as “Ether”.

Arguments

  • name_key: [StorageKey<StorageMap<AssetId, StorageKey>>] - The location in storage which the StorageMap that stores the names of assets is stored.
  • asset: [AssetId] - The asset of which to query the name.

Returns

  • [Option] - The name of asset.

Number of Storage Accesses

  • Reads: 1

Examples

use sway_libs::asset::base::_name;
use std::string::String;

storage {
    name: StorageMap<AssetId, StorageString> = StorageMap {},
}

fn foo(asset: AssetId) {
    let name = _name(storage.name, asset);
    assert(name.unwrap_or(String::new()).len() != 0);
}