Skip to content

Commit

Permalink
implemented erc721 transfer manager (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
ametel01 authored Dec 26, 2023
1 parent 2d0e88e commit a2dd7f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion flex_marketplace/src/marketplace/marketplace.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use starknet::{ContractAddress, ClassHash};

use flex::marketplace::utils::order_types::{MakerOrder, TakerOrder};

#[starknet::interface]
trait IMarketPlace<TState> {
fn initializer(
ref self: TState,
Expand Down
33 changes: 24 additions & 9 deletions flex_marketplace/src/marketplace/transfer_manager_ERC721.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use starknet::ContractAddress;
trait ITransferManagerNFT<TState> {
fn initializer(
ref self: TState,
address: ContractAddress,
marketplace: ContractAddress,
owner: ContractAddress,
proxy_admin: ContractAddress
);
Expand All @@ -16,16 +16,20 @@ trait ITransferManagerNFT<TState> {
token_id: u256,
amount: u128
);
fn update_marketplace(ref self: TState, address: ContractAddress);
fn update_marketplace(ref self: TState, new_address: ContractAddress);
fn get_marketplace(self: @TState) -> ContractAddress;
}

#[starknet::contract]
mod TransferManagerNFT {
use starknet::{ContractAddress, contract_address_const};
use starknet::{ContractAddress, get_caller_address};

use flex::{DebugContractAddress, DisplayContractAddress};
use flex::marketplace::utils::order_types::{MakerOrder, TakerOrder};

use openzeppelin::token::erc721::interface::{
IERC721CamelOnlyDispatcher, IERC721CamelOnlyDispatcherTrait
};
use openzeppelin::access::ownable::OwnableComponent;
component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);

Expand All @@ -52,10 +56,13 @@ mod TransferManagerNFT {
impl TransferManagerNFTImpl of super::ITransferManagerNFT<ContractState> {
fn initializer(
ref self: ContractState,
address: ContractAddress,
marketplace: ContractAddress,
owner: ContractAddress,
proxy_admin: ContractAddress
) { // TODO
) {
// TODO: verify the role of Proxy here.
self.marketplace.write(marketplace);
self.ownable.initializer(owner);
}

fn transfer_non_fungible_token(
Expand All @@ -65,15 +72,23 @@ mod TransferManagerNFT {
to: ContractAddress,
token_id: u256,
amount: u128
) { // TODO
) {
let caller = get_caller_address();
assert!(
caller == self.get_marketplace(),
"TransferManagerNFT: caller {} is not MarketPlace",
caller
);
IERC721CamelOnlyDispatcher { contract_address: collection }
.transferFrom(from, to, token_id);
}

fn update_marketplace(ref self: ContractState, address: ContractAddress) { // TODO
fn update_marketplace(ref self: ContractState, new_address: ContractAddress) {
self.marketplace.write(new_address);
}

fn get_marketplace(self: @ContractState) -> ContractAddress {
// TODO
contract_address_const::<0>()
self.marketplace.read()
}
}
}

0 comments on commit a2dd7f0

Please sign in to comment.