Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions contracts/bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,91 @@ mod bridge {
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum Error {
/// Caller is not authorized
Unauthorized,
/// Token does not exist
TokenNotFound,
/// Invalid chain ID
InvalidChain,
/// Bridge not supported for this token
BridgeNotSupported,
/// Insufficient signatures collected
InsufficientSignatures,
/// Bridge request has expired
RequestExpired,
/// Already signed this request
AlreadySigned,
/// Invalid bridge request
InvalidRequest,
/// Bridge operations are paused
BridgePaused,
/// Invalid metadata
InvalidMetadata,
/// Duplicate bridge request
DuplicateRequest,
/// Gas limit exceeded
GasLimitExceeded,
}

impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Error::Unauthorized => write!(f, "Caller is not authorized"),
Error::TokenNotFound => write!(f, "Token does not exist"),
Error::InvalidChain => write!(f, "Invalid chain ID"),
Error::BridgeNotSupported => write!(f, "Bridge not supported for this token"),
Error::InsufficientSignatures => write!(f, "Insufficient signatures collected"),
Error::RequestExpired => write!(f, "Bridge request has expired"),
Error::AlreadySigned => write!(f, "Already signed this request"),
Error::InvalidRequest => write!(f, "Invalid bridge request"),
Error::BridgePaused => write!(f, "Bridge operations are paused"),
Error::InvalidMetadata => write!(f, "Invalid metadata"),
Error::DuplicateRequest => write!(f, "Duplicate bridge request"),
Error::GasLimitExceeded => write!(f, "Gas limit exceeded"),
}
}
}

impl ContractError for Error {
fn error_code(&self) -> u32 {
match self {
Error::Unauthorized => bridge_codes::BRIDGE_UNAUTHORIZED,
Error::TokenNotFound => bridge_codes::BRIDGE_TOKEN_NOT_FOUND,
Error::InvalidChain => bridge_codes::BRIDGE_INVALID_CHAIN,
Error::BridgeNotSupported => bridge_codes::BRIDGE_NOT_SUPPORTED,
Error::InsufficientSignatures => bridge_codes::BRIDGE_INSUFFICIENT_SIGNATURES,
Error::RequestExpired => bridge_codes::BRIDGE_REQUEST_EXPIRED,
Error::AlreadySigned => bridge_codes::BRIDGE_ALREADY_SIGNED,
Error::InvalidRequest => bridge_codes::BRIDGE_INVALID_REQUEST,
Error::BridgePaused => bridge_codes::BRIDGE_PAUSED,
Error::InvalidMetadata => bridge_codes::BRIDGE_INVALID_METADATA,
Error::DuplicateRequest => bridge_codes::BRIDGE_DUPLICATE_REQUEST,
Error::GasLimitExceeded => bridge_codes::BRIDGE_GAS_LIMIT_EXCEEDED,
}
}

fn error_description(&self) -> &'static str {
match self {
Error::Unauthorized => "Caller does not have permission to perform this operation",
Error::TokenNotFound => "The specified token does not exist",
Error::InvalidChain => "The destination chain ID is invalid",
Error::BridgeNotSupported => "Cross-chain bridging is not supported for this token",
Error::InsufficientSignatures => "Not enough signatures collected for bridge operation",
Error::RequestExpired => "The bridge request has expired and can no longer be executed",
Error::AlreadySigned => "You have already signed this bridge request",
Error::InvalidRequest => "The bridge request is invalid or malformed",
Error::BridgePaused => "Bridge operations are temporarily paused",
Error::InvalidMetadata => "The token metadata is invalid",
Error::DuplicateRequest => "A bridge request with these parameters already exists",
Error::GasLimitExceeded => "The operation exceeded the gas limit",
}
}

fn error_category(&self) -> ErrorCategory {
ErrorCategory::Bridge
}
}

/// Bridge contract for cross-chain property token transfers
#[ink(storage)]
pub struct PropertyBridge {
Expand Down
68 changes: 68 additions & 0 deletions contracts/compliance_registry/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![cfg_attr(not(feature = "std"), no_std, no_main)]

use propchain_traits::ComplianceChecker;
use propchain_traits::*;

#[ink::contract]
mod compliance_registry {
Expand Down Expand Up @@ -244,19 +245,86 @@ mod compliance_registry {
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum Error {
/// Caller is not authorized
NotAuthorized,
/// User is not verified
NotVerified,
/// Verification has expired
VerificationExpired,
/// User has high risk level
HighRisk,
/// Jurisdiction is prohibited
ProhibitedJurisdiction,
/// User already verified
AlreadyVerified,
/// Consent not given
ConsentNotGiven,
/// Data retention period expired
DataRetentionExpired,
/// Invalid risk score
InvalidRiskScore,
/// Invalid document type
InvalidDocumentType,
/// Jurisdiction not supported
JurisdictionNotSupported,
}

impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Error::NotAuthorized => write!(f, "Caller is not authorized"),
Error::NotVerified => write!(f, "User is not verified"),
Error::VerificationExpired => write!(f, "Verification has expired"),
Error::HighRisk => write!(f, "User has high risk level"),
Error::ProhibitedJurisdiction => write!(f, "Jurisdiction is prohibited"),
Error::AlreadyVerified => write!(f, "User already verified"),
Error::ConsentNotGiven => write!(f, "Consent not given"),
Error::DataRetentionExpired => write!(f, "Data retention period expired"),
Error::InvalidRiskScore => write!(f, "Invalid risk score"),
Error::InvalidDocumentType => write!(f, "Invalid document type"),
Error::JurisdictionNotSupported => write!(f, "Jurisdiction not supported"),
}
}
}

impl ContractError for Error {
fn error_code(&self) -> u32 {
match self {
Error::NotAuthorized => propchain_traits::errors::compliance_codes::COMPLIANCE_UNAUTHORIZED,
Error::NotVerified => propchain_traits::errors::compliance_codes::COMPLIANCE_NOT_VERIFIED,
Error::VerificationExpired => propchain_traits::errors::compliance_codes::COMPLIANCE_EXPIRED,
Error::HighRisk => propchain_traits::errors::compliance_codes::COMPLIANCE_CHECK_FAILED,
Error::ProhibitedJurisdiction => propchain_traits::errors::compliance_codes::COMPLIANCE_CHECK_FAILED,
Error::AlreadyVerified => propchain_traits::errors::compliance_codes::COMPLIANCE_UNAUTHORIZED,
Error::ConsentNotGiven => propchain_traits::errors::compliance_codes::COMPLIANCE_NOT_VERIFIED,
Error::DataRetentionExpired => propchain_traits::errors::compliance_codes::COMPLIANCE_EXPIRED,
Error::InvalidRiskScore => propchain_traits::errors::compliance_codes::COMPLIANCE_CHECK_FAILED,
Error::InvalidDocumentType => propchain_traits::errors::compliance_codes::COMPLIANCE_DOCUMENT_MISSING,
Error::JurisdictionNotSupported => propchain_traits::errors::compliance_codes::COMPLIANCE_CHECK_FAILED,
}
}

fn error_description(&self) -> &'static str {
match self {
Error::NotAuthorized => "Caller does not have permission to perform this operation",
Error::NotVerified => "The user has not completed verification",
Error::VerificationExpired => "The user's verification has expired and needs renewal",
Error::HighRisk => "The user has been assessed as high risk",
Error::ProhibitedJurisdiction => "The user's jurisdiction is prohibited",
Error::AlreadyVerified => "The user is already verified",
Error::ConsentNotGiven => "The user has not provided required consent",
Error::DataRetentionExpired => "The data retention period has expired",
Error::InvalidRiskScore => "The risk score is invalid or out of range",
Error::InvalidDocumentType => "The document type is invalid or not supported",
Error::JurisdictionNotSupported => "The jurisdiction is not supported",
}
}

fn error_category(&self) -> ErrorCategory {
ErrorCategory::Compliance
}
}

pub type Result<T> = core::result::Result<T, Error>;

/// Events
Expand Down
76 changes: 76 additions & 0 deletions contracts/escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use ink::storage::Mapping;
#[cfg(not(feature = "std"))]
use scale_info::prelude::{string::String, vec::Vec};
use propchain_traits::*;

pub mod tests;

Expand All @@ -16,21 +17,96 @@ mod propchain_escrow {
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum Error {
/// Escrow does not exist
EscrowNotFound,
/// Caller is not authorized
Unauthorized,
/// Invalid escrow status for operation
InvalidStatus,
/// Insufficient funds in escrow
InsufficientFunds,
/// Required conditions not met
ConditionsNotMet,
/// Signature threshold not reached
SignatureThresholdNotMet,
/// Already signed this request
AlreadySigned,
/// Document does not exist
DocumentNotFound,
/// Dispute is currently active
DisputeActive,
/// Time lock period still active
TimeLockActive,
/// Invalid configuration parameters
InvalidConfiguration,
/// Escrow already funded
EscrowAlreadyFunded,
/// Participant not found
ParticipantNotFound,
}

impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Error::EscrowNotFound => write!(f, "Escrow does not exist"),
Error::Unauthorized => write!(f, "Caller is not authorized"),
Error::InvalidStatus => write!(f, "Invalid escrow status for operation"),
Error::InsufficientFunds => write!(f, "Insufficient funds in escrow"),
Error::ConditionsNotMet => write!(f, "Required conditions not met"),
Error::SignatureThresholdNotMet => write!(f, "Signature threshold not reached"),
Error::AlreadySigned => write!(f, "Already signed this request"),
Error::DocumentNotFound => write!(f, "Document does not exist"),
Error::DisputeActive => write!(f, "Dispute is currently active"),
Error::TimeLockActive => write!(f, "Time lock period still active"),
Error::InvalidConfiguration => write!(f, "Invalid configuration parameters"),
Error::EscrowAlreadyFunded => write!(f, "Escrow already funded"),
Error::ParticipantNotFound => write!(f, "Participant not found"),
}
}
}

impl ContractError for Error {
fn error_code(&self) -> u32 {
match self {
Error::EscrowNotFound => propchain_traits::errors::escrow_codes::ESCROW_NOT_FOUND,
Error::Unauthorized => propchain_traits::errors::escrow_codes::UNAUTHORIZED_ACCESS,
Error::InvalidStatus => propchain_traits::errors::escrow_codes::INVALID_STATUS,
Error::InsufficientFunds => propchain_traits::errors::escrow_codes::INSUFFICIENT_ESCROW_FUNDS,
Error::ConditionsNotMet => propchain_traits::errors::escrow_codes::CONDITIONS_NOT_MET,
Error::SignatureThresholdNotMet => propchain_traits::errors::escrow_codes::SIGNATURE_THRESHOLD_NOT_MET,
Error::AlreadySigned => propchain_traits::errors::escrow_codes::ALREADY_SIGNED_ESCROW,
Error::DocumentNotFound => propchain_traits::errors::escrow_codes::DOCUMENT_NOT_FOUND,
Error::DisputeActive => propchain_traits::errors::escrow_codes::DISPUTE_ACTIVE,
Error::TimeLockActive => propchain_traits::errors::escrow_codes::TIME_LOCK_ACTIVE,
Error::InvalidConfiguration => propchain_traits::errors::escrow_codes::INVALID_CONFIGURATION,
Error::EscrowAlreadyFunded => propchain_traits::errors::escrow_codes::ESCROW_ALREADY_FUNDED,
Error::ParticipantNotFound => propchain_traits::errors::escrow_codes::PARTICIPANT_NOT_FOUND,
}
}

fn error_description(&self) -> &'static str {
match self {
Error::EscrowNotFound => "The specified escrow does not exist",
Error::Unauthorized => "Caller does not have permission to perform this operation",
Error::InvalidStatus => "The escrow is not in the required state for this operation",
Error::InsufficientFunds => "The escrow does not have sufficient funds",
Error::ConditionsNotMet => "Not all required conditions have been met",
Error::SignatureThresholdNotMet => "Insufficient signatures collected",
Error::AlreadySigned => "You have already signed this request",
Error::DocumentNotFound => "The requested document does not exist",
Error::DisputeActive => "A dispute is currently active on this escrow",
Error::TimeLockActive => "The time lock period has not yet expired",
Error::InvalidConfiguration => "The escrow configuration is invalid",
Error::EscrowAlreadyFunded => "This escrow has already been funded",
Error::ParticipantNotFound => "The specified participant is not in the escrow",
}
}

fn error_category(&self) -> ErrorCategory {
ErrorCategory::Escrow
}
}

/// Escrow status enumeration
#[derive(Debug, Clone, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
Expand Down
56 changes: 56 additions & 0 deletions contracts/fees/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use ink::prelude::vec::Vec;
use ink::storage::Mapping;
use propchain_traits::DynamicFeeProvider;
use propchain_traits::FeeOperation;
use propchain_traits::*;

/// Dynamic Fee and Market Mechanism contract for PropChain.
/// Implements congestion-based fees, premium listing auctions, validator incentives,
Expand Down Expand Up @@ -144,16 +145,71 @@ mod propchain_fees {
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum FeeError {
/// Caller is not authorized
Unauthorized,
/// Auction does not exist
AuctionNotFound,
/// Auction has ended
AuctionEnded,
/// Auction has not ended yet
AuctionNotEnded,
/// Bid amount is too low
BidTooLow,
/// Auction already settled
AlreadySettled,
/// Invalid configuration
InvalidConfig,
/// Invalid property ID
InvalidProperty,
}

impl core::fmt::Display for FeeError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
FeeError::Unauthorized => write!(f, "Caller is not authorized"),
FeeError::AuctionNotFound => write!(f, "Auction does not exist"),
FeeError::AuctionEnded => write!(f, "Auction has ended"),
FeeError::AuctionNotEnded => write!(f, "Auction has not ended yet"),
FeeError::BidTooLow => write!(f, "Bid amount is too low"),
FeeError::AlreadySettled => write!(f, "Auction already settled"),
FeeError::InvalidConfig => write!(f, "Invalid configuration"),
FeeError::InvalidProperty => write!(f, "Invalid property ID"),
}
}
}

impl ContractError for FeeError {
fn error_code(&self) -> u32 {
match self {
FeeError::Unauthorized => propchain_traits::errors::fee_codes::FEE_UNAUTHORIZED,
FeeError::AuctionNotFound => propchain_traits::errors::fee_codes::FEE_AUCTION_NOT_FOUND,
FeeError::AuctionEnded => propchain_traits::errors::fee_codes::FEE_AUCTION_ENDED,
FeeError::AuctionNotEnded => propchain_traits::errors::fee_codes::FEE_AUCTION_NOT_ENDED,
FeeError::BidTooLow => propchain_traits::errors::fee_codes::FEE_BID_TOO_LOW,
FeeError::AlreadySettled => propchain_traits::errors::fee_codes::FEE_ALREADY_SETTLED,
FeeError::InvalidConfig => propchain_traits::errors::fee_codes::FEE_INVALID_CONFIG,
FeeError::InvalidProperty => propchain_traits::errors::fee_codes::FEE_INVALID_PROPERTY,
}
}

fn error_description(&self) -> &'static str {
match self {
FeeError::Unauthorized => "Caller does not have permission to perform this operation",
FeeError::AuctionNotFound => "The specified auction does not exist",
FeeError::AuctionEnded => "This auction has already ended",
FeeError::AuctionNotEnded => "The auction is still active and has not ended",
FeeError::BidTooLow => "The bid amount is below the minimum required",
FeeError::AlreadySettled => "This auction has already been settled",
FeeError::InvalidConfig => "The fee configuration is invalid",
FeeError::InvalidProperty => "The property ID is invalid or does not exist",
}
}

fn error_category(&self) -> ErrorCategory {
ErrorCategory::Fees
}
}

#[ink(storage)]
pub struct FeeManager {
admin: AccountId,
Expand Down
Loading
Loading