Skip to content

Commit

Permalink
feat: user storage done
Browse files Browse the repository at this point in the history
  • Loading branch information
eddnewgate committed Aug 5, 2024
1 parent 42ff7a9 commit 6a17923
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
31 changes: 26 additions & 5 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pub trait IPushComm<TContractState> {}

#[starknet::contract]
pub mod MyContract {
use starknet::storage::Map;
pub mod PushComm {
use starknet::storage::{Map, StorageMapReadAccess, StorageMapWriteAccess};
use starknet::ContractAddress;
use openzeppelin::access::ownable::OwnableComponent;

Expand All @@ -17,14 +17,35 @@ pub mod MyContract {

#[storage]
struct Storage {
// Ownable
#[substorage(v0)]
ownable: OwnableComponent::Storage,
user: User,

// Users
users: Map<ContractAddress,User>,
users_count:u256,
map_address_users:u256,
user_to_channel_notifs:Map<ContractAddress, Map<ContractAddress, ByteArray>>,

// Channels
delegatedNotificationSenders:Map<ContractAddress, bool>,


// Contract State
governance: ContractAddress,
is_migration_complete: bool,
push_core_address:ContractAddress
}

#[derive(Drop, Serde, starknet::Store)]
#[starknet::storage_node]
pub struct User {
count: u256,
is_activated:bool,
is_public_key_registered:bool,
start_block:u256,
subscribed_count:u256,
is_subscribed: Map<ContractAddress, u8>,
subscribed: Map<ContractAddress, u8>,
map_address_subscribed: Map<ContractAddress, u8>,
}

#[event]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use snforge_std::{declare, ContractClassTrait};

fn deploy_contract(name: ByteArray) -> ContractAddress {
let contract = declare(name).unwrap();
let (contract_address, _) = contract.deploy(@ArrayTrait::new()).unwrap();
let (contract_address, _) = contract.deploy(@array![0]).unwrap();
contract_address
}

Expand Down

0 comments on commit 6a17923

Please sign in to comment.