diff --git a/contracts/src/access_control/access_controller.cairo b/contracts/src/access_control/access_controller.cairo index bbd8cac8b..def9c2b74 100644 --- a/contracts/src/access_control/access_controller.cairo +++ b/contracts/src/access_control/access_controller.cairo @@ -6,7 +6,6 @@ mod AccessController { use openzeppelin::access::ownable::ownable::OwnableComponent; use chainlink::libraries::access_control::{AccessControlComponent, IAccessController}; - // use chainlink::libraries::ownable::{OwnableComponent, IOwnable}; use chainlink::libraries::type_and_version::ITypeAndVersion; use chainlink::libraries::upgradeable::{Upgradeable, IUpgradeable}; diff --git a/contracts/src/emergency/sequencer_uptime_feed.cairo b/contracts/src/emergency/sequencer_uptime_feed.cairo index 44125ef1e..b635e8e7c 100644 --- a/contracts/src/emergency/sequencer_uptime_feed.cairo +++ b/contracts/src/emergency/sequencer_uptime_feed.cairo @@ -29,7 +29,6 @@ mod SequencerUptimeFeed { use openzeppelin::access::ownable::ownable::OwnableComponent; - // use chainlink::libraries::ownable::{OwnableComponent, IOwnable}; use chainlink::libraries::access_control::{AccessControlComponent, IAccessController}; use chainlink::libraries::access_control::AccessControlComponent::InternalTrait as AccessControlInternalTrait; use chainlink::libraries::type_and_version::ITypeAndVersion; diff --git a/contracts/src/libraries.cairo b/contracts/src/libraries.cairo index 68c4710e6..02d62120e 100644 --- a/contracts/src/libraries.cairo +++ b/contracts/src/libraries.cairo @@ -1,5 +1,3 @@ -mod ownable; -mod zownable; mod access_control; mod token; mod upgradeable; diff --git a/contracts/src/libraries/access_control.cairo b/contracts/src/libraries/access_control.cairo index 85fc3082f..f4d903dcc 100644 --- a/contracts/src/libraries/access_control.cairo +++ b/contracts/src/libraries/access_control.cairo @@ -17,7 +17,6 @@ mod AccessControlComponent { use zeroable::Zeroable; use openzeppelin::access::ownable::ownable::OwnableComponent; - // use chainlink::libraries::ownable::{OwnableComponent}; use OwnableComponent::InternalImpl as OwnableInternalImpl; diff --git a/contracts/src/libraries/ownable.cairo b/contracts/src/libraries/ownable.cairo deleted file mode 100644 index d880eb672..000000000 --- a/contracts/src/libraries/ownable.cairo +++ /dev/null @@ -1,155 +0,0 @@ -use starknet::ContractAddress; - -// TODO: consider replacing with OwnableTwoStep if https://github.com/OpenZeppelin/cairo-contracts/pull/809/ lands - -#[starknet::interface] -trait IOwnable { - fn owner(self: @TState) -> ContractAddress; - fn proposed_owner(self: @TState) -> ContractAddress; - fn transfer_ownership(ref self: TState, new_owner: ContractAddress); - fn accept_ownership(ref self: TState); - fn renounce_ownership(ref self: TState); -} - -#[starknet::component] -mod OwnableComponent { - use starknet::ContractAddress; - use starknet::get_caller_address; - - #[storage] - struct Storage { - Ownable_owner: ContractAddress, - Ownable_proposed_owner: ContractAddress - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - OwnershipTransferred: OwnershipTransferred, - OwnershipTransferRequested: OwnershipTransferRequested - } - - #[derive(Drop, starknet::Event)] - struct OwnershipTransferred { - #[key] - previous_owner: ContractAddress, - #[key] - new_owner: ContractAddress, - } - - #[derive(Drop, starknet::Event)] - struct OwnershipTransferRequested { - #[key] - previous_owner: ContractAddress, - #[key] - new_owner: ContractAddress, - } - - mod Errors { - const NOT_OWNER: felt252 = 'Caller is not the owner'; - const NOT_PROPOSED_OWNER: felt252 = 'Caller is not proposed owner'; - const ZERO_ADDRESS_CALLER: felt252 = 'Caller is the zero address'; - const ZERO_ADDRESS_OWNER: felt252 = 'New owner is the zero address'; - } - - /// Adds support for two step ownership transfer. - #[embeddable_as(OwnableImpl)] - impl Ownable< - TContractState, +HasComponent - > of super::IOwnable> { - /// Returns the address of the current owner. - fn owner(self: @ComponentState) -> ContractAddress { - self.Ownable_owner.read() - } - - /// Returns the address of the pending owner. - fn proposed_owner(self: @ComponentState) -> ContractAddress { - self.Ownable_proposed_owner.read() - } - - /// Finishes the two-step ownership transfer process by accepting the ownership. - /// Can only be called by the pending owner. - fn accept_ownership(ref self: ComponentState) { - let caller = get_caller_address(); - let proposed_owner = self.Ownable_proposed_owner.read(); - assert(caller == proposed_owner, Errors::NOT_PROPOSED_OWNER); - self._accept_ownership(); - } - - /// Starts the two-step ownership transfer process by setting the pending owner. - fn transfer_ownership( - ref self: ComponentState, new_owner: ContractAddress - ) { - assert(!new_owner.is_zero(), 'Ownable: transfer to 0'); - self.assert_only_owner(); - self._propose_owner(new_owner); - } - - /// Leaves the contract without owner. It will not be possible to call `assert_only_owner` - /// functions anymore. Can only be called by the current owner. - fn renounce_ownership(ref self: ComponentState) { - self.assert_only_owner(); - self._transfer_ownership(Zeroable::zero()); - } - } - - #[generate_trait] - impl InternalImpl< - TContractState, +HasComponent - > of InternalTrait { - /// Sets the contract's initial owner. - /// - /// This function should be called at construction time. - fn initializer(ref self: ComponentState, owner: ContractAddress) { - self._transfer_ownership(owner); - } - - /// Panics if called by any account other than the owner. Use this - /// to restrict access to certain functions to the owner. - fn assert_only_owner(self: @ComponentState) { - let owner = self.Ownable_owner.read(); - let caller = get_caller_address(); - assert(!caller.is_zero(), Errors::ZERO_ADDRESS_CALLER); - assert(caller == owner, Errors::NOT_OWNER); - } - - /// Transfers ownership to the pending owner. - /// - /// Internal function without access restriction. - fn _accept_ownership(ref self: ComponentState) { - let proposed_owner = self.Ownable_proposed_owner.read(); - self.Ownable_proposed_owner.write(Zeroable::zero()); - self._transfer_ownership(proposed_owner); - } - - /// Sets a new pending owner. - /// - /// Internal function without access restriction. - fn _propose_owner(ref self: ComponentState, new_owner: ContractAddress) { - let previous_owner = self.Ownable_owner.read(); - self.Ownable_proposed_owner.write(new_owner); - self - .emit( - OwnershipTransferRequested { - previous_owner: previous_owner, new_owner: new_owner - } - ); - } - - /// Transfers ownership of the contract to a new address. - /// - /// Internal function without access restriction. - /// - /// Emits an `OwnershipTransferred` event. - fn _transfer_ownership( - ref self: ComponentState, new_owner: ContractAddress - ) { - let previous_owner: ContractAddress = self.Ownable_owner.read(); - self.Ownable_owner.write(new_owner); - self - .emit( - OwnershipTransferred { previous_owner: previous_owner, new_owner: new_owner } - ); - } - } -} diff --git a/contracts/src/libraries/zownable.cairo b/contracts/src/libraries/zownable.cairo deleted file mode 100644 index e69de29bb..000000000 diff --git a/contracts/src/ocr2/aggregator.cairo b/contracts/src/ocr2/aggregator.cairo index f84687f73..8280f4977 100644 --- a/contracts/src/ocr2/aggregator.cairo +++ b/contracts/src/ocr2/aggregator.cairo @@ -200,7 +200,6 @@ mod Aggregator { use openzeppelin::token::erc20::interface::{IERC20, IERC20Dispatcher, IERC20DispatcherTrait}; use chainlink::utils::split_felt; - // use chainlink::libraries::ownable::{OwnableComponent, IOwnable}; use chainlink::libraries::access_control::{AccessControlComponent, IAccessController}; use chainlink::libraries::access_control::AccessControlComponent::InternalTrait as AccessControlInternalTrait; use chainlink::libraries::upgradeable::{Upgradeable, IUpgradeable}; diff --git a/contracts/src/ocr2/aggregator_proxy.cairo b/contracts/src/ocr2/aggregator_proxy.cairo index 32950ac8e..291ab4f50 100644 --- a/contracts/src/ocr2/aggregator_proxy.cairo +++ b/contracts/src/ocr2/aggregator_proxy.cairo @@ -50,7 +50,6 @@ mod AggregatorProxy { use chainlink::ocr2::aggregator::IAggregator; use chainlink::ocr2::aggregator::Round; - // use chainlink::libraries::ownable::{OwnableComponent, IOwnable}; use chainlink::libraries::access_control::{AccessControlComponent, IAccessController}; use chainlink::libraries::access_control::AccessControlComponent::InternalTrait as AccessControlInternalTrait; use chainlink::utils::split_felt; diff --git a/contracts/src/tests/test_aggregator_proxy.cairo b/contracts/src/tests/test_aggregator_proxy.cairo index e138aa722..cbc7cdd4c 100644 --- a/contracts/src/tests/test_aggregator_proxy.cairo +++ b/contracts/src/tests/test_aggregator_proxy.cairo @@ -14,7 +14,6 @@ use core::result::ResultTrait; use chainlink::ocr2::mocks::mock_aggregator::{ MockAggregator, IMockAggregator, IMockAggregatorDispatcher, IMockAggregatorDispatcherTrait }; -// use chainlink::ocr2::aggregator::{IAggregator, IAggregatorDispatcher, IAggregatorDispatcherTrait}; use chainlink::ocr2::aggregator_proxy::AggregatorProxy; use chainlink::ocr2::aggregator_proxy::AggregatorProxy::{ AggregatorProxyImpl, AggregatorProxyInternal, UpgradeableImpl diff --git a/contracts/src/token/link_token.cairo b/contracts/src/token/link_token.cairo index 60c8c0251..77ea46df2 100644 --- a/contracts/src/token/link_token.cairo +++ b/contracts/src/token/link_token.cairo @@ -20,7 +20,6 @@ mod LinkToken { use super::IMintableToken; use openzeppelin::token::erc20::interface::{IERC20, IERC20Dispatcher, IERC20DispatcherTrait}; use chainlink::libraries::token::erc677::ERC677Component; - // use chainlink::libraries::ownable::{OwnableComponent, IOwnable}; use chainlink::libraries::type_and_version::ITypeAndVersion; use chainlink::libraries::upgradeable::{Upgradeable, IUpgradeable}; diff --git a/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo b/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo index f279d9985..06ddd331a 100644 --- a/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo +++ b/examples/contracts/aggregator-consumer/src/ocr2/price_consumer_with_sequencer.cairo @@ -53,7 +53,7 @@ mod AggregatorPriceConsumerWithSequencer { 0 => { assert(!report_stale, 'L2 seq up & report stale'); }, - _ => { + 1 | _ => { assert(!report_stale, 'L2 seq down & report stale'); assert(false, 'L2 seq down & report ok'); }