Skip to content

Commit

Permalink
Merge pull request #64 from briansinw3b/main
Browse files Browse the repository at this point in the history
Update openedition
  • Loading branch information
0xandee authored Mar 20, 2024
2 parents 3415161 + db2116b commit 22a824c
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 34 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ flex_marketplace/.snfoundry_cache/
tool-versions

.vscode/
target
target

deployment
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use starknet::ContractAddress;

#[starknet::interface]
trait ITransferManagerNFT<TState> {
fn initializer(
ref self: TState,
marketplace: ContractAddress,
owner: ContractAddress,
);
fn initializer(ref self: TState, marketplace: ContractAddress, owner: ContractAddress,);
fn transfer_non_fungible_token(
ref self: TState,
collection: ContractAddress,
Expand All @@ -18,4 +14,4 @@ trait ITransferManagerNFT<TState> {
);
fn update_marketplace(ref self: TState, new_address: ContractAddress);
fn get_marketplace(self: @TState) -> ContractAddress;
}
}
8 changes: 6 additions & 2 deletions flex_marketplace/src/marketplace/marketplace.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ mod MarketPlace {
transfer_selector_NFT::{
ITransferSelectorNFTDispatcher, ITransferSelectorNFTDispatcherTrait
},
interfaces::nft_transfer_manager::{ITransferManagerNFTDispatcher, ITransferManagerNFTDispatcherTrait}
interfaces::nft_transfer_manager::{
ITransferManagerNFTDispatcher, ITransferManagerNFTDispatcherTrait
}
};
use flex::marketplace::utils::order_types::{MakerOrder, TakerOrder};

Expand Down Expand Up @@ -698,7 +700,9 @@ mod MarketPlace {
.check_transfer_manager_for_token(collection);
assert!(!manager.is_zero(), "MarketPlace: invalid tranfer manager {}", manager);
ITransferManagerNFTDispatcher { contract_address: manager }
.transfer_non_fungible_token(collection, from, to, token_id, amount, ArrayTrait::<felt252>::new().span());
.transfer_non_fungible_token(
collection, from, to, token_id, amount, ArrayTrait::<felt252>::new().span()
);
}

fn calculate_protocol_fee(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ mod ERC721 {
owner: ContractAddress,
name: felt252,
symbol: felt252,
token_base_uri: felt252,
allowed_flex_drop: Array::<ContractAddress>,
) {
self.erc721_metadata.initializer(owner);
self.ownable.initializer(owner);
self.erc721_metadata.initializer(owner, token_base_uri);
self.erc721.initializer(name, symbol);
self.current_token_id.write(1);

Expand Down Expand Up @@ -240,13 +242,17 @@ mod ERC721 {
self.ownable.assert_only_owner();

let mut max_supply = config.max_supply;
if max_supply == 0 {
max_supply = BoundedU64::max();
if max_supply != 0 {
self.set_max_supply(max_supply);
}

self.set_max_supply(max_supply);
self.set_base_uri(config.base_uri);
self.set_contract_uri(config.contract_uri);
if config.base_uri.into() > 0_u256 {
self.set_base_uri(config.base_uri);
}

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

let public_drop = config.public_drop;
if public_drop.start_time != 0 && public_drop.end_time != 0 {
Expand Down Expand Up @@ -333,6 +339,7 @@ mod ERC721 {

self.current_token_id.write(current_token_id + quantity.into());
self.total_minted.write(self.get_total_minted() + quantity);
self.total_minted_per_wallet.write(to, self.total_minted_per_wallet.read(to) + quantity);

let mut index: u64 = 0;
loop {
Expand Down
56 changes: 43 additions & 13 deletions flex_marketplace/src/marketplace/openedition/FlexDrop.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#[starknet::contract]
mod FlexDrop {
use core::box::BoxTrait;
use core::option::OptionTrait;
use flex::marketplace::utils::openedition::PublicDrop;
use flex::marketplace::openedition::interfaces::IFlexDrop::IFlexDrop;
use flex::marketplace::openedition::interfaces::INonFungibleFlexDropToken::{
Expand Down Expand Up @@ -226,7 +224,7 @@ use core::option::OptionTrait;
let nft_address = get_caller_address();
if allowed {
assert(
self.allowed_fee_recipients.read((nft_address, fee_recipient)),
!self.allowed_fee_recipients.read((nft_address, fee_recipient)),
'Duplicate Fee Recipient'
);
self.allowed_fee_recipients.write((nft_address, fee_recipient), true);
Expand All @@ -239,14 +237,14 @@ use core::option::OptionTrait;
.write(nft_address, enumerated_allowed_fee_recipients);
} else {
assert(
!self.allowed_fee_recipients.read((nft_address, fee_recipient)),
self.allowed_fee_recipients.read((nft_address, fee_recipient)),
'Fee Recipient not present'
);
self.allowed_fee_recipients.write((nft_address, fee_recipient), false);
self.remove_enumerated_allowed_fee_recipient(nft_address, fee_recipient);
}

self.emit(FeeRecipientUpdated {nft_address, fee_recipient, allowed});
self.emit(FeeRecipientUpdated { nft_address, fee_recipient, allowed });
}

fn update_payer(ref self: ContractState, payer: ContractAddress, allowed: bool) {
Expand All @@ -256,19 +254,19 @@ use core::option::OptionTrait;

let nft_address = get_caller_address();
if allowed {
assert(self.allowed_payer.read((nft_address, payer)), 'Duplicate payer');
assert(!self.allowed_payer.read((nft_address, payer)), 'Duplicate payer');
self.allowed_payer.write((nft_address, payer), true);

let mut enumerated_allowed_payer = self.enumerated_allowed_payer.read(nft_address);
enumerated_allowed_payer.append(payer);
self.enumerated_allowed_payer.write(nft_address, enumerated_allowed_payer);
} else {
assert(!self.allowed_payer.read((nft_address, payer)), 'Payer not present');
assert(self.allowed_payer.read((nft_address, payer)), 'Payer not present');
self.allowed_payer.write((nft_address, payer), false);
self.remove_enumerated_allowed_payer(nft_address, payer);
}

self.emit(PayerUpdated {nft_address, payer, allowed});
self.emit(PayerUpdated { nft_address, payer, allowed });
}
}

Expand Down Expand Up @@ -311,6 +309,37 @@ use core::option::OptionTrait;
self.fee_bps.read()
}

#[external(v0)]
fn get_public_drop(self: @ContractState, nft_address: ContractAddress) -> PublicDrop {
self.public_drops.read(nft_address)
}

#[external(v0)]
fn get_currency_manager(self: @ContractState) -> ContractAddress {
self.currency_manager.read().contract_address
}

#[external(v0)]
fn get_creator_payout_address(
self: @ContractState, nft_address: ContractAddress
) -> ContractAddress {
self.creator_payout_address.read(nft_address)
}

#[external(v0)]
fn get_enumerated_allowed_fee_recipients(
self: @ContractState, nft_address: ContractAddress
) -> Span::<ContractAddress> {
self.enumerated_allowed_fee_recipients.read(nft_address).array().span()
}

#[external(v0)]
fn get_enumerated_allowed_payer(
self: @ContractState, nft_address: ContractAddress
) -> Span::<ContractAddress> {
self.enumerated_allowed_payer.read(nft_address).array().span()
}

fn assert_only_non_fungible_flex_drop_token(self: @ContractState) {
let nft_address = get_caller_address();
let is_supported_interface = ISRC5Dispatcher { contract_address: nft_address }
Expand Down Expand Up @@ -464,20 +493,21 @@ use core::option::OptionTrait;
}

if *cp_enumerated.get(index).unwrap().unbox() != to_remove {
new_enumerated_allowed_fee_recipients.append(*cp_enumerated.get(index).unwrap().unbox());
new_enumerated_allowed_fee_recipients
.append(*cp_enumerated.get(index).unwrap().unbox());
}
index += 1;
};
enumerated_allowed_fee_recipients.from_array(@new_enumerated_allowed_fee_recipients);
self.enumerated_allowed_fee_recipients.write(nft_address, enumerated_allowed_fee_recipients);
self
.enumerated_allowed_fee_recipients
.write(nft_address, enumerated_allowed_fee_recipients);
}

fn remove_enumerated_allowed_payer(
ref self: ContractState, nft_address: ContractAddress, to_remove: ContractAddress
) {
let mut enumerated_allowed_payer = self
.enumerated_allowed_payer
.read(nft_address);
let mut enumerated_allowed_payer = self.enumerated_allowed_payer.read(nft_address);

let mut index = 0;
let enumerated_allowed_payer_length = enumerated_allowed_payer.len();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod ERC721MetadataComponent {
> of IFlexDropContractMetadata<ComponentState<TContractState>> {
fn set_base_uri(ref self: ComponentState<TContractState>, new_token_uri: felt252) {
self.assert_only_owner();
self._set_base_uri(new_token_uri);
self._set_token_base_uri(new_token_uri);
}

fn set_contract_uri(ref self: ComponentState<TContractState>, new_contract_uri: felt252) {
Expand Down Expand Up @@ -57,11 +57,16 @@ mod ERC721MetadataComponent {
/// Sets the contract's initial owner.
///
/// This function should be called at construction time.
fn initializer(ref self: ComponentState<TContractState>, owner: ContractAddress,) {
fn initializer(
ref self: ComponentState<TContractState>,
owner: ContractAddress,
token_base_uri: felt252
) {
self.owner.write(owner);
self._set_token_base_uri(token_base_uri);
}

fn _set_base_uri(ref self: ComponentState<TContractState>, new_token_uri: felt252) {
fn _set_token_base_uri(ref self: ComponentState<TContractState>, new_token_uri: felt252) {
self.token_base_uri.write(new_token_uri);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ mod TransferManagerNFT {
#[external(v0)]
impl TransferManagerNFTImpl of ITransferManagerNFT<ContractState> {
fn initializer(
ref self: ContractState,
marketplace: ContractAddress,
owner: ContractAddress,
ref self: ContractState, marketplace: ContractAddress, owner: ContractAddress,
) {
// TODO: verify the role of Proxy here.
self.marketplace.write(marketplace);
Expand Down

0 comments on commit 22a824c

Please sign in to comment.