Skip to content

Commit

Permalink
Merge pull request #299 from Xaxxoo/update-dependencies
Browse files Browse the repository at this point in the history
chore: Update OpenZeppelin and Starknet dependencies to version 0.20.…
  • Loading branch information
fishonamos authored Feb 2, 2025
2 parents 68765c2 + 26076cd commit 4c1ae02
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 116 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ jobs:
- name: Set up Scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.8.2"
scarb-version: "2.9.2"

- name: Set up SNForge
uses: foundry-rs/setup-snfoundry@v3
with:
starknet-foundry-version: "0.31.0"
starknet-foundry-version: "0.36.0"

- name: Run tests
run: snforge test
Expand Down
71 changes: 43 additions & 28 deletions land_registry/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ dependencies = [

[[package]]
name = "openzeppelin"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_governance",
"openzeppelin_introspection",
"openzeppelin_merkle_tree",
Expand All @@ -28,87 +29,101 @@ dependencies = [

[[package]]
name = "openzeppelin_access"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_account"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"
dependencies = [
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_finance"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"
dependencies = [
"openzeppelin_access",
"openzeppelin_token",
]

[[package]]
name = "openzeppelin_governance"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_introspection"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"

[[package]]
name = "openzeppelin_merkle_tree"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"

[[package]]
name = "openzeppelin_presets"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_introspection",
"openzeppelin_token",
"openzeppelin_upgrades",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_security"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"

[[package]]
name = "openzeppelin_token"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"
dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_governance",
"openzeppelin_introspection",
"openzeppelin_utils",
]

[[package]]
name = "openzeppelin_upgrades"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"

[[package]]
name = "openzeppelin_utils"
version = "0.16.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb"
version = "0.20.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.20.0#7756fd1de2b4ebd239fa6e372d75535cea02e5e5"

[[package]]
name = "snforge_scarb_plugin"
version = "0.31.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.31.0#72ea785ca354e9e506de3e5d687da9fb2c1b3c67"
version = "0.36.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.36.0#6af1722bad3dd98001285e76f43a83d8b38614de"

[[package]]
name = "snforge_std"
version = "0.31.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.31.0#72ea785ca354e9e506de3e5d687da9fb2c1b3c67"
version = "0.36.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.36.0#6af1722bad3dd98001285e76f43a83d8b38614de"
dependencies = [
"snforge_scarb_plugin",
]
6 changes: 3 additions & 3 deletions land_registry/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ edition = "2023_11"


[dependencies]
starknet = ">=2.8.0"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.16.0" }
starknet = ">=2.9.2"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", tag = "v0.20.0" }

[dev-dependencies]
assert_macros = "2.8.2"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.31.0" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.36.0" }

[[target.starknet-contract]]
casm = true
Expand Down
10 changes: 5 additions & 5 deletions land_registry/src/interface/land_nft.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use starknet::ContractAddress;
#[starknet::interface]
pub trait ILandNFT<TContractState> {
fn upgrade(
ref self: TContractState, new_class_hash: starknet::class_hash::ClassHash
ref self: TContractState, new_class_hash: starknet::class_hash::ClassHash,
); // upgrade the contract class
// Mints a new NFT representing a land parcel
fn mint(ref self: TContractState, to: ContractAddress, token_id: u256);

// Transfers ownership of a land NFT
fn transfer(
ref self: TContractState, from: ContractAddress, to: ContractAddress, token_id: u256
ref self: TContractState, from: ContractAddress, to: ContractAddress, token_id: u256,
);

// Updates the base URI for NFT metadata
Expand All @@ -31,15 +31,15 @@ pub trait ILandNFT<TContractState> {
#[derive(Drop, starknet::Event)]
pub struct BaseURIUpdated {
pub caller: ContractAddress,
pub new_base_uri: ByteArray
pub new_base_uri: ByteArray,
}

#[derive(Drop, starknet::Event)]
pub struct Locked {
pub token_id: u256
pub token_id: u256,
}

#[derive(Drop, starknet::Event)]
pub struct Unlocked {
pub token_id: u256
pub token_id: u256,
}
28 changes: 14 additions & 14 deletions land_registry/src/interface/land_register.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ pub struct Land {
pub land_use: LandUse, // Designated purpose/usage of the land
pub status: LandStatus, // Current verification status
pub last_transaction_timestamp: u64, // Timestamp of the most recent transaction
pub inspector: ContractAddress, // Address of assigned inspector
pub inspector: ContractAddress // Address of assigned inspector
}

// Represents the verification status of a land parcel
#[derive(Drop, Debug, Copy, Serde, Clone, starknet::Store, PartialEq)]
pub enum LandStatus {
Pending, // Awaiting verification
Approved, // Verified and approved
Rejected, // Verification failed
Rejected // Verification failed
}

// Geographic coordinates of a land parcel
#[derive(Drop, Copy, Serde, starknet::Store, PartialEq)]
pub struct Location {
pub latitude: felt252, // Latitude coordinate
pub longitude: felt252, // Longitude coordinate
pub longitude: felt252 // Longitude coordinate
}

// Classification of land usage types
Expand All @@ -41,7 +41,7 @@ pub enum LandUse {
Recreational, // Parks and leisure
Institutional, // Schools, hospitals, government buildings
MixedUse, // Combined purposes
Unclassified, // Undefined usage
Unclassified // Undefined usage
}

// Represents a land listing in the marketplace
Expand All @@ -52,20 +52,20 @@ pub struct Listing {
pub price: u256,
pub status: ListingStatus,
pub created_at: u64,
pub updated_at: u64
pub updated_at: u64,
}

#[derive(Drop, Debug, Copy, Serde, Clone, starknet::Store, PartialEq)]
pub enum ListingStatus {
Active,
Sold,
Cancelled
Cancelled,
}

#[starknet::interface]
pub trait ILandRegistry<TContractState> {
fn upgrade(
ref self: TContractState, new_class_hash: starknet::class_hash::ClassHash
ref self: TContractState, new_class_hash: starknet::class_hash::ClassHash,
); // // upgrade the contract class
fn register_land(
ref self: TContractState, location: Location, area: u256, land_use: LandUse,
Expand All @@ -80,7 +80,7 @@ pub trait ILandRegistry<TContractState> {
land_id: u256,
area: u256,
land_use: LandUse,
land_status: LandStatus
land_status: LandStatus,
);
fn approve_land(ref self: TContractState, land_id: u256);
fn reject_land(ref self: TContractState, land_id: u256);
Expand All @@ -90,7 +90,7 @@ pub trait ILandRegistry<TContractState> {
fn is_land_approved(self: @TContractState, land_id: u256) -> bool;
fn get_pending_approvals(self: @TContractState) -> Array<u256>;
fn get_land_transaction_history(
self: @TContractState, land_id: u256
self: @TContractState, land_id: u256,
) -> Array<(ContractAddress, u64)>;
fn get_land_status(self: @TContractState, land_id: u256) -> LandStatus;

Expand Down Expand Up @@ -141,7 +141,7 @@ pub struct LandUpdated {
pub land_id: u256,
pub land_use: Option<felt252>,
pub area: u256,
pub status: LandStatus
pub status: LandStatus,
}


Expand All @@ -166,19 +166,19 @@ pub struct ListingCreated {
pub listing_id: u256,
pub land_id: u256,
pub seller: ContractAddress,
pub price: u256
pub price: u256,
}

#[derive(Drop, starknet::Event)]
pub struct ListingCancelled {
pub listing_id: u256
pub listing_id: u256,
}

#[derive(Drop, starknet::Event)]
pub struct ListingPriceUpdated {
pub listing_id: u256,
pub old_price: u256,
pub new_price: u256
pub new_price: u256,
}

#[derive(Drop, starknet::Event)]
Expand All @@ -187,5 +187,5 @@ pub struct LandSold {
pub land_id: u256,
pub seller: ContractAddress,
pub buyer: ContractAddress,
pub price: u256
pub price: u256,
}
12 changes: 6 additions & 6 deletions land_registry/src/land_nft.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod LandNFT {
use super::ILandNFT;
use starknet::ContractAddress;
use starknet::storage::{
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map,
};
use openzeppelin::token::erc721::ERC721Component;
use openzeppelin::introspection::src5::SRC5Component;
Expand Down Expand Up @@ -55,7 +55,7 @@ pub mod LandNFT {
#[substorage(v0)]
upgradeable: UpgradeableComponent::Storage, // Openzeppelin storage for Upgradable component
land_registry: ContractAddress, // Address of the land registry contract
locked: Map<u256, bool>, // Mapping of locked status for each token
locked: Map<u256, bool> // Mapping of locked status for each token
}

#[event]
Expand Down Expand Up @@ -94,18 +94,18 @@ pub mod LandNFT {
// Only the land registry contract can mint NFTs
assert(
starknet::get_caller_address() == self.land_registry.read(),
custom_error::Errors::MINT_NFT
custom_error::Errors::MINT_NFT,
);
self.erc721.mint(to, token_id);
}

fn transfer(
ref self: ContractState, from: ContractAddress, to: ContractAddress, token_id: u256
ref self: ContractState, from: ContractAddress, to: ContractAddress, token_id: u256,
) {
// Only the land registry contract can transfer NFTs
assert(
starknet::get_caller_address() == self.land_registry.read(),
custom_error::Errors::TRANSFER_NFT
custom_error::Errors::TRANSFER_NFT,
);
self._assert_not_locked(token_id);

Expand All @@ -115,7 +115,7 @@ pub mod LandNFT {
}

fn set_base_uri(
ref self: ContractState, new_base_uri: ByteArray, updater: ContractAddress
ref self: ContractState, new_base_uri: ByteArray, updater: ContractAddress,
) {
// Only the land registry contract can update the metadata URI
assert(
Expand Down
Loading

0 comments on commit 4c1ae02

Please sign in to comment.