aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts10
-rw-r--r--packages/contract-wrappers/test/erc721_wrapper_test.ts9
2 files changed, 11 insertions, 8 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
index 86c3e2d99..53190d007 100644
--- a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts
@@ -155,14 +155,14 @@ export class ERC721TokenWrapper extends ContractWrapper {
return isProxyApprovedForAll;
}
/**
- * Get the approved address for a single NFT
+ * Get the approved address for a single NFT. Returns undefined if no approval was set
* Throws if `_tokenId` is not a valid NFT
* @param tokenAddress The hex encoded contract Ethereum address where the ERC721 token is deployed.
* @param tokenId The identifier for an NFT
* @param methodOpts Optional arguments this method accepts.
- * @return The approved address for this NFT, or the zero address if there is none
+ * @return The approved address for this NFT, or the undefined if there is none
*/
- public async getApprovedAsync(
+ public async getApprovedIfExistsAsync(
tokenAddress: string,
tokenId: BigNumber,
methodOpts?: MethodOpts,
@@ -197,7 +197,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
methodOpts?: MethodOpts,
): Promise<boolean> {
const proxyAddress = this._erc721ProxyWrapper.getContractAddress();
- const approvedAddress = await this.getApprovedAsync(tokenAddress, tokenId, methodOpts);
+ const approvedAddress = await this.getApprovedIfExistsAsync(tokenAddress, tokenId, methodOpts);
const isProxyApproved = approvedAddress === proxyAddress;
return isProxyApproved;
}
@@ -354,7 +354,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
normalizedSenderAddress,
);
if (!isApprovedForAll) {
- const approved = await this.getApprovedAsync(normalizedTokenAddress, tokenId);
+ const approved = await this.getApprovedIfExistsAsync(normalizedTokenAddress, tokenId);
if (approved !== senderAddress) {
throw new Error(ContractWrappersError.ERC721NoApproval);
}
diff --git a/packages/contract-wrappers/test/erc721_wrapper_test.ts b/packages/contract-wrappers/test/erc721_wrapper_test.ts
index 170442690..9687af531 100644
--- a/packages/contract-wrappers/test/erc721_wrapper_test.ts
+++ b/packages/contract-wrappers/test/erc721_wrapper_test.ts
@@ -211,14 +211,17 @@ describe('ERC721Wrapper', () => {
expect(isApprovedForAll).to.be.true();
});
});
- describe('#setApprovalAsync/getApprovedAsync', () => {
+ describe('#setApprovalAsync/getApprovedIfExistsAsync', () => {
it("should set the spender's approval", async () => {
const tokenId = await tokenUtils.mintDummyERC721Async(tokenAddress, ownerAddress);
- const approvalBeforeSet = await contractWrappers.erc721Token.getApprovedAsync(tokenAddress, tokenId);
+ const approvalBeforeSet = await contractWrappers.erc721Token.getApprovedIfExistsAsync(
+ tokenAddress,
+ tokenId,
+ );
expect(approvalBeforeSet).to.be.undefined();
await contractWrappers.erc721Token.setApprovalAsync(tokenAddress, approvedAddress, tokenId);
- const approvalAfterSet = await contractWrappers.erc721Token.getApprovedAsync(tokenAddress, tokenId);
+ const approvalAfterSet = await contractWrappers.erc721Token.getApprovedIfExistsAsync(tokenAddress, tokenId);
expect(approvalAfterSet).to.be.equal(approvedAddress);
});
});