Skip to content

Commit

Permalink
update nonFungibleFlexDropToken contract, upgrade to cairo ver 2.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Sin committed May 6, 2024
1 parent e766420 commit 95111ec
Show file tree
Hide file tree
Showing 27 changed files with 847 additions and 160 deletions.
4 changes: 2 additions & 2 deletions flex_marketplace/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ dependencies = [

[[package]]
name = "openzeppelin"
version = "0.8.0"
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.8.0#c23e8e96de60e6e3159b1ff8591a1187269c0eb7"
version = "0.10.0"
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.10.0#d77082732daab2690ba50742ea41080eb23299d3"

[[package]]
name = "snforge_std"
Expand Down
4 changes: 2 additions & 2 deletions flex_marketplace/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = "0.1.0"
edition = "2023_01"

[dependencies]
starknet = "2.4.3"
starknet = ">=2.4.3"
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.14.0" }
openzeppelin = { git = "https://github.com/openzeppelin/cairo-contracts", tag = "v0.8.0" }
openzeppelin = { git = "https://github.com/openzeppelin/cairo-contracts", tag = "v0.10.0" }
alexandria_storage = { git = "https://github.com/keep-starknet-strange/alexandria.git", tag = "cairo-v2.3.0-rc0" }

[scripts]
Expand Down
2 changes: 1 addition & 1 deletion flex_marketplace/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ mod marketplace {
mod transfer_manager_ERC1155;
mod transfer_selector_NFT;
}

mod mocks {
mod account;
mod erc20;
mod erc1155;
mod erc721;
mod strategy;
}

2 changes: 1 addition & 1 deletion flex_marketplace/src/marketplace/currency_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mod CurrencyManager {
timestamp: u64,
}

#[external(v0)]
#[abi(embed_v0)]
impl CurrencyManagerImpl of super::ICurrencyManager<ContractState> {
fn initializer(
ref self: ContractState, owner: ContractAddress, proxy_admin: ContractAddress
Expand Down
2 changes: 1 addition & 1 deletion flex_marketplace/src/marketplace/execution_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mod ExecutionManager {
timestamp: u64
}

#[external(v0)]
#[abi(embed_v0)]
impl ExecutionManagerImpl of super::IExecutionManager<ContractState> {
fn initializer(ref self: ContractState, owner: ContractAddress) {
assert!(!self.initialized.read(), "ExecutionManager: already initialized");
Expand Down
10 changes: 4 additions & 6 deletions flex_marketplace/src/marketplace/marketplace.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,11 @@ trait IAuctionStrategy<TState> {
mod MarketPlace {
use super::{
IExecutionStrategyDispatcher, IExecutionStrategyDispatcherTrait, IAuctionStrategyDispatcher,
IAuctionStrategyDispatcherTrait
};
use starknet::{
ContractAddress, ClassHash, contract_address_const, get_block_timestamp, get_caller_address
IAuctionStrategyDispatcherTrait, ContractAddress, ClassHash
};
use starknet::{contract_address_const, get_block_timestamp, get_caller_address};

use flex::{DebugContractAddress, DisplayContractAddress};
use flex::{DisplayContractAddress};
use flex::marketplace::{
currency_manager::{ICurrencyManagerDispatcher, ICurrencyManagerDispatcherTrait},
execution_manager::{IExecutionManagerDispatcher, IExecutionManagerDispatcherTrait},
Expand Down Expand Up @@ -266,7 +264,7 @@ mod MarketPlace {
timestamp: u64,
}

#[external(v0)]
#[abi(embed_v0)]
impl MarketPlaceImpl of super::IMarketPlace<ContractState> {
fn initializer(
ref self: ContractState,
Expand Down
9 changes: 7 additions & 2 deletions flex_marketplace/src/marketplace/openedition.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod interfaces {
mod IERC721;
mod IFlexDrop;
mod IFlexDropContractMetadata;
mod INonFungibleFlexDropToken;
Expand All @@ -8,7 +9,11 @@ mod ERC721_open_edition;

mod FlexDrop;

mod erc721_metadata {
mod ERC721_metadata;
mod erc721 {
mod ERC721;
}

use erc721::ERC721;
use interfaces::IFlexDrop::IFlexDrop;
use interfaces::INonFungibleFlexDropToken::INonFungibleFlexDropToken;

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#[starknet::contract]
mod ERC721 {
mod ERC721OpenEdition {
use alexandria_storage::list::ListTrait;
use openzeppelin::token::erc721::erc721::ERC721Component;
use openzeppelin::access::ownable::OwnableComponent;
use openzeppelin::introspection::src5::SRC5Component;
use openzeppelin::security::reentrancyguard::ReentrancyGuardComponent;
use flex::marketplace::openedition::interfaces::IFlexDropContractMetadata::IFlexDropContractMetadata;
use flex::marketplace::openedition::erc721_metadata::ERC721_metadata::ERC721MetadataComponent;
use flex::marketplace::openedition::ERC721::ERC721Component;
use flex::marketplace::openedition::interfaces::IFlexDrop::{
IFlexDropDispatcher, IFlexDropDispatcherTrait
};
Expand All @@ -18,7 +16,6 @@ mod ERC721 {
use starknet::{ContractAddress, get_caller_address, get_contract_address};
use integer::BoundedU64;

component!(path: ERC721MetadataComponent, storage: erc721_metadata, event: ERC721MetadataEvent);
component!(path: SRC5Component, storage: src5, event: SRC5Event);
component!(path: ERC721Component, storage: erc721, event: ERC721Event);
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
Expand All @@ -33,15 +30,15 @@ mod ERC721 {
impl ERC721CamelImpl = ERC721Component::ERC721CamelOnlyImpl<ContractState>;

#[abi(embed_v0)]
impl ERC721Metadata = ERC721Component::ERC721MetadataImpl<ContractState>;
impl ERC721MetadataImpl = ERC721Component::ERC721MetadataImpl<ContractState>;

#[abi(embed_v0)]
impl ERC721MetadataCamel =
impl ERC721MetadataCamelImpl =
ERC721Component::ERC721MetadataCamelOnlyImpl<ContractState>;

#[abi(embed_v0)]
impl ERC721FlexMetadataImpl =
ERC721MetadataComponent::FlexDropContractMetadataImpl<ContractState>;
impl FlexDropContractMetadataImpl =
ERC721Component::FlexDropContractMetadataImpl<ContractState>;

#[abi(embed_v0)]
impl SRC5Impl = SRC5Component::SRC5Impl<ContractState>;
Expand All @@ -52,8 +49,6 @@ mod ERC721 {
#[abi(embed_v0)]
impl OwnableImpl = OwnableComponent::OwnableImpl<ContractState>;

impl ERC721MetadataInternalImpl = ERC721MetadataComponent::InternalImpl<ContractState>;

impl ERC721InternalImpl = ERC721Component::InternalImpl<ContractState>;

impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>;
Expand All @@ -75,8 +70,6 @@ mod ERC721 {
enumerated_allowed_flex_drop: List<ContractAddress>,
current_phase_id: u64,
#[substorage(v0)]
erc721_metadata: ERC721MetadataComponent::Storage,
#[substorage(v0)]
erc721: ERC721Component::Storage,
#[substorage(v0)]
src5: SRC5Component::Storage,
Expand All @@ -89,15 +82,14 @@ mod ERC721 {
#[constructor]
fn constructor(
ref self: ContractState,
owner: ContractAddress,
name: felt252,
symbol: felt252,
token_base_uri: felt252,
creator: ContractAddress,
name: ByteArray,
symbol: ByteArray,
token_base_uri: ByteArray,
allowed_flex_drop: Array::<ContractAddress>,
) {
self.ownable.initializer(owner);
self.erc721_metadata.initializer(owner, token_base_uri);
self.erc721.initializer(name, symbol);
self.ownable.initializer(creator);
self.erc721.initializer(name, symbol, creator, token_base_uri);
self.current_token_id.write(1);
self.current_phase_id.write(1);

Expand Down Expand Up @@ -125,8 +117,6 @@ mod ERC721 {
enum Event {
UpdateAllowedFlexDrop: UpdateAllowedFlexDrop,
#[flat]
ERC721MetadataEvent: ERC721MetadataComponent::Event,
#[flat]
ERC721Event: ERC721Component::Event,
#[flat]
SRC5Event: SRC5Component::Event,
Expand Down Expand Up @@ -257,11 +247,11 @@ mod ERC721 {
self.set_max_supply(max_supply);
}

if config.base_uri.into() > 0_u256 {
if config.base_uri.len() > 0 {
self.set_base_uri(config.base_uri);
}

if config.contract_uri.into() > 0_u256 {
if config.contract_uri.len() > 0 {
self.set_contract_uri(config.contract_uri);
}

Expand Down Expand Up @@ -323,7 +313,6 @@ mod ERC721 {
impl InternalFlexDropToken of InternalFlexDropTokenTrait {
fn safe_mint_flex_drop(ref self: ContractState, to: ContractAddress, quantity: u64) {
let mut current_token_id = self.get_current_token_id();
let base_uri = self.get_base_uri();

self
.total_minted_per_wallet
Expand All @@ -337,7 +326,6 @@ mod ERC721 {
break;
}
self.erc721._safe_mint(to, current_token_id, ArrayTrait::<felt252>::new().span());
self.erc721._set_token_uri(current_token_id, base_uri);
current_token_id += 1;
index += 1;
}
Expand Down
3 changes: 2 additions & 1 deletion flex_marketplace/src/marketplace/openedition/FlexDrop.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod FlexDrop {
use core::box::BoxTrait;
use flex::marketplace::utils::openedition::PhaseDrop;
use flex::marketplace::openedition::interfaces::IFlexDrop::IFlexDrop;
use flex::marketplace::openedition::IFlexDrop;
use flex::marketplace::openedition::interfaces::INonFungibleFlexDropToken::{
INonFungibleFlexDropTokenDispatcher, INonFungibleFlexDropTokenDispatcherTrait,
I_NON_FUNGIBLE_FLEX_DROP_TOKEN_ID
Expand Down Expand Up @@ -405,6 +405,7 @@ mod FlexDrop {
let nft_address = get_caller_address();
let is_supported_interface = ISRC5Dispatcher { contract_address: nft_address }
.supports_interface(I_NON_FUNGIBLE_FLEX_DROP_TOKEN_ID);
assert(is_supported_interface, 'FlexDrop: Unsupport Interface');
}

fn validate_new_phase_drop(self: @ContractState, phase_drop: @PhaseDrop) {
Expand Down
Loading

0 comments on commit 95111ec

Please sign in to comment.