use super::{
AccessControlError,
OwnableError,
PausableError,
ReentrancyGuardError,
};
use ink_prelude::string::String;
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum PSP1155Error {
Custom(String),
InsufficientBalance,
TransferToZeroAddress,
NotAllowed,
SafeTransferCheckFailed(String),
}
impl From<OwnableError> for PSP1155Error {
fn from(ownable: OwnableError) -> Self {
match ownable {
OwnableError::CallerIsNotOwner => PSP1155Error::Custom(String::from("O::CallerIsNotOwner")),
OwnableError::NewOwnerIsZero => PSP1155Error::Custom(String::from("O::NewOwnerIsZero")),
}
}
}
impl From<AccessControlError> for PSP1155Error {
fn from(access: AccessControlError) -> Self {
match access {
AccessControlError::MissingRole => PSP1155Error::Custom(String::from("AC::MissingRole")),
AccessControlError::RoleRedundant => PSP1155Error::Custom(String::from("AC::RoleRedundant")),
AccessControlError::InvalidCaller => PSP1155Error::Custom(String::from("AC::InvalidCaller")),
}
}
}
impl From<PausableError> for PSP1155Error {
fn from(pausable: PausableError) -> Self {
match pausable {
PausableError::Paused => PSP1155Error::Custom(String::from("P::Paused")),
PausableError::NotPaused => PSP1155Error::Custom(String::from("P::NotPaused")),
}
}
}
impl From<ReentrancyGuardError> for PSP1155Error {
fn from(guard: ReentrancyGuardError) -> Self {
match guard {
ReentrancyGuardError::ReentrantCall => PSP1155Error::Custom(String::from("RG::ReentrantCall")),
}
}
}
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum PSP1155ReceiverError {
TransferRejected(String),
}
impl From<PSP1155ReceiverError> for PSP1155Error {
fn from(error: PSP1155ReceiverError) -> Self {
match error {
PSP1155ReceiverError::TransferRejected(message) => PSP1155Error::SafeTransferCheckFailed(message),
}
}
}