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 9 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 @@ -21,6 +21,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
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/utils/_class_hashes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:account-class-hash: 0x01148c31dfa5c4708a4e9cf1eb0fd3d4d8ad9ccf09d0232cd6b56bee64a7de9d
:eth-account-upgradeable-class-hash: 0x023e416842ca96b1f7067693892ed00881d97a4b0d9a4c793b75cb887944d98d
:erc20-class-hash: 0x07c9b5a246fe83b0cd81de65daddb94b3803f94950db99bf2431bbfecf284642
:erc721-class-hash: 0x06b7c9efc5467c621f58d87995302d940a39b7217b5c5a7a55555c97cabf5cd8
:erc721-class-hash: 0x028cac62e55ba073d12c2e9119165ea437bd56e4313e37c6def96cf5ca6a76cf

// Presets page
:presets-page: xref:presets.adoc[Sierra class hash]
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;
30 changes: 0 additions & 30 deletions src/introspection/dual_src5.cairo

This file was deleted.

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
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
65 changes: 2 additions & 63 deletions src/tests/mocks/src5_mocks.cairo
Original file line number Diff line number Diff line change
@@ -1,60 +1,11 @@
#[starknet::contract]
mod DualCaseSRC5Mock {
mod SRC5Mock {
use openzeppelin::introspection::src5::SRC5Component;

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

#[abi(embed_v0)]
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;
#[abi(embed_v0)]
impl SRC5CamelOnlyImpl = SRC5Component::SRC5CamelImpl<ContractState>;
impl InternalImpl = SRC5Component::InternalImpl<ContractState>;

#[storage]
struct Storage {
#[substorage(v0)]
src5: SRC5Component::Storage
}

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

#[starknet::contract]
mod SnakeSRC5Mock {
use openzeppelin::introspection::src5::SRC5Component;

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

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

#[storage]
struct Storage {
#[substorage(v0)]
src5: SRC5Component::Storage
}

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

#[starknet::contract]
mod CamelSRC5Mock {
use openzeppelin::introspection::src5::SRC5Component;

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

#[abi(embed_v0)]
impl SRC5CamelImpl = SRC5Component::SRC5CamelImpl<ContractState>;

#[storage]
struct Storage {
Expand All @@ -71,7 +22,7 @@ mod CamelSRC5Mock {
}

#[starknet::contract]
mod SnakeSRC5PanicMock {
mod SRC5PanicMock {
TAdev0 marked this conversation as resolved.
Show resolved Hide resolved
#[storage]
struct Storage {}

Expand All @@ -81,15 +32,3 @@ mod SnakeSRC5PanicMock {
false
}
}

#[starknet::contract]
mod CamelSRC5PanicMock {
#[storage]
struct Storage {}

#[external(v0)]
fn supportsInterface(self: @ContractState, interfaceId: felt252) -> bool {
panic!("Some error");
false
}
}
8 changes: 5 additions & 3 deletions src/token/erc721/erc721.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#[starknet::component]
mod ERC721Component {
use openzeppelin::account;
use openzeppelin::introspection::dual_src5::{DualCaseSRC5, DualCaseSRC5Trait};
use openzeppelin::introspection::interface::ISRC5Dispatcher;
use openzeppelin::introspection::interface::ISRC5DispatcherTrait;
TAdev0 marked this conversation as resolved.
Show resolved Hide resolved
use openzeppelin::introspection::src5::SRC5Component::InternalTrait as SRC5InternalTrait;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::token::erc721::dual721_receiver::{
Expand Down Expand Up @@ -531,14 +532,15 @@ mod ERC721Component {
fn _check_on_erc721_received(
from: ContractAddress, to: ContractAddress, token_id: u256, data: Span<felt252>
) -> bool {
if (DualCaseSRC5 { contract_address: to }
if (ISRC5Dispatcher { contract_address: to }
.supports_interface(interface::IERC721_RECEIVER_ID)) {
DualCaseERC721Receiver { contract_address: to }
.on_erc721_received(
get_caller_address(), from, token_id, data
) == interface::IERC721_RECEIVER_ID
} else {
DualCaseSRC5 { contract_address: to }.supports_interface(account::interface::ISRC6_ID)
ISRC5Dispatcher { contract_address: to }
.supports_interface(account::interface::ISRC6_ID)
TAdev0 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}