Skip to content

Commit

Permalink
Project file structuring
Browse files Browse the repository at this point in the history
  • Loading branch information
Akashneelesh committed May 25, 2024
1 parent c1305d5 commit 8d3ce53
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod allo;
pub mod registry;
pub mod libraries;
6 changes: 6 additions & 0 deletions src/core/allo.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,10 @@ pub mod Allo {
base_fee: u256
) {}
}

/// ====================================
/// ==== Internal Functions ============
/// ====================================
#[generate_trait]
impl AlloInternalImpl of AlloInternalTrait {}
}
2 changes: 2 additions & 0 deletions src/core/libraries.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod clone;
mod errors;
Empty file added src/core/libraries/clone.cairo
Empty file.
79 changes: 79 additions & 0 deletions src/core/libraries/errors.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
use starknet::{ContractAddress, contract_address_const};

mod Errors {
/// Throws as an general error when input / data is invalid.
const INVALID: felt252 = 'Data is invalid';
/// Thrown when mismatch in decoding data.
const MISMATCH: felt252 = 'Mismatch in decoding data';
/// Thrown when not enough funds are available
const NOT_ENOUGH_FUNDS: felt252 = 'Not enough funds available';
/// Thrown when user is not authorized
const UNAUTHORIZED: felt252 = 'Not authorized';
// // /// Thrown when address is the zero address
// const ZERO_ADDRESS : ContractAddress = contract_address_const::<'0'>();
/// Thrown when the function is not implemented
const NOT_IMPLEMENTED: felt252 = 'Not implemented';
/// Thrown when the value is non-zero
const NON_ZERO_VALUE: felt252 = 'Non Zero Value';

/// ======================
/// ====== Registry ======
/// ======================

/// Thrown when the nonce passed has been used or not available
const NONCE_NOT_AVAILABLE: felt252 = 'Nonce not available';
/// Thrown when the 'msg.sender' is not the pending owner on ownership transfer
const NOT_PENDING_OWNER: felt252 = 'Not pending owner';
/// Thrown if the anchor creation fails
const ANCHOR_ERROR: felt252 = 'Anchor error';


/// ======================
/// ======== Allo ========
/// ======================

/// Thrown when the strategy is not approved
const NOT_APPROVED_STRATEGY: felt252 = 'Not approved strategy';
/// Thrown when the strategy is approved and should be cloned
const IS_APPROVED_STRATEGY: felt252 = 'Is approved strategy';
/// Thrown when the fee is below 1e18 which is the fee percentage denominator
const INVALID_FEE: felt252 = 'Invalid fee';

/// ======================
/// ===== IStrategy ======
/// ======================

/// Thrown when data is already intialized
const ALREADY_INITIALIZED: felt252 = 'Already initialized';
/// Thrown when data is yet to be initialized
const NOT_INITIALIZED: felt252 = 'Not initialized';
/// Thrown when an invalid address is used
const INVALID_ADDRESS: felt252 = 'Invalid address';
/// Thrown when a pool is inactive
const POOL_INACTIVE: felt252 = 'Pool inactive';
/// Thrown when a pool is already active
const POOL_ACTIVE: felt252 = 'Pool active';
/// Thrown when two arrays length are not equal
const ARRAY_MISMATCH: felt252 = 'Array mismatch';
/// Thrown when the registration is invalid.
const INVALID_REGISTRATION: felt252 = 'Invalid registration';
/// Thrown when the metadata is invalid.
const INVALID_METADATA: felt252 = 'Invalid metadata';
/// Thrown when the recipient is not accepted.
const RECIPIENT_NOT_ACCEPTED: felt252 = 'Recipient not accepted';
/// Thrown when recipient is already accepted.
const RECIPIENT_ALREADY_ACCEPTED: felt252 = 'Recipient already accepted';
/// Thrown when registration is not active.
const REGISTRATION_NOT_ACTIVE: felt252 = 'Registration not active';
/// Thrown when registration is active.
const REGISTRATION_ACTIVE: felt252 = 'Registration active';
/// Thrown when there is an error in recipient.
const RECIPIENT_ERROR: felt252 = 'Recipient error';
/// Thrown when the allocation is not active.
const ALLOCATION_NOT_ACTIVE: felt252 = 'Allocation not active';
/// Thrown when the allocation is not ended.
const ALLOCATION_NOT_ENDED: felt252 = 'Allocation not ended';
/// Thrown when the allocation is active.
const ALLOCATION_ACTIVE: felt252 = 'Allocation active';

}
6 changes: 6 additions & 0 deletions src/core/registry.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ pub mod Registry {
/// ====================================
#[abi(embed_v0)]
impl Registry of super::IRegistry<ContractState> {}

/// ====================================
/// ==== Internal Functions ============
/// ====================================
#[generate_trait]
impl RegistryInternalImpl of RegistryInternalTrait {}
}

0 comments on commit 8d3ce53

Please sign in to comment.