ERC721 setApprovalForAll by delegateCall

Hello everyone,

I'm developing an NFTStore.

The user should set the NFTStore as operator for transfer, I created a function in the store that call the setApprovalForAll passing the NFTStore address by delegateCall to garantee that msg.sender is the same of the token owner, but I always getting error.

Can anyone give me any advice on how to achieve this?

I don't need to set the NFTStore has ERC721Holder because he only transfer nfts.

Here is the code, where manager is the address of the NFTStore:
bytes memory data = Address.functionDelegateCall(contractAddress, abi.encode("setApprovalForAll(address,bool)", manager, true));

Thanks in advance.

You are making wrong assumptions about what delegateCall does.

Address.functionDelegateCall(contractAddress, abi.encode("setApprovalForAll(address,bool)", manager, true));

Means execute contractAddress.setApprovalForAll(manager, true) using the storage and balance of address(this)

It DOES NOT mean execute contractAddress.setApprovalForAll(manager, true) as if the transaction is coming from msg.sender

NFTStore is the operator. it's the user that needs to call any approval functions, not the contract getting approved

NFTStore is gonna receive NFTs and is a contract, it needs to implement IERC721Receiver, ERC721Holder is provided for that