Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some fixes #49

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
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
Loading