@0x/contracts-asset-proxy: Make setProxyAllowanceForAll() just accept a ownerAddress and give the proxy full control.

This commit is contained in:
Lawrence Forman 2019-05-18 02:14:38 -04:00 committed by Amir Bandeali
parent cdb938ea28
commit 3fb34a2a83
2 changed files with 15 additions and 4 deletions

View File

@ -68,6 +68,14 @@
{ {
"note": "Update tests to use contract-built-in `awaitTransactionSuccessAsync`", "note": "Update tests to use contract-built-in `awaitTransactionSuccessAsync`",
"pr": 1797 "pr": 1797
},
{
"note": "Make `ERC721Wrapper.setApprovalForAll()` take an owner address instead of a token ID",
"pr": 1819
},
{
"note": "Automatically set unlimited proxy allowances in `ERC721.setBalancesAndAllowancesAsync()`",
"pr": 1819
} }
], ],
"timestamp": 1557507213 "timestamp": 1557507213

View File

@ -69,7 +69,7 @@ export class ERC721Wrapper {
} }
this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address].push(tokenId); this._initialTokenIdsByOwner[tokenOwnerAddress][dummyTokenContract.address].push(tokenId);
await this.approveProxyAsync(dummyTokenContract.address, tokenId); await this.approveProxyForAllAsync(dummyTokenContract.address, tokenOwnerAddress, true);
} }
} }
} }
@ -84,14 +84,17 @@ export class ERC721Wrapper {
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address; const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
await this.approveAsync(proxyAddress, tokenAddress, tokenId); await this.approveAsync(proxyAddress, tokenAddress, tokenId);
} }
public async approveProxyForAllAsync(tokenAddress: string, tokenId: BigNumber, isApproved: boolean): Promise<void> { public async approveProxyForAllAsync(
tokenAddress: string,
ownerAddress: string,
isApproved: boolean,
): Promise<void> {
const tokenContract = this._getTokenContractFromAssetData(tokenAddress); const tokenContract = this._getTokenContractFromAssetData(tokenAddress);
const tokenOwner = await this.ownerOfAsync(tokenAddress, tokenId);
const proxyAddress = (this._proxyContract as ERC721ProxyContract).address; const proxyAddress = (this._proxyContract as ERC721ProxyContract).address;
await tokenContract.setApprovalForAll.awaitTransactionSuccessAsync( await tokenContract.setApprovalForAll.awaitTransactionSuccessAsync(
proxyAddress, proxyAddress,
isApproved, isApproved,
{ from: tokenOwner }, { from: ownerAddress },
constants.AWAIT_TRANSACTION_MINED_MS, constants.AWAIT_TRANSACTION_MINED_MS,
); );
} }