From 6a179238621c2afd35f16cfc983d28653150a3b2 Mon Sep 17 00:00:00 2001 From: eddnewgate Date: Mon, 5 Aug 2024 06:39:17 +0545 Subject: [PATCH] feat: user storage done --- src/lib.cairo | 31 ++++++++++++++++++++++++++----- tests/test_contract.cairo | 2 +- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/lib.cairo b/src/lib.cairo index 6d90822..0e773ef 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -2,8 +2,8 @@ pub trait IPushComm {} #[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; @@ -17,14 +17,35 @@ pub mod MyContract { #[storage] struct Storage { + // Ownable #[substorage(v0)] ownable: OwnableComponent::Storage, - user: User, + + // Users + users: Map, + users_count:u256, + map_address_users:u256, + user_to_channel_notifs:Map>, + + // Channels + delegatedNotificationSenders:Map, + + + // 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, + subscribed: Map, + map_address_subscribed: Map, } #[event] diff --git a/tests/test_contract.cairo b/tests/test_contract.cairo index 719fb28..5c2ee09 100644 --- a/tests/test_contract.cairo +++ b/tests/test_contract.cairo @@ -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 }