Skip to content

Commit

Permalink
feat: ozz access control added
Browse files Browse the repository at this point in the history
  • Loading branch information
eddnewgate committed Jul 28, 2024
1 parent 1bb6585 commit 29fcf77
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
version = 1

[[package]]
name = "push_coom"
name = "openzeppelin"
version = "0.15.0-rc.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?rev=49816b6763fea500396a97b5178c3e30a85eecc7#49816b6763fea500396a97b5178c3e30a85eecc7"

[[package]]
name = "push_comm"
version = "0.1.0"
dependencies = [
"openzeppelin",
"snforge_std",
]

Expand Down
5 changes: 3 additions & 2 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "push_coom"
name = "push_comm"
version = "0.1.0"
edition = "2023_11"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
starknet = "2.6.4"
starknet = "2.7.0-rc.3"
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev="49816b6763fea500396a97b5178c3e30a85eecc7" }

[dev-dependencies]
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.27.0" }
Expand Down
43 changes: 41 additions & 2 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,46 @@
pub trait IPushComm<TContractState> {}

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

component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);

// Ownable Mixin
#[abi(embed_v0)]
impl OwnableMixinImpl = OwnableComponent::OwnableMixinImpl<ContractState>;
impl InternalImpl = OwnableComponent::InternalImpl<ContractState>;


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

#[derive(Drop, Serde, starknet::Store)]
pub struct User {
count: u256,
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
OwnableEvent: OwnableComponent::Event
}

#[constructor]
fn constructor(ref self: ContractState, owner: ContractAddress) {
// Set the initial owner of the contract
self.ownable.initializer(owner);
}



#[abi(embed_v0)]
impl PushComm of super::IPushComm<ContractState> {}
}

0 comments on commit 29fcf77

Please sign in to comment.