Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Revalidate affected orders regardless of ERC721 approval operator (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
albrow authored Apr 8, 2020
1 parent 9613b42 commit c5213dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
4 changes: 1 addition & 3 deletions scenario/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,7 @@ func setDummyERC721BalanceAndAllowance(t *testing.T, traderAddress common.Addres
waitTxnSuccessfullyMined(t, txn)

// Set allowance
// HACK(albrow): Our tests rely on unapproving/unsetting the allowance. You can't do
// that for individual tokens, so we use SetApprovalForAll here.
txn, err = dummyERC721Token.SetApprovalForAll(opts, ganacheAddresses.ERC721Proxy, true)
txn, err = dummyERC721Token.Approve(opts, ganacheAddresses.ERC721Proxy, tokenID)
require.NoError(t, err)
waitTxnSuccessfullyMined(t, txn)
}
Expand Down
4 changes: 0 additions & 4 deletions zeroex/orderwatch/order_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,6 @@ func (w *Watcher) handleBlockEvents(
}
return err
}
// Ignores approvals set to anyone except the AssetProxy
if approvalEvent.Approved != w.contractAddresses.ERC721Proxy {
continue
}
contractEvent.Parameters = approvalEvent
orders, err = w.findOrdersByTokenAddressAndTokenID(approvalEvent.Owner, log.Address, approvalEvent.TokenId)
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions zeroex/orderwatch/order_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ func TestOrderWatcherUnfundedInsufficientERC721Allowance(t *testing.T) {
meshDB, err := meshdb.New("/tmp/leveldb_testing/"+uuid.New().String(), ganacheAddresses)
require.NoError(t, err)

makerAssetData := scenario.GetDummyERC721AssetData(big.NewInt(1))
tokenID := big.NewInt(1)
makerAssetData := scenario.GetDummyERC721AssetData(tokenID)
signedOrder := scenario.NewSignedTestOrder(t,
orderopts.SetupMakerState(true),
orderopts.MakerAssetAmount(big.NewInt(1)),
Expand All @@ -271,12 +272,13 @@ func TestOrderWatcherUnfundedInsufficientERC721Allowance(t *testing.T) {
defer cancelFn()
blockWatcher, orderEventsChan := setupOrderWatcherScenario(ctx, t, ethClient, meshDB, signedOrder)

// Remove Maker's NFT approval to ERC721Proxy
// Remove Maker's NFT approval to ERC721Proxy. We do this by setting the
// operator/spender to the null address.
opts := &bind.TransactOpts{
From: signedOrder.MakerAddress,
Signer: scenario.GetTestSignerFn(signedOrder.MakerAddress),
}
txn, err := dummyERC721Token.SetApprovalForAll(opts, ganacheAddresses.ERC721Proxy, false)
txn, err := dummyERC721Token.Approve(opts, constants.NullAddress, tokenID)
require.NoError(t, err)
waitTxnSuccessfullyMined(t, ethClient, txn)

Expand Down

0 comments on commit c5213dd

Please sign in to comment.