Skip to content

Commit

Permalink
feat: remove access dual dispatchers
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnordelo committed Sep 23, 2024
1 parent be991c0 commit 488efe9
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 937 deletions.
1 change: 0 additions & 1 deletion packages/access/src/accesscontrol.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod accesscontrol;
pub mod dual_accesscontrol;
pub mod interface;

pub use accesscontrol::AccessControlComponent;
Expand Down
88 changes: 0 additions & 88 deletions packages/access/src/accesscontrol/dual_accesscontrol.cairo

This file was deleted.

1 change: 0 additions & 1 deletion packages/access/src/ownable.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod dual_ownable;
pub mod interface;
pub mod ownable;

Expand Down
55 changes: 0 additions & 55 deletions packages/access/src/ownable/dual_ownable.cairo

This file was deleted.

4 changes: 0 additions & 4 deletions packages/access/src/tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ pub(crate) mod mocks;
#[cfg(test)]
mod test_accesscontrol;
#[cfg(test)]
mod test_dual_accesscontrol;
#[cfg(test)]
mod test_dual_ownable;
#[cfg(test)]
mod test_ownable;
#[cfg(test)]
mod test_ownable_twostep;
1 change: 0 additions & 1 deletion packages/access/src/tests/mocks.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub(crate) mod accesscontrol_mocks;
pub(crate) mod non_implementing_mock;
pub(crate) mod ownable_mocks;
185 changes: 0 additions & 185 deletions packages/access/src/tests/mocks/accesscontrol_mocks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -37,188 +37,3 @@ pub(crate) mod DualCaseAccessControlMock {
self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, admin);
}
}

#[starknet::contract]
pub(crate) mod SnakeAccessControlMock {
use crate::accesscontrol::AccessControlComponent;
use crate::accesscontrol::DEFAULT_ADMIN_ROLE;
use openzeppelin_introspection::src5::SRC5Component;
use starknet::ContractAddress;

component!(path: AccessControlComponent, storage: accesscontrol, event: AccessControlEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);

// AccessControl
#[abi(embed_v0)]
impl AccessControlImpl =
AccessControlComponent::AccessControlImpl<ContractState>;
impl AccessControlInternalImpl = AccessControlComponent::InternalImpl<ContractState>;

// SCR5
#[abi(embed_v0)]
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;

#[storage]
pub struct Storage {
#[substorage(v0)]
pub accesscontrol: AccessControlComponent::Storage,
#[substorage(v0)]
pub src5: SRC5Component::Storage,
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
AccessControlEvent: AccessControlComponent::Event,
#[flat]
SRC5Event: SRC5Component::Event
}

#[constructor]
fn constructor(ref self: ContractState, admin: ContractAddress) {
self.accesscontrol.initializer();
self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, admin);
}
}

#[starknet::contract]
pub(crate) mod CamelAccessControlMock {
use crate::accesscontrol::AccessControlComponent;
use crate::accesscontrol::DEFAULT_ADMIN_ROLE;
use openzeppelin_introspection::src5::SRC5Component;
use starknet::ContractAddress;

component!(path: AccessControlComponent, storage: accesscontrol, event: AccessControlEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);

// AccessControl
#[abi(embed_v0)]
impl AccessControlCamelImpl =
AccessControlComponent::AccessControlCamelImpl<ContractState>;
impl AccessControlInternalImpl = AccessControlComponent::InternalImpl<ContractState>;

// SCR5
#[abi(embed_v0)]
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;


#[storage]
pub struct Storage {
#[substorage(v0)]
pub accesscontrol: AccessControlComponent::Storage,
#[substorage(v0)]
pub src5: SRC5Component::Storage
}

#[event]
#[derive(Drop, starknet::Event)]
enum Event {
#[flat]
AccessControlEvent: AccessControlComponent::Event,
#[flat]
SRC5Event: SRC5Component::Event
}

#[constructor]
fn constructor(ref self: ContractState, admin: ContractAddress) {
self.accesscontrol.initializer();
self.accesscontrol._grant_role(DEFAULT_ADMIN_ROLE, admin);
}
}

// Although these modules are designed to panic, functions
// still need a valid return value. We chose:
//
// 3 for felt252
// false for bool

#[starknet::contract]
pub(crate) mod SnakeAccessControlPanicMock {
use starknet::ContractAddress;

#[storage]
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
impl ExternalImpl of ExternalTrait {
#[external(v0)]
fn has_role(self: @ContractState, role: felt252, account: ContractAddress) -> bool {
panic!("Some error");
false
}

#[external(v0)]
fn get_role_admin(self: @ContractState, role: felt252) -> felt252 {
panic!("Some error");
3
}

#[external(v0)]
fn grant_role(ref self: ContractState, role: felt252, account: ContractAddress) {
panic!("Some error");
}

#[external(v0)]
fn revoke_role(ref self: ContractState, role: felt252, account: ContractAddress) {
panic!("Some error");
}

#[external(v0)]
fn renounce_role(ref self: ContractState, role: felt252, account: ContractAddress) {
panic!("Some error");
}

#[external(v0)]
fn supports_interface(self: @ContractState, interface_id: felt252) -> bool {
panic!("Some error");
false
}
}
}

#[starknet::contract]
pub(crate) mod CamelAccessControlPanicMock {
use starknet::ContractAddress;

#[storage]
pub struct Storage {}

#[abi(per_item)]
#[generate_trait]
impl ExternalImpl of ExternalTrait {
#[external(v0)]
fn hasRole(self: @ContractState, role: felt252, account: ContractAddress) -> bool {
panic!("Some error");
false
}

#[external(v0)]
fn getRoleAdmin(self: @ContractState, role: felt252) -> felt252 {
panic!("Some error");
3
}

#[external(v0)]
fn grantRole(ref self: ContractState, role: felt252, account: ContractAddress) {
panic!("Some error");
}

#[external(v0)]
fn revokeRole(ref self: ContractState, role: felt252, account: ContractAddress) {
panic!("Some error");
}

#[external(v0)]
fn renounceRole(ref self: ContractState, role: felt252, account: ContractAddress) {
panic!("Some error");
}

#[external(v0)]
fn supportsInterface(self: @ContractState, interfaceId: felt252) -> bool {
panic!("Some error");
false
}
}
}
10 changes: 0 additions & 10 deletions packages/access/src/tests/mocks/non_implementing_mock.cairo

This file was deleted.

Loading

0 comments on commit 488efe9

Please sign in to comment.