use miden_protocol::account::StorageSlotName;
use miden_protocol::errors::{AccountError, TokenSymbolError};
use thiserror::Error;
use crate::account::access::Ownable2StepError;
use crate::utils::FixedWidthStringError;
mod fungible;
mod non_fungible;
mod token_metadata;
pub use fungible::{
FungibleFaucet,
FungibleFaucetBuilder,
create_guarded_user_fungible_faucet,
create_multisig_user_fungible_faucet,
create_network_fungible_faucet,
create_singlesig_user_fungible_faucet,
};
pub use non_fungible::{
AssetStatus,
NonFungibleFaucet,
NonFungibleFaucetBuilder,
create_network_non_fungible_faucet,
create_user_non_fungible_faucet,
};
pub use token_metadata::{Description, ExternalLink, LogoURI, TokenMetadata, TokenName};
#[derive(Debug, Error)]
pub enum TokenMetadataError {
#[error("failed to retrieve storage slot with name {slot_name}")]
StorageLookupFailed {
slot_name: StorageSlotName,
source: AccountError,
},
#[error("invalid string data in field '{field}'")]
InvalidStringField {
field: &'static str,
#[source]
source: FixedWidthStringError,
},
#[error("mutability flag at index {index} has invalid value {value}: must be 0 or 1")]
InvalidMutabilityFlag { index: usize, value: u64 },
#[error("storage slot name mismatch: expected {expected}, got {actual}")]
SlotNameMismatch {
expected: StorageSlotName,
actual: StorageSlotName,
},
#[error("invalid token symbol")]
InvalidTokenSymbol(#[source] TokenSymbolError),
}
#[derive(Debug, Error)]
pub enum FungibleFaucetError {
#[error("faucet metadata decimals is {actual} which exceeds max value of {max}")]
TooManyDecimals { actual: u64, max: u8 },
#[error("faucet metadata max supply is {actual} which exceeds max value of {max}")]
MaxSupplyTooLarge { actual: u64, max: u64 },
#[error("token supply {token_supply} exceeds max_supply {max_supply}")]
TokenSupplyExceedsMaxSupply { token_supply: u64, max_supply: u64 },
#[error(
"account interface does not have the procedures of the basic fungible faucet component"
)]
MissingFungibleFaucetInterface,
#[error("account creation failed")]
AccountError(#[source] AccountError),
#[error("account is not a fungible faucet account")]
NotAFungibleFaucetAccount,
#[error("failed to read ownership data from storage")]
OwnershipError(#[source] Ownable2StepError),
#[error(transparent)]
TokenMetadata(#[from] TokenMetadataError),
}
#[derive(Debug, Error)]
pub enum NonFungibleFaucetError {
#[error("account creation failed")]
AccountCreationFailed(#[source] AccountError),
#[error("account is not a non-fungible faucet account")]
NotANonFungibleFaucetAccount,
#[error("asset status registry holds invalid status code {status}: must be 0, 1 or 2")]
InvalidAssetStatus { status: u64 },
#[error(transparent)]
TokenMetadata(#[from] TokenMetadataError),
}