Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to oz ownable library #541

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion starknet/src/external.cairo

This file was deleted.

63 changes: 0 additions & 63 deletions starknet/src/external/ownable.cairo

This file was deleted.

2 changes: 0 additions & 2 deletions starknet/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ mod voting_strategies;

mod utils;

mod external;

mod interfaces;

mod tests;
Expand Down
19 changes: 8 additions & 11 deletions starknet/src/space/space.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ trait ISpace<TContractState> {
#[starknet::contract]
mod Space {
use super::ISpace;
use openzeppelin::access::ownable::Ownable;
use starknet::{
storage_access::{StorePacking, StoreUsingPacking}, ClassHash, ContractAddress, info, Store,
syscalls, SyscallResult,
Expand All @@ -95,7 +96,6 @@ mod Space {
},
constants::INITIALIZE_SELECTOR
},
external::ownable::Ownable
};

#[storage]
Expand Down Expand Up @@ -295,8 +295,7 @@ mod Space {

//TODO: temporary component syntax
let mut state = Ownable::unsafe_new_contract_state();
Ownable::initializer(ref state);
Ownable::transfer_ownership(ref state, owner);
Ownable::InternalImpl::initializer(ref state, owner);
_set_dao_uri(ref self, dao_uri);
_set_max_voting_duration(
ref self, max_voting_duration
Expand Down Expand Up @@ -469,7 +468,7 @@ mod Space {
fn cancel(ref self: ContractState, proposal_id: u256) {
//TODO: temporary component syntax
let state = Ownable::unsafe_new_contract_state();
Ownable::assert_only_owner(@state);
Ownable::InternalImpl::assert_only_owner(@state);

let mut proposal = self._proposals.read(proposal_id);
assert_proposal_exists(@proposal);
Expand Down Expand Up @@ -525,7 +524,7 @@ mod Space {
ref self: ContractState, class_hash: ClassHash, initialize_calldata: Array<felt252>
) -> SyscallResult<()> {
let state: Ownable::ContractState = Ownable::unsafe_new_contract_state();
Ownable::assert_only_owner(@state);
Ownable::InternalImpl::assert_only_owner(@state);

assert(class_hash.is_non_zero(), 'Class Hash cannot be zero');
starknet::replace_class_syscall(class_hash)?;
Expand Down Expand Up @@ -554,7 +553,7 @@ mod Space {
fn owner(self: @ContractState) -> ContractAddress {
//TODO: temporary component syntax
let state = Ownable::unsafe_new_contract_state();
Ownable::owner(@state)
Ownable::OwnableImpl::owner(@state)
}

fn max_voting_duration(self: @ContractState) -> u32 {
Expand Down Expand Up @@ -616,7 +615,7 @@ mod Space {
fn update_settings(ref self: ContractState, input: UpdateSettingsCalldata) {
//TODO: temporary component syntax
let state = Ownable::unsafe_new_contract_state();
Ownable::assert_only_owner(@state);
Ownable::InternalImpl::assert_only_owner(@state);

// Needed because the compiler will go crazy if we try to use `input` directly
let _min_voting_duration = input.min_voting_duration;
Expand Down Expand Up @@ -785,15 +784,13 @@ mod Space {
fn transfer_ownership(ref self: ContractState, new_owner: ContractAddress) {
//TODO: temporary component syntax
let mut state = Ownable::unsafe_new_contract_state();
Ownable::assert_only_owner(@state);
Ownable::transfer_ownership(ref state, new_owner);
Ownable::OwnableImpl::transfer_ownership(ref state, new_owner);
}

fn renounce_ownership(ref self: ContractState) {
//TODO: temporary component syntax
let mut state = Ownable::unsafe_new_contract_state();
Ownable::assert_only_owner(@state);
Ownable::renounce_ownership(ref state);
Ownable::OwnableImpl::renounce_ownership(ref state);
}
}

Expand Down