diff --git a/.DS_Store b/.DS_Store index c6dc4e16..38922d8e 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/land_registry/Scarb.lock b/land_registry/Scarb.lock index 366a208a..e8e9e5ee 100644 --- a/land_registry/Scarb.lock +++ b/land_registry/Scarb.lock @@ -2,7 +2,7 @@ version = 1 [[package]] -name = "landver" +name = "land_registry" version = "0.1.0" dependencies = [ "openzeppelin", diff --git a/land_registry/Scarb.toml b/land_registry/Scarb.toml index 0dc3a489..db7c0782 100644 --- a/land_registry/Scarb.toml +++ b/land_registry/Scarb.toml @@ -1,9 +1,16 @@ [package] -name = "landver" +name = "land_registry" version = "0.1.0" -edition = "2024_07" +cairo-version = "2.8.2" # See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html + [dependencies] +starknet = ">=2.8.0" openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.17.0" } + +[dev-dependencies] +cairo_test = "2.8.0" + +[[target.starknet-contract]] diff --git a/land_registry/src/contracts/LandHolder.cairo b/land_registry/src/contracts/LandHolder.cairo deleted file mode 100644 index bf64416d..00000000 --- a/land_registry/src/contracts/LandHolder.cairo +++ /dev/null @@ -1,91 +0,0 @@ -#[starknet::contract] -mod LandHolder { - use super::{ILandHolder, LandRegistered, ContractAddress}; - use core::starknet::get_caller_address; - - #[storage] - struct Storage { - lands: LegacyMap, - owner_lands: LegacyMap>, - } - - #[constructor] - fn constructor(ref self: ContractState) {// Initialize any necessary state - } - - #[external(v0)] - impl LandHolderImpl of ILandHolder { - fn get_registered_land( - self: @ContractState, land_id: u256, document_hash: felt252 - ) -> Option { - let land = self.lands.read(land_id); - if land.document_hash == document_hash { - Option::Some(land) - } else { - Option::None - } - } - - fn get_all_registered_lands( - self: @ContractState, owner: ContractAddress - ) -> Array { - let mut result = ArrayTrait::new(); - let land_ids = self.owner_lands.read(owner); - let mut i = 0; - loop { - if i >= land_ids.len() { - break; - } - let land_id = *land_ids.at(i); - let land = self.lands.read(land_id); - result.append(land); - i += 1; - }; - result - } - - fn check_land_ownership( - self: @ContractState, land_id: u256, owner: ContractAddress - ) -> bool { - let land = self.lands.read(land_id); - land.owner == owner - } - - fn update_land_document( - ref self: ContractState, land_id: u256, new_document_hash: felt252 - ) { - let mut land = self.lands.read(land_id); - assert(land.owner == get_caller_address(), 'Only owner can update'); - land.document_hash = new_document_hash; - self.lands.write(land_id, land); - } - - fn remove_registered_land(ref self: ContractState, land_id: u256) { - let land = self.lands.read(land_id); - assert(land.owner == get_caller_address(), 'Only owner can remove'); - - // Remove from lands mapping - self - .lands - .write( - land_id, - LandRegistered { land_id: 0, owner: ContractAddress::from(0), document_hash: 0 } - ); - - // Remove from owner_lands array - let mut owner_lands = self.owner_lands.read(land.owner); - let mut i = 0; - loop { - if i >= owner_lands.len() { - break; - } - if *owner_lands.at(i) == land_id { - owner_lands.pop_front(); - break; - } - i += 1; - }; - self.owner_lands.write(land.owner, owner_lands); - } - } -} diff --git a/land_registry/src/contracts/LandInspector.cairo b/land_registry/src/contracts/LandInspector.cairo deleted file mode 100644 index 3fdce453..00000000 --- a/land_registry/src/contracts/LandInspector.cairo +++ /dev/null @@ -1,68 +0,0 @@ -#[starknet::contract] -mod LandInspector { - use super::{ILandInspector, LandDetails, ContractAddress, ArrayTrait}; - use core::starknet::get_caller_address; - - #[storage] - struct Storage { - land_registry: ContractAddress, - inspectors: LegacyMap, - pending_requests: Array, - land_details: LegacyMap, - request_status: LegacyMap, - } - - #[constructor] - fn constructor( - ref self: ContractState, land_registry: ContractAddress, initial_inspector: ContractAddress - ) { - self.land_registry.write(land_registry); - self.inspectors.write(initial_inspector, true); - } - - #[external(v0)] - impl LandInspectorImpl of super::ILandInspector { - fn receive_land_request(ref self: ContractState, land_id: u256) { - // Only land registry can submit requests - assert(get_caller_address() == self.land_registry.read(), 'Unauthorized'); - self.pending_requests.write(self.pending_requests.read() + 1); - self.request_status.write(land_id, 'pending'); - } - - fn view_land(self: @ContractState, land_id: u256) -> LandDetails { - assert(self.inspectors.read(get_caller_address()), 'Not an inspector'); - self.land_details.read(land_id) - } - - fn approve_land_request(ref self: ContractState, land_id: u256) { - assert(self.inspectors.read(get_caller_address()), 'Not an inspector'); - assert(self.request_status.read(land_id) == 'pending', 'Not pending'); - self.request_status.write(land_id, 'approved'); - self._remove_from_pending(land_id); - // TODO: Notify land registry of approval - } - - fn reject_land_request(ref self: ContractState, land_id: u256, reason: felt252) { - assert(self.inspectors.read(get_caller_address()), 'Not an inspector'); - assert(self.request_status.read(land_id) == 'pending', 'Not pending'); - self.request_status.write(land_id, 'rejected'); - // TODO: Store rejection reason - self._remove_from_pending(land_id); - // TODO: Notify land registry of rejection - } - - fn delete_land_request(ref self: ContractState, land_id: u256) { - assert(get_caller_address() == self.land_registry.read(), 'Unauthorized'); - self.request_status.write(land_id, 'deleted'); - self._remove_from_pending(land_id); - } - - fn get_pending_requests(self: @ContractState) -> Array { - self.pending_requests.read() - } - - fn is_inspector(self: @ContractState, address: ContractAddress) -> bool { - self.inspectors.read(address) - } - } -} diff --git a/land_registry/src/contracts/LandNFT.cairo b/land_registry/src/contracts/LandNFT.cairo deleted file mode 100644 index 6191adb7..00000000 --- a/land_registry/src/contracts/LandNFT.cairo +++ /dev/null @@ -1,103 +0,0 @@ -#[starknet::contract] -mod LandNFT { - use super::ContractAddress; - use super::ERC721; -use super::ModelNFT::{LandDetails, Event}; - use models::ModelNFT; - use openzeppelin::introspection::src5::SRC5Component; - use openzeppelin::token::erc721::{ERC721Component, ERC721HooksEmptyImpl}; - use starknet::ContractAddress; - - #[constructor] - fn constructor( - ref self: ContractState, name: felt252, symbol: felt252, land_registry: ContractAddress - ) { - self.erc721.initializer(name, symbol); - self.land_registry.write(land_registry); - } - - #[external(v0)] - fn mint_land( - ref self: ContractState, - to: ContractAddress, - token_id: u256, - location: felt252, - area: u256, - land_use: felt252, - ) { - assert(get_caller_address() == self.land_registry.read(), 'Only LandRegistry can mint'); - - self.erc721._mint(to, token_id); - - let land_details = LandDetails { - location: location, - area: area, - land_use: land_use, - is_verified: false, - document_hash: document_hash, - }; - self.land_details.write(token_id, land_details); - - self.emit(Event::LandMinted(LandMinted { token_id: token_id, owner: to })); - - - - let land_details = LandDetails { - - self - .emit( - Event::LandDetailsUpdated( - LandDetailsUpdated { - token_id: token_id, - location: location, - area: area, - land_use: land_use, - is_verified: false, - document_hash: document_hash, - } - ) - ); - } - - #[external(v0)] - fn update_land_details( - ref self: ContractState, - token_id: u256, - location: felt252, - area: u256, - land_use: felt252, - is_verified: bool, - document_hash: felt252 - ) { - assert(get_caller_address() == self.land_registry.read(), 'Only LandRegistry can update'); - - let land_details = LandDetails { - location: location, - area: area, - land_use: land_use, - is_verified: is_verified, - document_hash: document_hash, - }; - self.land_details.write(token_id, land_details); - - self - .emit( - Event::LandDetailsUpdated( - LandDetailsUpdated { - token_id: token_id, - location: location, - area: area, - land_use: land_use, - is_verified: is_verified, - document_hash: document_hash, - } - ) - ); - } - - #[external(v0)] - fn get_land_details(self: @ContractState, token_id: u256) -> LandDetails { - self.land_details.read(token_id) - } - // Implement -} diff --git a/land_registry/src/contracts/LandRegistry.cairo b/land_registry/src/contracts/LandRegistry.cairo index 4081b4ef..221c5485 100644 --- a/land_registry/src/contracts/LandRegistry.cairo +++ b/land_registry/src/contracts/LandRegistry.cairo @@ -1,165 +1,133 @@ use core::starknet::ContractAddress; -use models::ModelLandRegistry; -#[starknet::contract] -pub mod LandRegistry { - use super::ContractAddress; - use super::ModelLandRegistry::{Land, Event}; - - #[constructor] - fn constructor(ref self: ContractState, land_nft: ContractAddress) { - self.land_nft.write(land_nft); - } - - #[external(v0)] +#[starknet::interface] +trait ILandRegistry { fn register_land( - ref self: ContractState, - land_id: u256, + ref self: TContractState, + owner: ContractAddress, location: felt252, area: u256, - land_use: felt252, - ) -> LandDetails { - let caller = get_caller_address(); - let new_land = Land { - owner: caller, - location: location, - area: area, - land_use: land_use, - is_registered: true, - is_verified: false, - last_transaction_timestamp: get_block_timestamp(), - }; - self.lands.write(land_id, new_land); - - let count = self.owner_land_count.read(caller); - self.owner_lands.write((caller, count), land_id); - self.owner_land_count.write(caller, count + 1); - - self - .emit( - Event::LandRegistered( - LandRegistered { - land_id: land_id, - owner: caller, - location: location, - area: area, - land_use: land_use, - } - ) - ); - - // Mint NFT - ILandNFT::mint_land( - self.land_nft.read(), caller, land_id, location, area, land_use, document_hash - ); - } - - #[external(v0)] - fn transfer_land(ref self: ContractState, land_id: u256, new_owner: ContractAddress) { - let caller = get_caller_address(); - let mut land = self.lands.read(land_id); - assert(land.owner == caller, 'Only the current owner can transfer the land'); - assert(land.is_registered, 'Land is not registered'); - land.owner = new_owner; - land.last_transaction_timestamp = get_block_timestamp(); - self.lands.write(land_id, land); - - // Update owner_lands and owner_land_count - let from_count = self.owner_land_count.read(caller); - let to_count = self.owner_land_count.read(new_owner); - self.owner_lands.write((new_owner, to_count), land_id); - self.owner_land_count.write(new_owner, to_count + 1); - self.owner_land_count.write(caller, from_count - 1); - - self - .emit( - Event::LandTransferred( - LandTransferred { land_id: land_id, from_owner: caller, to_owner: new_owner, } - ) - ); - - // Transfer NFT - ILandNFT::transferFrom(self.land_nft.read(), caller, new_owner, land_id); - } - - #[external(v0)] - fn get_land_details(self: @ContractState, land_id: u256) -> Land { - self.lands.read(land_id) - } + land_use: LandRegistry::LandUse, + ) -> u256; + fn transfer_land(ref self: TContractState, land_id: u256, new_owner: ContractAddress); + fn verify_land(ref self: TContractState, land_id: u256) -> LandRegistry::Land; + fn get_owner_lands(self: @TContractState, owner: ContractAddress) -> Array; + fn update_land(ref self: TContractState, owner: ContractAddress, land_id: u256) -> Land; +} - #[external(v0)] - fn get_owner_lands(self: @ContractState, owner: ContractAddress) -> Vec { - let mut lands = Vec::new(); - let count = self.owner_land_count.read(owner); - for i in 0..count { - let land_id = self.owner_lands.read((owner, i)); - lands.push(land_id); - } - lands +#[starknet::contract] +mod LandRegistry { + use super::ILandRegistry; + use core::array::ArrayTrait; + use core::starknet::{ContractAddress, get_caller_address, get_block_timestamp}; + use core::starknet::storage::{ + Map, StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess + }; + + #[storage] + struct Storage { + lands: Map, + owners: Map>, } - #[external(v0)] - fn get_land_count(self: @ContractState) -> u256 { - self.owner_land_count.read(get_caller_address()) + #[derive(Drop, Serde, starknet::Store)] + pub struct Land { + owner: ContractAddress, + location: felt252, + area: u256, + land_use: LandUse, + is_verified: bool, + last_transaction_timestamp: u64, } - #[external(v0)] - fn get_land_count_for_owner(self: @ContractState, owner: ContractAddress) -> u256 { - self.owner_land_count.read(owner) + enum LandUse { + Residential, + Commercial, + Industrial, + Recreational, + Agricultural, } - #[external(v0)] - fn get_land_owner(self: @ContractState, land_id: u256) -> ContractAddress { - self.lands.read(land_id).owner + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + LandRegistered: LandRegistered, + LandTransferred: LandTransferred, + LandVerified: LandVerified, } - #[external(v0)] - fn get_land_location(self: @ContractState, land_id: u256) -> felt252 { - self.lands.read(land_id).location + #[derive(Drop, starknet::Event)] + struct LandRegistered { + land_id: u256, + owner: ContractAddress, + location: felt252, + area: u256, + land_use: felt252, } - #[external(v0)] - fn get_land_area(self: @ContractState, land_id: u256) -> u256 { - self.lands.read(land_id).area + #[derive(Drop, starknet::Event)] + struct LandTransferred { + land_id: u256, + from_owner: ContractAddress, + to_owner: ContractAddress, } - #[external(v0)] - fn get_land_land_use(self: @ContractState, land_id: u256) -> felt252 { - self.lands.read(land_id).land_use + #[Contructor] + fn contructor(ref self: TContractSatate, deployer: ContractAddress) { + let deployer_address = get_caller_address(); + emit!(ContractDeployed { deployer: deployer_address, }); } - - #[external(v0)] - fn get_land_is_registered(self: @ContractState, land_id: u256) -> bool { - self.lands.read(land_id).is_registered + #[derive(Drop)] + struct Location { + latitude: f64, + longitude: f64, } - #[external(v0)] - fn get_land_is_verified(self: @ContractState, land_id: u256) -> bool { - self.lands.read(land_id).is_verified - } + #[abi(embed_v0)] + impl LandRegistryImpl of ILandRegistry { + fn register_land( + ref self: TContractState, + owner: OwnerAddress, + location: Location, + area: u256, + land_use: LandUse, + ) -> u256 { + //we will use the block time stamp as the landid for now. + let mut timestamp = get_block_timestamp(); + let land_id: u256 = timestamp.into(); + let new_land = Land { + owner: OwnerAddress, + location: location, + area: area, + land_use: LandUse, + landid: landid, + }; + + //store the land in the lands map.. + let result = self.lands.insert(land_id, new_land); + + // Add the land Id the list of owner lands by for an owner such that we can retrieve all + // the lands for a specific owner + let owner_lands = self.owner_lands.entry(owner).or_insert(Vec::new()); + + //Emit events for land registered. This will help use to track registered lands + + //How can we get owner lands? + + emit!( + LandRegistered { + land_id: u256, + owner: ContractAddress, + location: felt252, + area: u256, + land_use: felt252, + } + ); - #[external(v0)] - fn get_land_document_hash(self: @ContractState, land_id: u256) -> felt252 { - self.lands.read(land_id).document_hash - } + //finally return the landID + land_id - #[external(v0)] - fn get_land_last_transaction_timestamp(self: @ContractState, land_id: u256) -> u64 { - self.lands.read(land_id).last_transaction_timestamp + println!('You land has been succcessfully registered {:?}', result) + } } } -// #[starknet::interface] -// trait ILandNFT { -// fn mint_land( -// ref self: ContractState, -// to: ContractAddress, -// token_id: u256, -// location: felt252, -// area: u256, -// land_use: felt252, -// document_hash: felt252 -// ); -// fn transferFrom(ref self: ContractState, from: ContractAddress, to: ContractAddress, -// token_id: u256); -// } - diff --git a/land_registry/src/contracts/LandTransaction.cairo b/land_registry/src/contracts/LandTransaction.cairo deleted file mode 100644 index 170ff6b3..00000000 --- a/land_registry/src/contracts/LandTransaction.cairo +++ /dev/null @@ -1,119 +0,0 @@ -use core::starknet::ContractAddress; -use models::ModelLandTransaction; - -#[starknet::contract] -mod LandTransaction { - #[constructor] - fn constructor(ref self: ContractState, land_registry: ContractAddress) { - self.land_registry.write(land_registry); - } - - #[external(v0)] - fn create_transaction( - ref self: ContractState, - land_id: u256, - from_owner: ContractAddress, - to_owner: ContractAddress, - transaction_type: u8 - ) -> u256 { - assert( - get_caller_address() == self.land_registry.read(), - 'Only LandRegistry can create transactions' - ); - - let transaction_id = self.transaction_count.read() + 1; - self.transaction_count.write(transaction_id); - - let transaction = Transaction { - land_id: land_id, - from_owner: from_owner, - to_owner: to_owner, - transaction_type: transaction_type, - status: 0, // 0 for pending - initiation_date: get_block_timestamp(), - completion_date: 0, - }; - self.transactions.write(transaction_id, transaction); - - self - .emit( - Event::TransactionCreated( - TransactionCreated { - transaction_id: transaction_id, - land_id: land_id, - from_owner: from_owner, - to_owner: to_owner, - transaction_type: transaction_type, - } - ) - ); - - transaction_id - } - - #[external(v0)] - fn approve_transaction(ref self: ContractState, transaction_id: u256) { - let caller = get_caller_address(); - let mut transaction = self.transactions.read(transaction_id); - assert(transaction.to_owner == caller, 'Caller is not the transaction owner'); - assert(transaction.status == 0, 'Transaction is not pending'); - transaction.status = 1; // 1 for approved - transaction.completion_date = get_block_timestamp(); - self.transactions.write(transaction_id, transaction); - - // Call LandRegistry to transfer the land - ILandRegistry::transfer_land( - self.land_registry.read(), transaction.land_id, transaction.to_owner - ); - } - - #[external(v0)] - fn reject_transaction(self: @ContractState, transaction_id: u256) { - let caller = get_caller_address(); - let transaction = self.transactions.read(transaction_id); - assert(transaction.from_owner == caller, 'Caller is not the transaction owner'); - assert(transaction.status == 0, 'Transaction is not pending'); - transaction.status = 2; // 2 for rejected - self.transactions.write(transaction_id, transaction); - } - - #[external(v0)] - fn get_transaction_details(self: @ContractState, transaction_id: u256) -> Transaction { - return self.transactions.read(transaction_id); - } - - #[external(v0)] - fn get_transaction_status(self: @ContractState, transaction_id: u256) -> u8 { - return self.transactions.read(transaction_id).status; - } - - #[external(v0)] - fn get_transaction_initiation_date(self: @ContractState, transaction_id: u256) -> u64 { - return self.transactions.read(transaction_id).initiation_date; - } - - #[external(v0)] - fn get_transaction_completion_date(self: @ContractState, transaction_id: u256) -> u64 { - return self.transactions.read(transaction_id).completion_date; - } - - #[external(v0)] - fn get_transaction_type(self: @ContractState, transaction_id: u256) -> u8 { - return self.transactions.read(transaction_id).transaction_type; - } - - #[external(v0)] - fn get_transaction_from_owner(self: @ContractState, transaction_id: u256) -> ContractAddress { - return self.transactions.read(transaction_id).from_owner; - } - - #[external(v0)] - fn get_transaction_to_owner(self: @ContractState, transaction_id: u256) -> ContractAddress { - return self.transactions.read(transaction_id).to_owner; - } -} - -#[starknet::interface] -trait ILandRegistry { - fn transfer_land(ref self: ContractState, land_id: u256, new_owner: ContractAddress); -} diff --git a/land_registry/src/contracts/LandVerification.cairo b/land_registry/src/contracts/LandVerification.cairo deleted file mode 100644 index 611fef86..00000000 --- a/land_registry/src/contracts/LandVerification.cairo +++ /dev/null @@ -1,28 +0,0 @@ -#[starknet::contract] -mod LandVerification { - use core::starknet::get_caller_address; - use core::starknet::ContractAddress; - use super::LandRegistry; - use super::ILandRegistry; - - #[constructor] - fn constructor(ref self: ContractState, land_registry: ContractAddress) { - self.land_registry.write(land_registry); - } - - #[external(v0)] - fn add_verifier(ref self: ContractState, verifier: ContractAddress) { - // Only contract owner should be able to add verifiers - self.verifiers.write(verifier, true); - } - - #[external(v0)] - fn verify_land(ref self: ContractState, land_id: u256) { - let caller = get_caller_address(); - assert(self.verifiers.read(caller), 'Caller is not an authorized verifier'); - - ILandRegistry::verify_land(self.land_registry.read(), land_id, caller); - } - // Implement (reject_land_verification, get_land_verification_status, etc.) -} - diff --git a/land_registry/src/lib.cairo b/land_registry/src/lib.cairo index da6528f8..8b137891 100644 --- a/land_registry/src/lib.cairo +++ b/land_registry/src/lib.cairo @@ -1,12 +1 @@ -mod contracts { - mod LandNFT; - mod LandRegistry; - mod LandTransaction; - mod LandVerification; -} -mod models { - mod model_nft; - mod model_registry; - mod model_transaction; -} \ No newline at end of file diff --git a/land_registry/src/models/model_nft.cairo b/land_registry/src/models/model_nft.cairo deleted file mode 100644 index 054293b0..00000000 --- a/land_registry/src/models/model_nft.cairo +++ /dev/null @@ -1,44 +0,0 @@ -mod ModelNFT { - use openzeppelin::token::erc721::ERC721; - use openzeppelin::utils::legacy_map::LegacyMap; - use openzeppelin::utils::contract_address::ContractAddress; - use openzeppelin::utils::felt252::felt252; - use openzeppelin::utils::u256::u256; - use core::starknet::ContractAddress; - - #[storage] - struct Storage { - #[substorage(v0)] - erc721: ERC721::Storage, - land_details: LegacyMap, - land_registry: ContractAddress, - } - - #[derive(Copy, Drop, Serde, starknet::Store)] - struct LandDetails { - location: felt252, - area: u256, - land_use: felt252, - is_verified: bool, - document_hash: felt252, - } - - - - #[derive(Drop, starknet::Event)] - struct LandMinted { - token_id: u256, - owner: ContractAddress, - } - - #[derive(Drop, starknet::Event)] - struct LandDetailsUpdated { - token_id: u256, - location: felt252, - area: u256, - land_use: felt252, - is_verified: bool, - document_hash: felt252, - } -} - diff --git a/land_registry/src/models/model_registry.cairo b/land_registry/src/models/model_registry.cairo deleted file mode 100644 index b6a7c51e..00000000 --- a/land_registry/src/models/model_registry.cairo +++ /dev/null @@ -1,61 +0,0 @@ -mod ModelLandRegistry { - use core::starknet::get_caller_address; - use core::starknet::ContractAddress; - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - LandRegistered: LandRegistered, - LandTransferred: LandTransferred, - LandVerified: LandVerified, - } - - #[derive(Drop, starknet::Event)] - struct LandRegistered { - land_id: u256, - owner: ContractAddress, - location: felt252, - area: u256, - land_use: felt252, - } - - #[derive(Drop, starknet::Event)] - struct LandTransferred { - land_id: u256, - from_owner: ContractAddress, - to_owner: ContractAddress, - } - - #[derive(Drop, starknet::Event)] - struct LandVerified { - land_id: u256, - verifier: ContractAddress, - } - - #[derive(Drop, Serde, starknet::Store)] - struct Land { - owner: ContractAddress, - location: felt252, - area: u256, - land_use: felt252, - is_registered: bool, - is_verified: bool, - last_transaction_timestamp: u64, - } - - #[storage] - struct Storage { - lands: LegacyMap, - owner_lands: LegacyMap>, - owner_land_count: LegacyMap, - land_nft: ContractAddress, - } - - #[derive(Drop, Serde, starknet::Store)] - struct LandDetails { - owner: ContractAddress, - area: u256, - location: felt252, - status: felt252, - } -} diff --git a/land_registry/src/models/model_transaction.cairo b/land_registry/src/models/model_transaction.cairo deleted file mode 100644 index c8b314be..00000000 --- a/land_registry/src/models/model_transaction.cairo +++ /dev/null @@ -1,38 +0,0 @@ -mod ModelLandTransaction { - use core::starknet::get_caller_address; - use core::starknet::ContractAddress; - use super::LandRegistry; - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - TransactionCreated: TransactionCreated, - } - - #[derive(Drop, starknet::Event)] - struct TransactionCreated { - transaction_id: u256, - land_id: u256, - from_owner: ContractAddress, - to_owner: ContractAddress, - transaction_type: u8, - } - - #[derive(Storage)] - struct Transaction { - land_id: u256, - from_owner: ContractAddress, - to_owner: ContractAddress, - transaction_type: u8, - status: u8, - initiation_date: u64, - completion_date: u64, - } - - #[storage] - struct Storage { - transactions: LegacyMap, - transaction_count: u256, - land_registry: ContractAddress, - } -} diff --git a/land_registry/src/models/model_verification.cairo b/land_registry/src/models/model_verification.cairo deleted file mode 100644 index ba59a6bd..00000000 --- a/land_registry/src/models/model_verification.cairo +++ /dev/null @@ -1,8 +0,0 @@ - -mod ModelVerification { - #[storage] - struct Storage { - land_registry: ContractAddress, - verifiers: LegacyMap, - } -} diff --git a/land_registry/src/tests/test_land_registry.cairo b/land_registry/src/tests/test_land_registry.cairo new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/land_registry/src/tests/test_land_registry.cairo @@ -0,0 +1 @@ + diff --git a/land_registry/src/traits/ILandHolder.cairo b/land_registry/src/traits/ILandHolder.cairo deleted file mode 100644 index fd86dd12..00000000 --- a/land_registry/src/traits/ILandHolder.cairo +++ /dev/null @@ -1,16 +0,0 @@ -use core::starknet::ContractAddress; -#[starknet::interface] -pub trait ILandHolder { - fn get_registered_land( - self: @TContractState, land_id: u256, contract_address: ContractAddress - ) -> Option; - - - fn get_all_registered_lands( - self: @TContractState, owner_address: Address - ) -> Array; - - fn check_land_ownership(self: @TContractState, land_id: u256, contract_address: ContractAddress) -> bool; - fn update_land_document(ref self: TContractState, land_id: u256, contract_address: ContractAddress); - fn remove_registered_land(ref self: TContractState, land_id: u256, contract_address: ContractAddress); -} \ No newline at end of file diff --git a/land_registry/src/traits/ILandInspector.cairo b/land_registry/src/traits/ILandInspector.cairo deleted file mode 100644 index 6fa01d98..00000000 --- a/land_registry/src/traits/ILandInspector.cairo +++ /dev/null @@ -1,13 +0,0 @@ -use core::starknet::ContractAddress; - -#[starknet::interface] -trait ILandInspector { - fn receive_land_request(ref self: ContractState, land_id: u256); - fn view_land(self: @ContractState, land_id: u256) -> LandDetails; - fn approve_land_request(ref self: ContractState, land_id: u256); - fn reject_land_request(ref self: ContractState, land_id: u256, reason: felt252); - fn delete_land_request(ref self: TContractState, land_id: u256); - fn get_pending_requests(self: @ContractState) -> Array; - fn is_inspector(self: @ContractState, address: ContractAddress) -> bool; -} - diff --git a/land_registry/src/traits/ILandNFT.cairo b/land_registry/src/traits/ILandNFT.cairo deleted file mode 100644 index 65f52afa..00000000 --- a/land_registry/src/traits/ILandNFT.cairo +++ /dev/null @@ -1,31 +0,0 @@ -use core::starknet::ContractAddress; -use openzeppelin::token::erc721::ERC721; -use models::ModelNFT; -use openzeppelin::introspection::src5::SRC5Component; -use openzeppelin::token::erc721::{ERC721Component, ERC721HooksEmptyImpl}; - -#[starknet::interface] -trait ILandNFT { - fn mint_land( - ref self: ContractState, - to: ContractAddress, - token_id: u256, - location: felt252, - area: u256, - land_use: felt252, - document_hash: felt252 - ); - - fn update_land_details( - ref self: ContractState, - token_id: u256, - location: felt252, - area: u256, - land_use: felt252, - is_verified: bool, - document_hash: felt252 - ); - - fn get_land_details(self: @ContractState, token_id: u256) -> LandDetails; -} - diff --git a/land_registry/src/traits/ILandRegistry.cairo b/land_registry/src/traits/ILandRegistry.cairo deleted file mode 100644 index 49eaead5..00000000 --- a/land_registry/src/traits/ILandRegistry.cairo +++ /dev/null @@ -1,7 +0,0 @@ -use core::starknet::ContractAddress; -#[starknet::interface] -trait ILandRegistry { - fn verify_land(self: @TContractState, land_id: u256, verifier: ContractAddress); - fn register_land(ref self: TContractState, land_id: u256, owner: ContractAddress) -> LandDetails; - -} diff --git a/land_registry/src/traits/ILandTransaction.cairo b/land_registry/src/traits/ILandTransaction.cairo deleted file mode 100644 index e4d09d75..00000000 --- a/land_registry/src/traits/ILandTransaction.cairo +++ /dev/null @@ -1,10 +0,0 @@ -use core::starknet::ContractAddress; - -#[starknet::interface] -trait ILandInspector { - fn recive_land_request(ref self: ContractState, land_id: u256); - fn view_land(self: @ContractState, land_id: u256); - fn approve_land_request(ref self: ContractState, land_id: u256); - fn reject_land_request(ref self: ContractState, land_id: u256); - fn delete_land_request(ref self: ContractState, land_id: u256); -} diff --git a/land_registry/src/traits/ILandVerification.cairo b/land_registry/src/traits/ILandVerification.cairo deleted file mode 100644 index 0deb4a43..00000000 --- a/land_registry/src/traits/ILandVerification.cairo +++ /dev/null @@ -1,22 +0,0 @@ -use core::starknet::ContractAddress; -#[starknet::interface] -pub trait ILandVerifier { - // Function signature for land verification - fn verify_land(self: @ContractState, land_id: u256, verifier: ContractAddress); - - // Function signature for rejecting land verification - fn reject_land_verification(self: @ContractState, land_id: u256, verifier: ContractAddress); - - // Function signature for getting land verification status - fn get_land_verification_status(self: @ContractState, land_id: u256) -> bool; - - // Function signature for getting the land verifier address - fn get_land_verifier(self: @ContractState, land_id: u256) -> ContractAddress; - - // Function signature for getting land verification timestamp - fn get_land_verification_timestamp(self: @ContractState, land_id: u256) -> u64; - - // Function signature for getting the reason for land verification - fn get_land_verification_reason(self: @ContractState, land_id: u256) -> felt252; -} -