miden_standards/account/faucets/
mod.rs1use miden_protocol::account::StorageSlotName;
2use miden_protocol::errors::{AccountError, TokenSymbolError};
3use thiserror::Error;
4
5use crate::account::access::Ownable2StepError;
6use crate::utils::FixedWidthStringError;
7
8mod fungible;
9mod non_fungible;
10mod token_metadata;
11
12pub use fungible::{
13 FungibleFaucet,
14 FungibleFaucetBuilder,
15 create_guarded_user_fungible_faucet,
16 create_multisig_user_fungible_faucet,
17 create_native_fungible_faucet_for_genesis,
18 create_network_fungible_faucet,
19 create_singlesig_user_fungible_faucet,
20};
21pub use non_fungible::{
22 AssetStatus,
23 NonFungibleFaucet,
24 NonFungibleFaucetBuilder,
25 create_network_non_fungible_faucet,
26 create_user_non_fungible_faucet,
27};
28pub use token_metadata::{Description, ExternalLink, LogoURI, TokenMetadata, TokenName};
29
30#[derive(Debug, Error)]
35pub enum TokenMetadataError {
36 #[error("failed to retrieve storage slot with name {slot_name}")]
37 StorageLookupFailed {
38 slot_name: StorageSlotName,
39 source: AccountError,
40 },
41 #[error("invalid string data in field '{field}'")]
42 InvalidStringField {
43 field: &'static str,
44 #[source]
45 source: FixedWidthStringError,
46 },
47 #[error("mutability flag at index {index} has invalid value {value}: must be 0 or 1")]
48 InvalidMutabilityFlag { index: usize, value: u64 },
49 #[error("storage slot name mismatch: expected {expected}, got {actual}")]
50 SlotNameMismatch {
51 expected: StorageSlotName,
52 actual: StorageSlotName,
53 },
54 #[error("invalid token symbol")]
55 InvalidTokenSymbol(#[source] TokenSymbolError),
56}
57
58#[derive(Debug, Error)]
63pub enum FungibleFaucetError {
64 #[error("faucet metadata decimals is {actual} which exceeds max value of {max}")]
65 TooManyDecimals { actual: u64, max: u8 },
66 #[error("faucet metadata max supply is {actual} which exceeds max value of {max}")]
67 MaxSupplyTooLarge { actual: u64, max: u64 },
68 #[error("token supply {token_supply} exceeds max_supply {max_supply}")]
69 TokenSupplyExceedsMaxSupply { token_supply: u64, max_supply: u64 },
70 #[error(
71 "account interface does not have the procedures of the basic fungible faucet component"
72 )]
73 MissingFungibleFaucetInterface,
74 #[error("account creation failed")]
75 AccountError(#[source] AccountError),
76 #[error("account is not a fungible faucet account")]
77 NotAFungibleFaucetAccount,
78 #[error("failed to read ownership data from storage")]
79 OwnershipError(#[source] Ownable2StepError),
80 #[error(transparent)]
81 TokenMetadata(#[from] TokenMetadataError),
82}
83
84#[derive(Debug, Error)]
89pub enum NonFungibleFaucetError {
90 #[error("account creation failed")]
91 AccountCreationFailed(#[source] AccountError),
92 #[error("account is not a non-fungible faucet account")]
93 NotANonFungibleFaucetAccount,
94 #[error("asset status registry holds invalid status code {status}: must be 0, 1 or 2")]
95 InvalidAssetStatus { status: u64 },
96 #[error(transparent)]
97 TokenMetadata(#[from] TokenMetadataError),
98}