Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1300 support approved for all for erc721 tokens for mainnet #1302

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ contract DepositBoxERC721 is DepositBox, IDepositBoxERC721 {
address contractReceiver = schainLinks[schainHash];
require(contractReceiver != address(0), "Unconnected chain");
require(
IERC721Upgradeable(erc721OnMainnet).getApproved(tokenId) == address(this),
IERC721Upgradeable(erc721OnMainnet).getApproved(tokenId) == address(this) ||
IERC721Upgradeable(erc721OnMainnet).isApprovedForAll(msg.sender, address(this)),
"DepositBox was not approved for ERC721 token"
);
bytes memory data = _receiveERC721(
Expand Down
27 changes: 26 additions & 1 deletion proxy/test/DepositBoxERC721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ describe("DepositBoxERC721", () => {
// preparation
const error = "DepositBox was not approved for ERC721 token";
const contractHere = erc721OnChain.address;
const to = user.address;
const tokenId = 10;
// the wei should be MORE than (55000 * 1000000000)
// GAS_AMOUNT_POST_MESSAGE * AVERAGE_TX_PRICE constants in DepositBox.sol
Expand All @@ -172,6 +171,32 @@ describe("DepositBoxERC721", () => {
.should.be.eventually.rejectedWith(error);
});

it("should send token if DepositBox was approved for all transfers by user", async () => {
// preparation
const contractHere = erc721OnChain.address;
const tokenId = 10;
// the wei should be MORE than (55000 * 1000000000)
// GAS_AMOUNT_POST_MESSAGE * AVERAGE_TX_PRICE constants in DepositBox.sol
// add schain to avoid the `Unconnected chain` error
await linker
.connect(deployer)
.connectSchain(schainName, [deployer.address, deployer.address, deployer.address]);
await depositBoxERC721.connect(user).disableWhitelist(schainName);

await depositBoxERC721
.connect(deployer)
.depositERC721(schainName, contractHere, tokenId)
.should.be.eventually.rejectedWith("DepositBox was not approved for ERC721 token");

await erc721OnChain.connect(deployer).setApprovalForAll(depositBoxERC721.address, true);
await depositBoxERC721
.connect(deployer)
.depositERC721(schainName, contractHere, tokenId);
// console.log("Gas for depositERC721:", res.receipt.gasUsed);
// expectation
expect(await erc721OnChain.ownerOf(tokenId)).to.equal(depositBoxERC721.address);
});

it("should invoke `depositERC721` without mistakes", async () => {
// preparation
const contractHere = erc721OnChain.address;
Expand Down