Phoenix-Protocol-Group / phoenix-nft-marketplace

NFT marketplace with auctions and collections interface
GNU General Public License v3.0
0 stars 0 forks source link

Collections: Implement `approval_for_transfer` #14

Closed ueco-jb closed 2 months ago

ueco-jb commented 2 months ago

Similar to set_approval_for_all, implement another storage entry as set_approval_for_transfer. This is necessary for the auction house, since we don't want to change the ownership of the NFT while allowing the auction house to transfer the token after the auction is done.

After that, modify safe_transfer_from signature

    pub fn safe_transfer_from(
        env: Env,
        from: Address,
        to: Address,
        id: u64,
        transfer_amount: u64,
    ) -> Result<(), ContractError> {

Add extra field: sender The way it should work - first you check if sender is the owner, then if he's approved for all and then if he's approved for the transfer. If any of those is true, call sender.require_auth() and follow with the transaction (notice that from should always point to the main account you are transferring from - if owner transfers it, from and sender will contain the same data).