Function sway_libs::asset::base::_set_symbol
pub fn _set_symbol(
symbol_key: StorageKey<StorageMap<AssetId, StorageString>>,
asset: AssetId,
symbol: String,
)
Expand description
Unconditionally sets the symbol of an asset.
Additional Information
NOTE: This does not check whether the asset id provided is valid or already exists.
Arguments
symbol_key
: [StorageKey<StorageMap<AssetId, StorageKey>>] - The location in storage which theStorageMap
that stores the symbols of assets is stored.asset
: [AssetId] - The asset of which to set the symbol.symbol
: [String] - The symbol of the asset.
Reverts
- When passing an empty string.
Number of Storage Accesses
- Writes:
2
Examples
use sway_libs::asset::base::{_set_symbol, _symbol};
use std::string::String;
storage {
symbol: StorageMap<AssetId, StorageString> = StorageMap {},
}
fn foo(asset: AssetId) {
let symbol = String::from_ascii_str("ETH");
_set_symbol(storage.symbol, asset, symbol);
assert(_symbol(storage.symbol, asset).unwrap() == symbol);
}