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