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

Remove dualcase SRC5 #882

Merged
merged 22 commits into from
Mar 18, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Non standard increase_allowance and decrease_allowance functions in ERC20 contract (#881)

### Removed

- DualCase SRC5 (#882)

## 0.8.1 (2024-01-23)

### Added
Expand Down
2 changes: 0 additions & 2 deletions docs/modules/ROOT/pages/guides/src5-migration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ mod MigratingContract {
// SRC5
#[abi(embed_v0)]
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;
#[abi(embed_v0)]
impl SRC5CamelOnlyImpl = SRC5Component::SRC5CamelImpl<ContractState>;
impl SRC5InternalImpl = SRC5Component::InternalImpl<ContractState>;
// Initializable
Expand Down
8 changes: 2 additions & 6 deletions src/access/accesscontrol/dual_accesscontrol.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use openzeppelin::utils::serde::SerializedAppend;
use openzeppelin::utils::try_selector_with_fallback;
use starknet::ContractAddress;
use starknet::SyscallResultTrait;
use starknet::call_contract_syscall;

#[derive(Copy, Drop)]
struct DualCaseAccessControl {
Expand Down Expand Up @@ -81,12 +82,7 @@ impl DualCaseAccessControlImpl of DualCaseAccessControlTrait {
let mut args = array![];
args.append_serde(interface_id);

try_selector_with_fallback(
*self.contract_address,
selectors::supports_interface,
selectors::supportsInterface,
args.span()
)
call_contract_syscall(*self.contract_address, selectors::supports_interface, args.span())
.unwrap_and_cast()
}
}
2 changes: 1 addition & 1 deletion src/account/account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod AccountComponent {
use openzeppelin::account::utils::{MIN_TRANSACTION_VERSION, QUERY_VERSION, QUERY_OFFSET};
use openzeppelin::account::utils::{execute_calls, is_valid_stark_signature};
use openzeppelin::introspection::src5::SRC5Component::InternalTrait as SRC5InternalTrait;
use openzeppelin::introspection::src5::SRC5Component::{SRC5, SRC5Camel};
use openzeppelin::introspection::src5::SRC5Component::SRC5;
use openzeppelin::introspection::src5::SRC5Component;
use starknet::account::Call;
use starknet::get_caller_address;
Expand Down
8 changes: 2 additions & 6 deletions src/account/dual_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use openzeppelin::utils::serde::SerializedAppend;
use openzeppelin::utils::try_selector_with_fallback;
use starknet::ContractAddress;
use starknet::SyscallResultTrait;
use starknet::call_contract_syscall;

#[derive(Copy, Drop)]
struct DualCaseAccount {
Expand Down Expand Up @@ -59,12 +60,7 @@ impl DualCaseAccountImpl of DualCaseAccountABI {
fn supports_interface(self: @DualCaseAccount, interface_id: felt252) -> bool {
let args = array![interface_id];

try_selector_with_fallback(
*self.contract_address,
selectors::supports_interface,
selectors::supportsInterface,
args.span()
)
call_contract_syscall(*self.contract_address, selectors::supports_interface, args.span())
.unwrap_and_cast()
}
}
8 changes: 2 additions & 6 deletions src/account/dual_eth_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use openzeppelin::utils::serde::SerializedAppend;
use openzeppelin::utils::try_selector_with_fallback;
use starknet::ContractAddress;
use starknet::SyscallResultTrait;
use starknet::call_contract_syscall;

#[derive(Copy, Drop)]
struct DualCaseEthAccount {
Expand Down Expand Up @@ -62,12 +63,7 @@ impl DualCaseEthAccountImpl of DualCaseEthAccountABI {
fn supports_interface(self: @DualCaseEthAccount, interface_id: felt252) -> bool {
let args = array![interface_id];

try_selector_with_fallback(
*self.contract_address,
selectors::supports_interface,
selectors::supportsInterface,
args.span()
)
call_contract_syscall(*self.contract_address, selectors::supports_interface, args.span())
.unwrap_and_cast()
}
}
2 changes: 1 addition & 1 deletion src/account/eth_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod EthAccountComponent {
use openzeppelin::account::utils::{MIN_TRANSACTION_VERSION, QUERY_VERSION, QUERY_OFFSET};
use openzeppelin::account::utils::{execute_calls, is_valid_eth_signature};
use openzeppelin::introspection::src5::SRC5Component::InternalTrait as SRC5InternalTrait;
use openzeppelin::introspection::src5::SRC5Component::{SRC5, SRC5Camel};
use openzeppelin::introspection::src5::SRC5Component::SRC5;
use openzeppelin::introspection::src5::SRC5Component;
use poseidon::poseidon_hash_span;
use starknet::SyscallResultTrait;
Expand Down
1 change: 0 additions & 1 deletion src/introspection.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
mod dual_src5;
mod interface;
mod src5;
5 changes: 0 additions & 5 deletions src/introspection/interface.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,3 @@ const ISRC5_ID: felt252 = 0x3f918d17e5ee77373b56385708f855659a07f75997f365cf8774
trait ISRC5<TState> {
fn supports_interface(self: @TState, interface_id: felt252) -> bool;
}

#[starknet::interface]
trait ISRC5Camel<TState> {
fn supportsInterface(self: @TState, interfaceId: felt252) -> bool;
}
9 changes: 0 additions & 9 deletions src/introspection/src5.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ mod SRC5Component {
}
}

#[embeddable_as(SRC5CamelImpl)]
impl SRC5Camel<
TContractState, +HasComponent<TContractState>
> of interface::ISRC5Camel<ComponentState<TContractState>> {
fn supportsInterface(self: @ComponentState<TContractState>, interfaceId: felt252) -> bool {
self.supports_interface(interfaceId)
}
}

#[generate_trait]
impl InternalImpl<
TContractState, +HasComponent<TContractState>
Expand Down
2 changes: 1 addition & 1 deletion src/tests/access/test_accesscontrol.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use openzeppelin::access::accesscontrol::AccessControlComponent;
use openzeppelin::access::accesscontrol::DEFAULT_ADMIN_ROLE;
use openzeppelin::access::accesscontrol::interface::IACCESSCONTROL_ID;
use openzeppelin::access::accesscontrol::interface::{IAccessControl, IAccessControlCamel};
use openzeppelin::introspection::interface::{ISRC5, ISRC5Camel};
use openzeppelin::introspection::interface::ISRC5;
use openzeppelin::tests::mocks::accesscontrol_mocks::DualCaseAccessControlMock;
use openzeppelin::tests::utils::constants::{
ADMIN, AUTHORIZED, OTHER, OTHER_ADMIN, ROLE, OTHER_ROLE, ZERO
Expand Down
15 changes: 0 additions & 15 deletions src/tests/access/test_dual_accesscontrol.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,6 @@ fn test_dual_renounce_role_exists_and_panics() {
// camelCase target
//

#[test]
fn test_dual_supportsInterface() {
let (dispatcher, _) = setup_camel();

let supports_iaccesscontrol = dispatcher.supports_interface(IACCESSCONTROL_ID);
assert!(supports_iaccesscontrol);
}

#[test]
#[should_panic(expected: ("Some error", 'ENTRYPOINT_FAILED',))]
fn test_dual_supportsInterface_exists_and_panics() {
let (_, dispatcher) = setup_accesscontrol_panic();
dispatcher.supports_interface(IACCESSCONTROL_ID);
}

#[test]
fn test_dual_hasRole() {
let (dispatcher, _) = setup_camel();
Expand Down
14 changes: 0 additions & 14 deletions src/tests/account/test_dual_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,3 @@ fn test_dual_isValidSignature_exists_and_panics() {
let (_, dispatcher) = setup_account_panic();
dispatcher.is_valid_signature(hash, signature);
}

#[test]
fn test_dual_supportsInterface() {
let (camel_dispatcher, _) = setup_camel();
let supports_isrc5 = camel_dispatcher.supports_interface(ISRC5_ID);
assert!(supports_isrc5);
}

#[test]
#[should_panic(expected: ("Some error", 'ENTRYPOINT_FAILED',))]
fn test_dual_supportsInterface_exists_and_panics() {
let (_, dispatcher) = setup_account_panic();
dispatcher.supports_interface(ISRC5_ID);
}
13 changes: 0 additions & 13 deletions src/tests/account/test_dual_eth_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,3 @@ fn test_dual_isValidSignature_exists_and_panics() {
let (_, dispatcher) = setup_account_panic();
dispatcher.is_valid_signature(hash, signature);
}

#[test]
fn test_dual_supportsInterface() {
let (camel_dispatcher, _) = setup_camel();
assert!(camel_dispatcher.supports_interface(ISRC5_ID), "Should implement ISRC5");
}

#[test]
#[should_panic(expected: ("Some error", 'ENTRYPOINT_FAILED',))]
fn test_dual_supportsInterface_exists_and_panics() {
let (_, dispatcher) = setup_account_panic();
dispatcher.supports_interface(ISRC5_ID);
}
1 change: 0 additions & 1 deletion src/tests/introspection.cairo
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
mod test_dual_src5;
mod test_src5;
83 changes: 0 additions & 83 deletions src/tests/introspection/test_dual_src5.cairo

This file was deleted.

4 changes: 2 additions & 2 deletions src/tests/introspection/test_src5.cairo
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use openzeppelin::introspection::interface::{ISRC5_ID, ISRC5};
use openzeppelin::introspection::src5::SRC5Component::InternalTrait;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::tests::mocks::src5_mocks::DualCaseSRC5Mock;
use openzeppelin::tests::mocks::src5_mocks::SRC5Mock;

const OTHER_ID: felt252 = 0x12345678;

type ComponentState = SRC5Component::ComponentState<DualCaseSRC5Mock::ContractState>;
type ComponentState = SRC5Component::ComponentState<SRC5Mock::ContractState>;

fn COMPONENT_STATE() -> ComponentState {
SRC5Component::component_state_for_testing()
Expand Down
6 changes: 0 additions & 6 deletions src/tests/mocks/erc721_mocks.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,6 @@ mod CamelERC721PanicMock {
#[abi(per_item)]
#[generate_trait]
impl ExternalImpl of ExternalTrait {
#[external(v0)]
fn supportsInterface(self: @ContractState, interfaceId: felt252) -> bool {
panic!("Some error");
false
}

#[external(v0)]
fn tokenURI(self: @ContractState, tokenId: u256) -> felt252 {
panic!("Some error");
Expand Down