From f58c90d5faefd01f17fbe8e3e3f0d994f13cb176 Mon Sep 17 00:00:00 2001 From: Fishon Amos Date: Mon, 14 Oct 2024 12:05:09 +0100 Subject: [PATCH] land approver --- land_registry/src/interface.cairo | 13 ++++++++++++- land_registry/src/land_register.cairo | 11 +++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/land_registry/src/interface.cairo b/land_registry/src/interface.cairo index cac74521..544eca5a 100644 --- a/land_registry/src/interface.cairo +++ b/land_registry/src/interface.cairo @@ -9,6 +9,14 @@ pub struct Land { last_transaction_timestamp: u64, } +struct LandApprovalDetails { + ApprovedBy: felt252, + Agency: felt252, + land: Land, + land_id: u256, + timestamp: u64, +} + #[derive(Drop, Copy, Clone, Serde, starknet::Store, PartialEq)] pub enum LandUse { Residential, @@ -33,10 +41,13 @@ pub trait ILandRegistry { fn register_land( ref self: TContractState, location: felt252, area: u256, land_use: LandUse, ) -> u256; - //fn transfer_land(ref self: TContractState, land_id: u256, new_owner: ContractAddress); + fn transfer_land(ref self: TContractState, land_id: u256, new_owner: ContractAddress); fn get_land(self: @TContractState, land_id: u256) -> Land; //fn get_owner_lands(self: @TContractState, owner_lands: ContractAddress) -> Array; //fn get_lands(self: @TContractState, owner: ContractAddress, location: felt252, land_use: //felt252) -> Array; + fn update_land(ref self: TContractState, land_id: u256, area: u256, land_use: LandUse); + // fn get_approved_lands +//fn approve_land } diff --git a/land_registry/src/land_register.cairo b/land_registry/src/land_register.cairo index 92f99c03..3c2cfe21 100644 --- a/land_registry/src/land_register.cairo +++ b/land_registry/src/land_register.cairo @@ -14,9 +14,11 @@ pub mod LandRegistryContract { } - //What are we storing + //lands - //lands, owners. + //What are we storing? + + //lands, owners? #[event] #[derive(Drop, starknet::Event)] @@ -97,5 +99,10 @@ pub mod LandRegistryContract { self.emit(LandUpdated { land_id: land_id, area: area, land_use: land_use.into(), }); } + + fn transfer_land(ref self: ContractState, land_id: u256, new_owner: ContractAddress) { + let land = self.lands.read(land_id); + self.lands.write(land_id, Land { owner: new_owner, ..land }); + } } }