Skip to content

Commit

Permalink
Merge pull request #49 from NoshonNetworks/registry
Browse files Browse the repository at this point in the history
some fixes
  • Loading branch information
fishonamos authored Oct 11, 2024
2 parents 18ee222 + 6a79de7 commit 413676a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions land_registry/src/contracts/LandRegistry.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ mod LandRegistry {
Map, StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess
};


//stores the lands and owners.
#[storage]
struct Storage {
lands: Map<u256, Land>,
owners: Map<ContractAddress, Array<u256>>,
}

//Land structure
#[derive(Drop, Serde, starknet::Store)]
pub struct Land {
owner: ContractAddress,
Expand All @@ -41,6 +44,7 @@ mod LandRegistry {
last_transaction_timestamp: u64,
}


#[derive(Drop, Serde, starknet::Store)]
enum LandUse {
Residential,
Expand All @@ -50,6 +54,7 @@ mod LandRegistry {
Agricultural,
}

//Events emitted by the contract
#[event]
#[derive(Drop, starknet::Event)]
enum Event {
Expand All @@ -74,12 +79,15 @@ mod LandRegistry {
to_owner: ContractAddress,
}

//for deployer
#[constructor]
fn constructor(ref self: ContractState, deployer: ContractAddress) {
let deployer_address = get_caller_address();
self.emit(ContractDeployed { deployer: deployer_address });
}

//Main implementations

#[abi(embed_v0)]
impl LandRegistryImpl of ILandRegistry<ContractState> {
fn register_land(
Expand Down Expand Up @@ -109,7 +117,11 @@ mod LandRegistry {
land_id
}

//Transfers land current owner to new owner
//We should have a from, to address. ?

fn transfer_land(ref self: ContractState, land_id: u256, new_owner: ContractAddress) {
//read owner from landid
let mut land = self.lands.read(land_id);
let current_owner = land.owner;
assert(current_owner == get_caller_address(), 'Not the land owner');
Expand Down

0 comments on commit 413676a

Please sign in to comment.