Skip to content

Commit

Permalink
Feat/implement new identity contract (#183)
Browse files Browse the repository at this point in the history
* style: format styling with scarb fmt

* feat: add identity contract

* feat: add itentity contract to include web3 verification

* test: add passing tests

* feat: add Poseidon hash function for generating social proofs

* chore: scarb fmt

* fix: add new identity interface

* feat: add new verifiction functions

* test: add unit test suite for identity contract

* chore: update dependencies

* style: scarb fmt

* chore: comment unnecessary dependencies

* chore(refactor): scarb fmt
  • Loading branch information
psychemist authored Feb 27, 2025
1 parent bd29d54 commit af0d319
Show file tree
Hide file tree
Showing 8 changed files with 691 additions and 350 deletions.
4 changes: 2 additions & 2 deletions contracts/src/crowdfunding.cairo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use starknet::ContractAddress;
use starknet::storage::{Map, Vec};
use alexandria_storage::{ListTrait, List};
// use alexandria_storage::{ListTrait, List};

#[starknet::interface]
pub trait ICrowdfunding<TContractState> {
Expand Down Expand Up @@ -73,7 +73,7 @@ pub mod Crowdfunding {
use alexandria_storage::{ListTrait, List};
use core::option::OptionTrait;
use starknet::storage::{
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map, Vec,
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map,
StorageMapWriteAccess, MutableVecTrait,
};
use starknet::storage::StorageMapReadAccess;
Expand Down
21 changes: 17 additions & 4 deletions contracts/src/interfaces/IStarkIdentity.cairo
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use starknet::ContractAddress;
use contracts::starkidentity::StarkIdentity::{ActivityRecord, Identity};
use contracts::starkidentity::{ActivityRecord, Identity};

#[starknet::interface]
pub trait IStarkIdentity<TContractState> {
/// Creates a new identity for the caller with username, ENS name, Stark name, and recovery address.
/// Creates new identity caller with username, ENS name, Stark name, and recovery address.
fn create_identity(
ref self: TContractState,
username: felt252,
Expand All @@ -19,14 +19,23 @@ pub trait IStarkIdentity<TContractState> {
fn identity_exists(self: @TContractState, address: ContractAddress) -> bool;
/// Links an additional address to the caller's identity.
fn link_address(ref self: TContractState, address_to_link: ContractAddress);
/// Checks if two addresses are linked
fn verify_linked_addresses(
self: @TContractState, address1: ContractAddress, address2: ContractAddress,
) -> bool;
/// Adds a new verifier (admin only).
fn add_verifier(ref self: TContractState, verifier: ContractAddress);
/// Adds social verification for the caller's identity.
fn add_social_verification(
ref self: TContractState, platform: felt252, verification_proof: felt252,
);
/// Submits social proof for a user's identity (verifiers only).
fn submit_social_proof(ref self: TContractState, platform: felt252, uaer_address: ContractAddress, signature: felt252);
fn submit_social_proof(
ref self: TContractState,
platform: felt252,
user_address: ContractAddress,
signature: felt252,
);
/// Verifies the provided social proof.
fn verify_social_proof(self: @TContractState, platform: felt252, proof: felt252) -> bool;
/// Records a new activity for the caller's identity.
Expand All @@ -35,10 +44,14 @@ pub trait IStarkIdentity<TContractState> {
);
/// Retrieves recorded activities for the specified address.
fn get_activities(
self: @TContractState, address: ContractAddress, start_index: u32, limit: u32,
self: @TContractState, address: ContractAddress, start_index: u256, limit: u256,
) -> Array<ActivityRecord>;
/// Sends a verification request for the caller's identity.
fn request_verification(ref self: TContractState, verification_type: felt252);
/// Updates the status of the user's verification request (verifiers only).
fn update_verification_request(
ref self: TContractState, user: ContractAddress, verification_type: felt252, new_status: u8,
);
/// Updates the reputation score of a user's identity.
fn update_reputation(ref self: TContractState, address: ContractAddress, points: i32);
/// Records protocol usage for the specified address.
Expand Down
Loading

0 comments on commit af0d319

Please sign in to comment.