aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-utils
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-12-01 07:57:30 +0800
committerAmir Bandeali <abandeali1@gmail.com>2019-01-08 02:31:11 +0800
commit0cb5209266b979bcee094f3863efca0a1fa63697 (patch)
tree69fc139c139ed50ac56b8ff7af6556571bda6e3c /packages/order-utils
parent1553b366da410fbf00338a3207d326e5d57f54b2 (diff)
downloaddexon-sol-tools-0cb5209266b979bcee094f3863efca0a1fa63697.tar
dexon-sol-tools-0cb5209266b979bcee094f3863efca0a1fa63697.tar.gz
dexon-sol-tools-0cb5209266b979bcee094f3863efca0a1fa63697.tar.bz2
dexon-sol-tools-0cb5209266b979bcee094f3863efca0a1fa63697.tar.lz
dexon-sol-tools-0cb5209266b979bcee094f3863efca0a1fa63697.tar.xz
dexon-sol-tools-0cb5209266b979bcee094f3863efca0a1fa63697.tar.zst
dexon-sol-tools-0cb5209266b979bcee094f3863efca0a1fa63697.zip
Add length check to MultiAsset encoding
Diffstat (limited to 'packages/order-utils')
-rw-r--r--packages/order-utils/src/asset_data_utils.ts7
-rw-r--r--packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts2
2 files changed, 8 insertions, 1 deletions
diff --git a/packages/order-utils/src/asset_data_utils.ts b/packages/order-utils/src/asset_data_utils.ts
index b5cfe698e..0b32cf216 100644
--- a/packages/order-utils/src/asset_data_utils.ts
+++ b/packages/order-utils/src/asset_data_utils.ts
@@ -73,6 +73,13 @@ export const assetDataUtils = {
* @return The hex encoded assetData string
*/
encodeMultiAssetData(amounts: BigNumber[], nestedAssetData: string[]): string {
+ if (amounts.length !== nestedAssetData.length) {
+ throw new Error(
+ `Invalid MultiAsset arguments. Expected length of 'amounts' (${
+ amounts.length
+ }) to equal length of 'nestedAssetData' (${nestedAssetData.length})`,
+ );
+ }
_.forEach(nestedAssetData, assetDataElement => assetDataUtils.validateAssetDataOrThrow(assetDataElement));
const abiEncoder = new AbiEncoder.Method(constants.MULTI_ASSET_METHOD_ABI as MethodAbi);
const args = [amounts, nestedAssetData];
diff --git a/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts b/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts
index 0bbaa844a..ae3e36238 100644
--- a/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts
+++ b/packages/order-utils/src/store/balance_and_proxy_allowance_lazy_store.ts
@@ -122,7 +122,7 @@ export class BalanceAndProxyAllowanceLazyStore implements AbstractBalanceAndProx
const decodedAssetData = assetDataUtils.decodeERC721AssetData(assetData);
if (
decodedAssetData.assetProxyId === AssetProxyId.ERC721 &&
- !_.isUndefined(decodedAssetData.tokenAddress) &&
+ decodedAssetData.tokenAddress === tokenAddress &&
!_.isUndefined(this._proxyAllowance[assetData][userAddress])
) {
delete this._proxyAllowance[assetData][userAddress];