radix_engine/blueprints/resource/
vault_common.rs

1use crate::blueprints::resource::*;
2use crate::errors::{ApplicationError, RuntimeError};
3use crate::internal_prelude::*;
4use radix_engine_interface::blueprints::resource::*;
5use radix_engine_interface::types::*;
6
7#[derive(Debug, Clone, PartialEq, Eq, ScryptoSbor)]
8pub enum VaultError {
9    ResourceError(ResourceError),
10    ProofError(ProofError),
11    InvalidAmount(Decimal),
12    NotFreezable,
13    NotRecallable,
14    VaultIsFrozen,
15    LockFeeNotRadixToken,
16    LockFeeInsufficientBalance { requested: Decimal, actual: Decimal },
17    DecimalOverflow,
18}
19
20impl From<VaultError> for RuntimeError {
21    fn from(error: VaultError) -> Self {
22        RuntimeError::ApplicationError(ApplicationError::VaultError(error))
23    }
24}
25
26pub struct VaultUtil;
27
28impl VaultUtil {
29    pub fn is_vault_blueprint(blueprint: &BlueprintId) -> bool {
30        blueprint.package_address.eq(&RESOURCE_PACKAGE)
31            && (blueprint.blueprint_name.eq(NON_FUNGIBLE_VAULT_BLUEPRINT)
32                || blueprint.blueprint_name.eq(FUNGIBLE_VAULT_BLUEPRINT))
33    }
34}