From 774d831fae5809408f9ddfcf9393d579416b1bfb Mon Sep 17 00:00:00 2001 From: Greg Hysen Date: Mon, 4 Jun 2018 22:34:04 -0700 Subject: Style updates to ERC721 onReceiver --- packages/order-utils/src/asset_proxy_utils.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/order-utils') diff --git a/packages/order-utils/src/asset_proxy_utils.ts b/packages/order-utils/src/asset_proxy_utils.ts index 61a9b12e9..c7b301c1a 100644 --- a/packages/order-utils/src/asset_proxy_utils.ts +++ b/packages/order-utils/src/asset_proxy_utils.ts @@ -119,10 +119,12 @@ export const assetProxyUtils = { const tokenId = assetProxyUtils.decodeUint256(encodedTokenId); const nullData = '0x'; let receiverData = nullData; - if (encodedAssetData.byteLength > receiverDataLengthOffset + 1) { + const lengthUpToReceiverDataLength = receiverDataLengthOffset + 1; + if (encodedAssetData.byteLength > lengthUpToReceiverDataLength) { const encodedReceiverDataLength = encodedAssetData.slice(receiverDataLengthOffset, receiverDataOffset); const receiverDataLength = assetProxyUtils.decodeUint256(encodedReceiverDataLength); - const expectedReceiverDataLength = new BigNumber(encodedAssetData.byteLength - (receiverDataOffset + 1)); + const lengthUpToReceiverData = receiverDataOffset + 1; + const expectedReceiverDataLength = new BigNumber(encodedAssetData.byteLength - lengthUpToReceiverData); if (!receiverDataLength.equals(expectedReceiverDataLength)) { throw new Error( `Data length (${receiverDataLength}) does not match actual length of data (${expectedReceiverDataLength})`, @@ -167,12 +169,12 @@ export const assetProxyUtils = { return generalizedERC20AssetData; case AssetProxyId.ERC721: const erc721AssetData = assetProxyUtils.decodeERC721AssetData(assetData); - const generaliedERC721AssetData = { + const generalizedERC721AssetData = { assetProxyId, tokenAddress: erc721AssetData.tokenAddress, data: erc721AssetData.tokenId, }; - return generaliedERC721AssetData; + return generalizedERC721AssetData; default: throw new Error(`Unrecognized asset proxy id: ${assetProxyId}`); } -- cgit v1.2.3