-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from SoarinSkySagar/land_id_gen
Land ID generation and better Location format
- Loading branch information
Showing
4 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
//helper functions | ||
use starknet::{get_caller_address, get_block_timestamp, ContractAddress}; | ||
use core::poseidon::PoseidonTrait; | ||
use core::hash::{HashStateTrait, HashStateExTrait}; | ||
use land_registry::interface::Location; | ||
|
||
//LandHelpers | ||
|
||
pub fn create_land_id(caller: ContractAddress, timestamp: u64, location: Location) -> u256 { | ||
let caller_hash = PoseidonTrait::new().update_with(caller).finalize(); | ||
let timestamp_hash = PoseidonTrait::new().update_with(timestamp).finalize(); | ||
let location_hash = PoseidonTrait::new() | ||
.update_with(location.latitude + location.longitude) | ||
.finalize(); | ||
|
||
let felt_land_id = caller_hash + timestamp_hash + location_hash; | ||
let land_id: u256 = felt_land_id.into(); | ||
land_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters