Module 0x14066b3e527b0b87a6216b7cf1379f1f828de5e0aceea9b4a0b9a421945a933::mock_underlying_token_factory
@title Mock Underlying Token Factory @author Aave @notice Provides functionality to create and manage fungible assets for testing
- Resource
ManagedFungibleAsset
- Resource
CoinList
- Constants
- Function
create_token
- Function
mint
- Function
transfer_from
- Function
burn
- Function
assert_token_exists
- Function
get_metadata_by_symbol
- Function
get_token_account_address
- Function
supply
- Function
maximum
- Function
name
- Function
symbol
- Function
decimals
- Function
balance_of
- Function
token_address
use 0x1::error;
use 0x1::fungible_asset;
use 0x1::object;
use 0x1::option;
use 0x1::primary_fungible_store;
use 0x1::signer;
use 0x1::smart_table;
use 0x1::string;
Resource ManagedFungibleAsset
@notice Hold refs to control the minting, transfer and burning of fungible assets
#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
struct ManagedFungibleAsset has key
Resource CoinList
@notice Mapping of token addresses to existence flags
struct CoinList has key
Constants
@notice Only fungible asset metadata owner can make changes
const ENOT_OWNER: u64 = 1;
@notice Account does not exist
const E_ACCOUNT_NOT_EXISTS: u64 = 3;
@notice Token with this address already exists
const E_TOKEN_ALREADY_EXISTS: u64 = 2;
Function create_token
@notice Creates a new underlying token @param signer The signer of the transaction @param maximum_supply Maximum supply for the token (0 for unlimited) @param name The name of the underlying token @param symbol The symbol of the underlying token @param decimals The decimals of the underlying token @param icon_uri The icon URI of the underlying token @param project_uri The project URI of the underlying token
public entry fun create_token(signer: &signer, maximum_supply: u128, name: string::String, symbol: string::String, decimals: u8, icon_uri: string::String, project_uri: string::String)
Function mint
@notice Mints tokens as the owner of metadata object @param admin Admin signer with minting permission @param to Address to receive the minted tokens @param amount Amount of tokens to mint @param metadata_address Address of the token metadata
public entry fun mint(admin: &signer, to: address, amount: u64, metadata_address: address)
Function transfer_from
@notice Transfers tokens from one address to another @param from Source address @param to Destination address @param amount Amount of tokens to transfer @param metadata_address Address of the token metadata
public fun transfer_from(from: address, to: address, amount: u64, metadata_address: address)
Function burn
@notice Burns fungible assets as the owner of metadata object @param from Address to burn tokens from @param amount Amount of tokens to burn @param metadata_address Address of the token metadata
public fun burn(from: address, amount: u64, metadata_address: address)
Function assert_token_exists
@notice Verifies that a token exists @param token_metadata_address Address of the token metadata
public fun assert_token_exists(token_metadata_address: address)
Function get_metadata_by_symbol
@notice Gets the metadata object by symbol @param symbol Token symbol @return The metadata object
#[view]
public fun get_metadata_by_symbol(symbol: string::String): object::Object<fungible_asset::Metadata>
Function get_token_account_address
@notice Gets the token account address @return The token account address
#[view]
public fun get_token_account_address(): address
Function supply
@notice Gets the current supply from the metadata object @param metadata_address Address of the token metadata @return The current supply, or none if unlimited
#[view]
public fun supply(metadata_address: address): option::Option<u128>
Function maximum
@notice Gets the maximum supply from the metadata object @param metadata_address Address of the token metadata @return The maximum supply, or none if unlimited
#[view]
public fun maximum(metadata_address: address): option::Option<u128>
Function name
@notice Gets the name of the fungible asset from the metadata object @param metadata_address Address of the token metadata @return The token name
#[view]
public fun name(metadata_address: address): string::String
Function symbol
@notice Gets the symbol of the fungible asset from the metadata object @param metadata_address Address of the token metadata @return The token symbol
#[view]
public fun symbol(metadata_address: address): string::String
Function decimals
@notice Gets the decimals from the metadata object @param metadata_address Address of the token metadata @return The token decimals
#[view]
public fun decimals(metadata_address: address): u8
Function balance_of
@notice Gets the balance of a given store @param owner Address of the account to check @param metadata_address Address of the token metadata @return The token balance
#[view]
public fun balance_of(owner: address, metadata_address: address): u64
Function token_address
@notice Gets the token address from its symbol @param symbol Token symbol @return The token address
#[view]
public fun token_address(symbol: string::String): address